// File: /workspace/github_c_makefile_star2_O3/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 0x410442
movzbl %al, %ebp
shll $0x8, %ebp
movq %r14, %rdi
callq 0x410442
movzbl %al, %r12d
orl %ebp, %r12d
leaq 0xc889c(%rip), %r15     # 0x4d8961
cmpl $0xb, %r12d
jb 0x41023b
movq %r14, %rdi
callq 0x410442
cmpb $0x8, %al
jne 0x410219
movq %r14, %rdi
callq 0x410442
movzbl %al, %ebp
shll $0x8, %ebp
movq %r14, %rdi
callq 0x410442
movzbl %al, %eax
orl %ebp, %eax
movl %eax, 0x4(%r14)
je 0x410222
movq %r14, %rdi
callq 0x410442
movzbl %al, %ebp
shll $0x8, %ebp
movq %r14, %rdi
callq 0x410442
movzbl %al, %eax
orl %ebp, %eax
movl %eax, (%r14)
je 0x41022b
movq %r14, %rdi
callq 0x410442
movl %eax, %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
jne 0x410234
movzbl %al, %eax
movl %eax, 0x8(%r14)
movl %eax, %ecx
leaq 0x35e0(%rbx), %rdx
xorl %esi, %esi
movq %rsi, -0x10(%rdx)
movq %rsi, (%rdx)
addq $0x48, %rdx
decq %rcx
jne 0x410150
leal (%rax,%rax,2), %eax
addl $0x8, %eax
cmpl %eax, %r12d
jne 0x41023b
movl %r13d, (%rsp)
leaq 0x35a0(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x35ac(%rbx), %r12
xorl %r13d, %r13d
leaq 0xc881b(%rip), %r15     # 0x4d89ab
movslq 0x8(%r14), %rbp
cmpq %rbp, %r13
jge 0x410257
movq %r14, %rdi
callq 0x410442
movzbl %al, %eax
movl %eax, -0xc(%r12)
leaq 0x1(%r13), %rbp
cmpq %rax, %rbp
setne %cl
cmpq %rax, %r13
setne %al
testb %al, %cl
jne 0x41023b
movq %r14, %rdi
callq 0x410442
movzbl %al, %eax
movl %eax, %ecx
shrl $0x4, %ecx
movl %ecx, -0x8(%r12)
leal -0x50(%rax), %ecx
cmpb $-0x40, %cl
jb 0x41028d
andl $0xf, %eax
movl %eax, -0x4(%r12)
addl $-0x5, %eax
cmpl $-0x4, %eax
jb 0x410296
movq %r14, %rdi
callq 0x410442
movzbl %al, %eax
movl %eax, (%r12)
addq $0x48, %r12
movq %rbp, %r13
cmpb $0x3, %al
jbe 0x410190
leaq 0xc87b1(%rip), %r15     # 0x4d89c8
jmp 0x41023b
leaq 0xc8753(%rip), %r15     # 0x4d8973
jmp 0x41023b
leaq 0xc8755(%rip), %r15     # 0x4d897e
jmp 0x41023b
leaq 0xc875d(%rip), %r15     # 0x4d898f
jmp 0x41023b
leaq 0xc875c(%rip), %r15     # 0x4d8997
movq %r15, 0x10c2de(%rip)    # 0x51c520
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 0x410245
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 0x41029f
leaq 0xd26f4(%rip), %r15     # 0x4e297f
jmp 0x41023b
leaq 0xc8728(%rip), %r15     # 0x4d89bc
jmp 0x41023b
leaq 0xc8725(%rip), %r15     # 0x4d89c2
jmp 0x41023b
movl $0x1, %r12d
movl $0x1, %r13d
testl %ebp, %ebp
jle 0x4102ee
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 0x4102c9
leal (,%r12,8), %ecx
leal (,%r13,8), %esi
movq (%rsp), %rax
leal (%rax,%r12,8), %eax
decl %eax
xorl %edx, %edx
divl %ecx
movl %eax, %edi
movq 0x18(%rsp), %rax
leal (%rax,%r13,8), %eax
decl %eax
xorl %edx, %edx
divl %esi
movl %r12d, 0x3588(%rbx)
movl %r13d, 0x358c(%rbx)
movl %ecx, 0x3598(%rbx)
movl %esi, 0x359c(%rbx)
movl %edi, 0x3590(%rbx)
movl %eax, 0x3594(%rbx)
testl %ebp, %ebp
jle 0x410245
movl %eax, %r8d
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 0x4458c0
movq %rax, -0x8(%rbx)
testq %rax, %rax
je 0x410403
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 0x41037f
jmp 0x410245
leaq 0xc85c5(%rip), %r15     # 0x4d89cf
cmpq $0x1, %r14
je 0x41023b
movq 0x20(%rsp), %r12
leal -0x2(%r14), %eax
leaq (%rax,%rax,8), %rbx
movq 0x38(%r12,%rbx,8), %rdi
callq 0x445c00
movq $0x0, 0x30(%r12,%rbx,8)
decq %r14
cmpq $0x1, %r14
jg 0x410419
jmp 0x41023b