// File: /workspace/github_c_makefile_star2_O1/archer1357[P]Offline-Raytracer/stb_image.c
// Function: stbi__process_frame_header
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 stbi__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 stbi__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 != 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) {
            free(z->img_comp[i].raw_data);
            z->img_comp[i].data = NULL;
         }
         return stbi__err("outofmem", "Out of memory");
      }
      // align blocks for installable-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;
   }

   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r13d
movq %rdi, %rbx
movq (%rdi), %r14
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %ebp
shll $0x8, %ebp
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %r12d
orl %ebp, %r12d
leaq 0xc84c7(%rip), %r15     # 0x4d77f1
cmpl $0xb, %r12d
jb 0x40f4a3
movq %r14, %rdi
callq 0x40f6b6
cmpb $0x8, %al
jne 0x40f481
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %ebp
shll $0x8, %ebp
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %eax
orl %ebp, %eax
movl %eax, 0x4(%r14)
je 0x40f48a
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %ebp
shll $0x8, %ebp
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %eax
orl %ebp, %eax
movl %eax, (%r14)
je 0x40f493
movq %r14, %rdi
callq 0x40f6b6
movl %eax, %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
jne 0x40f49c
movzbl %al, %eax
movl %eax, 0x8(%r14)
testl %eax, %eax
je 0x40f3d6
leal (,%rax,8), %ecx
leaq (%rcx,%rcx,8), %rcx
xorl %edx, %edx
xorl %esi, %esi
movq %rdx, 0x35d0(%rbx,%rsi)
movq %rdx, 0x35e0(%rbx,%rsi)
addq $0x48, %rsi
cmpq %rsi, %rcx
jne 0x40f3bd
leal (%rax,%rax,2), %eax
addl $0x8, %eax
cmpl %eax, %r12d
jne 0x40f4a3
movl %r13d, (%rsp)
leaq 0x35ac(%rbx), %r13
xorl %r12d, %r12d
leaq 0xc8441(%rip), %r15     # 0x4d783b
movslq 0x8(%r14), %rbp
cmpq %rbp, %r12
jge 0x40f4bf
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %eax
movl %eax, -0xc(%r13)
leaq 0x1(%r12), %rbp
cmpq %rax, %rbp
setne %cl
cmpq %rax, %r12
setne %al
testb %al, %cl
jne 0x40f4a3
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %eax
movl %eax, %ecx
shrl $0x4, %ecx
movl %ecx, -0x8(%r13)
leal -0x50(%rax), %ecx
cmpb $-0x40, %cl
jb 0x40f4f5
andl $0xf, %eax
movl %eax, -0x4(%r13)
addl $-0x5, %eax
cmpl $-0x4, %eax
jb 0x40f4fe
movq %r14, %rdi
callq 0x40f6b6
movzbl %al, %eax
movl %eax, (%r13)
addq $0x48, %r13
movq %rbp, %r12
cmpb $0x3, %al
jbe 0x40f3fa
leaq 0xc83d9(%rip), %r15     # 0x4d7858
jmp 0x40f4a3
leaq 0xc837b(%rip), %r15     # 0x4d7803
jmp 0x40f4a3
leaq 0xc837d(%rip), %r15     # 0x4d780e
jmp 0x40f4a3
leaq 0xc8385(%rip), %r15     # 0x4d781f
jmp 0x40f4a3
leaq 0xc8384(%rip), %r15     # 0x4d7827
movq %r15, 0x10c096(%rip)    # 0x51b540
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r15d
cmpl $0x0, (%rsp)
jne 0x40f4ad
movl (%r14), %ecx
movl 0x4(%r14), %esi
movl $0x40000000, %eax       # imm = 0x40000000
xorl %edx, %edx
movq %rcx, (%rsp)
divl %ecx
xorl %edx, %edx
divl %ebp
movq %rsi, 0x18(%rsp)
cmpl %esi, %eax
jae 0x40f507
leaq 0xd22ac(%rip), %r15     # 0x4e179f
jmp 0x40f4a3
leaq 0xc8350(%rip), %r15     # 0x4d784c
jmp 0x40f4a3
leaq 0xc834d(%rip), %r15     # 0x4d7852
jmp 0x40f4a3
movl $0x1, %r12d
movl $0x1, %r13d
testl %ebp, %ebp
jle 0x40f556
leaq (,%rbp,8), %rax
leaq (%rax,%rax,8), %rax
movl $0x1, %r13d
xorl %ecx, %ecx
movl $0x1, %r12d
movl 0x35a4(%rbx,%rcx), %edx
movl 0x35a8(%rbx,%rcx), %esi
cmpl %r12d, %edx
cmovgl %edx, %r12d
cmpl %r13d, %esi
cmovgl %esi, %r13d
addq $0x48, %rcx
cmpq %rcx, %rax
jne 0x40f531
movl %r12d, 0x3588(%rbx)
movl %r13d, 0x358c(%rbx)
leal (,%r12,8), %ecx
movl %ecx, 0x3598(%rbx)
leal (,%r13,8), %esi
movl %esi, 0x359c(%rbx)
movq (%rsp), %rax
leal (%rax,%r12,8), %eax
decl %eax
xorl %edx, %edx
divl %ecx
movl %eax, %edi
movl %eax, 0x3590(%rbx)
movq 0x18(%rsp), %rax
leal (%rax,%r13,8), %eax
decl %eax
xorl %edx, %edx
divl %esi
movl %eax, 0x3594(%rbx)
testl %ebp, %ebp
jle 0x40f4ad
movl %eax, %r8d
leaq 0x35a0(%rbx), %rax
movq %rax, 0x20(%rsp)
leal -0x1(%r12), %eax
movl %eax, 0x14(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0x10(%rsp)
shll $0x3, %edi
shll $0x3, %r8d
addq $0x35e0, %rbx           # imm = 0x35E0
negq %rbp
movl $0x1, %r14d
movl %edi, 0xc(%rsp)
movl %r8d, 0x8(%rsp)
movl -0x3c(%rbx), %esi
movl -0x38(%rbx), %ecx
movl %esi, %eax
imull (%rsp), %eax
addl 0x14(%rsp), %eax
xorl %edx, %edx
divl %r12d
movl %eax, -0x24(%rbx)
movl %ecx, %eax
imull 0x18(%rsp), %eax
addl 0x10(%rsp), %eax
xorl %edx, %edx
divl %r13d
movl %eax, -0x20(%rbx)
imull %edi, %esi
movl %esi, -0x1c(%rbx)
imull %r8d, %ecx
movl %ecx, -0x18(%rbx)
imull %esi, %ecx
orl $0xf, %ecx
movslq %ecx, %rdi
callq 0x4449d0
movq %rax, -0x8(%rbx)
testq %rax, %rax
je 0x40f677
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, -0x10(%rbx)
movq $0x0, (%rbx)
addq $0x48, %rbx
leaq (%r14,%rbp), %rax
incq %rax
incq %r14
cmpq $0x1, %rax
movl 0xc(%rsp), %edi
movl 0x8(%rsp), %r8d
jne 0x40f5f3
jmp 0x40f4ad
leaq 0xc81e1(%rip), %r15     # 0x4d785f
cmpq $0x1, %r14
je 0x40f4a3
movq 0x20(%rsp), %r12
leal -0x2(%r14), %eax
leaq (%rax,%rax,8), %rbx
movq 0x38(%r12,%rbx,8), %rdi
callq 0x444d10
movq $0x0, 0x30(%r12,%rbx,8)
decq %r14
cmpq $0x1, %r14
jg 0x40f68d
jmp 0x40f4a3