// File: /workspace/github_c_makefile_star2_O1/archer1357[P]Offline-Raytracer/stb_image.c
// Function: stbi__zbuild_huffman
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, 255, sizeof(z->fast));
   for (i=0; i < num; ++i) 
      ++sizes[sizelist[i]];
   sizes[0] = 0;
   for (i=1; i < 16; ++i)
      STBI_ASSERT(sizes[i] <= (1 << i));
   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 JPEG");
      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];
         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] = (stbi__uint16) c;
               k += (1 << s);
            }
         }
         ++next_code[s];
      }
   }
   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movl $0x0, 0x40(%rsp)
movl $0x400, %edx            # imm = 0x400
movl $0xff, %esi
callq 0x4010e0
testl %ebp, %ebp
jle 0x4121db
movl %ebp, %eax
xorl %ecx, %ecx
movzbl (%rbx,%rcx), %edx
incl (%rsp,%rdx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x4121cc
movl $0x0, (%rsp)
movl $0x1, %ecx
movl $0x1, %eax
shll %cl, %eax
cmpl %eax, (%rsp,%rcx,4)
jg 0x41236b
incq %rcx
cmpq $0x10, %rcx
jne 0x4121e7
xorl %edx, %edx
movl $0xf, %eax
xorl %esi, %esi
xorl %edi, %edi
movl %esi, 0x54(%rsp,%rdx,4)
movw %si, 0x402(%r14,%rdx,2)
movw %di, 0x466(%r14,%rdx,2)
movl 0x4(%rsp,%rdx,4), %r8d
addl %r8d, %esi
leal 0x1(%rdx), %ecx
movl $0x1, %r9d
shll %cl, %r9d
testl %r8d, %r8d
je 0x412243
cmpl %r9d, %esi
jg 0x41234b
movl %esi, %r9d
movl %eax, %ecx
shll %cl, %r9d
movl %r9d, 0x424(%r14,%rdx,4)
addl %esi, %esi
addl %r8d, %edi
decl %eax
incq %rdx
cmpq $0xf, %rdx
jne 0x41220b
movl $0x10000, 0x460(%r14) # imm = 0x10000
movl $0x1, %eax
testl %ebp, %ebp
jle 0x41235b
movl %ebp, %esi
xorl %edi, %edi
movl $0xf0f, %r8d            # imm = 0xF0F
movl $0x3333, %r9d           # imm = 0x3333
movl $0x5555, %r10d          # imm = 0x5555
movzbl (%rbx,%rdi), %edx
testl %edx, %edx
je 0x41233d
movslq 0x50(%rsp,%rdx,4), %r11
movzwl 0x400(%r14,%rdx,2), %ecx
movq %r11, %r12
subq %rcx, %r12
movzwl 0x464(%r14,%rdx,2), %r15d
addq %r12, %r15
movb %dl, 0x484(%r14,%r15)
movw %di, 0x5a4(%r14,%r15,2)
cmpb $0x9, %dl
ja 0x412335
movl %r11d, %ecx
rolw $0x8, %cx
movl %ecx, %ebp
shrl $0x4, %ebp
andl %r8d, %ebp
andl %r8d, %ecx
shll $0x4, %ecx
orl %ebp, %ecx
movl %ecx, %r12d
andl %r9d, %r12d
shrl $0x2, %ecx
andl %r9d, %ecx
leal (%rcx,%r12,4), %ecx
movl %ecx, %r12d
andl %r10d, %r12d
shrl %ecx
andl %r10d, %ecx
leal (%rcx,%r12,2), %ebp
movb $0x10, %cl
subb %dl, %cl
shrl %cl, %ebp
cmpl $0x1ff, %ebp            # imm = 0x1FF
ja 0x412335
movl $0x1, %r12d
movl %edx, %ecx
shlq %cl, %r12
movl %ebp, %ecx
movw %r15w, (%r14,%rcx,2)
addq %r12, %rcx
cmpq $0x200, %rcx            # imm = 0x200
jb 0x412324
leal 0x1(%r11), %ecx
movl %ecx, 0x50(%rsp,%rdx,4)
incq %rdi
cmpq %rsi, %rdi
jne 0x412291
jmp 0x41235b
leaq 0xc5ba1(%rip), %rax     # 0x4d7ef3
movq %rax, 0x1091e7(%rip)    # 0x51b540
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc5b31(%rip), %rdi     # 0x4d7ea3
leaq 0xc55b5(%rip), %rsi     # 0x4d792e
leaq 0xc5b38(%rip), %rcx     # 0x4d7eb8
movl $0x6a7, %edx            # imm = 0x6A7
callq 0x41fae0