// File: alan0201tw[P]RayTracer/include/stb_image.h
// 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;
               }
            }
            // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0
         }
      } else if (stbi__DNL(m)) {
         int Ld = stbi__get16be(j->s);
         stbi__uint32 NL = stbi__get16be(j->s);
         if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG");
         if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG");
      } 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 0x6740e
movq -0x10(%rbp), %rax
addq $0x46a0, %rax           # imm = 0x46A0
movslq -0x14(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
addq $0x46a0, %rax           # imm = 0x46A0
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 0x673c3
movq -0x10(%rbp), %rax
movl $0x0, 0x4868(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x5ea70
cmpl $0x0, %eax
jne 0x67438
movl $0x0, -0x4(%rbp)
jmp 0x675b5
movq -0x10(%rbp), %rdi
callq 0x64cf0
movzbl %al, %eax
movl %eax, -0x14(%rbp)
cmpl $0xd9, -0x14(%rbp)
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x6745c
jmp 0x67598
cmpl $0xda, -0x14(%rbp)
jne 0x67506
movq -0x10(%rbp), %rdi
callq 0x678f0
cmpl $0x0, %eax
jne 0x67483
movl $0x0, -0x4(%rbp)
jmp 0x675b5
movq -0x10(%rbp), %rdi
callq 0x67c20
cmpl $0x0, %eax
jne 0x6749d
movl $0x0, -0x4(%rbp)
jmp 0x675b5
movq -0x10(%rbp), %rax
movzbl 0x4828(%rax), %eax
cmpl $0xff, %eax
jne 0x67504
jmp 0x674b1
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x653d0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x674cb
jmp 0x67502
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x65d00
movzbl %al, %eax
movl %eax, -0x18(%rbp)
cmpl $0xff, -0x18(%rbp)
jne 0x67500
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x65d00
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x4828(%rax)
jmp 0x67502
jmp 0x674b1
jmp 0x67504
jmp 0x67584
cmpl $0xdc, -0x14(%rbp)
jne 0x67566
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x65e40
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x65e40
movl %eax, -0x20(%rbp)
cmpl $0x4, -0x1c(%rbp)
je 0x67544
leaq 0x19bde(%rip), %rdi     # 0x81118
callq 0x56040
movl %eax, -0x4(%rbp)
jmp 0x675b5
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
je 0x67564
leaq 0x19bca(%rip), %rdi     # 0x81124
callq 0x56040
movl %eax, -0x4(%rbp)
jmp 0x675b5
jmp 0x67582
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x64d80
cmpl $0x0, %eax
jne 0x67580
movl $0x0, -0x4(%rbp)
jmp 0x675b5
jmp 0x67582
jmp 0x67584
movq -0x10(%rbp), %rdi
callq 0x64cf0
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x67447
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4830(%rax)
je 0x675ae
movq -0x10(%rbp), %rdi
callq 0x687a0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop