// File: /workspace/github_c_makefile_star2_O1/patriciogonzalezvivo[P]tprint/include/std/stb_image.h
// Function: stbi__zbuild_huffman(stbi__zhuffman*, unsigned char*, int)
static int stbi__zbuild_huffman(stbi__zhuffman *z, stbi_uc *sizelist, int num)
{
   int i,k=0;
   int code, next_code[16], sizes[17];

   // DEFLATE spec for generating codes
   memset(sizes, 0, sizeof(sizes));
   memset(z->fast, 0, sizeof(z->fast));
   for (i=0; i < num; ++i)
      ++sizes[sizelist[i]];
   sizes[0] = 0;
   for (i=1; i < 16; ++i)
      if (sizes[i] > (1 << i))
         return stbi__err("bad sizes", "Corrupt PNG");
   code = 0;
   for (i=1; i < 16; ++i) {
      next_code[i] = code;
      z->firstcode[i] = (stbi__uint16) code;
      z->firstsymbol[i] = (stbi__uint16) k;
      code = (code + sizes[i]);
      if (sizes[i])
         if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG");
      z->maxcode[i] = code << (16-i); // preshift for inner loop
      code <<= 1;
      k += sizes[i];
   }
   z->maxcode[16] = 0x10000; // sentinel
   for (i=0; i < num; ++i) {
      int s = sizelist[i];
      if (s) {
         int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s];
         stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i);
         z->size [c] = (stbi_uc     ) s;
         z->value[c] = (stbi__uint16) i;
         if (s <= STBI__ZFAST_BITS) {
            int k = stbi__bit_reverse(next_code[s],s);
            while (k < (1 << STBI__ZFAST_BITS)) {
               z->fast[k] = fastv;
               k += (1 << s);
            }
         }
         ++next_code[s];
      }
   }
   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
movdqa %xmm0, 0x40(%rsp)
movdqa %xmm0, 0x30(%rsp)
movdqa %xmm0, 0x20(%rsp)
movl $0x0, 0x60(%rsp)
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x81d0
testl %ebp, %ebp
jle 0x1f38a
movl %ebp, %eax
xorl %ecx, %ecx
movzbl (%rbx,%rcx), %edx
incl 0x20(%rsp,%rdx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1f37a
movl $0x0, 0x20(%rsp)
movl $0x1, %ecx
leaq 0x3381(%rip), %rdx      # 0x2271f
movl $0x1, %eax
shll %cl, %eax
cmpl %eax, 0x20(%rsp,%rcx,4)
jg 0x1f847
incq %rcx
cmpq $0x10, %rcx
jne 0x1f39e
xorl %esi, %esi
movl $0xf, %eax
leaq 0x3363(%rip), %rdx      # 0x22729
xorl %edi, %edi
xorl %r8d, %r8d
movl %r8d, 0x74(%rsp,%rsi,4)
movw %r8w, 0x402(%r14,%rsi,2)
movw %di, 0x466(%r14,%rsi,2)
movl 0x24(%rsp,%rsi,4), %r9d
addl %r9d, %r8d
leal 0x1(%rsi), %ecx
movl $0x1, %r10d
shll %cl, %r10d
testl %r9d, %r9d
je 0x1f404
cmpl %r10d, %r8d
jg 0x1f847
movl %r8d, %r10d
movl %eax, %ecx
shll %cl, %r10d
movl %r10d, 0x424(%r14,%rsi,4)
addl %r8d, %r8d
addl %r9d, %edi
decl %eax
incq %rsi
cmpq $0xf, %rsi
jne 0x1f3cb
movl $0x10000, 0x460(%r14) # imm = 0x10000
movl $0x1, %eax
testl %ebp, %ebp
jle 0x1f850
movl %ebp, %eax
movq %rax, 0x10(%rsp)
xorl %edi, %edi
movdqa 0x2512(%rip), %xmm0     # 0x21960
movdqa 0x251a(%rip), %xmm1     # 0x21970
movdqa 0x2522(%rip), %xmm2     # 0x21980
movdqa 0x252a(%rip), %xmm3     # 0x21990
movdqa 0x2532(%rip), %xmm4     # 0x219a0
pcmpeqd %xmm5, %xmm5
movq %rbx, 0x8(%rsp)
movzbl (%rbx,%rdi), %edx
testl %edx, %edx
je 0x1f832
movl 0x70(%rsp,%rdx,4), %ecx
movzwl 0x400(%r14,%rdx,2), %eax
movl %ecx, 0x4(%rsp)
subl %eax, %ecx
movzwl 0x464(%r14,%rdx,2), %eax
movslq %ecx, %rcx
addq %rax, %rcx
movb %dl, 0x484(%r14,%rcx)
movw %di, 0x5a4(%r14,%rcx,2)
cmpb $0x9, %dl
ja 0x1f823
movl 0x4(%rsp), %eax
rolw $0x8, %ax
movl %eax, %ecx
shrl $0x4, %ecx
movl $0xf0f, %esi            # imm = 0xF0F
andl %esi, %ecx
andl %esi, %eax
shll $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
movl $0x3333, %esi           # imm = 0x3333
andl %esi, %ecx
shrl $0x2, %eax
andl %esi, %eax
leal (%rax,%rcx,4), %eax
movl %eax, %ecx
movl $0x5555, %esi           # imm = 0x5555
andl %esi, %ecx
shrl %eax
andl %esi, %eax
leal (%rax,%rcx,2), %eax
movb $0x10, %cl
subb %dl, %cl
shrl %cl, %eax
cmpl $0x1ff, %eax            # imm = 0x1FF
ja 0x1f823
movl %edx, %ecx
shll $0x9, %ecx
movl %edi, %r15d
orl %ecx, %r15d
movl $0x1, %r12d
movl %edx, %ecx
shlq %cl, %r12
movl %eax, %r13d
leaq (%r12,%r13), %rax
xorl %esi, %esi
movl $0x200, %ecx            # imm = 0x200
cmpq %rcx, %rax
setb %sil
cmpq $0x201, %rax            # imm = 0x201
movl $0x200, %r8d            # imm = 0x200
cmovaeq %rax, %r8
subq %rsi, %r8
subq %rax, %r8
movl %edx, %ecx
shrq %cl, %r8
leaq (%rsi,%r8), %rax
leaq (%rsi,%r8), %r11
addq $0x8, %r11
andq $-0x8, %r11
movl $0x3, %r8d
shlq %cl, %r8
movl $0x5, %r9d
shlq %cl, %r9
movq %rax, %xmm6
pshufd $0x44, %xmm6, %xmm6     # xmm6 = xmm6[0,1,0,1]
movl $0x6, %r10d
shlq %cl, %r10
movl $0x7, %esi
shlq %cl, %rsi
leaq (%r12,%r12), %rax
movq %rax, 0x18(%rsp)
leaq (,%r12,4), %rbp
pxor %xmm4, %xmm6
xorl %eax, %eax
movq %rax, %rbx
movl %edx, %ecx
shlq %cl, %rbx
addq %r13, %rbx
movq %rax, %xmm7
pshufd $0x44, %xmm7, %xmm7     # xmm7 = xmm7[0,1,0,1]
movdqa %xmm7, %xmm8
por %xmm3, %xmm8
pxor %xmm4, %xmm8
movdqa %xmm8, %xmm10
pcmpgtd %xmm6, %xmm10
pshufd $0xa0, %xmm10, %xmm9    # xmm9 = xmm10[0,0,2,2]
pshuflw $0xe8, %xmm9, %xmm11    # xmm11 = xmm9[0,2,2,3,4,5,6,7]
pcmpeqd %xmm6, %xmm8
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pshuflw $0xe8, %xmm8, %xmm12    # xmm12 = xmm8[0,2,2,3,4,5,6,7]
pand %xmm11, %xmm12
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
pshuflw $0xe8, %xmm10, %xmm11   # xmm11 = xmm10[0,2,2,3,4,5,6,7]
por %xmm12, %xmm11
pxor %xmm5, %xmm11
packssdw %xmm11, %xmm11
movd %xmm11, %ecx
testb $0x1, %cl
je 0x1f620
movw %r15w, (%r14,%rbx,2)
pand %xmm9, %xmm8
por %xmm10, %xmm8
packssdw %xmm8, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm8
movd %xmm8, %ecx
shrl $0x10, %ecx
testb $0x1, %cl
je 0x1f64f
leaq (%rbx,%r12), %rcx
movw %r15w, (%r14,%rcx,2)
movdqa %xmm7, %xmm9
por %xmm2, %xmm9
pxor %xmm4, %xmm9
movdqa %xmm9, %xmm10
pcmpgtd %xmm6, %xmm10
pshufd $0xa0, %xmm10, %xmm8    # xmm8 = xmm10[0,0,2,2]
pcmpeqd %xmm6, %xmm9
pshufd $0xf5, %xmm9, %xmm9     # xmm9 = xmm9[1,1,3,3]
movdqa %xmm9, %xmm11
pand %xmm8, %xmm11
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
por %xmm10, %xmm11
packssdw %xmm11, %xmm11
pxor %xmm5, %xmm11
packssdw %xmm11, %xmm11
pextrw $0x2, %xmm11, %ecx
testb $0x1, %cl
je 0x1f6b5
movq 0x18(%rsp), %rcx
addq %rbx, %rcx
movw %r15w, (%r14,%rcx,2)
pshufhw $0x84, %xmm8, %xmm8     # xmm8 = xmm8[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm9, %xmm9     # xmm9 = xmm9[0,1,2,3,4,5,4,6]
pand %xmm8, %xmm9
pshufhw $0x84, %xmm10, %xmm8    # xmm8 = xmm10[0,1,2,3,4,5,4,6]
por %xmm9, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm8
pextrw $0x3, %xmm8, %ecx
testb $0x1, %cl
je 0x1f6ef
leaq (%rbx,%r8), %rcx
movw %r15w, (%r14,%rcx,2)
movdqa %xmm7, %xmm8
por %xmm1, %xmm8
pxor %xmm4, %xmm8
movdqa %xmm8, %xmm10
pcmpgtd %xmm6, %xmm10
pshufd $0xa0, %xmm10, %xmm9    # xmm9 = xmm10[0,0,2,2]
pshuflw $0xe8, %xmm9, %xmm11    # xmm11 = xmm9[0,2,2,3,4,5,6,7]
pcmpeqd %xmm6, %xmm8
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pshuflw $0xe8, %xmm8, %xmm12    # xmm12 = xmm8[0,2,2,3,4,5,6,7]
pand %xmm11, %xmm12
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
pshuflw $0xe8, %xmm10, %xmm11   # xmm11 = xmm10[0,2,2,3,4,5,6,7]
por %xmm12, %xmm11
pxor %xmm5, %xmm11
packssdw %xmm11, %xmm11
pextrw $0x4, %xmm11, %ecx
testb $0x1, %cl
je 0x1f759
leaq (%rbx,%rbp), %rcx
movw %r15w, (%r14,%rcx,2)
pand %xmm9, %xmm8
por %xmm10, %xmm8
packssdw %xmm8, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm8
pextrw $0x5, %xmm8, %ecx
testb $0x1, %cl
je 0x1f786
leaq (%rbx,%r9), %rcx
movw %r15w, (%r14,%rcx,2)
por %xmm0, %xmm7
pxor %xmm4, %xmm7
movdqa %xmm7, %xmm9
pcmpgtd %xmm6, %xmm9
pshufd $0xa0, %xmm9, %xmm8     # xmm8 = xmm9[0,0,2,2]
pcmpeqd %xmm6, %xmm7
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
movdqa %xmm7, %xmm10
pand %xmm8, %xmm10
pshufd $0xf5, %xmm9, %xmm9     # xmm9 = xmm9[1,1,3,3]
por %xmm9, %xmm10
packssdw %xmm10, %xmm10
pxor %xmm5, %xmm10
packssdw %xmm10, %xmm10
pextrw $0x6, %xmm10, %ecx
testb $0x1, %cl
je 0x1f7df
leaq (%rbx,%r10), %rcx
movw %r15w, (%r14,%rcx,2)
pshufhw $0x84, %xmm8, %xmm8     # xmm8 = xmm8[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm7, %xmm7     # xmm7 = xmm7[0,1,2,3,4,5,4,6]
pand %xmm8, %xmm7
pshufhw $0x84, %xmm9, %xmm8     # xmm8 = xmm9[0,1,2,3,4,5,4,6]
por %xmm7, %xmm8
pxor %xmm5, %xmm8
packssdw %xmm8, %xmm7
pextrw $0x7, %xmm7, %ecx
testb $0x1, %cl
je 0x1f816
addq %rsi, %rbx
movw %r15w, (%r14,%rbx,2)
addq $0x8, %rax
cmpq %rax, %r11
jne 0x1f5a6
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x70(%rsp,%rdx,4)
movq 0x8(%rsp), %rbx
incq %rdi
cmpq 0x10(%rsp), %rdi
jne 0x1f477
movl $0x1, %eax
jmp 0x1f850
movq %rdx, 0x8bba(%rip)      # 0x28408
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq