// File: /workspace/github_c_makefile_star2_O0/patriciogonzalezvivo[P]tprint/include/std/stb_image.h
// Function: load_jpeg_image(stbi__jpeg*, int*, int*, int*, int)
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, but leave in YCbCr format
   if (!stbi__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 = z->resample_row_hv_2_kernel;
         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) {
               z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
            } 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:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x178(%rsp)
movq %rsi, 0x170(%rsp)
movq %rdx, 0x168(%rsp)
movq %rcx, 0x160(%rsp)
movl %r8d, 0x15c(%rsp)
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl $0x0, 0x8(%rax)
cmpl $0x0, 0x15c(%rsp)
jl 0x21bc5
cmpl $0x4, 0x15c(%rsp)
jle 0x21be9
leaq 0xbf80(%rip), %rdi      # 0x2db4c
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x180(%rsp)
jmp 0x22400
movq 0x178(%rsp), %rdi
callq 0x22410
cmpl $0x0, %eax
jne 0x21c19
movq 0x178(%rsp), %rdi
callq 0x22600
movq $0x0, 0x180(%rsp)
jmp 0x22400
cmpl $0x0, 0x15c(%rsp)
je 0x21c30
movl 0x15c(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x21c42
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x158(%rsp)
movq 0x178(%rsp), %rax
movq (%rax), %rax
cmpl $0x3, 0x8(%rax)
jne 0x21c75
cmpl $0x3, 0x158(%rsp)
jge 0x21c75
movl $0x1, 0x154(%rsp)
jmp 0x21c8a
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, 0x154(%rsp)
movl $0x0, 0x150(%rsp)
movl 0x150(%rsp), %eax
cmpl 0x154(%rsp), %eax
jge 0x21f19
movslq 0x150(%rsp), %rcx
leaq 0x60(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x58(%rsp)
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl (%rax), %eax
addl $0x3, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x1ac80
movq %rax, %rcx
movq 0x178(%rsp), %rax
addq $0x45a0, %rax           # imm = 0x45A0
movslq 0x150(%rsp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x48(%rax)
movq 0x178(%rsp), %rax
addq $0x45a0, %rax           # imm = 0x45A0
movslq 0x150(%rsp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x48(%rax)
jne 0x21d54
movq 0x178(%rsp), %rdi
callq 0x22600
leaq 0xbe0c(%rip), %rdi      # 0x2db43
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x180(%rsp)
jmp 0x22400
movq 0x178(%rsp), %rax
movl 0x4588(%rax), %eax
movq 0x178(%rsp), %rcx
addq $0x45a0, %rcx           # imm = 0x45A0
movslq 0x150(%rsp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rcx
cltd
idivl 0x4(%rcx)
movl %eax, %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x178(%rsp), %rax
movl 0x458c(%rax), %eax
movq 0x178(%rsp), %rcx
addq $0x45a0, %rcx           # imm = 0x45A0
movslq 0x150(%rsp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rcx
cltd
idivl 0x8(%rcx)
movl %eax, %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x58(%rsp), %rax
movl 0x1c(%rax), %ecx
sarl %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x24(%rax)
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl (%rax), %eax
movq 0x58(%rsp), %rcx
addl 0x18(%rcx), %eax
subl $0x1, %eax
movq 0x58(%rsp), %rcx
xorl %edx, %edx
divl 0x18(%rcx)
movl %eax, %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x20(%rax)
movq 0x58(%rsp), %rax
movl $0x0, 0x28(%rax)
movq 0x178(%rsp), %rax
addq $0x45a0, %rax           # imm = 0x45A0
movslq 0x150(%rsp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq 0x30(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x58(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x58(%rsp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x21e6f
movq 0x58(%rsp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x21e6f
movq 0x58(%rsp), %rax
leaq 0x939(%rip), %rcx       # 0x227a0
movq %rcx, (%rax)
jmp 0x21f01
movq 0x58(%rsp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x21e96
movq 0x58(%rsp), %rax
cmpl $0x2, 0x1c(%rax)
jne 0x21e96
movq 0x58(%rsp), %rax
leaq 0x92f(%rip), %rcx       # 0x227c0
movq %rcx, (%rax)
jmp 0x21eff
movq 0x58(%rsp), %rax
cmpl $0x2, 0x18(%rax)
jne 0x21ebd
movq 0x58(%rsp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x21ebd
movq 0x58(%rsp), %rax
leaq 0x988(%rip), %rcx       # 0x22840
movq %rcx, (%rax)
jmp 0x21efd
movq 0x58(%rsp), %rax
cmpl $0x2, 0x18(%rax)
jne 0x21eec
movq 0x58(%rsp), %rax
cmpl $0x2, 0x1c(%rax)
jne 0x21eec
movq 0x178(%rsp), %rax
movq 0x4778(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, (%rax)
jmp 0x21efb
movq 0x58(%rsp), %rax
leaq 0xaf8(%rip), %rcx       # 0x229f0
movq %rcx, (%rax)
jmp 0x21efd
jmp 0x21eff
jmp 0x21f01
jmp 0x21f03
movl 0x150(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x150(%rsp)
jmp 0x21c95
movl 0x158(%rsp), %eax
movq 0x178(%rsp), %rcx
movq (%rcx), %rcx
imull (%rcx), %eax
movq 0x178(%rsp), %rcx
movq (%rcx), %rcx
imull 0x4(%rcx), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x1ac80
movq %rax, 0x140(%rsp)
cmpq $0x0, 0x140(%rsp)
jne 0x21f8d
movq 0x178(%rsp), %rdi
callq 0x22600
leaq 0xbbd3(%rip), %rdi      # 0x2db43
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x180(%rsp)
jmp 0x22400
movl $0x0, 0x148(%rsp)
movl 0x148(%rsp), %eax
movq 0x178(%rsp), %rcx
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jae 0x22391
movq 0x140(%rsp), %rax
movl 0x158(%rsp), %ecx
movq 0x178(%rsp), %rdx
movq (%rdx), %rdx
imull (%rdx), %ecx
imull 0x148(%rsp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0x150(%rsp)
movl 0x150(%rsp), %eax
cmpl 0x154(%rsp), %eax
jge 0x221b0
movslq 0x150(%rsp), %rcx
leaq 0x60(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl 0x24(%rax), %eax
movq 0x48(%rsp), %rcx
movl 0x1c(%rcx), %ecx
sarl %ecx
cmpl %ecx, %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x44(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x178(%rsp), %rax
addq $0x45a0, %rax           # imm = 0x45A0
movslq 0x150(%rsp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rax
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x22084
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x22092
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x220b2
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, (%rsp)
jmp 0x220bf
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq (%rsp), %rdx
movq 0x48(%rsp), %rcx
movl 0x20(%rcx), %ecx
movq 0x48(%rsp), %r8
movl 0x18(%r8), %r8d
callq *%rax
movq %rax, %rcx
movslq 0x150(%rsp), %rax
movq %rcx, 0x120(%rsp,%rax,8)
movq 0x48(%rsp), %rcx
movl 0x24(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x24(%rcx)
movq 0x48(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jl 0x22198
movq 0x48(%rsp), %rax
movl $0x0, 0x24(%rax)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rcx
movl 0x28(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x28(%rcx)
movq 0x178(%rsp), %rcx
addq $0x45a0, %rcx           # imm = 0x45A0
movslq 0x150(%rsp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x20(%rcx), %eax
jge 0x22196
movq 0x178(%rsp), %rax
addq $0x45a0, %rax           # imm = 0x45A0
movslq 0x150(%rsp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %edx
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x10(%rax)
jmp 0x22198
jmp 0x2219a
movl 0x150(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x150(%rsp)
jmp 0x21fed
cmpl $0x3, 0x158(%rsp)
jl 0x222a0
movq 0x120(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x178(%rsp), %rax
movq (%rax), %rax
cmpl $0x3, 0x8(%rax)
jne 0x2221f
movq 0x178(%rsp), %rax
movq 0x4770(%rax), %rax
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x128(%rsp), %rdx
movq 0x130(%rsp), %rcx
movq 0x178(%rsp), %r8
movq (%r8), %r8
movl (%r8), %r8d
movl 0x158(%rsp), %r9d
callq *%rax
jmp 0x2229b
movl $0x0, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
movq 0x178(%rsp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jae 0x22299
movq 0x38(%rsp), %rax
movl 0x14c(%rsp), %ecx
movb (%rax,%rcx), %cl
movq 0x50(%rsp), %rax
movb %cl, 0x2(%rax)
movq 0x50(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x50(%rsp), %rax
movb %cl, (%rax)
movq 0x50(%rsp), %rax
movb $-0x1, 0x3(%rax)
movl 0x158(%rsp), %ecx
movq 0x50(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x2222a
jmp 0x2229b
jmp 0x22379
movq 0x120(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpl $0x1, 0x158(%rsp)
jne 0x2230b
movl $0x0, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
movq 0x178(%rsp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jae 0x22309
movq 0x30(%rsp), %rax
movl 0x14c(%rsp), %ecx
movb (%rax,%rcx), %dl
movq 0x50(%rsp), %rax
movl 0x14c(%rsp), %ecx
movb %dl, (%rax,%rcx)
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x222c2
jmp 0x22377
movl $0x0, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
movq 0x178(%rsp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jae 0x22375
movq 0x30(%rsp), %rax
movl 0x14c(%rsp), %ecx
movb (%rax,%rcx), %cl
movq 0x50(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x50(%rsp)
movb %cl, (%rax)
movq 0x50(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x50(%rsp)
movb $-0x1, (%rax)
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x22316
jmp 0x22377
jmp 0x22379
jmp 0x2237b
movl 0x148(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x148(%rsp)
jmp 0x21f98
movq 0x178(%rsp), %rdi
callq 0x22600
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movq 0x170(%rsp), %rax
movl %ecx, (%rax)
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl 0x4(%rax), %ecx
movq 0x168(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x160(%rsp)
je 0x223f0
movq 0x178(%rsp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
movq 0x160(%rsp), %rax
movl %ecx, (%rax)
movq 0x140(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x180(%rsp), %rax
addq $0x188, %rsp            # imm = 0x188
retq