// File: /workspace/github_c_makefile_star2_O0/zhiyb[P]png2tlg/./stb_image.h
// Function: stbi__zbuild_huffman(stbi__zhuffman*, unsigned char const*, int)
static int stbi__zbuild_huffman(stbi__zhuffman *z, const 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 j = stbi__bit_reverse(next_code[s],s);
            while (j < (1 << STBI__ZFAST_BITS)) {
               z->fast[j] = fastv;
               j += (1 << s);
            }
         }
         ++next_code[s];
      }
   }
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x44, %edx
callq 0x2100
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2100
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1d687
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl -0xc0(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0xc0(%rbp,%rax,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1d657
movl $0x0, -0xc0(%rbp)
movl $0x1, -0x20(%rbp)
cmpl $0x10, -0x20(%rbp)
jge 0x1d6da
movslq -0x20(%rbp), %rax
movl -0xc0(%rbp,%rax,4), %eax
movl -0x20(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jle 0x1d6cd
leaq 0x3b7b(%rip), %rdi      # 0x2123b
callq 0x2680
movl %eax, -0x4(%rbp)
jmp 0x1d905
jmp 0x1d6cf
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1d698
movl $0x0, -0x28(%rbp)
movl $0x1, -0x20(%rbp)
cmpl $0x10, -0x20(%rbp)
jge 0x1d7b7
movl -0x28(%rbp), %ecx
movslq -0x20(%rbp), %rax
movl %ecx, -0x70(%rbp,%rax,4)
movl -0x28(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw %dx, 0x400(%rax,%rcx,2)
movl -0x24(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw %dx, 0x464(%rax,%rcx,2)
movl -0x28(%rbp), %eax
movslq -0x20(%rbp), %rcx
addl -0xc0(%rbp,%rcx,4), %eax
movl %eax, -0x28(%rbp)
movslq -0x20(%rbp), %rax
cmpl $0x0, -0xc0(%rbp,%rax,4)
je 0x1d774
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl -0x20(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jl 0x1d772
leaq 0x3ae0(%rip), %rdi      # 0x21245
callq 0x2680
movl %eax, -0x4(%rbp)
jmp 0x1d905
jmp 0x1d774
movl -0x28(%rbp), %edx
movl $0x10, %ecx
subl -0x20(%rbp), %ecx
shll %cl, %edx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl %edx, 0x420(%rax,%rcx,4)
movl -0x28(%rbp), %eax
shll %eax
movl %eax, -0x28(%rbp)
movslq -0x20(%rbp), %rax
movl -0xc0(%rbp,%rax,4), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1d6e8
movq -0x10(%rbp), %rax
movl $0x10000, 0x460(%rax)   # imm = 0x10000
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1d8fe
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0xc4(%rbp)
cmpl $0x0, -0xc4(%rbp)
je 0x1d8ee
movslq -0xc4(%rbp), %rax
movl -0x70(%rbp,%rax,4), %eax
movq -0x10(%rbp), %rcx
movslq -0xc4(%rbp), %rdx
movzwl 0x400(%rcx,%rdx,2), %ecx
subl %ecx, %eax
movq -0x10(%rbp), %rcx
movslq -0xc4(%rbp), %rdx
movzwl 0x464(%rcx,%rdx,2), %ecx
addl %ecx, %eax
movl %eax, -0xc8(%rbp)
movl -0xc4(%rbp), %eax
shll $0x9, %eax
orl -0x20(%rbp), %eax
movw %ax, -0xca(%rbp)
movl -0xc4(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movslq -0xc8(%rbp), %rcx
movb %dl, 0x484(%rax,%rcx)
movl -0x20(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movslq -0xc8(%rbp), %rcx
movw %dx, 0x5a4(%rax,%rcx,2)
cmpl $0x9, -0xc4(%rbp)
jg 0x1d8dc
movslq -0xc4(%rbp), %rax
movl -0x70(%rbp,%rax,4), %edi
movl -0xc4(%rbp), %esi
callq 0x1e0c0
movl %eax, -0xd0(%rbp)
cmpl $0x200, -0xd0(%rbp)     # imm = 0x200
jge 0x1d8da
movw -0xca(%rbp), %dx
movq -0x10(%rbp), %rax
movslq -0xd0(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0xc4(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0xd0(%rbp), %eax
movl %eax, -0xd0(%rbp)
jmp 0x1d89d
jmp 0x1d8dc
movslq -0xc4(%rbp), %rax
movl -0x70(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x70(%rbp,%rax,4)
jmp 0x1d8f0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1d7cc
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)