// File: /workspace/github_c_makefile_star2_O0/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
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 0x4010e0
movq -0x10(%rbp), %rdi
movl $0xff, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4010e0
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x41ce9a
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 0x41ce6a
movl $0x0, -0xc0(%rbp)
movl $0x1, -0x20(%rbp)
cmpl $0x10, -0x20(%rbp)
jge 0x41cefa
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
jg 0x41cece
jmp 0x41ceed
leaq 0xc8c4a(%rip), %rdi     # 0x4e5b1f
leaq 0xc86ce(%rip), %rsi     # 0x4e55aa
movl $0x6a7, %edx            # imm = 0x6A7
leaq 0xc8c4c(%rip), %rcx     # 0x4e5b34
callq 0x42dfd0
jmp 0x41ceef
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x41ceab
movl $0x0, -0x28(%rbp)
movl $0x1, -0x20(%rbp)
cmpl $0x10, -0x20(%rbp)
jge 0x41cfd7
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 0x41cf94
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl -0x20(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jl 0x41cf92
leaq 0xc8bea(%rip), %rdi     # 0x4e5b6f
callq 0x411080
movl %eax, -0x4(%rbp)
jmp 0x41d114
jmp 0x41cf94
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 0x41cf08
movq -0x10(%rbp), %rax
movl $0x10000, 0x460(%rax)   # imm = 0x10000
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x41d10d
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0xc4(%rbp)
cmpl $0x0, -0xc4(%rbp)
je 0x41d0fd
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
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 0x41d0eb
movslq -0xc4(%rbp), %rax
movl -0x70(%rbp,%rax,4), %edi
movl -0xc4(%rbp), %esi
callq 0x41d860
movl %eax, -0xcc(%rbp)
cmpl $0x200, -0xcc(%rbp)     # imm = 0x200
jge 0x41d0e9
movl -0xc8(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movslq -0xcc(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0xc4(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0xcc(%rbp), %eax
movl %eax, -0xcc(%rbp)
jmp 0x41d0aa
jmp 0x41d0eb
movslq -0xc4(%rbp), %rax
movl -0x70(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x70(%rbp,%rax,4)
jmp 0x41d0ff
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x41cfec
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq