// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/stb_image.c
// Function: load_jpeg_image
static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
{
   int n, decode_n;
   z->s->img_n = 0; // make stbi__cleanup_jpeg safe

   // validate req_comp
   if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");

   // load a jpeg image from whichever source
   if (!decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; }

   // determine actual number of components to generate
   n = req_comp ? req_comp : z->s->img_n;

   if (z->s->img_n == 3 && n < 3)
      decode_n = 1;
   else
      decode_n = z->s->img_n;

   // resample and color-convert
   {
      int k;
      unsigned int i,j;
      stbi_uc *output;
      stbi_uc *coutput[4];

      stbi__resample res_comp[4];

      for (k=0; k < decode_n; ++k) {
         stbi__resample *r = &res_comp[k];

         // allocate line buffer big enough for upsampling off the edges
         // with upsample factor of 4
         z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3);
         if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }

         r->hs      = z->img_h_max / z->img_comp[k].h;
         r->vs      = z->img_v_max / z->img_comp[k].v;
         r->ystep   = r->vs >> 1;
         r->w_lores = (z->s->img_x + r->hs-1) / r->hs;
         r->ypos    = 0;
         r->line0   = r->line1 = z->img_comp[k].data;

         if      (r->hs == 1 && r->vs == 1) r->resample = resample_row_1;
         else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2;
         else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2;
         else if (r->hs == 2 && r->vs == 2) r->resample = stbi__resample_row_hv_2;
         else                               r->resample = stbi__resample_row_generic;
      }

      // can't error after this so, this is safe
      output = (stbi_uc *) stbi__malloc(n * z->s->img_x * z->s->img_y + 1);
      if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }

      // now go ahead and resample
      for (j=0; j < z->s->img_y; ++j) {
         stbi_uc *out = output + n * z->s->img_x * j;
         for (k=0; k < decode_n; ++k) {
            stbi__resample *r = &res_comp[k];
            int y_bot = r->ystep >= (r->vs >> 1);
            coutput[k] = r->resample(z->img_comp[k].linebuf,
                                     y_bot ? r->line1 : r->line0,
                                     y_bot ? r->line0 : r->line1,
                                     r->w_lores, r->hs);
            if (++r->ystep >= r->vs) {
               r->ystep = 0;
               r->line0 = r->line1;
               if (++r->ypos < z->img_comp[k].y)
                  r->line1 += z->img_comp[k].w2;
            }
         }
         if (n >= 3) {
            stbi_uc *y = coutput[0];
            if (z->s->img_n == 3) {
               #ifdef STBI_SIMD
               stbi__YCbCr_installed(out, y, coutput[1], coutput[2], z->s->img_x, n);
               #else
               stbi__YCbCr_to_RGB_row(out, y, coutput[1], coutput[2], z->s->img_x, n);
               #endif
            } else
               for (i=0; i < z->s->img_x; ++i) {
                  out[0] = out[1] = out[2] = y[i];
                  out[3] = 255; // not used if n==3
                  out += n;
               }
         } else {
            stbi_uc *y = coutput[0];
            if (n == 1)
               for (i=0; i < z->s->img_x; ++i) out[i] = y[i];
            else
               for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255;
         }
      }
      stbi__cleanup_jpeg(z);
      *out_x = z->s->img_x;
      *out_y = z->s->img_y;
      if (comp) *comp  = z->s->img_n; // report original components, not output
      return output;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0x8(%rax)
