Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1718 mario79 1
kIfinityPrice equ 0x0FFFFFFF
2
 
3
;* Call: ***************************************************************
4
;lzma_compress(
5
;	const void* source,
6
;	void* destination,
7
;	unsigned length,
8
;	void* workmem)
9
lzma_compress:
10
	push	ebp
11
	mov	ebp,esp
12
	and	esp,0xFFFFFFF8
13
	sub	esp,12
14
	push	ebx
15
	push	esi
16
	push	edi
17
	push	2
18
	pop	esi
19
	xor	ebx,ebx
20
	mov	[esp+20],esi
21
	mov	[g_FastPos],bl
22
	mov	byte [g_FastPos+1],1
23
	mov	[esp+16],esi
24
;----------------------------------------------------------
25
.labl_00:
26
	mov	ecx,[esp+16]
27
	xor	edi,edi
28
	sar	ecx,1
29
	dec	ecx
30
	inc	edi
31
	shl	edi,cl
32
	cmp	edi,ebx
33
	jbe	.labl_01
34
 
35
	mov	eax,[esp+20]
36
	push	edi
37
	push	dword [esp+20]
38
	lea	eax,[eax+g_FastPos]
39
	push	eax
40
	call	_memset
41
	add	esp,12
42
	add	[esp+20],edi
43
;----------------------------------------------------------
44
.labl_01:
45
	inc	dword [esp+16]
46
	cmp	dword [esp+16],20
47
	jl	.labl_00
48
 
49
	mov	edi,[ebp+20]
50
	push	3
51
	pop	eax
52
	mov	ecx,edi
53
	and	ecx,eax
54
	mov	edx,128
55
	mov	[_numFastBytes],edx
56
	mov	[_posStateBits],esi
57
	mov	[_posStateMask],eax
58
	mov	[_numLiteralContextBits],eax
59
	mov	[_numLiteralPosStateBits],ebx
60
	mov	[_writeEndMark],bl
61
	mov	[_finished],bl
62
	je	.labl_02
63
 
64
	sub	edi,ecx
65
	add	edi,4
66
;----------------------------------------------------------
67
.labl_02:
68
;CLiteralEncoder_Create
69
	mov	[_numPrevBits],eax
70
	mov	eax,[_dictionarySize]
71
	mov	[_posEncoders],edi
72
	add	edi,0x6000
73
	inc	eax
74
	mov	[_numPosBits],ebx
75
	mov	[_posMask],ebx
76
;MatchFinder_Create
77
	mov	[_matchMaxLen],edx
78
	mov	[_cyclicBufferSize],eax
79
	mov	[_hash],edi
80
	mov	dword [_cutValue],0xFF
81
	call	CEncoder_Init
82
	call	FillPosSlotPrices
83
	call	FillDistancesPrices
84
	call	FillAlignPrices
85
	push	127
86
	pop	esi
87
	mov	[_lenEncoder+0xC88C],esi
88
	mov	[esp+16],ebx
89
;----------------------------------------------------------
90
.labl_03:
91
	push	dword [esp+16]
92
	mov	eax,_lenEncoder
93
	call	CPriceTableEncoder_UpdateTable
94
	inc	dword [esp+16]
95
	cmp	dword [esp+16],4
96
	jb	.labl_03
97
 
98
	mov	[_repMatchLenEncoder+0xC88C],esi
99
	xor	esi,esi
100
;----------------------------------------------------------
101
.labl_04:
102
	push	esi
103
	mov	eax,_repMatchLenEncoder
104
	call	CPriceTableEncoder_UpdateTable
105
	inc	esi
106
	cmp	esi,4
107
	jb	.labl_04
108
 
109
	mov	eax,[ebp+8]
110
	mov	esi,[ebp+12]
111
	dec	eax
112
	mov	[_buffer],eax
113
	mov	eax,[ebp+16]
114
	inc	eax
115
	mov	[_streamPos],eax
116
	mov	ecx,0x110000
117
	xor	eax,eax
118
	mov	[lastPosSlotFillingPos],ebx
119
	mov	[lastPosSlotFillingPos+4],ebx
120
	mov	[nowPos64],ebx
121
	mov	[nowPos64+4],ebx
122
	mov	[pack_length],esi
123
	mov	dword [_pos],1
124
	rep	stosd
125
	mov	[pack_pos],ebx
126
;----------------------------------------------------------
127
;MatchFinder_Init
128
.labl_08:
129
	push	8
130
	mov	eax,ebx
131
	pop	ecx
132
;----------------------------------------------------------
133
.labl_07:
134
	test	al,1
135
	je	.labl_05
136
 
137
	shr	eax,1
138
	xor	eax,0xEDB88320
139
	jmp	.labl_06
140
;----------------------------------------------------------
141
.labl_05:
142
	shr	eax,1
143
;----------------------------------------------------------
144
.labl_06:
145
	dec	ecx
146
	jne	.labl_07
147
 
148
	mov	[crc_table+ebx*4],eax
149
	inc	ebx
150
	cmp	ebx,256
151
	jb	.labl_08
152
;----------------------------------------------------------
153
.labl_09:
154
	call	CodeOneBlock
155
	test	al,al
156
	jne	.labl_09
157
 
158
	mov	eax,[pack_length]
159
	pop	edi
160
	sub	eax,esi
161
	pop	esi
162
	pop	ebx
163
	mov	esp,ebp
164
	pop	ebp
165
	ret	16
166
;*****************************************************************************
167
 
168
;* Call: ***************************************************************
169
_memset:
170
	push	edi
171
	mov	edi,[esp+8]
172
	mov	al,[esp+12]
173
	mov	ecx,[esp+16]
174
	rep	stosb
175
	pop	edi
176
	ret
177
;*****************************************************************************
178
 
179
;* Call: ***************************************************************
180
CEncoder_Init:
181
;RangeEncoder_Init
182
	and	dword [low],0
183
	and	dword [low+4],0
184
	or	dword [_range],0xFFFFFFFF
185
	push	ebx
186
	push	esi
187
	push	edi
188
	xor	eax,eax
189
	mov	edi,_repDistances
190
	stosd
191
	stosd
192
	xor	ebx,ebx
193
	stosd
194
	inc	ebx
195
;CBaseState_Init
196
	mov	byte [_state],0
197
	mov	byte [_previousByte],0
198
	stosd
199
	mov	[_cacheSize],ebx
200
	mov	byte [_cache],0
201
	xor	ecx,ecx
202
;----------------------------------------------------------
203
.labl_00:
204
	mov	eax,ebx
205
	shl	eax,cl
206
	push	8
207
	pop	edx
208
	sub	edx,ecx
209
	lea	esi,[Models+eax*4]
210
	shl	edx,6
211
;----------------------------------------------------------
212
.labl_01:
213
	mov	edi,eax
214
	shl	edi,6
215
	shr	edi,cl
216
	add	edi,edx
217
	mov	[esi],edi
218
	add	esi,4
219
	dec	eax
220
	jne	.labl_01
221
 
222
	inc	ecx
223
	cmp	ecx,9
224
	jl	.labl_00
225
 
226
	push	12
227
	pop	edx
228
	mov	esi,1024
229
	mov	eax,esi
230
	mov	ecx,edx
231
	mov	edi,_isRepG2
232
	rep	stosd
233
	mov	ecx,edx
234
	mov	edi,_isRepG1
235
	rep	stosd
236
	mov	ecx,edx
237
	mov	edi,_isRepG0
238
	rep	stosd
239
	mov	ecx,edx
240
	mov	edi,_isRep
241
	rep	stosd
242
	xor	ecx,ecx
243
;----------------------------------------------------------
244
.labl_02:
245
	lea	edi,[ecx+_isRep0Long]
246
	mov	eax,esi
247
	stosd
248
	stosd
249
	stosd
250
	stosd
251
	lea	edi,[ecx+_isMatch]
252
	mov	eax,esi
253
	stosd
254
	stosd
255
	stosd
256
	add	ecx,64
257
	cmp	ecx,768
258
	stosd
259
	jl	.labl_02
260
 
261
	mov	eax,[_numPrevBits]
262
	mov	ecx,[_numPosBits]
263
	add	ecx,eax
264
	mov	eax,ebx
265
	shl	eax,cl
266
	test	eax,eax
267
	jbe	.labl_04
268
 
269
	xor	edx,edx
270
	mov	ebx,eax
271
;----------------------------------------------------------
272
.labl_03:
273
	mov	eax,[_posEncoders]
274
	lea	edi,[edx+eax]
275
	mov	ecx,768
276
	mov	eax,esi
277
	add	edx,3072
278
	dec	ebx
279
	rep	stosd
280
	jne	.labl_03
281
;----------------------------------------------------------
282
.labl_04:
283
	mov	edi,_posSlotEncoder
284
;----------------------------------------------------------
285
.labl_05:
286
	push	6
287
	pop	ecx
288
	mov	eax,edi
289
	call	CBitTreeEncoder_Init
290
	add	edi,1028
291
	cmp	edi,lastPosSlotFillingPos
292
	jl	.labl_05
293
 
294
	push	114
295
	mov	eax,esi
296
	pop	ecx
297
	mov	edi,_literalEncoder
298
	mov	esi,_lenEncoder
299
	rep	stosd
300
	call	CPriceTableEncoder_Init
301
	mov	esi,_repMatchLenEncoder
302
	call	CPriceTableEncoder_Init
303
	push	4
304
	pop	ecx
305
	mov	eax,_posAlignEncoder
306
	call	CBitTreeEncoder_Init
307
	pop	edi
308
	xor	eax,eax
309
	pop	esi
310
	mov	byte [_longestMatchWasFound],0
311
	mov	[_optimumEndIndex],eax
312
	mov	[_optimumCurrentIndex],eax
313
	mov	[_additionalOffset],eax
314
	pop	ebx
315
	ret
316
;*****************************************************************************
317
 
318
;* Call: ***************************************************************
319
CodeOneBlock:
320
	sub	esp,0x2C
321
	cmp	byte [_finished],0
322
	push	ebx
323
	push	ebp
324
	push	esi
325
	push	edi
326
	je	.labl_01
327
;----------------------------------------------------------
328
.labl_00:
329
	xor	al,al
330
	jmp	.labl_28
331
;----------------------------------------------------------
332
.labl_01:
333
	mov	ebp,[nowPos64]
334
	mov	edi,[nowPos64+4]
335
	mov	eax,ebp
336
	or	eax,edi
337
	mov	byte [_finished],1
338
	mov	[esp+52],ebp
339
	mov	[esp+56],edi
340
	jne	.labl_04
341
 
342
	mov	eax,[_streamPos]
343
	sub	eax,[_pos]
344
	jne	.labl_03
345
 
346
	push	5
347
	pop	esi
348
;----------------------------------------------------------
349
.labl_02:
350
	call	RangeEncoder_ShiftLow
351
	dec	esi
352
	jne	.labl_02
353
 
354
	jmp	.labl_00
355
;----------------------------------------------------------
356
.labl_03:
357
	call	ReadMatchDistances
358
	movzx	esi,byte [_state]
359
	mov	edx,esi
360
	shl	edx,6
361
	xor	edi,edi
362
	push	edi
363
	add	edx,_isMatch
364
	call	CMyBitEncoder_Encode
365
	mov	al,[esi+LiteralNextStates]
366
	mov	ecx,[_pos]
367
	mov	[_state],al
368
	mov	eax,[_buffer]
369
	sub	eax,[_additionalOffset]
370
	mov	bl,[eax+ecx]
371
	mov	al,[_previousByte]
372
	mov	[esp+24],bl
373
	push	dword [esp+24]
374
	push	edi
375
	call	CState_IsCharState
376
	imul	eax,eax,3072
377
	add	eax,[_posEncoders]
378
	push	eax
379
	call	CLiteralEncoder2_Encode
380
	dec	dword [_additionalOffset]
381
	xor	ebp,ebp
382
	inc	ebp
383
	mov	[_previousByte],bl
384
	mov	[nowPos64],ebp
385
	mov	[nowPos64+4],edi
386
;----------------------------------------------------------
387
.labl_04:
388
	mov	eax,[_streamPos]
389
	sub	eax,[_pos]
390
	jne	.labl_06
391
 
392
	push	5
393
	pop	esi
394
;----------------------------------------------------------
395
.labl_05:
396
	call	RangeEncoder_ShiftLow
397
	dec	esi
398
	jne	.labl_05
399
 
400
	jmp	.labl_00
401
;----------------------------------------------------------
402
.labl_06:
403
	lea	eax,[esp+20]
404
	push	eax
405
	lea	eax,[esp+20]
406
	push	eax
407
	mov	ebx,ebp
408
	push	ebp
409
	and	ebx,3
410
	call	GetOptimum
411
	cmp	dword [esp+20],1
412
	jne	.labl_09
413
 
414
	cmp	dword [esp+16],0xFFFFFFFF
415
	jne	.labl_09
416
 
417
	movzx	eax,byte [_state]
418
	shl	eax,4
419
	add	eax,ebx
420
	push	0
421
	lea	edx,[_isMatch+eax*4]
422
	call	CMyBitEncoder_Encode
423
	mov	eax,[_buffer]
424
	mov	esi,[_additionalOffset]
425
	mov	ebx,[_pos]
426
	sub	eax,esi
427
	mov	al,[eax+ebx]
428
	mov	[esp+24],al
429
	mov	al,[_previousByte]
430
	push	ebp
431
	call	CState_IsCharState
432
	imul	eax,eax,3072
433
	add	eax,[_posEncoders]
434
	cmp	byte [_state],7
435
	push	dword [esp+24]
436
	jb	.labl_07
437
 
438
	mov	ecx,[_buffer]
439
	sub	ecx,[_repDistances]
440
	sub	ecx,esi
441
	mov	cl,[ecx+ebx-1]
442
	mov	[esp+52],cl
443
	push	dword [esp+52]
444
	push	eax
445
	call	CLiteralEncoder2_EncodeMatched
446
	jmp	.labl_08
447
;----------------------------------------------------------
448
.labl_07:
449
	push	eax
450
	call	CLiteralEncoder2_Encode
451
;----------------------------------------------------------
452
.labl_08:
453
	movzx	eax,byte [_state]
454
	mov	al,[eax+LiteralNextStates]
455
	mov	[_state],al
456
	mov	al,[esp+24]
457
	jmp	.labl_24
458
;----------------------------------------------------------
459
.labl_09:
460
	movzx	edi,byte [_state]
461
	mov	eax,edi
462
	shl	eax,4
463
	add	eax,ebx
464
	shl	eax,2
465
	push	1
466
	lea	edx,[eax+_isMatch]
467
	mov	[esp+40],eax
468
	call	CMyBitEncoder_Encode
469
	cmp	dword [esp+16],4
470
	jnb	.labl_17
471
 
472
	mov	esi,edi
473
	shl	esi,2
474
	push	1
475
	lea	edx,[esi+_isRep]
476
	call	CMyBitEncoder_Encode
477
	cmp	dword [esp+16],0
478
	lea	edx,[esi+_isRepG0]
479
	jne	.labl_10
480
 
481
	push	0
482
	call	CMyBitEncoder_Encode
483
	mov	edx,[esp+36]
484
	xor	eax,eax
485
	cmp	dword [esp+20],1
486
	lea	edx,[edx+_isRep0Long]
487
	setne	al
488
	jmp	.labl_12
489
;----------------------------------------------------------
490
.labl_10:
491
	push	1
492
	call	CMyBitEncoder_Encode
493
	cmp	dword [esp+16],1
494
	lea	edx,[esi+_isRepG1]
495
	jne	.labl_11
496
 
497
	push	0
498
	jmp	.labl_13
499
;----------------------------------------------------------
500
.labl_11:
501
	push	1
502
	call	CMyBitEncoder_Encode
503
	mov	eax,[esp+16]
504
	add	eax,0xFFFFFFFE
505
	lea	edx,[esi+_isRepG2]
506
;----------------------------------------------------------
507
.labl_12:
508
	push	eax
509
;----------------------------------------------------------
510
.labl_13:
511
	call	CMyBitEncoder_Encode
512
	mov	eax,[esp+20]
513
	cmp	eax,1
514
	jne	.labl_14
515
 
516
	mov	al,[edi+ShortRepNextStates]
517
	jmp	.labl_15
518
;----------------------------------------------------------
519
.labl_14:
520
	add	eax,0xFFFFFFFE
521
	mov	esi,_repMatchLenEncoder
522
	call	CPriceTableEncoder_Encode
523
	mov	al,[edi+RepNextStates]
524
;----------------------------------------------------------
525
.labl_15:
526
	mov	[_state],al
527
	mov	eax,[esp+16]
528
	mov	ecx,[_repDistances+eax*4]
529
	test	eax,eax
530
	je	.labl_23
531
;----------------------------------------------------------
532
.labl_16:
533
	dec	eax
534
	mov	edx,[_repDistances+eax*4]
535
	mov	[_repDistances+4+eax*4],edx
536
	jne	.labl_16
537
 
538
	mov	[_repDistances],ecx
539
	jmp	.labl_23
540
;----------------------------------------------------------
541
.labl_17:
542
	push	0
543
	lea	edx,[_isRep+edi*4]
544
	call	CMyBitEncoder_Encode
545
	mov	al,[edi+MatchNextStates]
546
	mov	edi,[esp+20]
547
	mov	[_state],al
548
	add	edi,0xFFFFFFFE
549
	mov	eax,edi
550
	mov	esi,_lenEncoder
551
	call	CPriceTableEncoder_Encode
552
	sub	dword [esp+16],4
553
	mov	eax,[esp+16]
554
	call	GetPosSlot
555
	cmp	dword [esp+20],6
556
	mov	ebx,eax
557
	jb	.labl_18
558
 
559
	push	3
560
	pop	edi
561
;----------------------------------------------------------
562
.labl_18:
563
	imul	edi,edi,1028
564
	push	ebx
565
	add	edi,_posSlotEncoder
566
	call	cm_pr_16
567
	cmp	ebx,4
568
	jb	.labl_21
569
 
570
	mov	esi,[esp+16]
571
	xor	eax,eax
572
	inc	eax
573
	mov	ecx,ebx
574
	mov	edi,ebx
575
	and	edi,eax
576
	shr	ecx,1
577
	dec	ecx
578
	or	edi,2
579
	shl	edi,cl
580
	sub	esi,edi
581
	cmp	ebx,14
582
	jnb	.labl_20
583
 
584
	mov	[esp+32],esi
585
	mov	[esp+28],eax
586
	test	ecx,ecx
587
	jle	.labl_21
588
 
589
	mov	[esp+36],ecx
590
;----------------------------------------------------------
591
.labl_19:
592
	mov	edx,[esp+28]
593
	mov	esi,[esp+32]
594
	sub	edx,ebx
595
	add	edx,edi
596
	and	esi,1
597
	push	esi
598
	lea	edx,[_numLiteralContextBits+edx*4]
599
	call	CMyBitEncoder_Encode
600
	mov	eax,[esp+28]
601
	shr	dword [esp+32],1
602
	dec	dword [esp+36]
603
	lea	eax,[esi+eax*2]
604
	mov	[esp+28],eax
605
	jne	.labl_19
606
 
607
	jmp	.labl_21
608
;----------------------------------------------------------
609
.labl_20:
610
	lea	eax,[ecx-4]
611
	mov	ecx,esi
612
	shr	ecx,4
613
	push	ecx
614
	call	RangeEncoder_EncodeDirectBits
615
	and	esi,0xF
616
	push	esi
617
	call	CBitTreeEncoder_ReverseEncode
618
	dec	dword [_alignPriceCount]
619
	jne	.labl_21
620
 
621
	call	FillAlignPrices
622
;----------------------------------------------------------
623
.labl_21:
624
	mov	eax,_repDistances+12
625
;----------------------------------------------------------
626
.labl_22:
627
	mov	ecx,[eax-4]
628
	mov	[eax],ecx
629
	sub	eax,4
630
	cmp	eax,_repDistances
631
	jne	.labl_22
632
 
633
	mov	eax,[esp+16]
634
	mov	[_repDistances],eax
635
;----------------------------------------------------------
636
.labl_23:
637
	mov	eax,[_buffer]
638
	mov	esi,[_additionalOffset]
639
	mov	ebx,[_pos]
640
	mov	ecx,[esp+20]
641
	mov	edi,[nowPos64+4]
642
	sub	eax,esi
643
	add	eax,ebx
644
	mov	al,[eax+ecx-1]
645
;----------------------------------------------------------
646
.labl_24:
647
	sub	esi,[esp+20]
648
	add	ebp,[esp+20]
649
	mov	[_previousByte],al
650
	adc	edi,0
651
	mov	eax,ebp
652
	sub	eax,[lastPosSlotFillingPos]
653
	mov	ecx,edi
654
	sbb	ecx,[lastPosSlotFillingPos+4]
655
	mov	[_additionalOffset],esi
656
	mov	[nowPos64],ebp
657
	mov	[nowPos64+4],edi
658
	mov	[esp+40],ecx
659
	jne	.labl_25
660
 
661
	cmp	eax,512
662
	jb	.labl_26
663
;----------------------------------------------------------
664
.labl_25:
665
	call	FillPosSlotPrices
666
	call	FillDistancesPrices
667
	mov	[lastPosSlotFillingPos],ebp
668
	mov	[lastPosSlotFillingPos+4],edi
669
;----------------------------------------------------------
670
.labl_26:
671
	test	esi,esi
672
	jne	.labl_06
673
 
674
	mov	eax,[_streamPos]
675
	sub	eax,ebx
676
	je	.labl_29
677
 
678
	mov	ecx,ebp
679
	sub	ecx,[esp+52]
680
	mov	eax,edi
681
	sbb	eax,[esp+56]
682
	test	eax,eax
683
	ja	.labl_27
684
 
685
	jb	.labl_06
686
 
687
	cmp	ecx,0x1000
688
	jb	.labl_06
689
;----------------------------------------------------------
690
.labl_27:
691
	mov	byte [_finished],0
692
	mov	al,1
693
;----------------------------------------------------------
694
.labl_28:
695
	pop	edi
696
	pop	esi
697
	pop	ebp
698
	pop	ebx
699
	add	esp,44
700
	ret
701
;----------------------------------------------------------
702
.labl_29:
703
	push	5
704
	pop	esi
705
;----------------------------------------------------------
706
.labl_30:
707
	call	RangeEncoder_ShiftLow
708
	dec	esi
709
	jne	.labl_30
710
 
711
	jmp	.labl_00
712
;*****************************************************************************
713
 
714
;* Call: ***************************************************************
715
GetOptimum:
716
	push	ebp
717
	mov	ebp,esp
718
	mov	ecx,[_optimumCurrentIndex]
719
	sub	esp,116
720
	push	esi
721
	cmp	[_optimumEndIndex],ecx
722
	je	.labl_00
723
 
724
	mov	eax,ecx
725
	imul	eax,eax,40
726
	add	eax,state.State
727
	mov	edx,[eax+16]
728
	mov	eax,[eax+20]
729
	mov	esi,edx
730
	sub	esi,ecx
731
	mov	ecx,[ebp+16]
732
	mov	[ecx],esi
733
	mov	ecx,[ebp+12]
734
	mov	[ecx],eax
735
	mov	[_optimumCurrentIndex],edx
736
	jmp	.labl_76
737
;----------------------------------------------------------
738
.labl_00:
739
	push	edi
740
	xor	edi,edi
741
	cmp	byte [_longestMatchWasFound],0
742
	mov	[_optimumEndIndex],edi
743
	mov	[_optimumCurrentIndex],edi
744
	jne	.labl_01
745
 
746
	call	ReadMatchDistances
747
	jmp	.labl_02
748
;----------------------------------------------------------
749
.labl_01:
750
	mov	eax,[_longestMatchLength]
751
	mov	byte [_longestMatchWasFound],0
752
;----------------------------------------------------------
753
.labl_02:
754
	push	ebx
755
	mov	ebx,[ebp+8]
756
	mov	[ebp-16],eax
757
	mov	eax,ebx
758
	shl	eax,2
759
	mov	[ebp-76],eax
760
;----------------------------------------------------------
761
.labl_03:
762
	mov	esi,edi
763
	shl	esi,2
764
	mov	eax,[esi+_repDistances]
765
	push	eax
766
	mov	[ebp+esi-100],eax
767
	push	dword 0xFFFFFFFF
768
	mov	eax,273
769
	call	GetMatchLen
770
	mov	[ebp+esi-116],eax
771
	test	edi,edi
772
	je	.labl_04
773
 
774
	mov	ecx,[ebp-76]
775
	cmp	eax,[ebp+ecx-116]
776
	jbe	.labl_05
777
;----------------------------------------------------------
778
.labl_04:
779
	mov	ebx,edi
780
	mov	[ebp-76],esi
781
;----------------------------------------------------------
782
.labl_05:
783
	inc	edi
784
	cmp	edi,4
785
	jb	.labl_03
786
 
787
	mov	eax,[ebp+ebx*4-116]
788
	mov	ecx,128
789
	mov	[ebp-68],eax
790
	cmp	eax,ecx
791
	jb	.labl_06
792
 
793
	mov	ecx,[ebp+12]
794
	mov	[ecx],ebx
795
	jmp	.labl_07
796
;----------------------------------------------------------
797
.labl_06:
798
	cmp	[ebp-16],ecx
799
	jb	.labl_08
800
 
801
	mov	eax,[distances+512]
802
	mov	ecx,[ebp+12]
803
	add	eax,4
804
	mov	[ecx],eax
805
	mov	eax,[ebp-16]
806
;----------------------------------------------------------
807
.labl_07:
808
	mov	ecx,[ebp+16]
809
	mov	[ecx],eax
810
	dec	eax
811
	call	MovePos
812
	jmp	.labl_75
813
;----------------------------------------------------------
814
.labl_08:
815
	mov	ecx,[_buffer]
816
	mov	eax,[_pos]
817
	mov	dl,[eax+ecx-1]
818
	sub	eax,[_repDistances]
819
	mov	bl,[_state]
820
	mov	[state.State],bl
821
	mov	al,[eax+ecx-2]
822
	mov	[ebp-52],al
823
	mov	eax,[ebp+8]
824
	and	eax,3
825
	movzx	ecx,bl
826
	shl	ecx,4
827
	add	ecx,eax
828
	mov	esi,[_isMatch+ecx*4]
829
	mov	[ebp-28],eax
830
	cmp	bl,7
831
	sbb	al,al
832
	mov	[ebp-48],dl
833
	push	dword [ebp-48]
834
	inc	al
835
	push	dword [ebp-52]
836
	movzx	eax,al
837
	push	eax
838
	push	dword [ebp+8]
839
	mov	al,[_previousByte]
840
	mov	[ebp-76],esi
841
	call	CLiteralEncoder_GetPrice
842
	or	dword [state.BackPrev+40],0xFFFFFFFF
843
	and	dword [state.PosPrev+40],0
844
	shr	esi,2
845
	add	eax,[Models+esi*4]
846
	mov	byte [state.Prev1IsChar+40],0
847
	mov	[state.Price+40],eax
848
	lea	esi,[ebp-100]
849
	mov	edi,state.Backs
850
	movsd
851
	movsd
852
	mov	eax,2048
853
	mov	ecx,eax
854
	sub	ecx,[ebp-76]
855
	movsd
856
	shr	ecx,2
857
	mov	edx,[Models+ecx*4]
858
	movzx	ecx,bl
859
	movsd
860
	mov	esi,[_isRep+ecx*4]
861
	sub	eax,esi
862
	shr	eax,2
863
	mov	edi,[Models+eax*4]
864
	mov	al,[ebp-48]
865
	add	edi,edx
866
	mov	[ebp-76],edx
867
	cmp	[ebp-52],al
868
	jne	.labl_09
869
 
870
	push	dword [ebp-28]
871
	mov	al,bl
872
	call	GetRepLen1Price
873
	add	eax,edi
874
	cmp	eax,[state.Price+40]
875
	jnb	.labl_09
876
 
877
	and	dword [state.BackPrev+40],0
878
	mov	[state.Price+40],eax
879
	mov	byte [state.Prev1IsChar+40],0
880
;----------------------------------------------------------
881
.labl_09:
882
	push	2
883
	pop	eax
884
	cmp	[ebp-16],eax
885
	jnb	.labl_10
886
 
887
	mov	eax,[ebp+12]
888
	mov	ecx,[state.BackPrev+40]
889
	mov	[eax],ecx
890
	mov	eax,[ebp+16]
