// File: srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__parse_huffman_block(stbi__zbuf*)
static int stbi__parse_huffman_block(stbi__zbuf *a)
{
   char *zout = a->zout;
   for(;;) {
      int z = stbi__zhuffman_decode(a, &a->z_length);
      if (z < 256) {
         if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes
         if (zout >= a->zout_end) {
            if (!stbi__zexpand(a, zout, 1)) return 0;
            zout = a->zout;
         }
         *zout++ = (char) z;
      } else {
         stbi_uc *p;
         int len,dist;
         if (z == 256) {
            a->zout = zout;
            return 1;
         }
         z -= 257;
         len = stbi__zlength_base[z];
         if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]);
         z = stbi__zhuffman_decode(a, &a->z_distance);
         if (z < 0) return stbi__err("bad huffman code","Corrupt PNG");
         dist = stbi__zdist_base[z];
         if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]);
         if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG");
         if (zout + len > a->zout_end) {
            if (!stbi__zexpand(a, zout, len)) return 0;
            zout = a->zout;
         }
         p = (stbi_uc *) (zout - dist);
         if (dist == 1) { // run of one byte; common in images.
            stbi_uc v = *p;
            if (len) { do *zout++ = v; while (--len); }
         } else {
            if (len) { do *zout++ = *p++; while (--len); }
         }
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x34, %rsi
callq 0x36a40
movl %eax, -0x1c(%rbp)
cmpl $0x100, -0x1c(%rbp)     # imm = 0x100
jge 0x365c7
cmpl $0x0, -0x1c(%rbp)
jge 0x3656f
leaq 0x11af0(%rip), %rdi     # 0x48052
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x367a4
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x365ac
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x36880
cmpl $0x0, %eax
jne 0x365a0
movl $0x0, -0x4(%rbp)
jmp 0x367a4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movb %cl, (%rax)
jmp 0x3679f
cmpl $0x100, -0x1c(%rbp)     # imm = 0x100
jne 0x365e8
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x367a4
movl -0x1c(%rbp), %eax
subl $0x101, %eax            # imm = 0x101
movl %eax, -0x1c(%rbp)
movslq -0x1c(%rbp), %rcx
leaq 0x25f42(%rip), %rax     # 0x5c540
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movslq -0x1c(%rbp), %rcx
leaq 0x25fb1(%rip), %rax     # 0x5c5c0
cmpl $0x0, (%rax,%rcx,4)
je 0x36632
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x25f9c(%rip), %rax     # 0x5c5c0
movl (%rax,%rcx,4), %esi
callq 0x35bb0
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x818, %rsi            # imm = 0x818
callq 0x36a40
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x36663
leaq 0x119fc(%rip), %rdi     # 0x48052
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x367a4
movslq -0x1c(%rbp), %rcx
leaq 0x25fd2(%rip), %rax     # 0x5c640
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movslq -0x1c(%rbp), %rcx
leaq 0x26041(%rip), %rax     # 0x5c6c0
cmpl $0x0, (%rax,%rcx,4)
je 0x366a2
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x2602c(%rip), %rax     # 0x5c6c0
movl (%rax,%rcx,4), %esi
callq 0x35bb0
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
movslq -0x30(%rbp), %rcx
cmpq %rcx, %rax
jge 0x366ce
leaq 0x12185(%rip), %rdi     # 0x48846
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x367a4
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jbe 0x36710
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x36880
cmpl $0x0, %eax
jne 0x36704
movl $0x0, -0x4(%rbp)
jmp 0x367a4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movslq -0x30(%rbp), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x30(%rbp)
jne 0x36761
movq -0x28(%rbp), %rax
movb (%rax), %al
movb %al, -0x31(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x3675f
jmp 0x3673b
movb -0x31(%rbp), %cl
movq -0x18(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movb %cl, (%rax)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
jne 0x3673b
jmp 0x3675f
jmp 0x3679d
cmpl $0x0, -0x2c(%rbp)
je 0x3679b
jmp 0x36769
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb (%rax), %cl
movq -0x18(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movb %cl, (%rax)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
jne 0x36769
jmp 0x3679b
jmp 0x3679d
jmp 0x3679f
jmp 0x36538
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)