cmpl $0x0, -0x2c(%rbp)
jl 0x415df9
cmpl $0x4, -0x2c(%rbp)
jle 0x415e19
leaq 0xcf6e4(%rip), %rdi     # 0x4e54e4
callq 0x411080
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x416520
movq -0x10(%rbp), %rdi
callq 0x416530
cmpl $0x0, %eax
jne 0x415e3d
movq -0x10(%rbp), %rdi
callq 0x416690
movq $0x0, -0x8(%rbp)
jmp 0x416520
cmpl $0x0, -0x2c(%rbp)
je 0x415e4e
movl -0x2c(%rbp), %eax
movl %eax, -0x164(%rbp)
jmp 0x415e5e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x164(%rbp)
movl -0x164(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x3, 0x8(%rax)
jne 0x415e83
cmpl $0x3, -0x30(%rbp)
jge 0x415e83
movl $0x1, -0x34(%rbp)
jmp 0x415e90
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x4160f1
movslq -0x38(%rbp), %rcx
leaq -0x130(%rbp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
addl $0x3, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x412250
movq %rax, %rcx
movq -0x10(%rbp), %rax
addq $0x35a0, %rax           # imm = 0x35A0
movslq -0x38(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
addq $0x35a0, %rax           # imm = 0x35A0
movslq -0x38(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x40(%rax)
jne 0x415f32
movq -0x10(%rbp), %rdi
callq 0x416690
leaq 0xcf5c2(%rip), %rdi     # 0x4e54db
callq 0x411080
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x416520
movq -0x10(%rbp), %rax
movl 0x3588(%rax), %eax
movq -0x10(%rbp), %rcx
addq $0x35a0, %rcx           # imm = 0x35A0
movslq -0x38(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
cltd
idivl 0x4(%rcx)
movl %eax, %ecx
movq -0x138(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x358c(%rax), %eax
movq -0x10(%rbp), %rcx
addq $0x35a0, %rcx           # imm = 0x35A0
movslq -0x38(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
cltd
idivl 0x8(%rcx)
movl %eax, %ecx
movq -0x138(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x138(%rbp), %rax
movl 0x1c(%rax), %ecx
sarl %ecx
movq -0x138(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movq -0x138(%rbp), %rcx
addl 0x18(%rcx), %eax
subl $0x1, %eax
movq -0x138(%rbp), %rcx
xorl %edx, %edx
divl 0x18(%rcx)
movl %eax, %ecx
movq -0x138(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x138(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
addq $0x35a0, %rax           # imm = 0x35A0
movslq -0x38(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq 0x30(%rax), %rcx
movq -0x138(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x138(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x138(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x416043
movq -0x138(%rbp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x416043
movq -0x138(%rbp), %rax
leaq 0x765(%rip), %rcx       # 0x4167a0
movq %rcx, (%rax)
jmp 0x4160e1
movq -0x138(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x416070
movq -0x138(%rbp), %rax
cmpl $0x2, 0x1c(%rax)
jne 0x416070
movq -0x138(%rbp), %rax
leaq 0x755(%rip), %rcx       # 0x4167c0
movq %rcx, (%rax)
jmp 0x4160df
movq -0x138(%rbp), %rax
cmpl $0x2, 0x18(%rax)
jne 0x41609d
movq -0x138(%rbp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x41609d
movq -0x138(%rbp), %rax
leaq 0x798(%rip), %rcx       # 0x416830
movq %rcx, (%rax)
jmp 0x4160dd
movq -0x138(%rbp), %rax
cmpl $0x2, 0x18(%rax)
jne 0x4160ca
movq -0x138(%rbp), %rax
cmpl $0x2, 0x1c(%rax)
jne 0x4160ca
movq -0x138(%rbp), %rax
leaq 0x8eb(%rip), %rcx       # 0x4169b0
movq %rcx, (%rax)
jmp 0x4160db
movq -0x138(%rbp), %rax
leaq 0xa08(%rip), %rcx       # 0x416ae0
movq %rcx, (%rax)
jmp 0x4160dd
jmp 0x4160df
jmp 0x4160e1
jmp 0x4160e3
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x415e97
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imull (%rcx), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imull 0x4(%rcx), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x412250
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x416149
movq -0x10(%rbp), %rdi
callq 0x416690
leaq 0xcf3ab(%rip), %rdi     # 0x4e54db
callq 0x411080
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x416520
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jae 0x4164d9
movq -0x48(%rbp), %rax
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rdx
movq (%rdx), %rdx
imull (%rdx), %ecx
imull -0x40(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x140(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x41635c
movslq -0x38(%rbp), %rcx
leaq -0x130(%rbp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x148(%rbp), %rcx
movl 0x1c(%rcx), %ecx
sarl %ecx
cmpl %ecx, %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14c(%rbp)
movq -0x148(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x178(%rbp)
movq -0x10(%rbp), %rax
addq $0x35a0, %rax           # imm = 0x35A0
movslq -0x38(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movq %rax, -0x170(%rbp)
cmpl $0x0, -0x14c(%rbp)
je 0x416224
movq -0x148(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x180(%rbp)
jmp 0x416236
movq -0x148(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x180(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x188(%rbp)
cmpl $0x0, -0x14c(%rbp)
je 0x416261
movq -0x148(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x190(%rbp)
jmp 0x416273
movq -0x148(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x190(%rbp)
movq -0x178(%rbp), %rax
movq -0x188(%rbp), %rsi
movq -0x170(%rbp), %rdi
movq -0x190(%rbp), %rdx
movq -0x148(%rbp), %rcx
movl 0x20(%rcx), %ecx
movq -0x148(%rbp), %r8
movl 0x18(%r8), %r8d
callq *%rax
movq %rax, %rcx
movslq -0x38(%rbp), %rax
movq %rcx, -0x70(%rbp,%rax,8)
movq -0x148(%rbp), %rcx
movl 0x24(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x24(%rcx)
movq -0x148(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jl 0x41634c
movq -0x148(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x148(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x148(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x148(%rbp), %rcx
movl 0x28(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x28(%rcx)
movq -0x10(%rbp), %rcx
addq $0x35a0, %rcx           # imm = 0x35A0
movslq -0x38(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x20(%rcx), %eax
jge 0x41634a
movq -0x10(%rbp), %rax
addq $0x35a0, %rax           # imm = 0x35A0
movslq -0x38(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %edx
movq -0x148(%rbp), %rax
movq 0x10(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x10(%rax)
jmp 0x41634c
jmp 0x41634e
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x41618b
cmpl $0x3, -0x30(%rbp)
jl 0x41641c
movq -0x70(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x3, 0x8(%rax)
jne 0x4163a9
movq -0x140(%rbp), %rdi
movq -0x158(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %r8d
movl -0x30(%rbp), %r9d
callq 0x416b60
jmp 0x416417
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jae 0x416415
movq -0x158(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb (%rax,%rcx), %cl
movq -0x140(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x140(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x140(%rbp), %rax
movb %cl, (%rax)
movq -0x140(%rbp), %rax
movb $-0x1, 0x3(%rax)
movl -0x30(%rbp), %ecx
movq -0x140(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x140(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4163b0
jmp 0x416417
jmp 0x4164c9
movq -0x70(%rbp), %rax
movq %rax, -0x160(%rbp)
cmpl $0x1, -0x30(%rbp)
jne 0x416469
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jae 0x416467
movq -0x160(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x140(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x416434
jmp 0x4164c7
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jae 0x4164c5
movq -0x160(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb (%rax,%rcx), %cl
movq -0x140(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x140(%rbp)
movb %cl, (%rax)
movq -0x140(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x140(%rbp)
movb $-0x1, (%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x416470
jmp 0x4164c7
jmp 0x4164c9
jmp 0x4164cb
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x416150
movq -0x10(%rbp), %rdi
callq 0x416690
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x416518
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopl (%rax)