891
	mov	dword [eax],1
892
	jmp	.labl_75
893
;----------------------------------------------------------
894
.labl_10:
895
	mov	ecx,[ebp-16]
896
	shr	esi,2
897
	mov	esi,[Models+esi*4]
898
	add	esi,[ebp-76]
899
	mov	[ebp-76],esi
900
	cmp	ecx,[ebp-68]
901
	ja	.labl_11
902
 
903
	and	dword [ebp-16],0
904
;----------------------------------------------------------
905
.labl_11:
906
	mov	[ebp-24],eax
907
	cmp	[ebp-16],eax
908
	jb	.labl_13
909
 
910
	mov	esi,state.BackPrev+40*2
911
;----------------------------------------------------------
912
.labl_12:
913
	mov	eax,[ebp-24]
914
	mov	edx,[distances+eax*4]
915
	push	dword [ebp-28]
916
	and	dword [esi-4],0
917
	lea	ecx,[edx+4]
918
	mov	[esi],ecx
919
	call	GetPosLenPrice
920
	add	eax,[ebp-76]
921
	inc	dword [ebp-24]
922
	mov	[esi-8],eax
923
	mov	eax,[ebp-24]
924
	mov	byte [esi-19],0
925
	add	esi,40
926
	cmp	eax,[ebp-16]
927
	jbe	.labl_12
928
;----------------------------------------------------------
929
.labl_13:
930
	mov	ecx,[ebp-16]
931
	cmp	ecx,[ebp-68]
932
	jnb	.labl_14
933
 
934
	mov	ecx,[ebp-68]
935
	mov	[ebp-16],ecx
936
;----------------------------------------------------------
937
.labl_14:
938
	cmp	[ebp-24],ecx
939
	ja	.labl_16
940
 
941
	mov	eax,[ebp-24]
942
	sub	ecx,[ebp-24]
943
	imul	eax,eax,40
944
	add	eax,state.Price
945
	inc	ecx
946
;----------------------------------------------------------
947
.labl_15:
948
	mov	dword [eax],kIfinityPrice
949
	add	eax,40
950
	dec	ecx
951
	jne	.labl_15
952
;----------------------------------------------------------
953
.labl_16:
954
	and	dword [ebp-24],0
955
;----------------------------------------------------------
956
.labl_17:
957
	mov	eax,[ebp-24]
958
	mov	eax,[ebp+eax*4-116]
959
	push	2
960
	pop	ecx
961
	mov	[ebp-32],ecx
962
	cmp	eax,ecx
963
	jb	.labl_20
964
 
965
	mov	esi,state.Price+40*2
966
;----------------------------------------------------------
967
.labl_18:
968
	push	dword [ebp-28]
969
	mov	edx,[ebp-24]
970
	movzx	eax,bl
971
	push	eax
972
	mov	eax,[ebp-32]
973
	call	GetRepPrice
974
	add	eax,edi
975
	cmp	eax,[esi]
976
	jnb	.labl_19
977
 
978
	and	dword [esi+4],0
979
	mov	[esi],eax
980
	mov	eax,[ebp-24]
981
	mov	[esi+8],eax
982
	mov	byte [esi-11],0
983
;----------------------------------------------------------
984
.labl_19:
985
	inc	dword [ebp-32]
986
	mov	eax,[ebp-24]
987
	mov	ecx,[ebp-32]
988
	add	esi,40
989
	cmp	ecx,[ebp+eax*4-116]
990
	jbe	.labl_18
991
;----------------------------------------------------------
992
.labl_20:
993
	inc	dword [ebp-24]
994
	cmp	dword [ebp-24],4
995
	jb	.labl_17
996
 
997
	mov	eax,[ebp-16]
998
	xor	ecx,ecx
999
	inc	ecx
1000
	mov	[ebp-8],eax
1001
	mov	[ebp-12],ecx
1002
	cmp	eax,ecx
1003
	je	.labl_74
1004
;----------------------------------------------------------
1005
.labl_21:
1006
	mov	edi,[ebp-12]
1007
	inc	dword [ebp+8]
1008
	mov	ebx,edi
1009
	imul	ebx,ebx,40
1010
	mov	dl,[ebx+state.Prev1IsChar]
1011
	mov	esi,[ebx+state.PosPrev]
1012
	test	dl,dl
1013
	je	.labl_25
1014
 
1015
	dec	esi
1016
	cmp	byte [ebx+state.Prev2],0
1017
	je	.labl_23
1018
 
1019
	mov	eax,[ebx+state.PosPrev2]
1020
	imul	eax,eax,40
1021
	cmp	dword [ebx+state.BackPrev2],4
1022
	mov	al,[eax+state.State]
1023
	movzx	eax,al
1024
	jnb	.labl_22
1025
 
1026
	mov	al,[eax+RepNextStates]
1027
	jmp	.labl_24
1028
;----------------------------------------------------------
1029
.labl_22:
1030
	mov	al,[eax+MatchNextStates]
1031
	jmp	.labl_24
1032
;----------------------------------------------------------
1033
.labl_23:
1034
	mov	eax,esi
1035
	imul	eax,eax,40
1036
	mov	al,[eax+state.State]
1037
;----------------------------------------------------------
1038
.labl_24:
1039
	movzx	eax,al
1040
	mov	cl,[eax+LiteralNextStates]
1041
	jmp	.labl_26
1042
;----------------------------------------------------------
1043
.labl_25:
1044
	mov	eax,esi
1045
	imul	eax,eax,40
1046
	mov	cl,[eax+state.State]
1047
;----------------------------------------------------------
1048
.labl_26:
1049
	dec	edi
1050
	cmp	esi,edi
1051
	jne	.labl_29
1052
 
1053
	cmp	dword [ebx+state.BackPrev],0
1054
	movzx	eax,cl
1055
	jne	.labl_27
1056
 
1057
	mov	al,[eax+ShortRepNextStates]
1058
	jmp	.labl_28
1059
;----------------------------------------------------------
1060
.labl_27:
1061
	mov	al,[eax+LiteralNextStates]
1062
;----------------------------------------------------------
1063
.labl_28:
1064
	mov	[ebp-20],al
1065
	jmp	.labl_35
1066
;----------------------------------------------------------
1067
.labl_29:
1068
	test	dl,dl
1069
	je	.labl_31
1070
 
1071
	cmp	byte [ebx+state.Prev2],0
1072
	je	.labl_31
1073
 
1074
	mov	esi,[ebx+state.PosPrev2]
1075
	mov	eax,[ebx+state.BackPrev2]
1076
	movzx	ecx,cl
1077
;----------------------------------------------------------
1078
.labl_30:
1079
	mov	cl,[ecx+RepNextStates]
1080
	jmp	.labl_32
1081
;----------------------------------------------------------
1082
.labl_31:
1083
	mov	eax,[ebx+state.BackPrev]
1084
	movzx	ecx,cl
1085
	cmp	eax,4
1086
	jb	.labl_30
1087
 
1088
	mov	cl,[ecx+MatchNextStates]
1089
;----------------------------------------------------------
1090
.labl_32:
1091
	imul	esi,esi,40
1092
	add	esi,state.State
1093
	mov	[ebp-20],cl
1094
	mov	edx,esi
1095
	cmp	eax,4
1096
	jnb	.labl_34
1097
 
1098
	mov	ecx,[edx+eax*4+24]
1099
	xor	esi,esi
1100
	inc	esi
1101
	mov	[ebp-100],ecx
1102
	cmp	eax,esi
1103
	jb	.labl_33
1104
 
1105
	lea	esi,[edx+24]
1106
	mov	ecx,eax
1107
	lea	edi,[ebp-96]
1108
	rep	movsd
1109
	lea	esi,[eax+1]
1110
	cmp	esi,4
1111
	jnb	.labl_35
1112
;----------------------------------------------------------
1113
.labl_33:
1114
	push	4
1115
	lea	edx,[edx+esi*4+24]
1116
	pop	ecx
1117
	lea	edi,[ebp+esi*4-100]
1118
	sub	ecx,esi
1119
	mov	esi,edx
1120
	rep	movsd
1121
	jmp	.labl_35
1122
;----------------------------------------------------------
1123
.labl_34:
1124
	add	eax,0xFFFFFFFC
1125
	mov	[ebp-100],eax
1126
	lea	esi,[edx+24]
1127
	lea	edi,[ebp-96]
1128
	movsd
1129
	movsd
1130
	movsd
1131
;----------------------------------------------------------
1132
.labl_35:
1133
	mov	al,[ebp-20]
1134
	mov	[ebx+state.State],al
1135
	lea	edi,[ebx+state.Backs]
1136
	lea	esi,[ebp-100]
1137
	movsd
1138
	movsd
1139
	movsd
1140
	movsd
1141
	call	ReadMatchDistances
1142
	mov	[ebp-44],eax
1143
	cmp	eax,128
1144
	jnb	.labl_73
1145
 
1146
	mov	eax,[ebx+state.Price]
1147
	mov	edi,[_pos]
1148
	mov	esi,[ebp+8]
1149
	mov	[ebp-72],eax
1150
	mov	eax,[_buffer]
1151
	lea	eax,[edi+eax-1]
1152
	mov	cl,[eax]
1153
	mov	[ebp-48],cl
1154
	push	dword [ebp-48]
1155
	mov	ecx,eax
1156
	sub	ecx,[ebp-100]
1157
	and	esi,3
1158
	mov	cl,[ecx-1]
1159
	mov	[ebp-52],cl
1160
	movzx	ecx,byte [ebp-20]
1161
	push	dword [ebp-52]
1162
	mov	[ebp-64],ecx
1163
	shl	ecx,4
1164
	add	ecx,esi
1165
	mov	ecx,[_isMatch+ecx*4]
1166
	cmp	byte [ebp-20],7
1167
	mov	[ebp-76],ecx
1168
	sbb	cl,cl
1169
	inc	cl
1170
	movzx	ecx,cl
1171
	push	ecx
1172
	push	dword [ebp+8]
1173
	mov	[ebp-40],eax
1174
	mov	al,[eax-1]
1175
	mov	[ebp-28],esi
1176
	call	CLiteralEncoder_GetPrice
1177
	mov	esi,eax
1178
	mov	eax,[ebp-76]
1179
	shr	eax,2
1180
	add	esi,[Models+eax*4]
1181
	mov	byte [ebp-1],0
1182
	add	esi,[ebp-72]
1183
	cmp	esi,[ebx+state.Price+40]
1184
	jnb	.labl_36
1185
 
1186
	mov	eax,[ebp-12]
1187
	or	dword [ebx+state.BackPrev+40],0xFFFFFFFF
1188
	mov	[ebx+state.Price+40],esi
1189
	mov	[ebx+state.PosPrev+40],eax
1190
	mov	byte [ebx+state.Prev1IsChar+40],0
1191
	mov	byte [ebp-1],1
1192
;----------------------------------------------------------
1193
.labl_36:
1194
	mov	edx,[ebp-64]
1195
	mov	edx,[_isRep+edx*4]
1196
	mov	ecx,2048
1197
	mov	eax,ecx
1198
	sub	eax,[ebp-76]
1199
	sub	ecx,edx
1200
	shr	eax,2
1201
	mov	eax,[Models+eax*4]
1202
	add	eax,[ebp-72]
1203
	shr	ecx,2
1204
	mov	ecx,[Models+ecx*4]
1205
	add	ecx,eax
1206
	mov	[ebp-76],eax
1207
	mov	al,[ebp-48]
1208
	mov	[ebp-84],edx
1209
	mov	[ebp-72],ecx
1210
	cmp	[ebp-52],al
1211
	jne	.labl_38
1212
 
1213
	mov	eax,[ebp-12]
1214
	cmp	[ebx+state.PosPrev+40],eax
1215
	jnb	.labl_37
1216
 
1217
	cmp	dword [ebx+state.BackPrev+40],0
1218
	je	.labl_38
1219
;----------------------------------------------------------
1220
.labl_37:
1221
	push	dword [ebp-28]
1222
	mov	al,[ebp-20]
1223
	call	GetRepLen1Price
1224
	add	eax,[ebp-72]
1225
	cmp	eax,[ebx+state.Price+40]
1226
	ja	.labl_38
1227
 
1228
	and	dword [ebx+state.BackPrev+40],0
1229
	mov	[ebx+state.Price+40],eax
1230
	mov	eax,[ebp-12]
1231
	mov	[ebx+state.PosPrev+40],eax
1232
	mov	byte [ebx+state.Prev1IsChar+40],0
1233
;----------------------------------------------------------
1234
.labl_38:
1235
	mov	eax,[_streamPos]
1236
	sub	eax,edi
1237
	mov	ecx,4095
1238
	sub	ecx,[ebp-12]
1239
	inc	eax
1240
	mov	[ebp-56],eax
1241
	cmp	eax,ecx
1242
	jbe	.labl_39
1243
 
1244
	mov	eax,ecx
1245
	mov	[ebp-56],ecx
1246
;----------------------------------------------------------
1247
.labl_39:
1248
	mov	[ebp-36],eax
1249
	cmp	eax,2
1250
	jb	.labl_72
1251
 
1252
	mov	ecx,128
1253
	cmp	eax,ecx
1254
	jbe	.labl_40
1255
 
1256
	mov	[ebp-36],ecx
1257
;----------------------------------------------------------
1258
.labl_40:
1259
	cmp	dword [ebp-36],3
1260
	jb	.labl_45
1261
 
1262
	cmp	byte [ebp-1],0
1263
	jne	.labl_45
1264
 
1265
	mov	ecx,[ebp-100]
1266
	xor	eax,eax
1267
	inc	eax
1268
	inc	ecx
1269
	cmp	[ebp-36],eax
1270
	jbe	.labl_42
1271
 
1272
	mov	edi,[ebp-40]
1273
	mov	edx,edi
1274
	sub	edx,ecx
1275
;----------------------------------------------------------
1276
.labl_41:
1277
	mov	cl,[eax+edi]
1278
	cmp	cl,[edx+eax]
1279
	jne	.labl_42
1280
 
1281
	inc	eax
1282
	cmp	eax,[ebp-36]
1283
	jb	.labl_41
1284
;----------------------------------------------------------
1285
.labl_42:
1286
	dec	eax
1287
	mov	[ebp-32],eax
1288
	cmp	eax,2
1289
	jb	.labl_45
1290
 
1291
	mov	eax,[ebp-64]
1292
	mov	al,[eax+LiteralNextStates]
1293
	mov	ecx,[ebp+8]
1294
	movzx	edx,al
1295
	mov	[ebp-60],al
1296
	mov	eax,edx
1297
	shl	eax,4
1298
	inc	ecx
1299
	mov	edi,2048
1300
	and	ecx,3
1301
	add	eax,ecx
1302
	mov	ebx,edi
1303
	sub	ebx,[_isMatch+eax*4]
1304
	mov	eax,edi
1305
	sub	eax,[_isRep+edx*4]
1306
	mov	edx,[ebp-12]
1307
	shr	ebx,2
1308
	mov	edi,[Models+ebx*4]
1309
	shr	eax,2
1310
	add	edi,[Models+eax*4]
1311
	mov	eax,[ebp-32]
1312
	add	edi,esi
1313
	lea	esi,[edx+eax]
1314
	mov	eax,[ebp-8]
1315
	lea	edx,[esi+1]
1316
	cmp	eax,edx
1317
	jnb	.labl_44
1318
 
1319
	sub	edx,[ebp-8]
1320
	imul	eax,eax,40
1321
	add	eax,state.Price
1322
	add	[ebp-8],edx
1323
;----------------------------------------------------------
1324
.labl_43:
1325
	add	eax,40
1326
	dec	edx
1327
	mov	dword [eax],kIfinityPrice
1328
	jne	.labl_43
1329
;----------------------------------------------------------
1330
.labl_44:
1331
	mov	eax,[ebp-32]
1332
	push	ecx
1333
	push	dword [ebp-60]
1334
	xor	edx,edx
1335
	call	GetRepPrice
1336
	imul	esi,esi,40
1337
	add	eax,edi
1338
	add	esi,state.State+40
1339
	cmp	eax,[esi+12]
1340
	jnb	.labl_45
1341
 
1342
	mov	[esi+12],eax
1343
	mov	eax,[ebp-12]
1344
	inc	eax
1345
	and	dword [esi+20],0
1346
	mov	[esi+16],eax
1347
	mov	byte [esi+1],1
1348
	mov	byte [esi+2],0
1349
;----------------------------------------------------------
1350
.labl_45:
1351
	and	dword [ebp-24],0
1352
;----------------------------------------------------------
1353
.labl_46:
1354
	mov	eax,[ebp-24]
1355
	mov	eax,[ebp+eax*4-100]
1356
	mov	edx,[ebp-40]
1357
	inc	eax
1358
	mov	ecx,edx
1359
	sub	ecx,eax
1360
	mov	[ebp-68],eax
1361
	mov	al,[edx]
1362
	mov	[ebp-80],ecx
1363
	cmp	al,[ecx]
1364
	jne	.labl_58
1365
 
1366
	mov	al,[edx+1]
1367
	cmp	al,[ecx+1]
1368
	jne	.labl_58
1369
 
1370
	push	2
1371
	pop	esi
1372
	cmp	[ebp-36],esi
1373
	jbe	.labl_48
1374
;----------------------------------------------------------
1375
.labl_47:
1376
	mov	al,[edx+esi]
1377
	cmp	al,[ecx+esi]
1378
	jne	.labl_48
1379
 
1380
	inc	esi
1381
	cmp	esi,[ebp-36]
1382
	jb	.labl_47
1383
;----------------------------------------------------------
1384
.labl_48:
1385
	mov	eax,[ebp-12]
1386
	lea	ebx,[eax+esi]
1387
	mov	[ebp-32],ebx
1388
	imul	ebx,ebx,40
1389
	mov	edi,esi
1390
	add	ebx,state.Price
1391
;----------------------------------------------------------
1392
.labl_49:
1393
	mov	eax,[ebp-8]
1394
	mov	ecx,[ebp-32]
1395
	cmp	eax,ecx
1396
	jnb	.labl_51
1397
 
1398
	sub	ecx,[ebp-8]
1399
	imul	eax,eax,40
1400
	add	eax,state.Price
1401
	add	[ebp-8],ecx
1402
;----------------------------------------------------------
1403
.labl_50:
1404
	add	eax,40
1405
	dec	ecx
1406
	mov	dword [eax],kIfinityPrice
1407
	jne	.labl_50
1408
;----------------------------------------------------------
1409
.labl_51:
1410
	push	dword [ebp-28]
1411
	mov	edx,[ebp-24]
1412
	push	dword [ebp-20]
1413
	mov	eax,esi
1414
	call	GetRepPrice
1415
	add	eax,[ebp-72]
1416
	cmp	eax,[ebx]
1417
	jnb	.labl_52
1418
 
1419
	mov	[ebx],eax
1420
	mov	eax,[ebp-12]
1421
	mov	[ebx+4],eax
1422
	mov	eax,[ebp-24]
1423
	mov	[ebx+8],eax
1424
	mov	byte [ebx-11],0
1425
;----------------------------------------------------------
1426
.labl_52:
1427
	dec	esi
1428
	sub	ebx,40
1429
	dec	dword [ebp-32]
1430
	cmp	esi,2
1431
	jnb	.labl_49
1432
 
1433
	lea	eax,[edi+1]
1434
	lea	esi,[eax+128]
1435
	cmp	esi,[ebp-56]
1436
	jbe	.labl_53
1437
 
1438
	mov	esi,[ebp-56]
1439
;----------------------------------------------------------
1440
.labl_53:
1441
	cmp	eax,esi
1442
	jnb	.labl_55
1443
 
1444
	mov	edx,[ebp-40]
1445
	mov	ecx,eax
1446
	sub	ecx,[ebp-68]
1447
	add	ecx,edx
1448
;----------------------------------------------------------
1449
.labl_54:
1450
	mov	bl,[eax+edx]
1451
	cmp	bl,[ecx]
1452
	jne	.labl_55
1453
 
1454
	inc	eax
1455
	inc	ecx
1456
	cmp	eax,esi
1457
	jb	.labl_54
1458
;----------------------------------------------------------
1459
.labl_55:
1460
	or	ecx,0xFFFFFFFF
1461
	sub	ecx,edi
1462
	add	eax,ecx
1463
	mov	[ebp-16],eax
1464
	cmp	eax,2
1465
	jb	.labl_58
1466
 
1467
	mov	eax,[ebp-64]
1468
	mov	al,[eax+RepNextStates]
1469
	mov	edx,[ebp+8]
1470
	movzx	eax,al
1471
	mov	ebx,eax
1472
	mov	al,[eax+LiteralNextStates]
1473
	lea	ecx,[edi+edx]
1474
	mov	[ebp-60],al
1475
	movzx	eax,al
1476
	mov	esi,ecx
1477
	and	esi,3
1478
	shl	ebx,4
1479
	add	esi,ebx
1480
	mov	esi,[_isMatch+esi*4]
1481
	lea	ebx,[edi+edx+1]
1482
	mov	[ebp-32],eax
1483
	mov	eax,[ebp-40]
1484
	movzx	edx,byte [edi+eax]
1485
	mov	al,[eax+edi-1]
1486
	push	edx
1487
	mov	edx,[ebp-80]
1488
	movzx	edx,byte [edx+edi]
1489
	push	edx
1490
	shr	esi,2
1491
	mov	esi,[Models+esi*4]
1492
	push	1
1493
	push	ecx
1494
	mov	[ebp-68],esi
1495
	and	ebx,3
1496
	call	CLiteralEncoder_GetPrice
1497
	push	dword [ebp-28]
1498
	mov	edx,[ebp-24]
1499
	push	dword [ebp-20]
1500
	mov	esi,eax
1501
	mov	eax,edi
1502
	call	GetRepPrice
1503
	mov	ecx,[ebp-32]
1504
	add	esi,eax
1505
	shl	ecx,4
1506
	add	ecx,ebx
1507
	mov	eax,2048
1508
	mov	edx,eax
1509
	sub	edx,[_isMatch+ecx*4]
1510
	mov	ecx,[ebp-32]
1511
	sub	eax,[_isRep+ecx*4]
1512
	mov	ecx,[ebp-12]
1513
	shr	edx,2
1514
	add	esi,[Models+edx*4]
1515
	shr	eax,2
1516
	add	esi,[Models+eax*4]
1517
	mov	eax,[ebp-16]
1518
	add	esi,[ebp-68]
1519
	lea	eax,[eax+edi+1]
1520
	add	esi,[ebp-72]
1521
	add	eax,ecx
1522
	mov	[ebp-68],eax
1523
	cmp	[ebp-8],eax
1524
	jnb	.labl_57
1525
 
1526
	mov	eax,[ebp-8]
1527
	mov	ecx,[ebp-68]
1528
	imul	eax,eax,40
1529
	sub	ecx,[ebp-8]
1530
	add	eax,state.Price
1531
	add	[ebp-8],ecx
1532
;----------------------------------------------------------
1533
.labl_56:
1534
	add	eax,40
1535
	dec	ecx
1536
	mov	dword [eax],kIfinityPrice
1537
	jne	.labl_56
1538
;----------------------------------------------------------
1539
.labl_57:
1540
	mov	eax,[ebp-16]
1541
	push	ebx
1542
	push	dword [ebp-60]
1543
	xor	edx,edx
1544
	call	GetRepPrice
1545
	mov	ecx,[ebp-68]
1546
	imul	ecx,ecx,40
1547
	add	eax,esi
1548
	add	ecx,state.State
1549
	cmp	eax,[ecx+12]
1550
	jnb	.labl_58
1551
 
1552
	and	dword [ecx+20],0
1553
	mov	[ecx+12],eax
1554
	mov	eax,[ebp-12]
1555
	lea	edx,[edi+eax+1]
1556
	mov	[ecx+4],eax
1557
	mov	eax,[ebp-24]
1558
	mov	[ecx+16],edx
1559
	mov	byte [ecx+1],1
1560
	mov	byte [ecx+2],1
1561
	mov	[ecx+8],eax
1562
;----------------------------------------------------------
1563
.labl_58:
1564
	inc	dword [ebp-24]
1565
	cmp	dword [ebp-24],4
1566
	jb	.labl_46
1567
 
1568
	mov	eax,[ebp-36]
1569
	cmp	[ebp-44],eax
1570
	jbe	.labl_59
1571
 
1572
	mov	[ebp-44],eax
1573
;----------------------------------------------------------
1574
.labl_59:
1575
	cmp	dword [ebp-44],2
1576
	jb	.labl_72
1577
 
1578
	mov	esi,[ebp-44]
1579
	cmp	esi,2
1580
	jne	.labl_60
1581
 
1582
	cmp	dword [distances+8],0x80
1583
	jnb	.labl_72
1584
;----------------------------------------------------------
1585
.labl_60:
1586
	mov	eax,[ebp-84]
1587
	shr	eax,2
1588
	mov	eax,[Models+eax*4]
1589
	add	eax,[ebp-76]
1590
	mov	[ebp-76],eax
1591
	mov	eax,[ebp-12]
1592
	lea	ecx,[esi+eax]
1593
	cmp	[ebp-8],ecx
1594
	jnb	.labl_62
1595
 
1596
	mov	eax,[ebp-8]
1597
	imul	eax,eax,40
1598
	mov	edx,ecx
1599
	sub	edx,[ebp-8]
1600
	add	eax,state.Price
1601
	add	[ebp-8],edx
1602
;----------------------------------------------------------
1603
.labl_61:
1604
	add	eax,40
1605
	dec	edx
1606
	mov	dword [eax],kIfinityPrice
1607
	jne	.labl_61
1608
;----------------------------------------------------------
1609
.labl_62:
1610
	imul	ecx,ecx,40
1611
	add	ecx,state.Price
1612
	lea	eax,[distances+4+esi*4]
1613
	lea	edi,[esi+1]
1614
	mov	[ebp-36],eax
1615
	mov	ebx,ecx
1616
	mov	[ebp-72],ecx
1617
;----------------------------------------------------------
1618
.labl_63:
1619
	mov	eax,[ebp-36]
1620
	mov	esi,[eax-4]
1621
	push	dword [ebp-28]
1622
	lea	eax,[edi-1]
1623
	mov	edx,esi
1624
	call	GetPosLenPrice
1625
	add	eax,[ebp-76]
1626
	mov	[ebp-80],eax
1627
	cmp	eax,[ebx]
1628
	jnb	.labl_64
1629
 
1630
	mov	[ebx],eax
1631
	mov	eax,[ebp-12]
1632
	mov	[ebx+4],eax
1633
	lea	eax,[esi+4]
1634
	mov	[ebx+8],eax
1635
	mov	byte [ebx-11],0
1636
;----------------------------------------------------------
1637
.labl_64:
1638
	lea	eax,[edi-1]
1639
	cmp	eax,[ebp-44]
1640
	je	.labl_65
1641
 
1642
	mov	eax,[ebp-36]
1643
	cmp	esi,[eax]
1644
	je	.labl_71
1645
;----------------------------------------------------------
1646
.labl_65:
1647
	inc	esi
1648
	lea	ecx,[edi+128]
1649
	mov	[ebp-68],esi
1650
	mov	[ebp-16],edi
1651
	cmp	ecx,[ebp-56]
1652
	jbe	.labl_66
1653
 
1654
	mov	ecx,[ebp-56]
1655
;----------------------------------------------------------
1656
.labl_66:
1657
	cmp	edi,ecx
1658
	jnb	.labl_68
1659
 
1660
	mov	eax,edi
1661
	sub	eax,esi
1662
	add	eax,[ebp-40]
1663
;----------------------------------------------------------
1664
.labl_67:
1665
	mov	edx,[ebp-16]
1666
	mov	esi,[ebp-40]
1667
	mov	dl,[edx+esi]
1668
	cmp	dl,[eax]
1669
	jne	.labl_68
1670
 
1671
	inc	dword [ebp-16]
1672
	inc	eax
1673
	cmp	[ebp-16],ecx
1674
	jb	.labl_67
1675
;----------------------------------------------------------
1676
.labl_68:
1677
	or	ecx,0xFFFFFFFF
1678
	lea	eax,[edi-1]
1679
	sub	ecx,eax
1680
	add	[ebp-16],ecx
1681
	cmp	dword [ebp-16],2
1682
	jb	.labl_71
1683
 
1684
	mov	eax,[ebp-64]
1685
	mov	al,[eax+MatchNextStates]
1686
	mov	ecx,[ebp+8]
