// File: /workspace/github_cpp_makefile_star2_O1/alan0201tw[P]RayTracer/include/stb_image.h
// 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 && c != 4) return stbi__err("bad component count","Corrupt JPEG");
   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");

   z->rgb = 0;
   for (i=0; i < s->img_n; ++i) {
      static const unsigned char rgb[3] = { 'R', 'G', 'B' };
      z->img_comp[i].id = stbi__get8(s);
      if (s->img_n == 3 && z->img_comp[i].id == rgb[i])
         ++z->rgb;
      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 (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) 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;
   // these sizes can't be more than 17 bits
   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
      //
      // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier)
      // so these muls can't overflow with 32-bit ints (which we require)
      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].coeff = 0;
      z->img_comp[i].raw_coeff = 0;
      z->img_comp[i].linebuf = NULL;
      z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15);
      if (z->img_comp[i].raw_data == NULL)
         return stbi__free_jpeg_components(z, i+1, 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);
      if (z->progressive) {
         // w2, h2 are multiples of 8 (see above)
         z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8;
         z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8;
         z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15);
         if (z->img_comp[i].raw_coeff == NULL)
            return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory"));
         z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15);
      }
   }

   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 0x31ea4
cmpl $0xa, %eax
ja 0x317ca
leaq 0xdefe(%rip), %rax      # 0x3f6c3
jmp 0x31dbd
movl %eax, %r15d
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x3183a
cmpl $0x0, 0x30(%r14)
je 0x318b0
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r12
movl 0x34(%r14), %edx
movq %r12, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x31814
movq %r12, 0xb8(%r14)
cltq
addq %r12, %rax
movq %rax, 0xc0(%r14)
jmp 0x31833
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 0x318b0
movq %r14, %rdi
callq 0x31ea4
movl %eax, 0x4(%r14)
testl %eax, %eax
je 0x318bc
movq %r14, %rdi
callq 0x31ea4
movl %eax, (%r14)
testl %eax, %eax
je 0x318c8
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x318fe
cmpl $0x0, 0x30(%r14)
je 0x318d4
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r12
movl 0x34(%r14), %edx
movq %r12, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x318d8
movq %r12, 0xb8(%r14)
cltq
addq %r12, %rax
movq %rax, 0xc0(%r14)
jmp 0x318f7
leaq 0xde18(%rip), %rax      # 0x3f6cf
jmp 0x31dbd
leaq 0xde17(%rip), %rax      # 0x3f6da
jmp 0x31dbd
leaq 0xde1c(%rip), %rax      # 0x3f6eb
jmp 0x31dbd
xorl %eax, %eax
jmp 0x3190b
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
cmpb $0x4, %al
ja 0x31db6
movzbl %al, %eax
movl $0x1a, %ecx
btl %eax, %ecx
jae 0x31db6
movl %eax, 0x8(%r14)
testl %eax, %eax
je 0x31952
movl %eax, %ecx
shll $0x5, %ecx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movq %rdx, 0x46d0(%rbx,%rsi)
movq %rdx, 0x46e8(%rbx,%rsi)
addq $0x60, %rsi
cmpq %rsi, %rcx
jne 0x31939
leal (%rax,%rax,2), %eax
addl $0x8, %eax
cmpl %eax, %r15d
jne 0x317be
movl $0x0, 0x4850(%rbx)
movl 0x8(%r14), %r13d
testl %r13d, %r13d
jle 0x31b6f
leaq 0x38(%r14), %rsi
leaq 0x39(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x46ac(%rbx), %r12
xorl %r15d, %r15d
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x319fc
cmpl $0x0, 0x30(%r14)
je 0x319ce
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %r13
callq *0x10(%r14)
testl %eax, %eax
je 0x319d2
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x319f2
xorl %eax, %eax
jmp 0x31a09
movl $0x0, 0x30(%r14)
movq %r13, 0xb8(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %r13, %rsi
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movzbl %al, %ecx
movl %ecx, -0xc(%r12)
cmpl $0x3, 0x8(%r14)
jne 0x31a2b
leaq 0xbc90(%rip), %rcx      # 0x3d6af
cmpb (%r15,%rcx), %al
jne 0x31a2b
incl 0x4850(%rbx)
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x31a98
cmpl $0x0, 0x30(%r14)
je 0x31a6a
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %r13
callq *0x10(%r14)
testl %eax, %eax
je 0x31a6e
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x31a8e
xorl %eax, %eax
jmp 0x31aa5
movl $0x0, 0x30(%r14)
movq %r13, 0xb8(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %r13, %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(%r12)
leal -0x50(%rax), %ecx
cmpb $-0x41, %cl
jbe 0x31dd9
andl $0xf, %eax
movl %eax, -0x4(%r12)
addl $-0x5, %eax
cmpl $-0x5, %eax
jbe 0x31de2
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x31b3f
cmpl $0x0, 0x30(%r14)
je 0x31b11
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %rsi, %r13
callq *0x10(%r14)
testl %eax, %eax
je 0x31b15
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x31b35
xorl %eax, %eax
jmp 0x31b4c
movl $0x0, 0x30(%r14)
movq %r13, 0xb8(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %r13, %rsi
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movzbl %al, %eax
movl %eax, (%r12)
cmpb $0x4, %al
jae 0x31deb
incq %r15
movslq 0x8(%r14), %r13
addq $0x60, %r12
cmpq %r13, %r15
jl 0x3198f
movl $0x1, %r12d
testl %ebp, %ebp
jne 0x31dc7
movl (%r14), %edi
movl 0x4(%r14), %esi
xorl %r12d, %r12d
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x32132
testl %eax, %eax
je 0x31df4
movl $0x1, %r12d
movl %r13d, %ecx
movl $0x1, %r15d
movl $0x1, %r8d
testl %r13d, %r13d
jle 0x31bfb
movq %rcx, %rax
shlq $0x5, %rax
leaq (%rax,%rax,2), %rax
movl $0x1, %r8d
xorl %edx, %edx
movl $0x1, %r15d
movl 0x46a4(%rbx,%rdx), %esi
movl 0x46a8(%rbx,%rdx), %edi
cmpl %r15d, %esi
cmovgl %esi, %r15d
cmpl %r8d, %edi
cmovgl %edi, %r8d
addq $0x60, %rdx
cmpq %rdx, %rax
jne 0x31bd6
movl %r15d, 0x4688(%rbx)
movl %r8d, 0x468c(%rbx)
leal (,%r15,8), %esi
movl %esi, 0x4698(%rbx)
leal (,%r8,8), %edi
movl %edi, 0x469c(%rbx)
movq 0x30(%rsp), %rax
leal (%rax,%r15,8), %eax
decl %eax
xorl %edx, %edx
divl %esi
movl %eax, 0x20(%rsp)
movl %eax, 0x4690(%rbx)
movq 0x28(%rsp), %rax
leal (%rax,%r8,8), %eax
decl %eax
xorl %edx, %edx
divl %edi
movl %eax, 0x1c(%rsp)
movl %eax, 0x4694(%rbx)
testl %r13d, %r13d
jle 0x31dc7
leal -0x1(%r15), %eax
movl %eax, 0x18(%rsp)
leal -0x1(%r8), %eax
movl %eax, 0x14(%rsp)
shlq $0x5, %rcx
leaq (%rcx,%rcx,2), %rax
movq %rax, 0x38(%rsp)
movl $0x1, %eax
xorl %r13d, %r13d
movq %r8, 0x40(%rsp)
movl %eax, 0x8(%rsp)
movl 0x46a4(%rbx,%r13), %r12d
movl 0x46a8(%rbx,%r13), %ebp
movl %r12d, %eax
imull 0x30(%rsp), %eax
addl 0x18(%rsp), %eax
xorl %edx, %edx
divl %r15d
movl %eax, 0x46bc(%rbx,%r13)
movl %ebp, %eax
imull 0x28(%rsp), %eax
addl 0x14(%rsp), %eax
xorl %edx, %edx
divl %r8d
movl %eax, 0x46c0(%rbx,%r13)
imull 0x20(%rsp), %r12d
leal (,%r12,8), %edi
movl %edi, 0x46c4(%rbx,%r13)
imull 0x1c(%rsp), %ebp
leal (,%rbp,8), %r14d
movl %r14d, 0x46c8(%rbx,%r13)
movl %edi, 0x24(%rsp)
movl %r14d, %esi
movl $0xf, %edx
callq 0x3218f
xorps %xmm0, %xmm0
movups %xmm0, 0x46e0(%rbx,%r13)
movq $0x0, 0x46f0(%rbx,%r13)
movq %rax, 0x46d8(%rbx,%r13)
testq %rax, %rax
je 0x31e04
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, 0x46d0(%rbx,%r13)
cmpl $0x0, 0x4830(%rbx)
je 0x31d94
movl %r12d, 0x46f8(%rbx,%r13)
movl %ebp, 0x46fc(%rbx,%r13)
movl 0x24(%rsp), %edi
movl %r14d, %esi
movl $0x2, %edx
movl $0xf, %ecx
callq 0x32255
movq %rax, 0x46e0(%rbx,%r13)
testq %rax, %rax
je 0x31e04
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, 0x46f0(%rbx,%r13)
movl 0x8(%rsp), %eax
incl %eax
addq $0x60, %r13
movl $0x1, %r12d
cmpq %r13, 0x38(%rsp)
movq 0x40(%rsp), %r8
jne 0x31c8a
jmp 0x31dc7
leaq 0xd936(%rip), %rax      # 0x3f6f3
movq %rax, 0x1d724(%rip)     # 0x4f4e8
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd927(%rip), %rax      # 0x3f707
jmp 0x31dbd
leaq 0xd924(%rip), %rax      # 0x3f70d
jmp 0x31dbd
leaq 0xd921(%rip), %rax      # 0x3f713
jmp 0x31dbd
leaq 0xd91f(%rip), %rax      # 0x3f71a
movq %rax, 0x1d6e6(%rip)     # 0x4f4e8
jmp 0x31dc7
leaq 0xd919(%rip), %rax      # 0x3f724
movq %rax, 0x1d6d6(%rip)     # 0x4f4e8
movq %rbx, %rdi
movl 0x8(%rsp), %esi
callq 0x321d2
jmp 0x31dc4