novi upstream verzije 2.8.3
[ossec-hids.git] / src / external / zlib-1.2.8 / contrib / masmx86 / inffas32.asm
diff --git a/src/external/zlib-1.2.8/contrib/masmx86/inffas32.asm b/src/external/zlib-1.2.8/contrib/masmx86/inffas32.asm
new file mode 100644 (file)
index 0000000..03d20f8
--- /dev/null
@@ -0,0 +1,1080 @@
+;/* inffas32.asm is a hand tuned assembler version of inffast.c -- fast decoding\r
+; *\r
+; * inffas32.asm is derivated from inffas86.c, with translation of assembly code\r
+; *\r
+; * Copyright (C) 1995-2003 Mark Adler\r
+; * For conditions of distribution and use, see copyright notice in zlib.h\r
+; *\r
+; * Copyright (C) 2003 Chris Anderson <christop@charm.net>\r
+; * Please use the copyright conditions above.\r
+; *\r
+; * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from\r
+; * the gcc -S output of zlib-1.2.0/inffast.c.  Zlib-1.2.0 is in beta release at\r
+; * the moment.  I have successfully compiled and tested this code with gcc2.96,\r
+; * gcc3.2, icc5.0, msvc6.0.  It is very close to the speed of inffast.S\r
+; * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX\r
+; * enabled.  I will attempt to merge the MMX code into this version.  Newer\r
+; * versions of this and inffast.S can be found at\r
+; * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/\r
+; *\r
+; * 2005 : modification by Gilles Vollant\r
+; */\r
+; For Visual C++ 4.x and higher and ML 6.x and higher\r
+;   ml.exe is in directory \MASM611C of Win95 DDK\r
+;   ml.exe is also distributed in http://www.masm32.com/masmdl.htm\r
+;    and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/\r
+;\r
+;\r
+;   compile with command line option\r
+;   ml  /coff /Zi /c /Flinffas32.lst inffas32.asm\r
+\r
+;   if you define NO_GZIP (see inflate.h), compile with\r
+;   ml  /coff /Zi /c /Flinffas32.lst /DNO_GUNZIP inffas32.asm\r
+\r
+\r
+; zlib122sup is 0 fort zlib 1.2.2.1 and lower\r
+; zlib122sup is 8 fort zlib 1.2.2.2 and more (with addition of dmax and head\r
+;        in inflate_state in inflate.h)\r
+zlib1222sup      equ    8\r
+\r
+\r
+IFDEF GUNZIP\r
+  INFLATE_MODE_TYPE    equ 11\r
+  INFLATE_MODE_BAD     equ 26\r
+ELSE\r
+  IFNDEF NO_GUNZIP\r
+    INFLATE_MODE_TYPE    equ 11\r
+    INFLATE_MODE_BAD     equ 26\r
+  ELSE\r
+    INFLATE_MODE_TYPE    equ 3\r
+    INFLATE_MODE_BAD     equ 17\r
+  ENDIF\r
+ENDIF\r
+\r
+\r
+; 75 "inffast.S"\r
+;FILE "inffast.S"\r
+\r
+;;;GLOBAL _inflate_fast\r
+\r
+;;;SECTION .text\r
+\r
+\r
+\r
+       .586p\r
+       .mmx\r
+\r
+       name    inflate_fast_x86\r
+       .MODEL  FLAT\r
+\r
+_DATA                  segment\r
+inflate_fast_use_mmx:\r
+       dd      1\r
+\r
+\r
+_TEXT                  segment\r
+\r
+\r
+\r
+ALIGN 4\r
+       db      'Fast decoding Code from Chris Anderson'\r
+       db      0\r
+\r
+ALIGN 4\r
+invalid_literal_length_code_msg:\r
+       db      'invalid literal/length code'\r
+       db      0\r
+\r
+ALIGN 4\r
+invalid_distance_code_msg:\r
+       db      'invalid distance code'\r
+       db      0\r
+\r
+ALIGN 4\r
+invalid_distance_too_far_msg:\r
+       db      'invalid distance too far back'\r
+       db      0\r
+\r
+\r
+ALIGN 4\r
+inflate_fast_mask:\r
+dd     0\r
+dd     1\r
+dd     3\r
+dd     7\r
+dd     15\r
+dd     31\r
+dd     63\r
+dd     127\r
+dd     255\r
+dd     511\r
+dd     1023\r
+dd     2047\r
+dd     4095\r
+dd     8191\r
+dd     16383\r
+dd     32767\r
+dd     65535\r
+dd     131071\r
+dd     262143\r
+dd     524287\r
+dd     1048575\r
+dd     2097151\r
+dd     4194303\r
+dd     8388607\r
+dd     16777215\r
+dd     33554431\r
+dd     67108863\r
+dd     134217727\r
+dd     268435455\r
+dd     536870911\r
+dd     1073741823\r
+dd     2147483647\r
+dd     4294967295\r
+\r
+\r
+mode_state      equ    0       ;/* state->mode */\r
+wsize_state     equ    (32+zlib1222sup)        ;/* state->wsize */\r
+write_state     equ    (36+4+zlib1222sup)      ;/* state->write */\r
+window_state    equ    (40+4+zlib1222sup)      ;/* state->window */\r
+hold_state      equ    (44+4+zlib1222sup)      ;/* state->hold */\r
+bits_state      equ    (48+4+zlib1222sup)      ;/* state->bits */\r
+lencode_state   equ    (64+4+zlib1222sup)      ;/* state->lencode */\r
+distcode_state  equ    (68+4+zlib1222sup)      ;/* state->distcode */\r
+lenbits_state   equ    (72+4+zlib1222sup)      ;/* state->lenbits */\r
+distbits_state  equ    (76+4+zlib1222sup)      ;/* state->distbits */\r
+\r
+\r
+;;SECTION .text\r
+; 205 "inffast.S"\r
+;GLOBAL        inflate_fast_use_mmx\r
+\r
+;SECTION .data\r
+\r
+\r
+; GLOBAL inflate_fast_use_mmx:object\r
+;.size inflate_fast_use_mmx, 4\r
+; 226 "inffast.S"\r
+;SECTION .text\r
+\r
+ALIGN 4\r
+_inflate_fast proc near\r
+.FPO (16, 4, 0, 0, 1, 0)\r
+       push  edi\r
+       push  esi\r
+       push  ebp\r
+       push  ebx\r
+       pushfd\r
+       sub  esp,64\r
+       cld\r
+\r
+\r
+\r
+\r
+       mov  esi, [esp+88]\r
+       mov  edi, [esi+28]\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+       mov  edx, [esi+4]\r
+       mov  eax, [esi+0]\r
+\r
+       add  edx,eax\r
+       sub  edx,11\r
+\r
+       mov  [esp+44],eax\r
+       mov  [esp+20],edx\r
+\r
+       mov  ebp, [esp+92]\r
+       mov  ecx, [esi+16]\r
+       mov  ebx, [esi+12]\r
+\r
+       sub  ebp,ecx\r
+       neg  ebp\r
+       add  ebp,ebx\r
+\r
+       sub  ecx,257\r
+       add  ecx,ebx\r
+\r
+       mov  [esp+60],ebx\r
+       mov  [esp+40],ebp\r
+       mov  [esp+16],ecx\r
+; 285 "inffast.S"\r
+       mov  eax, [edi+lencode_state]\r
+       mov  ecx, [edi+distcode_state]\r
+\r
+       mov  [esp+8],eax\r
+       mov  [esp+12],ecx\r
+\r
+       mov  eax,1\r
+       mov  ecx, [edi+lenbits_state]\r
+       shl  eax,cl\r
+       dec  eax\r
+       mov  [esp+0],eax\r
+\r
+       mov  eax,1\r
+       mov  ecx, [edi+distbits_state]\r
+       shl  eax,cl\r
+       dec  eax\r
+       mov  [esp+4],eax\r
+\r
+       mov  eax, [edi+wsize_state]\r
+       mov  ecx, [edi+write_state]\r
+       mov  edx, [edi+window_state]\r
+\r
+       mov  [esp+52],eax\r
+       mov  [esp+48],ecx\r
+       mov  [esp+56],edx\r
+\r
+       mov  ebp, [edi+hold_state]\r
+       mov  ebx, [edi+bits_state]\r
+; 321 "inffast.S"\r
+       mov  esi, [esp+44]\r
+       mov  ecx, [esp+20]\r
+       cmp  ecx,esi\r
+       ja   L_align_long\r
+\r
+       add  ecx,11\r
+       sub  ecx,esi\r
+       mov  eax,12\r
+       sub  eax,ecx\r
+       lea  edi, [esp+28]\r
+       rep movsb\r
+       mov  ecx,eax\r
+       xor  eax,eax\r
+       rep stosb\r
+       lea  esi, [esp+28]\r
+       mov  [esp+20],esi\r
+       jmp  L_is_aligned\r
+\r
+\r
+L_align_long:\r
+       test  esi,3\r
+       jz   L_is_aligned\r
+       xor  eax,eax\r
+       mov  al, [esi]\r
+       inc  esi\r
+       mov  ecx,ebx\r
+       add  ebx,8\r
+       shl  eax,cl\r
+       or  ebp,eax\r
+       jmp L_align_long\r
+\r
+L_is_aligned:\r
+       mov  edi, [esp+60]\r
+; 366 "inffast.S"\r
+L_check_mmx:\r
+       cmp  dword ptr [inflate_fast_use_mmx],2\r
+       je   L_init_mmx\r
+       ja   L_do_loop\r
+\r
+       push  eax\r
+       push  ebx\r
+       push  ecx\r
+       push  edx\r
+       pushfd\r
+       mov  eax, [esp]\r
+       xor  dword ptr [esp],0200000h\r
+\r
+\r
+\r
+\r
+       popfd\r
+       pushfd\r
+       pop  edx\r
+       xor  edx,eax\r
+       jz   L_dont_use_mmx\r
+       xor  eax,eax\r
+       cpuid\r
+       cmp  ebx,0756e6547h\r
+       jne  L_dont_use_mmx\r
+       cmp  ecx,06c65746eh\r
+       jne  L_dont_use_mmx\r
+       cmp  edx,049656e69h\r
+       jne  L_dont_use_mmx\r
+       mov  eax,1\r
+       cpuid\r
+       shr  eax,8\r
+       and  eax,15\r
+       cmp  eax,6\r
+       jne  L_dont_use_mmx\r
+       test  edx,0800000h\r
+       jnz  L_use_mmx\r
+       jmp  L_dont_use_mmx\r
+L_use_mmx:\r
+       mov  dword ptr [inflate_fast_use_mmx],2\r
+       jmp  L_check_mmx_pop\r
+L_dont_use_mmx:\r
+       mov  dword ptr [inflate_fast_use_mmx],3\r
+L_check_mmx_pop:\r
+       pop  edx\r
+       pop  ecx\r
+       pop  ebx\r
+       pop  eax\r
+       jmp  L_check_mmx\r
+; 426 "inffast.S"\r
+ALIGN 4\r
+L_do_loop:\r
+; 437 "inffast.S"\r
+       cmp  bl,15\r
+       ja   L_get_length_code\r
+\r
+       xor  eax,eax\r
+       lodsw\r
+       mov  cl,bl\r
+       add  bl,16\r
+       shl  eax,cl\r
+       or  ebp,eax\r
+\r
+L_get_length_code:\r
+       mov  edx, [esp+0]\r
+       mov  ecx, [esp+8]\r
+       and  edx,ebp\r
+       mov  eax, [ecx+edx*4]\r
+\r
+L_dolen:\r
+\r
+\r
+\r
+\r
+\r
+\r
+       mov  cl,ah\r
+       sub  bl,ah\r
+       shr  ebp,cl\r
+\r
+\r
+\r
+\r
+\r
+\r
+       test  al,al\r
+       jnz   L_test_for_length_base\r
+\r
+       shr  eax,16\r
+       stosb\r
+\r
+L_while_test:\r
+\r
+\r
+       cmp  [esp+16],edi\r
+       jbe  L_break_loop\r
+\r
+       cmp  [esp+20],esi\r
+       ja   L_do_loop\r
+       jmp  L_break_loop\r
+\r
+L_test_for_length_base:\r
+; 502 "inffast.S"\r
+       mov  edx,eax\r
+       shr  edx,16\r
+       mov  cl,al\r
+\r
+       test  al,16\r
+       jz   L_test_for_second_level_length\r
+       and  cl,15\r
+       jz   L_save_len\r
+       cmp  bl,cl\r
+       jae  L_add_bits_to_len\r
+\r
+       mov  ch,cl\r
+       xor  eax,eax\r
+       lodsw\r
+       mov  cl,bl\r
+       add  bl,16\r
+       shl  eax,cl\r
+       or  ebp,eax\r
+       mov  cl,ch\r
+\r
+L_add_bits_to_len:\r
+       mov  eax,1\r
+       shl  eax,cl\r
+       dec  eax\r
+       sub  bl,cl\r
+       and  eax,ebp\r
+       shr  ebp,cl\r
+       add  edx,eax\r
+\r
+L_save_len:\r
+       mov  [esp+24],edx\r
+\r
+\r
+L_decode_distance:\r
+; 549 "inffast.S"\r
+       cmp  bl,15\r
+       ja   L_get_distance_code\r
+\r
+       xor  eax,eax\r
+       lodsw\r
+       mov  cl,bl\r
+       add  bl,16\r
+       shl  eax,cl\r
+       or  ebp,eax\r
+\r
+L_get_distance_code:\r
+       mov  edx, [esp+4]\r
+       mov  ecx, [esp+12]\r
+       and  edx,ebp\r
+       mov  eax, [ecx+edx*4]\r
+\r
+\r
+L_dodist:\r
+       mov  edx,eax\r
+       shr  edx,16\r
+       mov  cl,ah\r
+       sub  bl,ah\r
+       shr  ebp,cl\r
+; 584 "inffast.S"\r
+       mov  cl,al\r
+\r
+       test  al,16\r
+       jz  L_test_for_second_level_dist\r
+       and  cl,15\r
+       jz  L_check_dist_one\r
+       cmp  bl,cl\r
+       jae  L_add_bits_to_dist\r
+\r
+       mov  ch,cl\r
+       xor  eax,eax\r
+       lodsw\r
+       mov  cl,bl\r
+       add  bl,16\r
+       shl  eax,cl\r
+       or  ebp,eax\r
+       mov  cl,ch\r
+\r
+L_add_bits_to_dist:\r
+       mov  eax,1\r
+       shl  eax,cl\r
+       dec  eax\r
+       sub  bl,cl\r
+       and  eax,ebp\r
+       shr  ebp,cl\r
+       add  edx,eax\r
+       jmp  L_check_window\r
+\r
+L_check_window:\r
+; 625 "inffast.S"\r
+       mov  [esp+44],esi\r
+       mov  eax,edi\r
+       sub  eax, [esp+40]\r
+\r
+       cmp  eax,edx\r
+       jb   L_clip_window\r
+\r
+       mov  ecx, [esp+24]\r
+       mov  esi,edi\r
+       sub  esi,edx\r
+\r
+       sub  ecx,3\r
+       mov  al, [esi]\r
+       mov  [edi],al\r
+       mov  al, [esi+1]\r
+       mov  dl, [esi+2]\r
+       add  esi,3\r
+       mov  [edi+1],al\r
+       mov  [edi+2],dl\r
+       add  edi,3\r
+       rep movsb\r
+\r
+       mov  esi, [esp+44]\r
+       jmp  L_while_test\r
+\r
+ALIGN 4\r
+L_check_dist_one:\r
+       cmp  edx,1\r
+       jne  L_check_window\r
+       cmp  [esp+40],edi\r
+       je  L_check_window\r
+\r
+       dec  edi\r
+       mov  ecx, [esp+24]\r
+       mov  al, [edi]\r
+       sub  ecx,3\r
+\r
+       mov  [edi+1],al\r
+       mov  [edi+2],al\r
+       mov  [edi+3],al\r
+       add  edi,4\r
+       rep stosb\r
+\r
+       jmp  L_while_test\r
+\r
+ALIGN 4\r
+L_test_for_second_level_length:\r
+\r
+\r
+\r
+\r
+       test  al,64\r
+       jnz   L_test_for_end_of_block\r
+\r
+       mov  eax,1\r
+       shl  eax,cl\r
+       dec  eax\r
+       and  eax,ebp\r
+       add  eax,edx\r
+       mov  edx, [esp+8]\r
+       mov  eax, [edx+eax*4]\r
+       jmp  L_dolen\r
+\r
+ALIGN 4\r
+L_test_for_second_level_dist:\r
+\r
+\r
+\r
+\r
+       test  al,64\r
+       jnz   L_invalid_distance_code\r
+\r
+       mov  eax,1\r
+       shl  eax,cl\r
+       dec  eax\r
+       and  eax,ebp\r
+       add  eax,edx\r
+       mov  edx, [esp+12]\r
+       mov  eax, [edx+eax*4]\r
+       jmp  L_dodist\r
+\r
+ALIGN 4\r
+L_clip_window:\r
+; 721 "inffast.S"\r
+       mov  ecx,eax\r
+       mov  eax, [esp+52]\r
+       neg  ecx\r
+       mov  esi, [esp+56]\r
+\r
+       cmp  eax,edx\r
+       jb   L_invalid_distance_too_far\r
+\r
+       add  ecx,edx\r
+       cmp  dword ptr [esp+48],0\r
+       jne  L_wrap_around_window\r
+\r
+       sub  eax,ecx\r
+       add  esi,eax\r
+; 749 "inffast.S"\r
+       mov  eax, [esp+24]\r
+       cmp  eax,ecx\r
+       jbe  L_do_copy1\r
+\r
+       sub  eax,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,edx\r
+       jmp  L_do_copy1\r
+\r
+       cmp  eax,ecx\r
+       jbe  L_do_copy1\r
+\r
+       sub  eax,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,edx\r
+       jmp  L_do_copy1\r
+\r
+L_wrap_around_window:\r
+; 793 "inffast.S"\r
+       mov  eax, [esp+48]\r
+       cmp  ecx,eax\r
+       jbe  L_contiguous_in_window\r
+\r
+       add  esi, [esp+52]\r
+       add  esi,eax\r
+       sub  esi,ecx\r
+       sub  ecx,eax\r
+\r
+\r
+       mov  eax, [esp+24]\r
+       cmp  eax,ecx\r
+       jbe  L_do_copy1\r
+\r
+       sub  eax,ecx\r
+       rep movsb\r
+       mov  esi, [esp+56]\r
+       mov  ecx, [esp+48]\r
+       cmp  eax,ecx\r
+       jbe  L_do_copy1\r
+\r
+       sub  eax,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,edx\r
+       jmp  L_do_copy1\r
+\r
+L_contiguous_in_window:\r
+; 836 "inffast.S"\r
+       add  esi,eax\r
+       sub  esi,ecx\r
+\r
+\r
+       mov  eax, [esp+24]\r
+       cmp  eax,ecx\r
+       jbe  L_do_copy1\r
+\r
+       sub  eax,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,edx\r
+\r
+L_do_copy1:\r
+; 862 "inffast.S"\r
+       mov  ecx,eax\r
+       rep movsb\r
+\r
+       mov  esi, [esp+44]\r
+       jmp  L_while_test\r
+; 878 "inffast.S"\r
+ALIGN 4\r
+L_init_mmx:\r
+       emms\r
+\r
+\r
+\r
+\r
+\r
+       movd mm0,ebp\r
+       mov  ebp,ebx\r
+; 896 "inffast.S"\r
+       movd mm4,dword ptr [esp+0]\r
+       movq mm3,mm4\r
+       movd mm5,dword ptr [esp+4]\r
+       movq mm2,mm5\r
+       pxor mm1,mm1\r
+       mov  ebx, [esp+8]\r
+       jmp  L_do_loop_mmx\r
+\r
+ALIGN 4\r
+L_do_loop_mmx:\r
+       psrlq mm0,mm1\r
+\r
+       cmp  ebp,32\r
+       ja  L_get_length_code_mmx\r
+\r
+       movd mm6,ebp\r
+       movd mm7,dword ptr [esi]\r
+       add  esi,4\r
+       psllq mm7,mm6\r
+       add  ebp,32\r
+       por mm0,mm7\r
+\r
+L_get_length_code_mmx:\r
+       pand mm4,mm0\r
+       movd eax,mm4\r
+       movq mm4,mm3\r
+       mov  eax, [ebx+eax*4]\r
+\r
+L_dolen_mmx:\r
+       movzx  ecx,ah\r
+       movd mm1,ecx\r
+       sub  ebp,ecx\r
+\r
+       test  al,al\r
+       jnz L_test_for_length_base_mmx\r
+\r
+       shr  eax,16\r
+       stosb\r
+\r
+L_while_test_mmx:\r
+\r
+\r
+       cmp  [esp+16],edi\r
+       jbe L_break_loop\r
+\r
+       cmp  [esp+20],esi\r
+       ja L_do_loop_mmx\r
+       jmp L_break_loop\r
+\r
+L_test_for_length_base_mmx:\r
+\r
+       mov  edx,eax\r
+       shr  edx,16\r
+\r
+       test  al,16\r
+       jz  L_test_for_second_level_length_mmx\r
+       and  eax,15\r
+       jz L_decode_distance_mmx\r
+\r
+       psrlq mm0,mm1\r
+       movd mm1,eax\r
+       movd ecx,mm0\r
+       sub  ebp,eax\r
+       and  ecx, [inflate_fast_mask+eax*4]\r
+       add  edx,ecx\r
+\r
+L_decode_distance_mmx:\r
+       psrlq mm0,mm1\r
+\r
+       cmp  ebp,32\r
+       ja L_get_dist_code_mmx\r
+\r
+       movd mm6,ebp\r
+       movd mm7,dword ptr [esi]\r
+       add  esi,4\r
+       psllq mm7,mm6\r
+       add  ebp,32\r
+       por mm0,mm7\r
+\r
+L_get_dist_code_mmx:\r
+       mov  ebx, [esp+12]\r
+       pand mm5,mm0\r
+       movd eax,mm5\r
+       movq mm5,mm2\r
+       mov  eax, [ebx+eax*4]\r
+\r
+L_dodist_mmx:\r
+\r
+       movzx  ecx,ah\r
+       mov  ebx,eax\r
+       shr  ebx,16\r
+       sub  ebp,ecx\r
+       movd mm1,ecx\r
+\r
+       test  al,16\r
+       jz L_test_for_second_level_dist_mmx\r
+       and  eax,15\r
+       jz L_check_dist_one_mmx\r
+\r
+L_add_bits_to_dist_mmx:\r
+       psrlq mm0,mm1\r
+       movd mm1,eax\r
+       movd ecx,mm0\r
+       sub  ebp,eax\r
+       and  ecx, [inflate_fast_mask+eax*4]\r
+       add  ebx,ecx\r
+\r
+L_check_window_mmx:\r
+       mov  [esp+44],esi\r
+       mov  eax,edi\r
+       sub  eax, [esp+40]\r
+\r
+       cmp  eax,ebx\r
+       jb L_clip_window_mmx\r
+\r
+       mov  ecx,edx\r
+       mov  esi,edi\r
+       sub  esi,ebx\r
+\r
+       sub  ecx,3\r
+       mov  al, [esi]\r
+       mov  [edi],al\r
+       mov  al, [esi+1]\r
+       mov  dl, [esi+2]\r
+       add  esi,3\r
+       mov  [edi+1],al\r
+       mov  [edi+2],dl\r
+       add  edi,3\r
+       rep movsb\r
+\r
+       mov  esi, [esp+44]\r
+       mov  ebx, [esp+8]\r
+       jmp  L_while_test_mmx\r
+\r
+ALIGN 4\r
+L_check_dist_one_mmx:\r
+       cmp  ebx,1\r
+       jne  L_check_window_mmx\r
+       cmp  [esp+40],edi\r
+       je   L_check_window_mmx\r
+\r
+       dec  edi\r
+       mov  ecx,edx\r
+       mov  al, [edi]\r
+       sub  ecx,3\r
+\r
+       mov  [edi+1],al\r
+       mov  [edi+2],al\r
+       mov  [edi+3],al\r
+       add  edi,4\r
+       rep stosb\r
+\r
+       mov  ebx, [esp+8]\r
+       jmp  L_while_test_mmx\r
+\r
+ALIGN 4\r
+L_test_for_second_level_length_mmx:\r
+       test  al,64\r
+       jnz L_test_for_end_of_block\r
+\r
+       and  eax,15\r
+       psrlq mm0,mm1\r
+       movd ecx,mm0\r
+       and  ecx, [inflate_fast_mask+eax*4]\r
+       add  ecx,edx\r
+       mov  eax, [ebx+ecx*4]\r
+       jmp L_dolen_mmx\r
+\r
+ALIGN 4\r
+L_test_for_second_level_dist_mmx:\r
+       test  al,64\r
+       jnz L_invalid_distance_code\r
+\r
+       and  eax,15\r
+       psrlq mm0,mm1\r
+       movd ecx,mm0\r
+       and  ecx, [inflate_fast_mask+eax*4]\r
+       mov  eax, [esp+12]\r
+       add  ecx,ebx\r
+       mov  eax, [eax+ecx*4]\r
+       jmp  L_dodist_mmx\r
+\r
+ALIGN 4\r
+L_clip_window_mmx:\r
+\r
+       mov  ecx,eax\r
+       mov  eax, [esp+52]\r
+       neg  ecx\r
+       mov  esi, [esp+56]\r
+\r
+       cmp  eax,ebx\r
+       jb  L_invalid_distance_too_far\r
+\r
+       add  ecx,ebx\r
+       cmp  dword ptr [esp+48],0\r
+       jne  L_wrap_around_window_mmx\r
+\r
+       sub  eax,ecx\r
+       add  esi,eax\r
+\r
+       cmp  edx,ecx\r
+       jbe  L_do_copy1_mmx\r
+\r
+       sub  edx,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,ebx\r
+       jmp  L_do_copy1_mmx\r
+\r
+       cmp  edx,ecx\r
+       jbe  L_do_copy1_mmx\r
+\r
+       sub  edx,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,ebx\r
+       jmp  L_do_copy1_mmx\r
+\r
+L_wrap_around_window_mmx:\r
+\r
+       mov  eax, [esp+48]\r
+       cmp  ecx,eax\r
+       jbe  L_contiguous_in_window_mmx\r
+\r
+       add  esi, [esp+52]\r
+       add  esi,eax\r
+       sub  esi,ecx\r
+       sub  ecx,eax\r
+\r
+\r
+       cmp  edx,ecx\r
+       jbe  L_do_copy1_mmx\r
+\r
+       sub  edx,ecx\r
+       rep movsb\r
+       mov  esi, [esp+56]\r
+       mov  ecx, [esp+48]\r
+       cmp  edx,ecx\r
+       jbe  L_do_copy1_mmx\r
+\r
+       sub  edx,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,ebx\r
+       jmp  L_do_copy1_mmx\r
+\r
+L_contiguous_in_window_mmx:\r
+\r
+       add  esi,eax\r
+       sub  esi,ecx\r
+\r
+\r
+       cmp  edx,ecx\r
+       jbe  L_do_copy1_mmx\r
+\r
+       sub  edx,ecx\r
+       rep movsb\r
+       mov  esi,edi\r
+       sub  esi,ebx\r
+\r
+L_do_copy1_mmx:\r
+\r
+\r
+       mov  ecx,edx\r
+       rep movsb\r
+\r
+       mov  esi, [esp+44]\r
+       mov  ebx, [esp+8]\r
+       jmp  L_while_test_mmx\r
+; 1174 "inffast.S"\r
+L_invalid_distance_code:\r
+\r
+\r
+\r
+\r
+\r
+       mov  ecx, invalid_distance_code_msg\r
+       mov  edx,INFLATE_MODE_BAD\r
+       jmp  L_update_stream_state\r
+\r
+L_test_for_end_of_block:\r
+\r
+\r
+\r
+\r
+\r
+       test  al,32\r
+       jz  L_invalid_literal_length_code\r
+\r
+       mov  ecx,0\r
+       mov  edx,INFLATE_MODE_TYPE\r
+       jmp  L_update_stream_state\r
+\r
+L_invalid_literal_length_code:\r
+\r
+\r
+\r
+\r
+\r
+       mov  ecx, invalid_literal_length_code_msg\r
+       mov  edx,INFLATE_MODE_BAD\r
+       jmp  L_update_stream_state\r
+\r
+L_invalid_distance_too_far:\r
+\r
+\r
+\r
+       mov  esi, [esp+44]\r
+       mov  ecx, invalid_distance_too_far_msg\r
+       mov  edx,INFLATE_MODE_BAD\r
+       jmp  L_update_stream_state\r
+\r
+L_update_stream_state:\r
+\r
+       mov  eax, [esp+88]\r
+       test  ecx,ecx\r
+       jz  L_skip_msg\r
+       mov  [eax+24],ecx\r
+L_skip_msg:\r
+       mov  eax, [eax+28]\r
+       mov  [eax+mode_state],edx\r
+       jmp  L_break_loop\r
+\r
+ALIGN 4\r
+L_break_loop:\r
+; 1243 "inffast.S"\r
+       cmp  dword ptr [inflate_fast_use_mmx],2\r
+       jne  L_update_next_in\r
+\r
+\r
+\r
+       mov  ebx,ebp\r
+\r
+L_update_next_in:\r
+; 1266 "inffast.S"\r
+       mov  eax, [esp+88]\r
+       mov  ecx,ebx\r
+       mov  edx, [eax+28]\r
+       shr  ecx,3\r
+       sub  esi,ecx\r
+       shl  ecx,3\r
+       sub  ebx,ecx\r
+       mov  [eax+12],edi\r
+       mov  [edx+bits_state],ebx\r
+       mov  ecx,ebx\r
+\r
+       lea  ebx, [esp+28]\r
+       cmp  [esp+20],ebx\r
+       jne  L_buf_not_used\r
+\r
+       sub  esi,ebx\r
+       mov  ebx, [eax+0]\r
+       mov  [esp+20],ebx\r
+       add  esi,ebx\r
+       mov  ebx, [eax+4]\r
+       sub  ebx,11\r
+       add  [esp+20],ebx\r
+\r
+L_buf_not_used:\r
+       mov  [eax+0],esi\r
+\r
+       mov  ebx,1\r
+       shl  ebx,cl\r
+       dec  ebx\r
+\r
+\r
+\r
+\r
+\r
+       cmp  dword ptr [inflate_fast_use_mmx],2\r
+       jne  L_update_hold\r
+\r
+\r
+\r
+       psrlq mm0,mm1\r
+       movd ebp,mm0\r
+\r
+       emms\r
+\r
+L_update_hold:\r
+\r
+\r
+\r
+       and  ebp,ebx\r
+       mov  [edx+hold_state],ebp\r
+\r
+\r
+\r
+\r
+       mov  ebx, [esp+20]\r
+       cmp  ebx,esi\r
+       jbe  L_last_is_smaller\r
+\r
+       sub  ebx,esi\r
+       add  ebx,11\r
+       mov  [eax+4],ebx\r
+       jmp  L_fixup_out\r
+L_last_is_smaller:\r
+       sub  esi,ebx\r
+       neg  esi\r
+       add  esi,11\r
+       mov  [eax+4],esi\r
+\r
+\r
+\r
+\r
+L_fixup_out:\r
+\r
+       mov  ebx, [esp+16]\r
+       cmp  ebx,edi\r
+       jbe  L_end_is_smaller\r
+\r
+       sub  ebx,edi\r
+       add  ebx,257\r
+       mov  [eax+16],ebx\r
+       jmp  L_done\r
+L_end_is_smaller:\r
+       sub  edi,ebx\r
+       neg  edi\r
+       add  edi,257\r
+       mov  [eax+16],edi\r
+\r
+\r
+\r
+\r
+\r
+L_done:\r
+       add  esp,64\r
+       popfd\r
+       pop  ebx\r
+       pop  ebp\r
+       pop  esi\r
+       pop  edi\r
+       ret\r
+_inflate_fast endp\r
+\r
+_TEXT  ends\r
+end\r