// File: /workspace/github_c_makefile_star2_O0/patriciogonzalezvivo[P]tprint/include/std/stb_image.h
// Function: stbi__convert_format(unsigned char*, int, int, unsigned int, unsigned int)
static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)
{
   int i,j;
   unsigned char *good;

   if (req_comp == img_n) return data;
   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);

   good = (unsigned char *) stbi__malloc(req_comp * x * y);
   if (good == NULL) {
      STBI_FREE(data);
      return stbi__errpuc("outofmem", "Out of memory");
   }

   for (j=0; j < (int) y; ++j) {
      unsigned char *src  = data + j * x * img_n   ;
      unsigned char *dest = good + j * x * req_comp;

      #define COMBO(a,b)  ((a)*8+(b))
      #define CASE(a,b)   case COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
      // convert source image with img_n components to one with req_comp components;
      // avoid switch per pixel, so use switch per scanline and massive macros
      switch (COMBO(img_n, req_comp)) {
         CASE(1,2) dest[0]=src[0], dest[1]=255; break;
         CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break;
         CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break;
         CASE(2,1) dest[0]=src[0]; break;
         CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break;
         CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break;
         CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break;
         CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break;
         CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; break;
         CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break;
         CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break;
         CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break;
         default: STBI_ASSERT(0);
      }
      #undef CASE
   }

   STBI_FREE(data);
   return good;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movl %esi, 0x44(%rsp)
movl %edx, 0x40(%rsp)
movl %ecx, 0x3c(%rsp)
movl %r8d, 0x38(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x44(%rsp), %eax
jne 0x25b63
movq 0x48(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x26195
xorl %eax, %eax
cmpl $0x1, 0x40(%rsp)
movb %al, 0x17(%rsp)
jl 0x25b7c
cmpl $0x4, 0x40(%rsp)
setle %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x25b86
jmp 0x25b88
jmp 0x25ba7
leaq 0x83c6(%rip), %rdi      # 0x2df55
leaq 0x807d(%rip), %rsi      # 0x2dc13
movl $0x52c, %edx            # imm = 0x52C
leaq 0x83d2(%rip), %rcx      # 0x2df74
callq 0xd270
movl 0x40(%rsp), %eax
imull 0x3c(%rsp), %eax
imull 0x38(%rsp), %eax
movl %eax, %eax
movl %eax, %edi
callq 0x1ac80
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x25bf6
movq 0x48(%rsp), %rdi
callq 0xd4e0
leaq 0x7f67(%rip), %rdi      # 0x2db43
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x50(%rsp)
jmp 0x26195
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x38(%rsp), %eax
jge 0x26181
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
movl 0x3c(%rsp), %edx
imull %edx, %ecx
movl 0x44(%rsp), %edx
imull %edx, %ecx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movl 0x30(%rsp), %ecx
movl 0x3c(%rsp), %edx
imull %edx, %ecx
movl 0x40(%rsp), %edx
imull %edx, %ecx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movl 0x44(%rsp), %eax
movl 0x40(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal -0xa(%rax,%rcx,8), %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x19, %eax
ja 0x26150
movq 0x8(%rsp), %rax
leaq 0x7c1a(%rip), %rcx      # 0x2d890
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25cd1
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x18(%rsp), %rax
movb $-0x1, 0x1(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x18(%rsp)
jmp 0x25c8a
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25d2f
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x2(%rax)
movq 0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x18(%rsp)
jmp 0x25ce1
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25d96
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x2(%rax)
movq 0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x18(%rsp), %rax
movb $-0x1, 0x3(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
jmp 0x25d3f
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25de4
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x25da6
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25e42
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x2(%rax)
movq 0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x18(%rsp)
jmp 0x25df4
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25eb0
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x2(%rax)
movq 0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x20(%rsp), %rax
movb 0x1(%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x3(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
jmp 0x25e52
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25f27
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x20(%rsp), %rax
movb 0x1(%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x20(%rsp), %rax
movb 0x2(%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x2(%rax)
movq 0x18(%rsp), %rax
movb $-0x1, 0x3(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
jmp 0x25ec0
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x25f8f
movq 0x20(%rsp), %rax
movzbl (%rax), %edi
movq 0x20(%rsp), %rax
movzbl 0x1(%rax), %esi
movq 0x20(%rsp), %rax
movzbl 0x2(%rax), %edx
callq 0x28810
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x25f37
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x26000
movq 0x20(%rsp), %rax
movzbl (%rax), %edi
movq 0x20(%rsp), %rax
movzbl 0x1(%rax), %esi
movq 0x20(%rsp), %rax
movzbl 0x2(%rax), %edx
callq 0x28810
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x18(%rsp), %rax
movb $-0x1, 0x1(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x18(%rsp)
jmp 0x25f9f
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x26068
movq 0x20(%rsp), %rax
movzbl (%rax), %edi
movq 0x20(%rsp), %rax
movzbl 0x1(%rax), %esi
movq 0x20(%rsp), %rax
movzbl 0x2(%rax), %edx
callq 0x28810
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x26010
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x260e0
movq 0x20(%rsp), %rax
movzbl (%rax), %edi
movq 0x20(%rsp), %rax
movzbl 0x1(%rax), %esi
movq 0x20(%rsp), %rax
movzbl 0x2(%rax), %edx
callq 0x28810
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x20(%rsp), %rax
movb 0x3(%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x18(%rsp)
jmp 0x26078
jmp 0x2616f
movl 0x3c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jl 0x2614e
movq 0x20(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x20(%rsp), %rax
movb 0x1(%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x20(%rsp), %rax
movb 0x2(%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, 0x2(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x18(%rsp)
jmp 0x260f0
jmp 0x2616f
leaq 0x811f(%rip), %rdi      # 0x2e276
leaq 0x7ab5(%rip), %rsi      # 0x2dc13
movl $0x549, %edx            # imm = 0x549
leaq 0x7e0a(%rip), %rcx      # 0x2df74
callq 0xd270
jmp 0x26171
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x25bfe
movq 0x48(%rsp), %rdi
callq 0xd4e0
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nop