// File: /workspace/github_c_makefile_star2_O0/zhiyb[P]png2tlg/./stb_image.h
// Function: stbi__build_huffman(stbi__huffman*, int*)
static int stbi__build_huffman(stbi__huffman *h, int *count)
{
   int i,j,k=0;
   unsigned int code;
   // build size list for each symbol (from JPEG spec)
   for (i=0; i < 16; ++i)
      for (j=0; j < count[i]; ++j)
         h->size[k++] = (stbi_uc) (i+1);
   h->size[k] = 0;

   // compute actual symbols (from jpeg spec)
   code = 0;
   k = 0;
   for(j=1; j <= 16; ++j) {
      // compute delta to add to code to compute symbol id
      h->delta[j] = k - code;
      if (h->size[k] == j) {
         while (h->size[k] == j)
            h->code[k++] = (stbi__uint16) (code++);
         if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG");
      }
      // compute largest code + 1 for this size, preshifted as needed later
      h->maxcode[j] = code << (16-j);
      code <<= 1;
   }
   h->maxcode[j] = 0xffffffff;

   // build non-spec acceleration table; 255 is flag for not-accelerated
   memset(h->fast, 255, 1 << FAST_BITS);
   for (i=0; i < k; ++i) {
      int s = h->size[i];
      if (s <= FAST_BITS) {
         int c = h->code[i] << (FAST_BITS-s);
         int m = 1 << (FAST_BITS-s);
         for (j=0; j < m; ++j) {
            h->fast[c+j] = (stbi_uc) i;
         }
      }
   }
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x10, -0x1c(%rbp)
jge 0x13054
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x13047
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movb %dl, 0x500(%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1300b
jmp 0x13049
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x12ffe
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb $0x0, 0x500(%rax,%rcx)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x1, -0x20(%rbp)
cmpl $0x10, -0x20(%rbp)
jg 0x1314c
movl -0x24(%rbp), %edx
subl -0x28(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl %edx, 0x64c(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl 0x500(%rax,%rcx), %eax
cmpl -0x20(%rbp), %eax
jne 0x1311a
jmp 0x130af
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl 0x500(%rax,%rcx), %eax
cmpl -0x20(%rbp), %eax
jne 0x130ee
movl -0x28(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x28(%rbp)
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movw %dx, 0x200(%rax,%rcx,2)
jmp 0x130af
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl -0x20(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jb 0x13118
leaq 0xd7c1(%rip), %rdi      # 0x208cc
callq 0x2680
movl %eax, -0x4(%rbp)
jmp 0x13215
jmp 0x1311a
movl -0x28(%rbp), %edx
movl $0x10, %ecx
subl -0x20(%rbp), %ecx
shll %cl, %edx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl %edx, 0x604(%rax,%rcx,4)
movl -0x28(%rbp), %eax
shll %eax
movl %eax, -0x28(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x13079
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl $0xffffffff, 0x604(%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0xff, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x2100
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1320e
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzbl 0x500(%rax,%rcx), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x9, -0x2c(%rbp)
jg 0x131fe
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl 0x200(%rax,%rcx,2), %eax
movl $0x9, %ecx
subl -0x2c(%rbp), %ecx
shll %cl, %eax
movl %eax, -0x30(%rbp)
movl $0x9, %ecx
subl -0x2c(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x131fc
movl -0x1c(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x131d4
jmp 0x131fe
jmp 0x13200
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13179
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop