// File: srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__decode_jpeg_image(stbi__jpeg*)
static int stbi__decode_jpeg_image(stbi__jpeg *j)
{
   int m;
   for (m = 0; m < 4; m++) {
      j->img_comp[m].raw_data = NULL;
      j->img_comp[m].raw_coeff = NULL;
   }
   j->restart_interval = 0;
   if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0;
   m = stbi__get_marker(j);
   while (!stbi__EOI(m)) {
      if (stbi__SOS(m)) {
         if (!stbi__process_scan_header(j)) return 0;
         if (!stbi__parse_entropy_coded_data(j)) return 0;
         if (j->marker == STBI__MARKER_none ) {
            // handle 0s at the end of image data from IP Kamera 9060
            while (!stbi__at_eof(j->s)) {
               int x = stbi__get8(j->s);
               if (x == 255) {
                  j->marker = stbi__get8(j->s);
                  break;
               } else if (x != 0) {
                  return stbi__err("junk before marker", "Corrupt JPEG");
               }
            }
            // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0
         }
      } else {
         if (!stbi__process_marker(j, m)) return 0;
      }
      m = stbi__get_marker(j);
   }
   if (j->progressive)
      stbi__jpeg_finish(j);
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jge 0x2dbce
movq -0x10(%rbp), %rax
addq $0x45a0, %rax           # imm = 0x45A0
movslq -0x14(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
addq $0x45a0, %rax           # imm = 0x45A0
movslq -0x14(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x40(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2db83
movq -0x10(%rbp), %rax
movl $0x0, 0x475c(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x2b2d0
cmpl $0x0, %eax
jne 0x2dbf8
movl $0x0, -0x4(%rbp)
jmp 0x2dd2c
movq -0x10(%rbp), %rdi
callq 0x2c0b0
movzbl %al, %eax
movl %eax, -0x14(%rbp)
cmpl $0xd9, -0x14(%rbp)
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2dc1c
jmp 0x2dd0f
cmpl $0xda, -0x14(%rbp)
jne 0x2dcdf
movq -0x10(%rbp), %rdi
callq 0x2e150
cmpl $0x0, %eax
jne 0x2dc43
movl $0x0, -0x4(%rbp)
jmp 0x2dd2c
movq -0x10(%rbp), %rdi
callq 0x2e480
cmpl $0x0, %eax
jne 0x2dc5d
movl $0x0, -0x4(%rbp)
jmp 0x2dd2c
movq -0x10(%rbp), %rax
movzbl 0x4728(%rax), %eax
cmpl $0xff, %eax
jne 0x2dcdd
jmp 0x2dc71
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2c540
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2dc8b
jmp 0x2dcdb
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x18(%rbp)
cmpl $0xff, -0x18(%rbp)
jne 0x2dcc0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2ce50
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x4728(%rax)
jmp 0x2dcdb
cmpl $0x0, -0x18(%rbp)
je 0x2dcd7
leaq 0x1a32e(%rip), %rdi     # 0x47ffb
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x2dd2c
jmp 0x2dcd9
jmp 0x2dc71
jmp 0x2dcdd
jmp 0x2dcfb
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2c140
cmpl $0x0, %eax
jne 0x2dcf9
movl $0x0, -0x4(%rbp)
jmp 0x2dd2c
jmp 0x2dcfb
movq -0x10(%rbp), %rdi
callq 0x2c0b0
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x2dc07
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4730(%rax)
je 0x2dd25
movq -0x10(%rbp), %rdi
callq 0x2f000
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)