// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %rdi, %r14
movq %rsi, 0x18(%rsp)
cmpl %esi, %edx
jne 0x156e3
movq %r14, %rbp
jmp 0x15a55
movl %edx, %r15d
leal -0x1(%r15), %eax
cmpl $0x4, %eax
jae 0x15a86
movl %r8d, %r13d
movl %ecx, %ebx
movl %ecx, %eax
imull %r15d, %eax
movl %eax, 0xc(%rsp)
movl %eax, %edi
imull %r8d, %edi
callq 0x8420
testq %rax, %rax
je 0x15a3d
movq %rax, %rbp
movq %r15, 0x28(%rsp)
movq 0x18(%rsp), %rdx
leal (%r15,%rdx,8), %r12d
xorl %ecx, %ecx
testl %r13d, %r13d
cmovlel %ecx, %r13d
leal -0x1(%rbx), %eax
movl %eax, 0x4(%rsp)
movq %rbx, %rax
movq %rbx, 0x30(%rsp)
imull %edx, %eax
movl %eax, 0x8(%rsp)
leaq 0x3(%rbp), %rax
movq %rax, 0x20(%rsp)
leaq 0x2(%rbp), %rax
movq %rax, 0x10(%rsp)
addl $-0xa, %r12d
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpq %r13, %r11
je 0x15a33
cmpl $0x19, %r12d
ja 0x15a67
movq %r13, %rax
movl %r10d, %r9d
addq %r14, %r9
movl %ecx, %esi
leaq (%rsi,%rbp), %rdx
movq 0x20(%rsp), %rdi
leaq (%rdi,%rsi), %r15
movl %r11d, %edi
imull 0x30(%rsp), %edi
movl %edi, %r8d
imull 0x18(%rsp), %r8d
addq %r14, %r8
imull 0x28(%rsp), %edi
addq %rbp, %rdi
leaq 0x3150(%rip), %rbx      # 0x18900
movslq (%rbx,%r12,4), %r13
addq %rbx, %r13
jmpq *%r13
xorl %esi, %esi
movl 0x4(%rsp), %edi
movq %rax, %r13
testl %edi, %edi
js 0x15a22
movb (%r9,%rsi), %r8b
movb %r8b, (%rdx,%rsi,2)
movb $-0x1, 0x1(%rdx,%rsi,2)
decl %edi
incq %rsi
jmp 0x157c3
movl 0x4(%rsp), %edx
movq %rax, %r13
testl %edx, %edx
js 0x15a22
movb (%r8), %al
movb %al, (%rdi)
movb 0x1(%r8), %al
movb %al, 0x1(%rdi)
movb 0x2(%r8), %al
movb %al, 0x2(%rdi)
addq $0x4, %r8
addq $0x3, %rdi
decl %edx
jmp 0x157e6
xorl %esi, %esi
movl 0x4(%rsp), %edi
movq %rax, %r13
testl %edi, %edi
js 0x15a22
movzbl (%r9,%rsi,4), %r8d
movzbl 0x1(%r9,%rsi,4), %ebx
movzbl 0x2(%r9,%rsi,4), %r15d
imull $0x4d, %r8d, %r8d
imull $0x96, %ebx, %ebx
addl %r8d, %ebx
imull $0x1d, %r15d, %eax
addl %ebx, %eax
movb %ah, (%rdx,%rsi)
decl %edi
incq %rsi
jmp 0x15816
xorl %esi, %esi
movl 0x4(%rsp), %edi
movq %rax, %r13
testl %edi, %edi
js 0x15a22
movzbl (%r9,%rsi,2), %eax
movzbl 0x1(%r9,%rsi,2), %r8d
movzbl 0x2(%r9,%rsi,2), %ebx
imull $0x4d, %eax, %eax
imull $0x96, %r8d, %r8d
addl %eax, %r8d
imull $0x1d, %ebx, %eax
addl %r8d, %eax
movb %ah, (%rdx,%rsi)
movb 0x3(%r9,%rsi,2), %al
movb %al, 0x1(%rdx,%rsi)
decl %edi
addq $0x2, %rsi
jmp 0x15855
movl 0x4(%rsp), %edx
movq %rax, %r13
testl %edx, %edx
js 0x15a22
movb (%r8), %sil
movb %sil, (%rdi)
movb 0x1(%r8), %sil
movb %sil, 0x1(%rdi)
movb 0x2(%r8), %sil
movb %sil, 0x2(%rdi)
movb $-0x1, 0x3(%rdi)
addq $0x3, %r8
addq $0x4, %rdi
decl %edx
jmp 0x1589c
addq 0x10(%rsp), %rsi
movl 0x4(%rsp), %edx
movq %rax, %r13
testl %edx, %edx
js 0x15a22
movb (%r8), %dil
movb %dil, (%rsi)
movb %dil, -0x1(%rsi)
movb %dil, -0x2(%rsi)
addq $0x2, %r8
decl %edx
addq $0x3, %rsi
jmp 0x158d6
addq 0x10(%rsp), %rsi
movl 0x4(%rsp), %edx
movq %rax, %r13
testl %edx, %edx
js 0x15a22
movb (%r8), %dil
movb %dil, (%rsi)
movb %dil, -0x1(%rsi)
movb %dil, -0x2(%rsi)
incq %r8
decl %edx
addq $0x3, %rsi
jmp 0x15904
xorl %edx, %edx
movl 0x4(%rsp), %esi
movq %rax, %r13
testl %esi, %esi
js 0x15a22
movb (%r9,%rdx), %dil
movb %dil, -0x1(%r15,%rdx,2)
movb %dil, -0x2(%r15,%rdx,2)
movb %dil, -0x3(%r15,%rdx,2)
movb 0x1(%r9,%rdx), %dil
movb %dil, (%r15,%rdx,2)
decl %esi
addq $0x2, %rdx
jmp 0x1592e
xorl %edx, %edx
movl 0x4(%rsp), %esi
movq %rax, %r13
testl %esi, %esi
js 0x15a22
movb (%r9,%rdx), %dil
movb %dil, -0x1(%r15,%rdx,4)
movb %dil, -0x2(%r15,%rdx,4)
movb %dil, -0x3(%r15,%rdx,4)
movb $-0x1, (%r15,%rdx,4)
decl %esi
incq %rdx
jmp 0x15963
movl 0x4(%rsp), %edx
movq %rax, %r13
testl %edx, %edx
js 0x15a22
movzbl (%r8), %esi
movzbl 0x1(%r8), %r9d
movzbl 0x2(%r8), %ebx
imull $0x4d, %esi, %esi
imull $0x96, %r9d, %r9d
addl %esi, %r9d
imull $0x1d, %ebx, %ebx
addl %r9d, %ebx
movb %bh, (%rdi)
movb $-0x1, 0x1(%rdi)
addq $0x3, %r8
addq $0x2, %rdi
decl %edx
jmp 0x15991
xorl %esi, %esi
movl 0x4(%rsp), %edi
movq %rax, %r13
testl %edi, %edi
js 0x15a22
movb (%r9,%rsi,2), %r8b
movb %r8b, (%rdx,%rsi)
decl %edi
incq %rsi
jmp 0x159d5
movl 0x4(%rsp), %edx
movq %rax, %r13
testl %edx, %edx
js 0x15a22
movzbl (%r8), %esi
movzbl 0x1(%r8), %r9d
movzbl 0x2(%r8), %r15d
imull $0x4d, %esi, %esi
imull $0x96, %r9d, %r9d
addl %esi, %r9d
imull $0x1d, %r15d, %ebx
addl %r9d, %ebx
movb %bh, (%rdi)
addq $0x3, %r8
incq %rdi
decl %edx
jmp 0x159ef
incq %r11
addl 0x8(%rsp), %r10d
addl 0xc(%rsp), %ecx
jmp 0x15762
movq %r14, %rdi
callq 0x83d0
jmp 0x15a55
movq %r14, %rdi
callq 0x83d0
leaq 0x344b(%rip), %rax      # 0x18e97
movq %rax, 0xa9b5(%rip)      # 0x20408
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b58(%rip), %rdi      # 0x195c6
leaq 0x34f2(%rip), %rsi      # 0x18f67
leaq 0x384c(%rip), %rcx      # 0x192c8
movl $0x549, %edx            # imm = 0x549
callq 0x8210
leaq 0x381c(%rip), %rdi      # 0x192a9
leaq 0x34d3(%rip), %rsi      # 0x18f67
leaq 0x382d(%rip), %rcx      # 0x192c8
movl $0x52c, %edx            # imm = 0x52C
callq 0x8210