// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movl %edx, 0xac(%rsp)
movl $0x0, 0xa4(%rsp)
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
movl $0x44, %edx
callq 0xd200
movq 0xb8(%rsp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0xd200
movl $0x0, 0xa8(%rsp)
movl 0xa8(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x2b1eb
movq 0xb0(%rsp), %rax
movslq 0xa8(%rsp), %rcx
movzbl (%rax,%rcx), %eax
movl 0x10(%rsp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rsp,%rax,4)
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x2b1a9
movl $0x0, 0x10(%rsp)
movl $0x1, 0xa8(%rsp)
cmpl $0x10, 0xa8(%rsp)
jge 0x2b255
movslq 0xa8(%rsp), %rax
movl 0x10(%rsp,%rax,4), %eax
movl 0xa8(%rsp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jle 0x2b240
leaq 0x30ac(%rip), %rdi      # 0x2e2db
callq 0x1a190
movl %eax, 0xc4(%rsp)
jmp 0x2b4fa
jmp 0x2b242
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x2b1fe
movl $0x0, 0xa0(%rsp)
movl $0x1, 0xa8(%rsp)
cmpl $0x10, 0xa8(%rsp)
jge 0x2b39d
movl 0xa0(%rsp), %ecx
movslq 0xa8(%rsp), %rax
movl %ecx, 0x60(%rsp,%rax,4)
movl 0xa0(%rsp), %eax
movw %ax, %dx
movq 0xb8(%rsp), %rax
movslq 0xa8(%rsp), %rcx
movw %dx, 0x400(%rax,%rcx,2)
movl 0xa4(%rsp), %eax
movw %ax, %dx
movq 0xb8(%rsp), %rax
movslq 0xa8(%rsp), %rcx
movw %dx, 0x464(%rax,%rcx,2)
movl 0xa0(%rsp), %eax
movslq 0xa8(%rsp), %rcx
addl 0x10(%rsp,%rcx,4), %eax
movl %eax, 0xa0(%rsp)
movslq 0xa8(%rsp), %rax
cmpl $0x0, 0x10(%rsp,%rax,4)
je 0x2b331
movl 0xa0(%rsp), %eax
subl $0x1, %eax
movl 0xa8(%rsp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jl 0x2b32f
leaq 0x2fc7(%rip), %rdi      # 0x2e2e5
callq 0x1a190
movl %eax, 0xc4(%rsp)
jmp 0x2b4fa
jmp 0x2b331
movl 0xa0(%rsp), %edx
movl $0x10, %ecx
subl 0xa8(%rsp), %ecx
shll %cl, %edx
movq 0xb8(%rsp), %rax
movslq 0xa8(%rsp), %rcx
movl %edx, 0x420(%rax,%rcx,4)
movl 0xa0(%rsp), %eax
shll %eax
movl %eax, 0xa0(%rsp)
movslq 0xa8(%rsp), %rax
movl 0x10(%rsp,%rax,4), %eax
addl 0xa4(%rsp), %eax
movl %eax, 0xa4(%rsp)
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x2b26b
movq 0xb8(%rsp), %rax
movl $0x10000, 0x460(%rax)   # imm = 0x10000
movl $0x0, 0xa8(%rsp)
movl 0xa8(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x2b4ef
movq 0xb0(%rsp), %rax
movslq 0xa8(%rsp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x2b4d7
movslq 0xc(%rsp), %rax
movl 0x60(%rsp,%rax,4), %eax
movq 0xb8(%rsp), %rcx
movslq 0xc(%rsp), %rdx
movzwl 0x400(%rcx,%rdx,2), %ecx
subl %ecx, %eax
movq 0xb8(%rsp), %rcx
movslq 0xc(%rsp), %rdx
movzwl 0x464(%rcx,%rdx,2), %ecx
addl %ecx, %eax
movl %eax, 0x8(%rsp)
movl 0xc(%rsp), %eax
shll $0x9, %eax
orl 0xa8(%rsp), %eax
movw %ax, 0x6(%rsp)
movl 0xc(%rsp), %eax
movb %al, %dl
movq 0xb8(%rsp), %rax
movslq 0x8(%rsp), %rcx
movb %dl, 0x484(%rax,%rcx)
movl 0xa8(%rsp), %eax
movw %ax, %dx
movq 0xb8(%rsp), %rax
movslq 0x8(%rsp), %rcx
movw %dx, 0x5a4(%rax,%rcx,2)
cmpl $0x9, 0xc(%rsp)
jg 0x2b4c7
movslq 0xc(%rsp), %rax
movl 0x60(%rsp,%rax,4), %edi
movl 0xc(%rsp), %esi
callq 0x2bce0
movl %eax, (%rsp)
cmpl $0x200, (%rsp)          # imm = 0x200
jge 0x2b4c5
movw 0x6(%rsp), %dx
movq 0xb8(%rsp), %rax
movslq (%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movl 0xc(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl (%rsp), %eax
movl %eax, (%rsp)
jmp 0x2b494
jmp 0x2b4c7
movslq 0xc(%rsp), %rax
movl 0x60(%rsp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, 0x60(%rsp,%rax,4)
jmp 0x2b4d9
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x2b3ba
movl $0x1, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
nopl (%rax)