1687
	movzx	eax,al
1688
	mov	esi,eax
1689
	mov	al,[eax+LiteralNextStates]
1690
	lea	edx,[edi+ecx-1]
1691
	mov	[ebp-60],al
1692
	movzx	eax,al
1693
	shl	esi,4
1694
	mov	ebx,edx
1695
	and	ebx,3
1696
	add	esi,ebx
1697
	mov	esi,[_isMatch+esi*4]
1698
	lea	ebx,[edi+ecx]
1699
	mov	[ebp-32],eax
1700
	mov	eax,[ebp-40]
1701
	movzx	ecx,byte [edi+eax-1]
1702
	push	ecx
1703
	mov	ecx,edi
1704
	sub	ecx,[ebp-68]
1705
	shr	esi,2
1706
	movzx	ecx,byte [ecx+eax-1]
1707
	mov	esi,[Models+esi*4]
1708
	mov	al,[edi+eax-2]
1709
	push	ecx
1710
	push	1
1711
	push	edx
1712
	mov	[ebp-84],esi
1713
	and	ebx,3
1714
	call	CLiteralEncoder_GetPrice
1715
	mov	ecx,[ebp-32]
1716
	mov	esi,eax
1717
	shl	ecx,4
1718
	add	ecx,ebx
1719
	mov	eax,2048
1720
	mov	edx,eax
1721
	sub	edx,[_isMatch+ecx*4]
1722
	mov	ecx,[ebp-32]
1723
	sub	eax,[_isRep+ecx*4]
1724
	mov	ecx,[ebp-12]
1725
	shr	edx,2
1726
	add	esi,[Models+edx*4]
1727
	shr	eax,2
1728
	add	esi,[Models+eax*4]
1729
	mov	eax,[ebp-16]
1730
	add	esi,[ebp-84]
1731
	add	eax,edi
1732
	add	esi,[ebp-80]
1733
	add	eax,ecx
1734
	mov	[ebp-32],eax
1735
	cmp	[ebp-8],eax
1736
	jnb	.labl_70
1737
 
1738
	mov	eax,[ebp-8]
1739
	mov	ecx,[ebp-32]
1740
	imul	eax,eax,40
1741
	sub	ecx,[ebp-8]
1742
	add	eax,state.Price
1743
	add	[ebp-8],ecx
1744
;----------------------------------------------------------
1745
.labl_69:
1746
	add	eax,40
1747
	dec	ecx
1748
	mov	dword [eax],kIfinityPrice
1749
	jne	.labl_69
1750
;----------------------------------------------------------
1751
.labl_70:
1752
	mov	eax,[ebp-16]
1753
	push	ebx
1754
	push	dword [ebp-60]
1755
	xor	edx,edx
1756
	call	GetRepPrice
1757
	mov	ecx,[ebp-32]
1758
	mov	ebx,[ebp-72]
1759
	imul	ecx,ecx,40
1760
	add	eax,esi
1761
	add	ecx,state.State
1762
	cmp	eax,[ecx+12]
1763
	jnb	.labl_71
1764
 
1765
	and	dword [ecx+20],0
1766
	mov	[ecx+12],eax
1767
	mov	eax,[ebp-12]
1768
	lea	edx,[edi+eax]
1769
	mov	[ecx+4],eax
1770
	mov	eax,[ebp-68]
1771
	add	eax,3
1772
	mov	[ecx+16],edx
1773
	mov	byte [ecx+1],1
1774
	mov	byte [ecx+2],1
1775
	mov	[ecx+8],eax
1776
;----------------------------------------------------------
1777
.labl_71:
1778
	sub	dword [ebp-36],4
1779
	sub	ebx,40
1780
	dec	edi
1781
	lea	eax,[edi-1]
1782
	mov	[ebp-72],ebx
1783
	cmp	eax,2
1784
	jnb	.labl_63
1785
;----------------------------------------------------------
1786
.labl_72:
1787
	inc	dword [ebp-12]
1788
	mov	eax,[ebp-12]
1789
	cmp	eax,[ebp-8]
1790
	jne	.labl_21
1791
 
1792
	jmp	.labl_74
1793
;----------------------------------------------------------
1794
.labl_73:
1795
	mov	eax,[ebp-44]
1796
	mov	[_longestMatchLength],eax
1797
	mov	byte [_longestMatchWasFound],1
1798
;----------------------------------------------------------
1799
.labl_74:
1800
	push	dword [ebp-12]
1801
	push	dword [ebp+12]
1802
	call	Backward
1803
	mov	ecx,[ebp+16]
1804
	mov	[ecx],eax
1805
;----------------------------------------------------------
1806
.labl_75:
1807
	pop	ebx
1808
	pop	edi
1809
;----------------------------------------------------------
1810
.labl_76:
1811
	pop	esi
1812
	leave
1813
	ret	12
1814
;*****************************************************************************
1815
 
1816
;* Call: ***************************************************************
1817
CLiteralEncoder2_EncodeMatched:
1818
	push	ebp
1819
	mov	ebp,esp
1820
	push	ecx
1821
	push	ebx
1822
	push	esi
1823
	xor	ebx,ebx
1824
	push	edi
1825
	inc	ebx
1826
	mov	dword [ebp-4],8
1827
;----------------------------------------------------------
1828
.labl_00:
1829
	dec	dword [ebp-4]
1830
	movzx	ecx,byte [ebp-4]
1831
	movzx	esi,byte [ebp+12]
1832
	movzx	edi,byte [ebp+16]
1833
	shr	esi,cl
1834
	shr	edi,cl
1835
	mov	ecx,[ebp+8]
1836
	and	esi,1
1837
	lea	eax,[esi+1]
1838
	shl	eax,8
1839
	add	eax,ebx
1840
	and	edi,1
1841
	push	edi
1842
	lea	edx,[ecx+eax*4]
1843
	call	CMyBitEncoder_Encode
1844
	add	ebx,ebx
1845
	or	ebx,edi
1846
	cmp	esi,edi
1847
	jne	.labl_02
1848
 
1849
	cmp	dword [ebp-4],0
1850
	jne	.labl_00
1851
 
1852
	jmp	.labl_03
1853
;----------------------------------------------------------
1854
.labl_01:
1855
	dec	dword [ebp-4]
1856
	movzx	esi,byte [ebp+16]
1857
	mov	cl,[ebp-4]
1858
	mov	eax,[ebp+8]
1859
	shr	esi,cl
1860
	lea	edx,[eax+ebx*4]
1861
	and	esi,1
1862
	push	esi
1863
	call	CMyBitEncoder_Encode
1864
	add	ebx,ebx
1865
	or	ebx,esi
1866
;----------------------------------------------------------
1867
.labl_02:
1868
	cmp	dword [ebp-4],0
1869
	jne	.labl_01
1870
;----------------------------------------------------------
1871
.labl_03:
1872
	pop	edi
1873
	pop	esi
1874
	pop	ebx
1875
	leave
1876
	ret	12
1877
;*****************************************************************************
1878
 
1879
;* Call: ***************************************************************
1880
RangeEncoder_EncodeDirectBits:
1881
	push	esi
1882
	mov	esi,eax
1883
	jmp	.labl_02
1884
;----------------------------------------------------------
1885
.labl_00:
1886
	mov	eax,[esp+8]
1887
	shr	dword [_range],1
1888
	dec	esi
1889
	mov	ecx,esi
1890
	shr	eax,cl
1891
	test	al,1
1892
	je	.labl_01
1893
 
1894
	mov	eax,[_range]
1895
	add	[low],eax
1896
	adc	dword [low+4],0
1897
;----------------------------------------------------------
1898
.labl_01:
1899
	cmp	dword [_range],0x1000000
1900
	jnb	.labl_02
1901
 
1902
	shl	dword [_range],8
1903
	call	RangeEncoder_ShiftLow
1904
;----------------------------------------------------------
1905
.labl_02:
1906
	test	esi,esi
1907
	jne	.labl_00
1908
 
1909
	pop	esi
1910
	ret	4
1911
;*****************************************************************************
1912
 
1913
;* Call: ***************************************************************
1914
CBitTreeEncoder_ReverseEncode:
1915
	push	esi
1916
	xor	esi,esi
1917
	push	edi
1918
	mov	edi,[i_01]
1919
	inc	esi
1920
;----------------------------------------------------------
1921
.labl_00:
1922
	mov	eax,[esp+12]
1923
	and	eax,1
1924
	lea	edx,[_posAlignEncoder+esi*4]
1925
	push	eax
1926
	lea	esi,[eax+esi*2]
1927
	call	CMyBitEncoder_Encode
1928
	shr	dword [esp+12],1
1929
	dec	edi
1930
	jne	.labl_00
1931
 
1932
	pop	edi
1933
	pop	esi
1934
	ret	4
1935
;*****************************************************************************
1936
 
1937
;* Call: ***************************************************************
1938
MovePos:
1939
	push	esi
1940
	mov	esi,eax
1941
	test	esi,esi
1942
	je	.labl_01
1943
 
1944
	add	[_additionalOffset],esi
1945
;----------------------------------------------------------
1946
.labl_00:
1947
	dec	esi
1948
	call	lz_cm_09
1949
	call	MatchFinder_MovePos
1950
	test	esi,esi
1951
	jne	.labl_00
1952
;----------------------------------------------------------
1953
.labl_01:
1954
	pop	esi
1955
	ret
1956
;*****************************************************************************
1957
 
1958
;* Call: ***************************************************************
1959
Backward:
1960
	push	ebp
1961
	mov	ebp,esp
1962
	push	ecx
1963
	mov	ecx,[ebp+12]
1964
	mov	eax,ecx
1965
	imul	eax,eax,40
1966
	mov	edx,[eax+state.PosPrev]
1967
	mov	eax,[eax+state.BackPrev]
1968
	push	ebx
1969
	push	esi
1970
	mov	[_optimumEndIndex],ecx
1971
	mov	[ebp-4],eax
1972
	push	edi
1973
;----------------------------------------------------------
1974
.labl_00:
1975
	imul	ecx,ecx,40
1976
	cmp	byte [ecx+state.Prev1IsChar],0
1977
	je	.labl_01
1978
 
1979
	mov	eax,edx
1980
	imul	eax,eax,40
1981
	or	dword [eax+state.BackPrev],0xFFFFFFFF
1982
	lea	esi,[eax+state.Prev1IsChar]
1983
	lea	edi,[eax+state.PosPrev]
1984
	lea	ebx,[edx-1]
1985
	mov	byte [esi],0
1986
	mov	[edi],ebx
1987
	cmp	byte [ecx+state.Prev2],0
1988
	je	.labl_01
1989
 
1990
	mov	byte [esi-40],0
1991
	mov	esi,[ecx+state.PosPrev2]
1992
	mov	[edi-40],esi
1993
	mov	ecx,[ecx+state.BackPrev2]
1994
	mov	[eax+state.BackPrev-40],ecx
1995
;----------------------------------------------------------
1996
.labl_01:
1997
	mov	ecx,[ebp-4]
1998
	mov	eax,edx
1999
	imul	eax,eax,40
2000
	mov	esi,edx
2001
	mov	edx,[eax+state.BackPrev]
2002
	mov	[eax+state.BackPrev],ecx
2003
	mov	ecx,[ebp+12]
2004
	mov	[ebp-4],edx
2005
	mov	edx,[eax+state.PosPrev]
2006
	mov	[eax+state.PosPrev],ecx
2007
	mov	ecx,esi
2008
	mov	[ebp+12],ecx
2009
	test	esi,esi
2010
	jne	.labl_00
2011
 
2012
	mov	eax,[state.BackPrev]
2013
	mov	ecx,[ebp+8]
2014
	pop	edi
2015
	mov	[ecx],eax
2016
	mov	eax,[state.PosPrev]
2017
	pop	esi
2018
	mov	[_optimumCurrentIndex],eax
2019
	pop	ebx
2020
	leave
2021
	ret	8
2022
;*****************************************************************************
2023
 
2024
;* Call: ***************************************************************
2025
lz_cm_09:
2026
	push	ebp
2027
	mov	ebp,esp
2028
	mov	edx,[_matchMaxLen]
2029
	mov	eax,[_pos]
2030
	mov	ecx,[_streamPos]
2031
	sub	esp,44
2032
	push	esi
2033
	lea	esi,[edx+eax]
2034
	cmp	esi,ecx
2035
	ja	.labl_00
2036
 
2037
	mov	[ebp-24],edx
2038
	jmp	.labl_01
2039
;----------------------------------------------------------
2040
.labl_00:
2041
	sub	ecx,eax
2042
	mov	[ebp-24],ecx
2043
	cmp	ecx,3
2044
	jb	.labl_13
2045
;----------------------------------------------------------
2046
.labl_01:
2047
	mov	ecx,[_cyclicBufferSize]
2048
	mov	edx,eax
2049
	sub	edx,ecx
2050
	cmp	ecx,eax
2051
	mov	ecx,[_buffer]
2052
	lea	esi,[ecx+eax]
2053
	movzx	ecx,byte [esi+2]
2054
	push	ebx
2055
	movzx	ebx,word [esi]
2056
	push	edi
2057
	sbb	edi,edi
2058
	and	dword [ebp-28],0
2059
	and	dword [ebp-40],0
2060
	shl	ecx,8
2061
	and	edi,edx
2062
	movzx	edx,byte [esi]
2063
	xor	ecx,[crc_table+edx*4]
2064
	movzx	edx,byte [esi+1]
2065
	xor	ecx,edx
2066
	mov	edx,[_hash]
2067
	and	ecx,0xFFFFF
2068
	lea	ecx,[edx+ecx*4]
2069
	mov	[edx+ebx*4+0x400000],eax
2070
	mov	ebx,[ecx]
2071
	mov	[ecx],eax
2072
	mov	ecx,[pack_pos]
2073
	lea	ecx,[edx+ecx*8+0x440000]
2074
	mov	[ebp-4],ebx
2075
	lea	ebx,[ecx+4]
2076
	mov	[ebp-12],ecx
2077
	mov	ecx,[_cutValue]
2078
	mov	[ebp-16],ebx
2079
	mov	[ebp-20],ecx
2080
	cmp	[ebp-4],edi
2081
	jbe	.labl_11
2082
;----------------------------------------------------------
2083
.labl_02:
2084
	mov	ecx,[ebp-20]
2085
	dec	dword [ebp-20]
2086
	test	ecx,ecx
2087
	je	.labl_11
2088
 
2089
	mov	ecx,[_buffer]
2090
	mov	ebx,[ebp-4]
2091
	add	ecx,ebx
2092
	mov	[ebp-36],ecx
2093
	mov	ecx,[ebp-40]
2094
	cmp	ecx,[ebp-28]
2095
	jb	.labl_03
2096
 
2097
	mov	ecx,[ebp-28]
2098
;----------------------------------------------------------
2099
.labl_03:
2100
	mov	ebx,[ebp-36]
2101
	mov	[ebp-8],ecx
2102
	add	ecx,esi
2103
	sub	ebx,esi
2104
	mov	[ebp-32],ebx
2105
	jmp	.labl_05
2106
;----------------------------------------------------------
2107
.labl_04:
2108
	mov	ecx,[ebp-44]
2109
	mov	ebx,[ebp-32]
2110
;----------------------------------------------------------
2111
.labl_05:
2112
	mov	bl,[ebx+ecx]
2113
	cmp	bl,[ecx]
2114
	jne	.labl_06
2115
 
2116
	inc	dword [ebp-8]
2117
	inc	ecx
2118
	mov	[ebp-44],ecx
2119
	mov	ecx,[ebp-8]
2120
	cmp	ecx,[ebp-24]
2121
	jne	.labl_04
2122
;----------------------------------------------------------
2123
.labl_06:
2124
	mov	ecx,[pack_pos]
2125
	mov	ebx,eax
2126
	sub	ebx,[ebp-4]
2127
	cmp	ebx,ecx
2128
	ja	.labl_07
2129
 
2130
	sub	ecx,ebx
2131
	jmp	.labl_08
2132
;----------------------------------------------------------
2133
.labl_07:
2134
	sub	ecx,ebx
2135
	add	ecx,[_cyclicBufferSize]
2136
;----------------------------------------------------------
2137
.labl_08:
2138
	lea	ecx,[edx+ecx*8+0x440000]
2139
	mov	[ebp-32],ecx
2140
	mov	ecx,[ebp-8]
2141
	cmp	ecx,[ebp-24]
2142
	je	.labl_14
2143
 
2144
	mov	ebx,[ebp-36]
2145
	mov	bl,[ecx+ebx]
2146
	cmp	bl,[ecx+esi]
2147
	mov	ecx,[ebp-4]
2148
	jnb	.labl_09
2149
 
2150
	mov	ebx,[ebp-12]
2151
	mov	[ebx],ecx
2152
	mov	ecx,[ebp-32]
2153
	mov	ebx,[ebp-8]
2154
	add	ecx,4
2155
	mov	[ebp-12],ecx
2156
	mov	[ebp-28],ebx
2157
	jmp	.labl_10
2158
;----------------------------------------------------------
2159
.labl_09:
2160
	mov	ebx,[ebp-16]
2161
	mov	[ebx],ecx
2162
	mov	ecx,[ebp-32]
2163
	mov	ebx,[ebp-8]
2164
	mov	[ebp-16],ecx
2165
	mov	[ebp-40],ebx
2166
;----------------------------------------------------------
2167
.labl_10:
2168
	mov	ecx,[ecx]
2169
	mov	[ebp-4],ecx
2170
	cmp	ecx,edi
2171
	ja	.labl_02
2172
;----------------------------------------------------------
2173
.labl_11:
2174
	mov	eax,[ebp-12]
2175
	and	dword [eax],0
2176
	mov	eax,[ebp-16]
2177
	and	dword [eax],0
2178
;----------------------------------------------------------
2179
.labl_12:
2180
	pop	edi
2181
	pop	ebx
2182
;----------------------------------------------------------
2183
.labl_13:
2184
	pop	esi
2185
	leave
2186
	ret
2187
;----------------------------------------------------------
2188
.labl_14:
2189
	mov	eax,[ebp-32]
2190
	mov	ecx,[eax]
2191
	mov	edx,[ebp-12]
2192
	mov	[edx],ecx
2193
	mov	eax,[eax+4]
2194
	mov	ecx,[ebp-16]
2195
	mov	[ecx],eax
2196
	jmp	.labl_12
2197
;*****************************************************************************
2198
 
2199
;* Call: ***************************************************************
2200
GetPosSlot:
2201
	cmp	eax,1024
2202
	jnb	.labl_00
2203
 
2204
	movzx	eax,byte [eax+g_FastPos]
2205
	ret
2206
;----------------------------------------------------------
2207
.labl_00:
2208
	cmp	eax,0x80000
2209
	jnb	.labl_01
2210
 
2211
	shr	eax,9
2212
	movzx	eax,byte [eax+g_FastPos]
2213
	add	eax,18
2214
	ret
2215
;----------------------------------------------------------
2216
.labl_01:
2217
	shr	eax,18
2218
	movzx	eax,byte [eax+g_FastPos]
2219
	add	eax,36 ;'$'
2220
	ret
2221
;*****************************************************************************
2222
 
2223
;* Call: ***************************************************************
2224
CPriceTableEncoder_Init:
2225
	push	ebx
2226
	push	edi
2227
	mov	eax,1024
2228
	push	4
2229
	mov	[esi],eax
2230
	mov	[esi+4],eax
2231
	lea	edi,[esi+0x4048]
2232
	pop	ebx
2233
;----------------------------------------------------------
2234
.labl_00:
2235
	push	3
2236
	lea	eax,[edi-0x4040]
2237
	pop	ecx
2238
	call	CBitTreeEncoder_Init
2239
	push	3
2240
	pop	ecx
2241
	mov	eax,edi
2242
	call	CBitTreeEncoder_Init
2243
	add	edi,1028
2244
	dec	ebx
2245
	jne	.labl_00
2246
 
2247
	push	8
2248
	pop	ecx
2249
	pop	edi
2250
	lea	eax,[esi+0x8088]
2251
	pop	ebx
2252
	jmp	CBitTreeEncoder_Init
2253
;*****************************************************************************
2254
 
2255
;* Call: ***************************************************************
2256
CPriceTableEncoder_UpdateTable:
2257
	push	ebx
2258
	push	edi
2259
	mov	edi,eax
2260
	xor	ebx,ebx
2261
	cmp	[edi+0xC88C],ebx
2262
	jbe	.labl_01
2263
 
2264
	mov	eax,[esp+12]
2265
	push	esi
2266
	lea	esi,[edi+eax*4+0x848C]
2267
;----------------------------------------------------------
2268
.labl_00:
2269
	mov	eax,[esp+16]
2270
	mov	edx,ebx
2271
	call	NLength_CEncoder_GetPrice
2272
	mov	[esi],eax
2273
	inc	ebx
2274
	add	esi,64
2275
	cmp	ebx,[edi+0xC88C]
2276
	jb	.labl_00
2277
 
2278
	pop	esi
2279
;----------------------------------------------------------
2280
.labl_01:
2281
	mov	eax,[edi+0xC88C]
2282
	mov	ecx,[esp+12]
2283
	mov	[edi+ecx*4+0xC890],eax
2284
	pop	edi
2285
	pop	ebx
2286
	ret	4
2287
;*****************************************************************************
2288
 
2289
;* Call: ***************************************************************
2290
NLength_CEncoder_GetPrice:
2291
	push	ebp
2292
	mov	ebp,esp
2293
	push	ecx
2294
	push	esi
2295
	cmp	edx,8
2296
	jnb	.labl_00
2297
 
2298
	imul	eax,eax,1028
2299
	lea	esi,[eax+edi+8]
2300
	call	CBitTreeEncoder_GetPrice
2301
	mov	ecx,[edi]
2302
	shr	ecx,2
2303
	add	eax,[Models+ecx*4]
2304
	jmp	.labl_03
2305
;----------------------------------------------------------
2306
.labl_00:
2307
	push	ebx
2308
	mov	ebx,2048
2309
	mov	ecx,ebx
2310
	sub	ecx,[edi]
2311
	shr	ecx,2
2312
	mov	ecx,[Models+ecx*4]
2313
	mov	[ebp-4],ecx
2314
	cmp	edx,16
2315
	jnb	.labl_01
2316
 
2317
	imul	eax,eax,1028
2318
	add	edx,0xFFFFFFF8
2319
	lea	esi,[eax+edi+0x4048]
2320
	call	CBitTreeEncoder_GetPrice
2321
	mov	ecx,[edi+4]
2322
	shr	ecx,2
2323
	add	eax,[Models+ecx*4]
2324
	jmp	.labl_02
2325
;----------------------------------------------------------
2326
.labl_01:
2327
	add	edx,0xFFFFFFF0
2328
	lea	esi,[edi+0x8088]
2329
	call	CBitTreeEncoder_GetPrice
2330
	sub	ebx,[edi+4]
2331
	shr	ebx,2
2332
	add	eax,[Models+ebx*4]
2333
;----------------------------------------------------------
2334
.labl_02:
2335
	add	[ebp-4],eax
2336
	mov	eax,[ebp-4]
2337
	pop	ebx
2338
;----------------------------------------------------------
2339
.labl_03:
2340
	pop	esi
2341
	leave
2342
	ret
2343
;*****************************************************************************
2344
 
2345
;* Call: ***************************************************************
2346
CPriceTableEncoder_Encode:
2347
	push	edi
2348
	mov	edi,eax
2349
	mov	edx,esi
2350
	cmp	edi,8
2351
	jnb	.labl_00
2352
 
2353
	push	0
2354
	call	CMyBitEncoder_Encode
2355
	mov	eax,ebx
2356
	imul	eax,eax,1028
2357
	push	edi
2358
	lea	edi,[eax+esi+8]
2359
	jmp	.labl_02
2360
;----------------------------------------------------------
2361
.labl_00:
2362
	push	1
2363
	call	CMyBitEncoder_Encode
2364
	lea	edx,[esi+4]
2365
	cmp	edi,16
2366
	jnb	.labl_01
2367
 
2368
	push	0
2369
	call	CMyBitEncoder_Encode
2370
	add	edi,0xFFFFFFF8
2371
	mov	eax,ebx
2372
	imul	eax,eax,1028
2373
	push	edi
2374
	lea	edi,[eax+esi+0x4048]
2375
	jmp	.labl_02
2376
;----------------------------------------------------------
2377
.labl_01:
2378
	push	1
2379
	call	CMyBitEncoder_Encode
2380
	add	edi,0xFFFFFFF0
2381
	push	edi
2382
	lea	edi,[esi+0x8088]
2383
;----------------------------------------------------------
2384
.labl_02:
2385
	call	cm_pr_16
2386
	dec	dword [esi+ebx*4+0xC890]
2387
	pop	edi
2388
	jne	.labl_03
2389
 
2390
	push	ebx
2391
	mov	eax,esi
2392
	call	CPriceTableEncoder_UpdateTable
2393
;----------------------------------------------------------
2394
.labl_03:
2395
	ret
2396
;*****************************************************************************
2397
 
2398
;* Call: ***************************************************************
2399
CLiteralEncoder2_Encode:
2400
	push	ebx
2401
	push	esi
2402
	push	edi
2403
	xor	edi,edi
2404
	push	8
2405
	inc	edi
2406
	pop	ebx
2407
;----------------------------------------------------------
2408
.labl_00:
2409
	movzx	esi,byte [esp+20]
2410
	mov	eax,[esp+16]
2411
	dec	ebx
2412
	mov	cl,bl
2413
	shr	esi,cl
2414
	lea	edx,[eax+edi*4]
2415
	and	esi,1
2416
	push	esi
2417
	call	CMyBitEncoder_Encode
2418
	add	edi,edi
2419
	or	edi,esi
2420
	test	ebx,ebx
2421
	jne	.labl_00
2422
 
2423
	pop	edi
2424
	pop	esi
2425
	pop	ebx
2426
	ret	8
2427
;*****************************************************************************
2428
 
2429
;* Call: ***************************************************************
2430
CState_IsCharState:
2431
	mov	edx,[_numPrevBits]
2432
	push	esi
2433
	mov	esi,[_posMask]
2434
	and	esi,[esp+8]
2435
	push	8
2436
	pop	ecx
2437
	movzx	eax,al
2438
	sub	cl,dl
2439
	shr	eax,cl
2440
	mov	ecx,edx
2441
	shl	esi,cl
2442
	add	eax,esi
2443
	pop	esi
2444
	ret	4
2445
;*****************************************************************************
2446
 
2447
;* Call: ***************************************************************
2448
CLiteralEncoder_GetPrice:
2449
	push	dword [esp+16]
2450
	push	dword [esp+16]
2451
	push	dword [esp+16]
2452
	push	dword [esp+16]
2453
	call	CState_IsCharState
2454
	imul	eax,eax,3072
2455
	add	eax,[_posEncoders]
2456
	push	eax
2457
	call	lz_cm_11
2458
	ret	16
2459
;*****************************************************************************
2460
 
2461
;* Call: ***************************************************************
2462
lz_cm_11:
2463
	push	ebp
2464
	mov	ebp,esp
2465
	push	ecx
2466
	push	ebx
2467
	push	esi
2468
	xor	esi,esi
2469
	xor	eax,eax
2470
	inc	esi
2471
	push	edi
2472
	mov	dword [ebp-4],8
2473
	cmp	[ebp+12],al
2474
	je	.labl_02
2475
 
2476
	movzx	ecx,byte [ebp+20]
2477
	mov	[ebp+12],ecx
2478
;----------------------------------------------------------
2479
.labl_00:
2480
	dec	dword [ebp-4]
2481
	movzx	ecx,byte [ebp-4]
2482
	movzx	edi,byte [ebp+16]
2483
	mov	edx,[ebp+12]
2484
	mov	ebx,[ebp+8]
2485
	shr	edi,cl
2486
	shr	edx,cl
2487
	and	edi,1
2488
	mov	ecx,edi
2489
	shl	ecx,8
2490
	add	ecx,esi
2491
	mov	ecx,[ebx+ecx*4+1024]
2492
	and	edx,1
2493
	sub	ecx,edx
2494
	mov	ebx,edx
2495
	neg	ebx
2496
	xor	ecx,ebx
2497
	shr	ecx,2
2498
	and	ecx,0x1FF
2499
	add	eax,[Models+ecx*4]
2500
	add	esi,esi
2501
	or	esi,edx
2502
	cmp	edi,edx
2503
	jne	.labl_01
