// File: /workspace/github_cpp_makefile_star2_O3/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 0x1e517
leaq 0xe3b9(%rip), %r13      # 0x2c257
cmpl $0xb, %eax
jb 0x1e216
movl %eax, %r15d
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jae 0x1dec9
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
jmp 0x1df1c
cmpl $0x0, 0x30(%r14)
je 0x1df61
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r12
movl 0x34(%r14), %edx
movq %r12, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x1def7
movslq %eax, %rcx
addq %r12, %rcx
movb (%r12), %al
jmp 0x1df0a
movl $0x0, 0x30(%r14)
leaq 0x39(%r14), %rcx
movb $0x0, 0x38(%r14)
xorl %eax, %eax
movq %rcx, 0xc0(%r14)
leaq 0x39(%r14), %rcx
movq %rcx, 0xb8(%r14)
cmpb $0x8, %al
jne 0x1df61
movq %r14, %rdi
callq 0x1e517
movl %eax, 0x4(%r14)
testl %eax, %eax
je 0x1df6d
movq %r14, %rdi
callq 0x1e517
movl %eax, (%r14)
testl %eax, %eax
je 0x1df79
movq 0xb8(%r14), %rdx
movq 0xc0(%r14), %rax
cmpq %rax, %rdx
jae 0x1df85
leaq 0x1(%rdx), %rcx
movq %rcx, 0xb8(%r14)
movb (%rdx), %dl
jmp 0x1dfd7
leaq 0xe2fb(%rip), %r13      # 0x2c263
jmp 0x1e216
leaq 0xe2fa(%rip), %r13      # 0x2c26e
jmp 0x1e216
leaq 0xe2ff(%rip), %r13      # 0x2c27f
jmp 0x1e216
cmpl $0x0, 0x30(%r14)
je 0x1e20f
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r12
movl 0x34(%r14), %edx
movq %r12, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x1dfb2
cltq
addq %r12, %rax
movb (%r12), %dl
jmp 0x1dfc5
movl $0x0, 0x30(%r14)
leaq 0x39(%r14), %rax
movb $0x0, 0x38(%r14)
xorl %edx, %edx
movq %rax, 0xc0(%r14)
leaq 0x39(%r14), %rcx
movq %rcx, 0xb8(%r14)
movl %edx, %esi
andb $-0x3, %sil
cmpb $0x1, %sil
jne 0x1e20f
movzbl %dl, %edx
movl %edx, 0x8(%r14)
movl %edx, %esi
leaq 0x45e8(%rbx), %rdi
xorl %r8d, %r8d
movq %r8, -0x18(%rdi)
movq %r8, (%rdi)
addq $0x60, %rdi
decq %rsi
jne 0x1dffa
leal (%rdx,%rdx,2), %edx
addl $0x8, %edx
cmpl %edx, %r15d
jne 0x1e216
movl %ebp, 0x10(%rsp)
leaq 0x38(%r14), %rsi
leaq 0x39(%r14), %rdx
movq %rdx, 0x8(%rsp)
leaq 0x45a0(%rbx), %rdx
movq %rdx, 0x40(%rsp)
leaq 0x45ac(%rbx), %r15
xorl %ebp, %ebp
leaq 0xe266(%rip), %r13      # 0x2c2ac
movq %rbp, %r12
movslq 0x8(%r14), %rbp
cmpq %rbp, %r12
jge 0x1e232
cmpq %rax, %rcx
jae 0x1e06d
leaq 0x1(%rcx), %rdi
movq %rdi, 0xb8(%r14)
movb (%rcx), %dl
movq %rdi, %rcx
jmp 0x1e0c5
cmpl $0x0, 0x30(%r14)
je 0x1e099
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %rbp
callq *0x10(%r14)
testl %eax, %eax
je 0x1e09d
cltq
addq %rbp, %rax
movb (%rbp), %dl
movq %rbp, %rsi
movq 0x8(%rsp), %rcx
jmp 0x1e0b7
xorl %edx, %edx
jmp 0x1e0c5
movl $0x0, 0x30(%r14)
movb $0x0, 0x38(%r14)
xorl %edx, %edx
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movq %rbp, %rsi
movq %rax, 0xc0(%r14)
movq %rcx, 0xb8(%r14)
movzbl %dl, %edx
movl %edx, -0xc(%r15)
leaq 0x1(%r12), %rbp
cmpq %rdx, %rbp
setne %dil
cmpq %rdx, %r12
setne %dl
testb %dl, %dil
jne 0x1e26a
cmpq %rax, %rcx
jae 0x1e0fe
leaq 0x1(%rcx), %rdi
movq %rdi, 0xb8(%r14)
movb (%rcx), %dl
movq %rdi, %rcx
jmp 0x1e157
cmpl $0x0, 0x30(%r14)
je 0x1e27c
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %r12
callq *0x10(%r14)
testl %eax, %eax
je 0x1e12f
cltq
addq %r12, %rax
movb (%r12), %dl
movq %r12, %rsi
movq 0x8(%rsp), %rcx
jmp 0x1e149
movl $0x0, 0x30(%r14)
movb $0x0, 0x38(%r14)
xorl %edx, %edx
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movq %r12, %rsi
movq %rax, 0xc0(%r14)
movq %rcx, 0xb8(%r14)
movzbl %dl, %edx
movl %edx, %edi
shrl $0x4, %edi
movl %edi, -0x8(%r15)
leal -0x50(%rdx), %edi
cmpb $-0x40, %dil
jb 0x1e216
andl $0xf, %edx
movl %edx, -0x4(%r15)
addl $-0x5, %edx
cmpl $-0x4, %edx
jb 0x1e273
cmpq %rax, %rcx
jae 0x1e19a
leaq 0x1(%rcx), %rdi
movq %rdi, 0xb8(%r14)
movb (%rcx), %dl
movq %rdi, %rcx
jmp 0x1e1f3
cmpl $0x0, 0x30(%r14)
je 0x1e1c7
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %r12
callq *0x10(%r14)
testl %eax, %eax
je 0x1e1cb
cltq
addq %r12, %rax
movb (%r12), %dl
movq %r12, %rsi
movq 0x8(%rsp), %rcx
jmp 0x1e1e5
xorl %edx, %edx
jmp 0x1e1f3
movl $0x0, 0x30(%r14)
movb $0x0, 0x38(%r14)
xorl %edx, %edx
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movq %r12, %rsi
movq %rax, 0xc0(%r14)
movq %rcx, 0xb8(%r14)
movzbl %dl, %edx
movl %edx, (%r15)
addq $0x60, %r15
cmpb $0x3, %dl
jbe 0x1e046
leaq 0xe0ab(%rip), %r13      # 0x2c2b8
jmp 0x1e216
leaq 0xe071(%rip), %r13      # 0x2c287
movq %r13, 0x19173(%rip)     # 0x37390
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 0x1e220
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 0x1e286
leaq 0xe057(%rip), %r13      # 0x2c2bf
jmp 0x1e216
leaq 0xe02a(%rip), %r13      # 0x2c29b
jmp 0x1e216
leaq 0xe038(%rip), %r13      # 0x2c2b2
jmp 0x1e216
movl $0x0, -0x8(%r15)
jmp 0x1e216
movl $0x1, %r8d
movl $0x1, %edi
testl %ebp, %ebp
jle 0x1e2d0
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 0x1e2ad
leal (,%r8,8), %ecx
leal (,%rdi,8), %esi
movq 0x10(%rsp), %rax
leal (%rax,%r8,8), %eax
decl %eax
xorl %edx, %edx
divl %ecx
movl %eax, %r9d
movq 0x38(%rsp), %rax
leal (%rax,%rdi,8), %eax
decl %eax
xorl %edx, %edx
divl %esi
movl %r8d, 0x4588(%rbx)
movl %edi, 0x458c(%rbx)
movl %ecx, 0x4598(%rbx)
movl %esi, 0x459c(%rbx)
movl %r9d, 0x24(%rsp)
movl %r9d, 0x4590(%rbx)
movl %eax, 0x20(%rsp)
movl %eax, 0x4594(%rbx)
testl %ebp, %ebp
jle 0x1e220
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 0x43f0
movq %rax, -0x24(%r14)
testq %rax, %rax
je 0x1e454
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, -0x2c(%r14)
movq $0x0, -0x14(%r14)
cmpl $0x0, 0x4730(%rbx)
je 0x1e41c
movl %r13d, -0x4(%r14)
movl %r12d, (%r14)
imull %r12d, %r13d
shll $0x6, %r13d
movslq %r13d, %rax
leaq 0xf(,%rax,2), %rdi
callq 0x43f0
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
jmp 0x1e420
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %r8
movq %rcx, -0xc(%r14)
movq %rax, -0x1c(%r14)
addq $0x60, %r14
movq 0x8(%rsp), %rcx
leaq (%rcx,%rbp), %rax
incq %rax
incq %rcx
cmpq $0x1, %rax
jne 0x1e35e
jmp 0x1e220
leaq 0xde6e(%rip), %r13      # 0x2c2c9
movq 0x8(%rsp), %r15
cmpq $0x1, %r15
je 0x1e216
movq 0x40(%rsp), %r14
leal -0x2(%r15), %eax
leaq (%rax,%rax,2), %rbx
shlq $0x5, %rbx
movq 0x38(%r14,%rbx), %rdi
callq 0x4380
movq $0x0, 0x38(%r14,%rbx)
decq %r15
cmpq $0x1, %r15
jg 0x1e46f
jmp 0x1e216