// File: alan0201tw[P]RayTracer/include/stb_image.h
// Function: stbi__compute_huffman_codes(stbi__zbuf*)
static int stbi__compute_huffman_codes(stbi__zbuf *a)
{
   static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
   stbi__zhuffman z_codelength;
   stbi_uc lencodes[286+32+137];//padding for maximum single op
   stbi_uc codelength_sizes[19];
   int i,n;

   int hlit  = stbi__zreceive(a,5) + 257;
   int hdist = stbi__zreceive(a,5) + 1;
   int hclen = stbi__zreceive(a,4) + 4;
   int ntot  = hlit + hdist;

   memset(codelength_sizes, 0, sizeof(codelength_sizes));
   for (i=0; i < hclen; ++i) {
      int s = stbi__zreceive(a,3);
      codelength_sizes[length_dezigzag[i]] = (stbi_uc) s;
   }
   if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0;

   n = 0;
   while (n < ntot) {
      int c = stbi__zhuffman_decode(a, &z_codelength);
      if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG");
      if (c < 16)
         lencodes[n++] = (stbi_uc) c;
      else {
         stbi_uc fill = 0;
         if (c == 16) {
            c = stbi__zreceive(a,2)+3;
            if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG");
            fill = lencodes[n-1];
         } else if (c == 17)
            c = stbi__zreceive(a,3)+3;
         else {
            STBI_ASSERT(c == 18);
            c = stbi__zreceive(a,7)+11;
         }
         if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG");
         memset(lencodes+n, fill, c);
         n += c;
      }
   }
   if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG");
   if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0;
   if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0;
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa10, %rsp            # imm = 0xA10
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x5, %esi
callq 0x70270
addl $0x101, %eax            # imm = 0x101
movl %eax, -0x9ec(%rbp)
movq -0x10(%rbp), %rdi
movl $0x5, %esi
callq 0x70270
addl $0x1, %eax
movl %eax, -0x9f0(%rbp)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x70270
addl $0x4, %eax
movl %eax, -0x9f4(%rbp)
movl -0x9ec(%rbp), %eax
addl -0x9f0(%rbp), %eax
movl %eax, -0x9f8(%rbp)
leaq -0x9e0(%rbp), %rdi
xorl %esi, %esi
movl $0x13, %edx
callq 0x7290
movl $0x0, -0x9e4(%rbp)
movl -0x9e4(%rbp), %eax
cmpl -0x9f4(%rbp), %eax
jge 0x70899
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x70270
movl %eax, -0x9fc(%rbp)
movl -0x9fc(%rbp), %eax
movb %al, %cl
movslq -0x9e4(%rbp), %rdx
leaq 0xeec3(%rip), %rax      # 0x7f740
movzbl (%rax,%rdx), %eax
movb %cl, -0x9e0(%rbp,%rax)
movl -0x9e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9e4(%rbp)
jmp 0x70845
leaq -0x9e0(%rbp), %rsi
leaq -0x7f4(%rbp), %rdi
movl $0x13, %edx
callq 0x704b0
cmpl $0x0, %eax
jne 0x708c2
movl $0x0, -0x4(%rbp)
jmp 0x70af6
movl $0x0, -0x9e8(%rbp)
movl -0x9e8(%rbp), %eax
cmpl -0x9f8(%rbp), %eax
jge 0x70a73
movq -0x10(%rbp), %rdi
leaq -0x7f4(%rbp), %rsi
callq 0x71030
movl %eax, -0xa00(%rbp)
cmpl $0x0, -0xa00(%rbp)
jl 0x70906
cmpl $0x13, -0xa00(%rbp)
jl 0x7091a
leaq 0x110fc(%rip), %rdi     # 0x81a09
callq 0x56040
movl %eax, -0x4(%rbp)
jmp 0x70af6
cmpl $0x10, -0xa00(%rbp)
jge 0x7094a
movl -0xa00(%rbp), %eax
movb %al, %cl
movl -0x9e8(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x9e8(%rbp)
cltq
movb %cl, -0x9c0(%rbp,%rax)
jmp 0x70a6e
movb $0x0, -0xa01(%rbp)
cmpl $0x10, -0xa00(%rbp)
jne 0x709a8
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x70270
addl $0x3, %eax
movl %eax, -0xa00(%rbp)
cmpl $0x0, -0x9e8(%rbp)
jne 0x7098e
leaq 0x11088(%rip), %rdi     # 0x81a09
callq 0x56040
movl %eax, -0x4(%rbp)
jmp 0x70af6
movl -0x9e8(%rbp), %eax
subl $0x1, %eax
cltq
movb -0x9c0(%rbp,%rax), %al
movb %al, -0xa01(%rbp)
jmp 0x70a0d
cmpl $0x11, -0xa00(%rbp)
jne 0x709ca
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x70270
addl $0x3, %eax
movl %eax, -0xa00(%rbp)
jmp 0x70a0b
cmpl $0x12, -0xa00(%rbp)
jne 0x709d5
jmp 0x709f4
leaq 0x11068(%rip), %rdi     # 0x81a44
leaq 0x105b1(%rip), %rsi     # 0x80f94
movl $0x1019, %edx           # imm = 0x1019
leaq 0x1105d(%rip), %rcx     # 0x81a4c
callq 0x7310
movq -0x10(%rbp), %rdi
movl $0x7, %esi
callq 0x70270
addl $0xb, %eax
movl %eax, -0xa00(%rbp)
jmp 0x70a0d
movl -0x9f8(%rbp), %eax
subl -0x9e8(%rbp), %eax
cmpl -0xa00(%rbp), %eax
jge 0x70a35
leaq 0x10fe1(%rip), %rdi     # 0x81a09
callq 0x56040
movl %eax, -0x4(%rbp)
jmp 0x70af6
leaq -0x9c0(%rbp), %rdi
movslq -0x9e8(%rbp), %rax
addq %rax, %rdi
movzbl -0xa01(%rbp), %eax
movslq -0xa00(%rbp), %rdx
movzbl %al, %esi
callq 0x7290
movl -0xa00(%rbp), %eax
addl -0x9e8(%rbp), %eax
movl %eax, -0x9e8(%rbp)
jmp 0x708cc
movl -0x9e8(%rbp), %eax
cmpl -0x9f8(%rbp), %eax
je 0x70a92
leaq 0x10f81(%rip), %rdi     # 0x81a09
callq 0x56040
movl %eax, -0x4(%rbp)
jmp 0x70af6
movq -0x10(%rbp), %rdi
addq $0x34, %rdi
leaq -0x9c0(%rbp), %rsi
movl -0x9ec(%rbp), %edx
callq 0x704b0
cmpl $0x0, %eax
jne 0x70aba
movl $0x0, -0x4(%rbp)
jmp 0x70af6
movq -0x10(%rbp), %rdi
addq $0x818, %rdi            # imm = 0x818
leaq -0x9c0(%rbp), %rsi
movslq -0x9ec(%rbp), %rax
addq %rax, %rsi
movl -0x9f0(%rbp), %edx
callq 0x704b0
cmpl $0x0, %eax
jne 0x70aef
movl $0x0, -0x4(%rbp)
jmp 0x70af6
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa10, %rsp            # imm = 0xA10
popq %rbp
retq
nopw %cs:(%rax,%rax)