2504
 
2505
	cmp	dword [ebp-4],0
2506
	jne	.labl_00
2507
 
2508
	jmp	.labl_04
2509
;----------------------------------------------------------
2510
.labl_01:
2511
	cmp	dword [ebp-4],0
2512
	je	.labl_04
2513
;----------------------------------------------------------
2514
.labl_02:
2515
	movzx	edi,byte [ebp+20]
2516
;----------------------------------------------------------
2517
.labl_03:
2518
	dec	dword [ebp-4]
2519
	mov	cl,[ebp-4]
2520
	mov	edx,edi
2521
	shr	edx,cl
2522
	mov	ecx,[ebp+8]
2523
	mov	ecx,[ecx+esi*4]
2524
	add	esi,esi
2525
	and	edx,1
2526
	sub	ecx,edx
2527
	mov	ebx,edx
2528
	neg	ebx
2529
	xor	ecx,ebx
2530
	shr	ecx,2
2531
	and	ecx,0x1FF
2532
	add	eax,[Models+ecx*4]
2533
	or	esi,edx
2534
	cmp	dword [ebp-4],0
2535
	jne	.labl_03
2536
;----------------------------------------------------------
2537
.labl_04:
2538
	pop	edi
2539
	pop	esi
2540
	pop	ebx
2541
	leave
2542
	ret	16
2543
;*****************************************************************************
2544
 
2545
;* Call: ***************************************************************
2546
ReadMatchDistances:
2547
	push	esi
2548
	call	GetLongestMatch
2549
	mov	ecx,eax
2550
	mov	esi,0x80
2551
	cmp	ecx,esi
2552
	jne	.labl_00
2553
 
2554
	push	dword [distances+512]
2555
	lea	eax,[esi+17]
2556
	push	esi
2557
	call	GetMatchLen
2558
	mov	ecx,eax
2559
	add	ecx,esi
2560
;----------------------------------------------------------
2561
.labl_00:
2562
	inc	dword [_additionalOffset]
2563
	call	MatchFinder_MovePos
2564
	mov	eax,ecx
2565
	pop	esi
2566
	ret
2567
;*****************************************************************************
2568
 
2569
;* Call: ***************************************************************
2570
GetLongestMatch:
2571
	push	ebp
2572
	mov	ebp,esp
2573
	sub	esp,0x34
2574
	mov	edx,[_matchMaxLen]
2575
	mov	ecx,[_pos]
2576
	mov	eax,[_streamPos]
2577
	and	dword [ebp-24],0
2578
	push	esi
2579
	lea	esi,[edx+ecx]
2580
	cmp	esi,eax
2581
	ja	.labl_02
2582
 
2583
	mov	[ebp-32],edx
2584
;----------------------------------------------------------
2585
.labl_00:
2586
	mov	eax,[_cyclicBufferSize]
2587
	mov	edx,ecx
2588
	sub	edx,eax
2589
	cmp	eax,ecx
2590
	sbb	eax,eax
2591
	and	eax,edx
2592
	mov	[ebp-40],eax
2593
	mov	eax,[_buffer]
2594
	push	ebx
2595
	push	edi
2596
	lea	edi,[eax+ecx]
2597
	movzx	edx,byte [edi+2]
2598
	movzx	esi,byte [edi]
2599
	movzx	eax,word [edi]
2600
	shl	edx,8
2601
	xor	edx,[crc_table+esi*4]
2602
	movzx	esi,byte [edi+1]
2603
	xor	edx,esi
2604
	mov	esi,[_hash]
2605
	and	edx,0xFFFFF
2606
	lea	edx,[esi+edx*4]
2607
	mov	ebx,[edx]
2608
	lea	eax,[esi+eax*4+0x400000]
2609
	mov	[ebp-8],ebx
2610
	mov	ebx,[eax]
2611
	mov	[eax],ecx
2612
	or	dword [distances+8],0xFFFFFFFF
2613
	cmp	ebx,[ebp-40]
2614
	jbe	.labl_01
2615
 
2616
	mov	eax,ecx
2617
	sub	eax,ebx
2618
	dec	eax
2619
	mov	[distances+8],eax
2620
	mov	dword [ebp-24],2
2621
;----------------------------------------------------------
2622
.labl_01:
2623
	mov	ebx,[pack_pos]
2624
	and	dword [ebp-36],0
2625
	mov	[edx],ecx
2626
	or	dword [distances+12],0xFFFFFFFF
2627
	and	dword [ebp-48],0
2628
	lea	edx,[esi+ebx*8+0x440000]
2629
	lea	eax,[edx+4]
2630
	mov	[ebp-20],eax
2631
	mov	eax,[_cutValue]
2632
	mov	[ebp-28],eax
2633
	mov	eax,[ebp-8]
2634
	mov	[ebp-16],edx
2635
	jmp	.labl_13
2636
;----------------------------------------------------------
2637
.labl_02:
2638
	sub	eax,ecx
2639
	mov	[ebp-32],eax
2640
	cmp	eax,3
2641
	jnb	.labl_00
2642
 
2643
	xor	eax,eax
2644
	jmp	.labl_16
2645
;----------------------------------------------------------
2646
.labl_03:
2647
	mov	eax,[ebp-28]
2648
	dec	dword [ebp-28]
2649
	test	eax,eax
2650
	je	.labl_14
2651
 
2652
	mov	eax,[_buffer]
2653
	mov	edx,[ebp-8]
2654
	add	eax,edx
2655
	mov	[ebp-44],eax
2656
	mov	eax,[ebp-48]
2657
	cmp	eax,[ebp-36]
2658
	jb	.labl_04
2659
 
2660
	mov	eax,[ebp-36]
2661
;----------------------------------------------------------
2662
.labl_04:
2663
	mov	edx,[ebp-44]
2664
	mov	[ebp-4],eax
2665
	add	eax,edi
2666
	sub	edx,edi
2667
	mov	[ebp-12],edx
2668
	jmp	.labl_06
2669
;----------------------------------------------------------
2670
.labl_05:
2671
	mov	edx,[ebp-12]
2672
	mov	eax,[ebp-52]
2673
;----------------------------------------------------------
2674
.labl_06:
2675
	mov	dl,[edx+eax]
2676
	cmp	dl,[eax]
2677
	jne	.labl_07
2678
 
2679
	inc	dword [ebp-4]
2680
	inc	eax
2681
	mov	[ebp-52],eax
2682
	mov	eax,[ebp-4]
2683
	cmp	eax,[ebp-32]
2684
	jne	.labl_05
2685
;----------------------------------------------------------
2686
.labl_07:
2687
	mov	eax,ecx
2688
	sub	eax,[ebp-8]
2689
	mov	[ebp-12],eax
2690
	mov	eax,[ebp-24]
2691
	cmp	eax,[ebp-4]
2692
	jnb	.labl_09
2693
;----------------------------------------------------------
2694
.labl_08:
2695
	mov	edx,[ebp-12]
2696
	inc	eax
2697
	dec	edx
2698
	mov	[distances+eax*4],edx
2699
	cmp	eax,[ebp-4]
2700
	jb	.labl_08
2701
 
2702
	mov	[ebp-24],eax
2703
;----------------------------------------------------------
2704
.labl_09:
2705
	mov	eax,ebx
2706
	sub	eax,[ebp-12]
2707
	cmp	[ebp-12],ebx
2708
	jbe	.labl_10
2709
 
2710
	add	eax,[_cyclicBufferSize]
2711
;----------------------------------------------------------
2712
.labl_10:
2713
	lea	eax,[esi+eax*8+0x440000]
2714
	mov	[ebp-12],eax
2715
	mov	eax,[ebp-4]
2716
	cmp	eax,[ebp-32]
2717
	je	.labl_17
2718
 
2719
	mov	edx,[ebp-44]
2720
	mov	dl,[eax+edx]
2721
	cmp	dl,[eax+edi]
2722
	mov	eax,[ebp-8]
2723
	jnb	.labl_11
2724
 
2725
	mov	edx,[ebp-16]
2726
	mov	[edx],eax
2727
	mov	eax,[ebp-12]
2728
	mov	edx,[ebp-4]
2729
	add	eax,4
2730
	mov	[ebp-16],eax
2731
	mov	[ebp-36],edx
2732
	jmp	.labl_12
2733
;----------------------------------------------------------
2734
.labl_11:
2735
	mov	edx,[ebp-20]
2736
	mov	[edx],eax
2737
	mov	eax,[ebp-12]
2738
	mov	edx,[ebp-4]
2739
	mov	[ebp-20],eax
2740
	mov	[ebp-48],edx
2741
;----------------------------------------------------------
2742
.labl_12:
2743
	mov	eax,[eax]
2744
	mov	[ebp-8],eax
2745
;----------------------------------------------------------
2746
.labl_13:
2747
	cmp	eax,[ebp-40]
2748
	ja	.labl_03
2749
;----------------------------------------------------------
2750
.labl_14:
2751
	mov	eax,[ebp-16]
2752
	and	dword [eax],0
2753
	mov	eax,[ebp-20]
2754
	and	dword [eax],0
2755
;----------------------------------------------------------
2756
.labl_15:
2757
	mov	eax,[ebp-24]
2758
	pop	edi
2759
	pop	ebx
2760
;----------------------------------------------------------
2761
.labl_16:
2762
	pop	esi
2763
	leave
2764
	ret
2765
;----------------------------------------------------------
2766
.labl_17:
2767
	mov	eax,[ebp-12]
2768
	mov	ecx,[eax]
2769
	mov	edx,[ebp-16]
2770
	mov	[edx],ecx
2771
	mov	eax,[eax+4]
2772
	mov	ecx,[ebp-20]
2773
	mov	[ecx],eax
2774
	jmp	.labl_15
2775
;*****************************************************************************
2776
 
2777
;* Call: ***************************************************************
2778
FillPosSlotPrices:
2779
	push	ecx
2780
	push	ebx
2781
	push	ebp
2782
	push	esi
2783
	push	edi
2784
	xor	ebp,ebp
2785
	mov	esi,_posSlotEncoder
2786
	mov	dword [esp+16],4
2787
;----------------------------------------------------------
2788
.labl_00:
2789
	xor	edi,edi
2790
;----------------------------------------------------------
2791
.labl_01:
2792
	mov	ebx,[_distTableSize]
2793
	cmp	edi,ebx
2794
	jnb	.labl_03
2795
 
2796
	mov	edx,edi
2797
	call	CBitTreeEncoder_GetPrice
2798
	lea	ecx,[edi+ebp]
2799
	inc	edi
2800
	mov	[_posSlotPrices+ecx*4],eax
2801
	cmp	edi,14
2802
	jb	.labl_01
2803
 
2804
	cmp	edi,ebx
2805
	jnb	.labl_03
2806
 
2807
	lea	ebx,[edi+ebp]
2808
	lea	ebx,[_posSlotPrices+ebx*4]
2809
;----------------------------------------------------------
2810
.labl_02:
2811
	mov	edx,edi
2812
	call	CBitTreeEncoder_GetPrice
2813
	mov	ecx,edi
2814
	shr	ecx,1
2815
	sub	ecx,5
2816
	shl	ecx,6
2817
	add	eax,ecx
2818
	mov	[ebx],eax
2819
	inc	edi
2820
	add	ebx,4
2821
	cmp	edi,[_distTableSize]
2822
	jb	.labl_02
2823
;----------------------------------------------------------
2824
.labl_03:
2825
	add	esi,1028
2826
	add	ebp,64
2827
	dec	dword [esp+16]
2828
	jne	.labl_00
2829
 
2830
	pop	edi
2831
	pop	esi
2832
	pop	ebp
2833
	pop	ebx
2834
	pop	ecx
2835
	ret
2836
;***********************************************************************
2837
 
2838
;* Call: ***************************************************************
2839
FillDistancesPrices:
2840
	push	ebp
2841
	mov	ebp,esp
2842
	sub	esp,36
2843
	and	dword [ebp-20],0
2844
	push	ebx
2845
	push	esi
2846
	push	edi
2847
	push	4
2848
	pop	ebx
2849
	mov	dword [ebp-24],_distancesPrices+16
2850
	mov	dword [ebp-16],_posSlotPrices
2851
	mov	[ebp-36],ebx
2852
;----------------------------------------------------------
2853
.labl_00:
2854
	mov	eax,[ebp-24]
2855
	mov	esi,[ebp-16]
2856
	lea	edi,[eax-16]
2857
	movsd
2858
	movsd
2859
	movsd
2860
	movsd
2861
	mov	[ebp-4],ebx
2862
	mov	[ebp-12],eax
2863
;----------------------------------------------------------
2864
.labl_01:
2865
	mov	esi,[ebp-4]
2866
	mov	eax,esi
2867
	call	GetPosSlot
2868
	mov	edx,eax
2869
	mov	ecx,edx
2870
	xor	eax,eax
2871
	inc	eax
2872
	mov	[ebp-32],edx
2873
	and	edx,eax
2874
	shr	ecx,1
2875
	dec	ecx
2876
	or	edx,2
2877
	shl	edx,cl
2878
	xor	edi,edi
2879
	mov	[ebp-8],eax
2880
	mov	[ebp-28],ecx
2881
	sub	esi,edx
2882
	test	ecx,ecx
2883
	je	.labl_03
2884
;----------------------------------------------------------
2885
.labl_02:
2886
	mov	eax,[ebp-8]
2887
	sub	eax,[ebp-32]
2888
	mov	ecx,esi
2889
	add	eax,edx
2890
	mov	eax,[_numLiteralContextBits+eax*4]
2891
	and	ecx,1
2892
	sub	eax,ecx
2893
	mov	ebx,ecx
2894
	neg	ebx
2895
	xor	eax,ebx
2896
	shr	eax,2
2897
	and	eax,0x1FF
2898
	add	edi,[Models+eax*4]
2899
	mov	eax,[ebp-8]
2900
	shr	esi,1
2901
	dec	dword [ebp-28]
2902
	lea	eax,[ecx+eax*2]
2903
	mov	[ebp-8],eax
2904
	jne	.labl_02
2905
 
2906
	push	4
2907
	pop	ebx
2908
;----------------------------------------------------------
2909
.labl_03:
2910
	mov	eax,[ebp-32]
2911
	mov	ecx,[ebp-20]
2912
	add	ecx,eax
2913
	mov	eax,[_posSlotPrices+ecx*4]
2914
	mov	ecx,[ebp-12]
2915
	add	[ebp-12],ebx
2916
	add	eax,edi
2917
	inc	dword [ebp-4]
2918
	cmp	dword [ebp-4],0x80
2919
	mov	[ecx],eax
2920
	jb	.labl_01
2921
 
2922
	add	dword [ebp-16],256
2923
	add	dword [ebp-20],64
2924
	add	dword [ebp-24],512
2925
	dec	dword [ebp-36]
2926
	jne	.labl_00
2927
 
2928
	pop	edi
2929
	pop	esi
2930
	pop	ebx
2931
	leave
2932
	ret
2933
;***********************************************************************
2934
 
2935
;* Call: ***************************************************************
2936
FillAlignPrices:
2937
	push	ebp
2938
	mov	ebp,esp
2939
	push	ecx
2940
	push	ecx
2941
	push	ebx
2942
	push	esi
2943
	xor	esi,esi
2944
	push	edi
2945
	mov	[ebp-8],esi
2946
;----------------------------------------------------------
2947
.labl_00:
2948
	mov	eax,[i_01]
2949
	xor	edx,edx
2950
	xor	ecx,ecx
2951
	inc	edx
2952
	mov	[ebp-4],eax
2953
;----------------------------------------------------------
2954
.labl_01:
2955
	mov	edi,[_posAlignEncoder+edx*4]
2956
	mov	eax,esi
2957
	and	eax,1
2958
	sub	edi,eax
2959
	mov	ebx,eax
2960
	neg	ebx
2961
	xor	edi,ebx
2962
	shr	edi,2
2963
	and	edi,0x1FF
2964
	add	ecx,[Models+edi*4]
2965
	shr	esi,1
2966
	dec	dword [ebp-4]
2967
	lea	edx,[eax+edx*2]
2968
	jne	.labl_01
2969
 
2970
	mov	esi,[ebp-8]
2971
	push	16
2972
	mov	[_alignPrices+esi*4],ecx
2973
	inc	esi
2974
	pop	eax
2975
	mov	[ebp-8],esi
2976
	cmp	esi,eax
2977
	jb	.labl_00
2978
 
2979
	pop	edi
2980
	pop	esi
2981
	mov	[_alignPriceCount],eax
2982
	pop	ebx
2983
	leave
2984
	ret
2985
;***********************************************************************
2986
 
2987
;* Call: ***************************************************************
2988
GetRepLen1Price:
2989
	movzx	eax,al
2990
	mov	edx,[_isRepG0+eax*4]
2991
	mov	ecx,eax
2992
	shl	ecx,4
2993
	add	ecx,[esp+4]
2994
	shr	edx,2
2995
	mov	ecx,[_isRep0Long+ecx*4]
2996
	shr	ecx,2
2997
	mov	eax,[Models+ecx*4]
2998
	add	eax,[Models+edx*4]
2999
	ret	4
3000
;***********************************************************************
3001
 
3002
;* Call: ***************************************************************
3003
GetRepPrice:
3004
	movzx	ecx,byte [esp+4]
3005
	shl	eax,4
3006
	add	eax,[esp+8]
3007
	push	esi
3008
	mov	eax,[_repMatchLenEncoder+0x840C+eax*4]
3009
	mov	esi,2048
3010
	test	edx,edx
3011
	jne	.labl_00
3012
 
3013
	mov	edx,ecx
3014
	mov	ecx,[_isRepG0+ecx*4]
3015
	shl	edx,4
3016
	add	edx,[esp+12]
3017
	sub	esi,[_isRep0Long+edx*4]
3018
	shr	ecx,2
3019
	jmp	.labl_02
3020
;----------------------------------------------------------
3021
.labl_00:
3022
	push	edi
3023
	shl	ecx,2
3024
	mov	edi,esi
3025
	sub	edi,[ecx+_isRepG0]
3026
	shr	edi,2
3027
	add	eax,[Models+edi*4]
3028
	pop	edi
3029
	cmp	edx,1
3030
	jne	.labl_01
3031
 
3032
	mov	ecx,[ecx+_isRepG1]
3033
	shr	ecx,2
3034
	add	eax,[Models+ecx*4]
3035
	jmp	.labl_03
3036
;----------------------------------------------------------
3037
.labl_01:
3038
	sub	esi,[ecx+_isRepG1]
3039
	mov	ecx,[ecx+_isRepG2]
3040
	add	edx,0xFFFFFFFE
3041
	sub	ecx,edx
3042
	neg	edx
3043
	xor	ecx,edx
3044
	shr	ecx,2
3045
	and	ecx,0x1FF
3046
;----------------------------------------------------------
3047
.labl_02:
3048
	shr	esi,2
3049
	mov	edx,[Models+esi*4]
3050
	add	edx,[Models+ecx*4]
3051
	add	eax,edx
3052
;----------------------------------------------------------
3053
.labl_03:
3054
	pop	esi
3055
	ret	8
3056
;***********************************************************************
3057
 
3058
;* Call: ***************************************************************
3059
GetPosLenPrice:
3060
	push	esi
3061
	mov	esi,eax
3062
	mov	ecx,0x80
3063
	cmp	esi,2
3064
	jne	.labl_00
3065
 
3066
	cmp	edx,ecx
3067
	jb	.labl_01
3068
 
3069
	mov	eax,kIfinityPrice
3070
	jmp	.labl_09
3071
;----------------------------------------------------------
3072
.labl_00:
3073
	cmp	esi,6
3074
	jnb	.labl_02
3075
;----------------------------------------------------------
3076
.labl_01:
3077
	lea	eax,[esi-2]
3078
	jmp	.labl_03
3079
;----------------------------------------------------------
3080
.labl_02:
3081
	push	3
3082
	pop	eax
3083
;----------------------------------------------------------
3084
.labl_03:
3085
	cmp	edx,ecx
3086
	jnb	.labl_04
3087
 
3088
	shl	eax,7
3089
	add	eax,edx
3090
	mov	ecx,[_distancesPrices+eax*4]
3091
	jmp	.labl_08
3092
;----------------------------------------------------------
3093
.labl_04:
3094
	mov	ecx,edx
3095
;GetPosSlot2
3096
	cmp	edx,0x10000	;if (pos < (1<<16))
3097
	jnb	.labl_05
3098
 
3099
	shr	ecx,6
3100
	movzx	ecx,byte [ecx+g_FastPos]
3101
	add	ecx,12
3102
	jmp	.labl_07
3103
;----------------------------------------------------------
3104
.labl_05:
3105
	cmp	edx,0x2000000	;if (pos < (1<<25))
3106
	jnb	.labl_06
3107
 
3108
	shr	ecx,15
3109
	movzx	ecx,byte [ecx+g_FastPos]
3110
	add	ecx,30
3111
	jmp	.labl_07
3112
;----------------------------------------------------------
3113
.labl_06:
3114
	shr	ecx,24
3115
	movzx	ecx,byte [ecx+g_FastPos]
3116
	add	ecx,48
3117
;----------------------------------------------------------
3118
.labl_07:
3119
	shl	eax,6
3120
	add	eax,ecx
3121
	mov	ecx,[_posSlotPrices+eax*4]
3122
	and	edx,15
3123
	add	ecx,[_alignPrices+edx*4]
3124
;----------------------------------------------------------
3125
.labl_08:
3126
	shl	esi,4
3127
	add	esi,[esp+8]
3128
	mov	eax,[_prices+esi*4]
3129
	add	eax,ecx
3130
;----------------------------------------------------------
3131
.labl_09:
3132
	pop	esi
3133
	ret	4
3134
;***********************************************************************
3135
 
3136
;* Call: ***************************************************************
3137
RangeEncoder_ShiftLow:
3138
	push	ecx
3139
	push	ecx
3140
	mov	eax,[low]
3141
	push	esi
3142
	mov	esi,[low+4]
3143
	cmp	eax,0xFF000000
3144
	jb	.labl_00
3145
 
3146
	test	esi,esi
3147
	je	.labl_02
3148
;----------------------------------------------------------
3149
.labl_00:
3150
	mov	cl,[_cache]
3151
	and	dword [esp+8],0
3152
	mov	edx,esi
3153
	push	ebx
3154
;----------------------------------------------------------
3155
.labl_01:
3156
	mov	bl,dl
3157
	add	bl,cl
3158
	mov	ecx,[pack_length]
3159
	inc	dword [pack_length]
3160
	mov	[ecx],bl
3161
	or	cl,0xFF
3162
	dec	dword [_cacheSize]
3163
	jne	.labl_01
3164
 
3165
	mov	cl,[low+3]
3166
	mov	[_cache],cl
3167
	pop	ebx
3168
;----------------------------------------------------------
3169
.labl_02:
3170
	inc	dword [_cacheSize]
3171
	shl	eax,8
3172
	and	dword [low+4],0
3173
	mov	[low],eax
3174
	pop	esi
3175
	pop	ecx
3176
	pop	ecx
3177
	ret
3178
;***********************************************************************
3179
 
3180
;* Call: ***************************************************************
3181
CMyBitEncoder_Encode:
3182
	mov	ecx,[_range]
3183
	mov	eax,[edx]
3184
	shr	ecx,0xB
3185
	imul	ecx,eax
3186
	cmp	dword [esp+4],0
3187
	jne	.labl_00
3188
 
3189
	mov	[_range],ecx
3190
	mov	ecx,2048
3191
	sub	ecx,eax
3192
	shr	ecx,5
3193
	add	ecx,eax
3194
	mov	[edx],ecx
3195
	jmp	.labl_01
3196
;----------------------------------------------------------
3197
.labl_00:
3198
	add	[low],ecx
3199
	adc	dword [low+4],0
3200
	sub	[_range],ecx
3201
	mov	ecx,eax
3202
	shr	ecx,5
3203
	sub	eax,ecx
3204
	mov	[edx],eax
3205
;----------------------------------------------------------
3206
.labl_01:
3207
	cmp	dword [_range],0x1000000
3208
	jnb	.labl_02
3209
 
3210
	shl	dword [_range],8
3211
	call	RangeEncoder_ShiftLow
3212
;----------------------------------------------------------
3213
.labl_02:
3214
	ret	4
3215
;***********************************************************************
3216
 
3217
;* Call: ***************************************************************
3218
CBitTreeEncoder_Init:
3219
	xor	edx,edx
3220
	inc	edx
3221
	shl	edx,cl
3222
	mov	[eax+1024],ecx
3223
	lea	ecx,[edx-1]
3224
	test	ecx,ecx
3225
	jbe	.labl_00
3226
 
3227
	push	edi
3228
	lea	edi,[eax+4]
3229
	mov	eax,1024
3230
	rep	stosd
3231
	pop	edi
3232
;----------------------------------------------------------
3233
.labl_00:
3234
	ret
3235
;***********************************************************************
3236
 
3237
;* Call: ***************************************************************
3238
cm_pr_16:
3239
	mov	eax,[esp+4]
3240
	push	ebx
3241
	mov	ebx,[edi+1024]
3242
	push	esi
3243
	xor	esi,esi
3244
	inc	esi
3245
	add	eax,eax
3246
	mov	[esp+12],eax
3247
;----------------------------------------------------------
3248
.labl_00:
3249
	mov	eax,[esp+12]
3250
	mov	ecx,ebx
3251
	shr	eax,cl
3252
	lea	edx,[edi+esi*4]
3253
	and	eax,1
3254
	push	eax
3255
	lea	esi,[eax+esi*2]
3256
	call	CMyBitEncoder_Encode
3257
	dec	ebx
3258
	jne	.labl_00
3259
 
3260
	pop	esi
3261
	pop	ebx
3262
	ret	4
3263
;***********************************************************************
3264
 
3265
;* Call: ***************************************************************
3266
CBitTreeEncoder_GetPrice:
3267
	mov	ecx,[esi+1024]
3268
	push	edi
3269
	xor	edi,edi
3270
	inc	edi
3271
	shl	edi,cl
3272
	xor	eax,eax
3273
	or	edx,edi
3274
;----------------------------------------------------------
3275
.labl_00:
3276
	mov	ecx,edx
3277
	shr	edx,1
3278
	mov	edi,[esi+edx*4]
3279
	and	ecx,1
3280
	sub	edi,ecx
3281
	neg	ecx
3282
	xor	edi,ecx
3283
	shr	edi,2
3284
	and	edi,0x1FF
3285
	add	eax,[Models+edi*4]
3286
	cmp	edx,1
3287
	jne	.labl_00
3288
 
3289
	pop	edi
3290
	ret
3291
;***********************************************************************
3292
 
3293
;* Call: ***************************************************************
3294
GetMatchLen:
3295
	mov	ecx,[_streamPos]
3296
	push	edi
3297
	mov	edi,eax
3298
	mov	eax,[_pos]
3299
	sub	ecx,eax
3300
	sub	ecx,[esp+8]
3301
	cmp	edi,ecx
3302
	jbe	.labl_00
3303
 
3304
	mov	edi,ecx
3305
;----------------------------------------------------------
3306
.labl_00:
3307
	mov	ecx,[_buffer]
3308
	inc	dword [esp+12]
3309
	add	ecx,eax
3310
	add	ecx,[esp+8]
3311
	xor	eax,eax
3312
	test	edi,edi
3313
	jbe	.labl_03
3314
 
3315
	push	esi
3316
	mov	esi,ecx
3317
	sub	esi,[esp+16]
3318
;----------------------------------------------------------
3319
.labl_01:
3320
	mov	dl,[eax+ecx]
3321
	cmp	dl,[esi+eax]
3322
	jne	.labl_02
3323
 
3324
	inc	eax
3325
	cmp	eax,edi
3326
	jb	.labl_01
3327
;----------------------------------------------------------
3328
.labl_02:
3329
	pop	esi
3330
;----------------------------------------------------------
3331
.labl_03:
3332
	pop	edi
3333
	ret	8
3334
;***********************************************************************
3335
 
3336
;* Call: ***************************************************************
3337
MatchFinder_MovePos:
3338
	inc	dword [pack_pos]
3339
	mov	eax,[pack_pos]
3340
	cmp	eax,[_cyclicBufferSize]
3341
	jne	.labl_00
3342
 
3343
	and	dword [pack_pos],0
3344
;----------------------------------------------------------
3345
.labl_00:
3346
	inc	dword [_pos]
3347
	ret
3348
;***********************************************************************