// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x18(%rsp)
movq %rdi, %rbx
cmpl %esi, %edx
je 0x1c78e
movl %edx, %r14d
leal -0x1(%r14), %eax
cmpl $0x4, %eax
jae 0x1c7a0
movl %r8d, %ebp
movl %esi, %r12d
movq 0x18(%rsp), %rax
imull %r14d, %eax
movl %eax, 0x24(%rsp)
movl %eax, %edi
imull %r8d, %edi
callq 0x8420
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1c776
movq %r14, 0x28(%rsp)
testl %ebp, %ebp
jle 0x1c767
movq 0x28(%rsp), %rax
leal (%rax,%r12,8), %r14d
cmpl $0x23, %r14d
ja 0x1c7bf
movabsq $0xe161a1c00, %rax      # imm = 0xE161A1C00
btq %r14, %rax
jae 0x1c7bf
movq 0x18(%rsp), %rax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rsp)
movl %ebp, %ecx
movq %rcx, 0x40(%rsp)
movl %eax, %esi
imull %r12d, %eax
movl %eax, 0x20(%rsp)
movq 0x10(%rsp), %rax
leaq 0x3(%rax), %rcx
movq %rcx, 0x38(%rsp)
addq $0x2, %rax
movq %rax, 0x30(%rsp)
xorl %r10d, %r10d
addl $-0xa, %r14d
xorl %ebp, %ebp
xorl %r13d, %r13d
leaq 0x4571(%rip), %r15      # 0x209f0
movl %r10d, %r11d
addq %rbx, %r11
movl %r13d, %r9d
imull 0x18(%rsp), %r9d
cmpl $0x18, %r14d
ja 0x1c718
movl %ebp, %edx
movq 0x10(%rsp), %rax
leaq (%rax,%rdx), %rcx
movq 0x38(%rsp), %rax
leaq (%rax,%rdx), %rdi
movl %r9d, %r8d
imull %r12d, %r8d
addq %rbx, %r8
movslq (%r15,%r14,4), %rax
addq %r15, %rax
jmpq *%rax
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %eax, %eax
movb (%r11,%rax), %dl
movb %dl, (%rcx,%rax,2)
movb $-0x1, 0x1(%rcx,%rax,2)
incq %rax
cmpl %eax, %esi
jne 0x1c4cc
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %edx, %edx
movzbl (%r11,%rdx,4), %edi
movzbl 0x1(%r11,%rdx,4), %r8d
movzbl 0x2(%r11,%rdx,4), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r8d, %r8d
addl %edi, %r8d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r8d, %eax
movb %ah, (%rcx,%rdx,2)
movb 0x3(%r11,%rdx,4), %al
movb %al, 0x1(%rcx,%rdx,2)
incq %rdx
cmpl %edx, %esi
jne 0x1c4f1
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
addq 0x30(%rsp), %rdx
xorl %ecx, %ecx
movb (%r11,%rcx,2), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
incq %rcx
addq $0x3, %rdx
cmpl %ecx, %esi
jne 0x1c546
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %ecx, %ecx
movb (%r11,%rcx,2), %al
movb %al, -0x1(%rdi,%rcx,4)
movb %al, -0x2(%rdi,%rcx,4)
movb %al, -0x3(%rdi,%rcx,4)
movb 0x1(%r11,%rcx,2), %al
movb %al, (%rdi,%rcx,4)
incq %rcx
cmpl %ecx, %esi
jne 0x1c56f
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %eax, %eax
movb (%r11,%rax,2), %dl
movb %dl, (%rcx,%rax)
incq %rax
cmpl %eax, %esi
jne 0x1c5a0
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %eax, %eax
movb (%r11,%rax), %cl
movb %cl, -0x1(%rdi,%rax,4)
movb %cl, -0x2(%rdi,%rax,4)
movb %cl, -0x3(%rdi,%rax,4)
movb $-0x1, (%rdi,%rax,4)
incq %rax
cmpl %eax, %esi
jne 0x1c5c0
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
addq 0x30(%rsp), %rdx
xorl %ecx, %ecx
movb (%r11,%rcx), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
incq %rcx
addq $0x3, %rdx
cmpl %ecx, %esi
jne 0x1c5f2
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %edx, %edx
movzbl (%r8), %edi
movzbl 0x1(%r8), %r9d
movzbl 0x2(%r8), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r9d, %r9d
addl %edi, %r9d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r9d, %eax
movb %ah, (%rcx,%rdx)
incq %rdx
addq $0x3, %r8
cmpl %edx, %esi
jne 0x1c61b
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %edx, %edx
movzbl (%r8), %edi
movzbl 0x1(%r8), %r9d
movzbl 0x2(%r8), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r9d, %r9d
addl %edi, %r9d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r9d, %eax
movb %ah, (%rcx,%rdx,2)
movb $-0x1, 0x1(%rcx,%rdx,2)
incq %rdx
addq $0x3, %r8
cmpl %edx, %esi
jne 0x1c663
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %edx, %edx
movzbl (%r11,%rdx,4), %edi
movzbl 0x1(%r11,%rdx,4), %r8d
movzbl 0x2(%r11,%rdx,4), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r8d, %r8d
addl %edi, %r8d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r8d, %eax
movb %ah, (%rcx,%rdx)
incq %rdx
cmpl %edx, %esi
jne 0x1c6b0
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
xorl %edx, %edx
movb (%r8), %al
movb %al, (%rcx,%rdx,4)
movb 0x1(%r8), %al
movb %al, 0x1(%rcx,%rdx,4)
movb 0x2(%r8), %al
movb %al, 0x2(%rcx,%rdx,4)
movb $-0x1, 0x3(%rcx,%rdx,4)
incq %rdx
addq $0x3, %r8
cmpl %edx, %esi
jne 0x1c6f0
jmp 0x1c750
cmpl $0x0, 0xc(%rsp)
js 0x1c750
imull 0x28(%rsp), %r9d
addq 0x10(%rsp), %r9
xorl %ecx, %ecx
movb (%r11,%rcx,4), %al
movb %al, (%r9)
movb 0x1(%r11,%rcx,4), %al
movb %al, 0x1(%r9)
movb 0x2(%r11,%rcx,4), %al
movb %al, 0x2(%r9)
incq %rcx
addq $0x3, %r9
cmpl %ecx, %esi
jne 0x1c72c
incq %r13
addl 0x24(%rsp), %ebp
addl 0x20(%rsp), %r10d
cmpq 0x40(%rsp), %r13
jne 0x1c47f
movq %rbx, %rdi
callq 0x83e0
movq 0x10(%rsp), %rbx
jmp 0x1c78e
movq %rbx, %rdi
callq 0x83e0
leaq 0x4812(%rip), %rax      # 0x20f97
movq %rax, 0xac5c(%rip)      # 0x273e8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4c02(%rip), %rdi      # 0x213a9
leaq 0x48b9(%rip), %rsi      # 0x21067
leaq 0x4c13(%rip), %rcx      # 0x213c8
movl $0x52c, %edx            # imm = 0x52C
callq 0x8200
leaq 0x4f00(%rip), %rdi      # 0x216c6
leaq 0x489a(%rip), %rsi      # 0x21067
leaq 0x4bf4(%rip), %rcx      # 0x213c8
movl $0x549, %edx            # imm = 0x549
callq 0x8200