// File: /workspace/github_cpp_makefile_star2_O1/srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__process_frame_header(stbi__jpeg*, int)
static int stbi__process_frame_header(stbi__jpeg *z, int scan)
{
   stbi__context *s = z->s;
   int Lf,p,i,q, h_max=1,v_max=1,c;
   Lf = stbi__get16be(s);         if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG
   p  = stbi__get8(s);            if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline
   s->img_y = stbi__get16be(s);   if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG
   s->img_x = stbi__get16be(s);   if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires
   c = stbi__get8(s);
   if (c != 3 && c != 1) return stbi__err("bad component count","Corrupt JPEG");    // JFIF requires
   s->img_n = c;
   for (i=0; i < c; ++i) {
      z->img_comp[i].data = NULL;
      z->img_comp[i].linebuf = NULL;
   }

   if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG");

   for (i=0; i < s->img_n; ++i) {
      z->img_comp[i].id = stbi__get8(s);
      if (z->img_comp[i].id != i+1)   // JFIF requires
         if (z->img_comp[i].id != i)  // some version of jpegtran outputs non-JFIF-compliant files!
            return stbi__err("bad component ID","Corrupt JPEG");
      q = stbi__get8(s);
      z->img_comp[i].h = (q >> 4);  if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG");
      z->img_comp[i].v = q & 15;    if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG");
      z->img_comp[i].tq = stbi__get8(s);  if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG");
   }

   if (scan != STBI__SCAN_load) return 1;

   if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode");

   for (i=0; i < s->img_n; ++i) {
      if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h;
      if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
   }

   // compute interleaved mcu info
   z->img_h_max = h_max;
   z->img_v_max = v_max;
   z->img_mcu_w = h_max * 8;
   z->img_mcu_h = v_max * 8;
   z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w;
   z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h;

   for (i=0; i < s->img_n; ++i) {
      // number of effective pixels (e.g. for non-interleaved MCU)
      z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max;
      z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max;
      // to simplify generation, we'll allocate enough memory to decode
      // the bogus oversized data from using interleaved MCUs and their
      // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't
      // discard the extra data until colorspace conversion
      z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8;
      z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8;
      z->img_comp[i].raw_data = stbi__malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15);

      if (z->img_comp[i].raw_data == NULL) {
         for(--i; i >= 0; --i) {
            STBI_FREE(z->img_comp[i].raw_data);
            z->img_comp[i].raw_data = NULL;
         }
         return stbi__err("outofmem", "Out of memory");
      }
      // align blocks for idct using mmx/sse
      z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15);
      z->img_comp[i].linebuf = NULL;
      if (z->progressive) {
         z->img_comp[i].coeff_w = (z->img_comp[i].w2 + 7) >> 3;
         z->img_comp[i].coeff_h = (z->img_comp[i].h2 + 7) >> 3;
         z->img_comp[i].raw_coeff = STBI_MALLOC(z->img_comp[i].coeff_w * z->img_comp[i].coeff_h * 64 * sizeof(short) + 15);
         z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15);
      } else {
         z->img_comp[i].coeff = 0;
         z->img_comp[i].raw_coeff = 0;
      }
   }

   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %r14
movq %r14, %rdi
callq 0x1e01c
leaq 0xf835(%rip), %r13      # 0x2d197
cmpl $0xb, %eax
jb 0x1dd07
movl %eax, %r15d
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x1d9db
cmpl $0x0, 0x30(%r14)
je 0x1da51
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r12
movl 0x34(%r14), %edx
movq %r12, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x1d9b5
movq %r12, 0xb8(%r14)
cltq
addq %r12, %rax
movq %rax, 0xc0(%r14)
jmp 0x1d9d4
movl $0x0, 0x30(%r14)
movq %r12, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
cmpb $0x8, (%rax)
jne 0x1da51
movq %r14, %rdi
callq 0x1e01c
movl %eax, 0x4(%r14)
testl %eax, %eax
je 0x1da5d
movq %r14, %rdi
callq 0x1e01c
movl %eax, (%r14)
testl %eax, %eax
je 0x1da69
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x1da9f
cmpl $0x0, 0x30(%r14)
je 0x1da75
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r12
movl 0x34(%r14), %edx
movq %r12, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x1da79
movq %r12, 0xb8(%r14)
cltq
addq %r12, %rax
movq %rax, 0xc0(%r14)
jmp 0x1da98
leaq 0xf74b(%rip), %r13      # 0x2d1a3
jmp 0x1dd07
leaq 0xf74a(%rip), %r13      # 0x2d1ae
jmp 0x1dd07
leaq 0xf74f(%rip), %r13      # 0x2d1bf
jmp 0x1dd07
xorl %eax, %eax
jmp 0x1daac
movl $0x0, 0x30(%r14)
movq %r12, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movl %eax, %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
jne 0x1dd00
movzbl %al, %eax
movl %eax, 0x8(%r14)
testl %eax, %eax
je 0x1daeb
movl %eax, %ecx
shll $0x5, %ecx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movq %rdx, 0x45d0(%rbx,%rsi)
movq %rdx, 0x45e8(%rbx,%rsi)
addq $0x60, %rsi
cmpq %rsi, %rcx
jne 0x1dad2
leal (%rax,%rax,2), %eax
addl $0x8, %eax
cmpl %eax, %r15d
jne 0x1dd07
movl %ebp, 0x10(%rsp)
leaq 0x38(%r14), %rsi
leaq 0x39(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x45ac(%rbx), %r15
xorl %r12d, %r12d
leaq 0xf6bf(%rip), %r13      # 0x2d1db
movslq 0x8(%r14), %rbp
cmpq %rbp, %r12
jge 0x1dd23
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x1db96
cmpl $0x0, 0x30(%r14)
je 0x1db68
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %rbp
callq *0x10(%r14)
testl %eax, %eax
je 0x1db6c
movq %rbp, 0xb8(%r14)
cltq
addq %rbp, %rax
movq %rax, 0xc0(%r14)
jmp 0x1db8c
xorl %eax, %eax
jmp 0x1dba3
movl $0x0, 0x30(%r14)
movq %rbp, 0xb8(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %rbp, %rsi
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movzbl %al, %eax
movl %eax, -0xc(%r15)
leaq 0x1(%r12), %rbp
cmpq %rax, %rbp
setne %cl
cmpq %rax, %r12
setne %al
testb %al, %cl
jne 0x1dd07
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x1dc30
cmpl $0x0, 0x30(%r14)
je 0x1dc02
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %r12
callq *0x10(%r14)
testl %eax, %eax
je 0x1dc06
movq %r12, 0xb8(%r14)
cltq
addq %r12, %rax
movq %rax, 0xc0(%r14)
jmp 0x1dc26
xorl %eax, %eax
jmp 0x1dc3d
movl $0x0, 0x30(%r14)
movq %r12, 0xb8(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %r12, %rsi
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movzbl %al, %eax
movl %eax, %ecx
shrl $0x4, %ecx
movl %ecx, -0x8(%r15)
leal -0x50(%rax), %ecx
cmpb $-0x40, %cl
jb 0x1dd5b
andl $0xf, %eax
movl %eax, -0x4(%r15)
addl $-0x5, %eax
cmpl $-0x4, %eax
jb 0x1dd64
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x1dcd5
cmpl $0x0, 0x30(%r14)
je 0x1dca7
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %r12
callq *0x10(%r14)
testl %eax, %eax
je 0x1dcab
movq %r12, 0xb8(%r14)
cltq
addq %r12, %rax
movq %rax, 0xc0(%r14)
jmp 0x1dccb
xorl %eax, %eax
jmp 0x1dce2
movl $0x0, 0x30(%r14)
movq %r12, 0xb8(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %r12, %rsi
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movzbl %al, %eax
movl %eax, (%r15)
addq $0x60, %r15
movq %rbp, %r12
cmpb $0x3, %al
jbe 0x1db1c
leaq 0xf4fa(%rip), %r13      # 0x2d1f8
jmp 0x1dd07
leaq 0xf4c0(%rip), %r13      # 0x2d1c7
movq %r13, 0x1a6a2(%rip)     # 0x383b0
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r15d
cmpl $0x0, 0x10(%rsp)
jne 0x1dd11
movl (%r14), %ecx
movl 0x4(%r14), %esi
movl $0x40000000, %eax       # imm = 0x40000000
xorl %edx, %edx
movq %rcx, 0x10(%rsp)
divl %ecx
xorl %edx, %edx
divl %ebp
movq %rsi, 0x38(%rsp)
cmpl %esi, %eax
jae 0x1dd6d
leaq 0xf4a6(%rip), %r13      # 0x2d1ff
jmp 0x1dd07
leaq 0xf48a(%rip), %r13      # 0x2d1ec
jmp 0x1dd07
leaq 0xf487(%rip), %r13      # 0x2d1f2
jmp 0x1dd07
movl $0x1, %r8d
movl $0x1, %edi
testl %ebp, %ebp
jle 0x1ddb7
movq %rbp, %rax
shlq $0x5, %rax
leaq (%rax,%rax,2), %rax
movl $0x1, %edi
xorl %ecx, %ecx
movl $0x1, %r8d
movl 0x45a4(%rbx,%rcx), %edx
movl 0x45a8(%rbx,%rcx), %esi
cmpl %r8d, %edx
cmovgl %edx, %r8d
cmpl %edi, %esi
cmovgl %esi, %edi
addq $0x60, %rcx
cmpq %rcx, %rax
jne 0x1dd94
movl %r8d, 0x4588(%rbx)
movl %edi, 0x458c(%rbx)
leal (,%r8,8), %ecx
movl %ecx, 0x4598(%rbx)
leal (,%rdi,8), %esi
movl %esi, 0x459c(%rbx)
movq 0x10(%rsp), %rax
leal (%rax,%r8,8), %eax
decl %eax
xorl %edx, %edx
divl %ecx
movl %eax, 0x24(%rsp)
movl %eax, 0x4590(%rbx)
movq 0x38(%rsp), %rax
leal (%rax,%rdi,8), %eax
decl %eax
xorl %edx, %edx
divl %esi
movl %eax, 0x20(%rsp)
movl %eax, 0x4594(%rbx)
testl %ebp, %ebp
jle 0x1dd11
leaq 0x45a0(%rbx), %rax
movq %rax, 0x40(%rsp)
leal -0x1(%r8), %eax
movl %eax, 0x1c(%rsp)
leal -0x1(%rdi), %eax
movl %eax, 0x18(%rsp)
leaq 0x45fc(%rbx), %r14
negq %rbp
movl $0x1, %ecx
movq %rdi, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rcx, 0x8(%rsp)
movl -0x58(%r14), %r13d
movl -0x54(%r14), %r12d
movl %r13d, %eax
imull 0x10(%rsp), %eax
addl 0x1c(%rsp), %eax
xorl %edx, %edx
divl %r8d
movl %eax, -0x40(%r14)
movl %r12d, %eax
imull 0x38(%rsp), %eax
addl 0x18(%rsp), %eax
xorl %edx, %edx
divl %edi
movl %eax, -0x3c(%r14)
imull 0x24(%rsp), %r13d
leal (,%r13,8), %eax
movl %eax, -0x38(%r14)
imull 0x20(%rsp), %r12d
leal (,%r12,8), %ecx
movl %ecx, -0x34(%r14)
imull %eax, %ecx
orl $0xf, %ecx
movslq %ecx, %rdi
callq 0x4400
movq %rax, -0x24(%r14)
testq %rax, %rax
je 0x1df50
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, -0x2c(%r14)
movq $0x0, -0x14(%r14)
cmpl $0x0, 0x4730(%rbx)
je 0x1df10
movl %r13d, -0x4(%r14)
movl %r12d, (%r14)
imull %r12d, %r13d
shll $0x6, %r13d
movslq %r13d, %rax
leaq 0xf(,%rax,2), %rdi
callq 0x4400
movq %rax, -0x1c(%r14)
addq $0xf, %rax
andq $-0x10, %rax
movl $0x50, %ecx
jmp 0x1df1f
movq $0x0, -0xc(%r14)
movl $0x40, %ecx
xorl %eax, %eax
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %r8
movq %rax, -0x5c(%r14,%rcx)
addq $0x60, %r14
movq 0x8(%rsp), %rcx
leaq (%rcx,%rbp), %rax
incq %rax
incq %rcx
cmpq $0x1, %rax
jne 0x1de4c
jmp 0x1dd11
leaq 0xf2b2(%rip), %r13      # 0x2d209
movq 0x8(%rsp), %r15
cmpq $0x1, %r15
je 0x1dd07
movq 0x40(%rsp), %r14
leal -0x2(%r15), %eax
leaq (%rax,%rax,2), %rbx
shlq $0x5, %rbx
movq 0x38(%r14,%rbx), %rdi
callq 0x4390
movq $0x0, 0x38(%r14,%rbx)
decq %r15
cmpq $0x1, %r15
jg 0x1df6b
jmp 0x1dd07