// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rsi, 0x8(%rsp)
cmpl %esi, %edx
je 0x1d2a6
movl %edx, %r15d
leal -0x1(%r15), %eax
cmpl $0x4, %eax
jae 0x1d2b8
movl %r8d, %ebp
movl %ecx, %r14d
movl %ecx, %eax
imull %r15d, %eax
movl %eax, 0x14(%rsp)
movl %eax, %edi
imull %r8d, %edi
callq 0x8430
testq %rax, %rax
je 0x1d28e
movq %rax, %r12
testl %ebp, %ebp
jle 0x1d281
movq 0x8(%rsp), %rax
leal (%r15,%rax,8), %ecx
cmpl $0x23, %ecx
ja 0x1d2d7
movabsq $0xe161a1c00, %rax      # imm = 0xE161A1C00
btq %rcx, %rax
jae 0x1d2d7
leal -0x1(%r14), %eax
movl %eax, 0x4(%rsp)
cmpl $0x2, %ebp
movl $0x1, %eax
cmovgel %ebp, %eax
movq %rax, 0x30(%rsp)
movl %r14d, %eax
imull 0x8(%rsp), %eax
movl %eax, 0x10(%rsp)
leaq 0x3(%r12), %rax
movq %rax, 0x28(%rsp)
leaq 0x2(%r12), %rax
movq %rax, 0x18(%rsp)
xorl %r9d, %r9d
addl $-0xa, %ecx
xorl %r11d, %r11d
xorl %edi, %edi
movq %rcx, 0x20(%rsp)
leaq 0x4a74(%rip), %r13      # 0x219e0
movl %edi, %ebp
imull %r14d, %ebp
movl %ebp, %r8d
imull 0x8(%rsp), %r8d
addq %rbx, %r8
imull %r15d, %ebp
addq %r12, %rbp
cmpl $0x18, %ecx
ja 0x1d238
movl %r11d, %edx
leaq (%r12,%rdx), %rcx
movl %r9d, %r10d
addq %rbx, %r10
movq 0x28(%rsp), %rax
leaq (%rax,%rdx), %rsi
movq 0x20(%rsp), %rax
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
cmpl $0x0, 0x4(%rsp)
js 0x1d264
xorl %edx, %edx
movl %r14d, %eax
movb (%r10,%rdx), %sil
movb %sil, (%rcx,%rdx,2)
movb $-0x1, 0x1(%rcx,%rdx,2)
decl %eax
incq %rdx
testl %eax, %eax
jg 0x1cfc3
jmp 0x1d264
cmpl $0x0, 0x4(%rsp)
js 0x1d264
xorl %edx, %edx
movl %r14d, %esi
movzbl (%r10,%rdx,2), %r8d
movzbl 0x1(%r10,%rdx,2), %ebp
movzbl 0x2(%r10,%rdx,2), %eax
imull $0x4d, %r8d, %r8d
imull $0x96, %ebp, %ebp
addl %r8d, %ebp
leal (%rax,%rax,8), %r8d
leal (%r8,%r8,2), %r8d
addl %eax, %eax
addl %r8d, %eax
addl %ebp, %eax
movb %ah, (%rcx,%rdx)
movb 0x3(%r10,%rdx,2), %al
movb %al, 0x1(%rcx,%rdx)
decl %esi
addq $0x2, %rdx
testl %esi, %esi
jg 0x1cfee
jmp 0x1d264
cmpl $0x0, 0x4(%rsp)
js 0x1d264
addq 0x18(%rsp), %rdx
movl %r14d, %ecx
movb (%r8), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
addq $0x2, %r8
decl %ecx
addq $0x3, %rdx
testl %ecx, %ecx
jg 0x1d049
jmp 0x1d264
cmpl $0x0, 0x4(%rsp)
js 0x1d264
xorl %ecx, %ecx
movl %r14d, %edx
movb (%r10,%rcx), %al
movb %al, -0x1(%rsi,%rcx,2)
movb %al, -0x2(%rsi,%rcx,2)
movb %al, -0x3(%rsi,%rcx,2)
movb 0x1(%r10,%rcx), %al
movb %al, (%rsi,%rcx,2)
decl %edx
addq $0x2, %rcx
testl %edx, %edx
jg 0x1d077
jmp 0x1d264
cmpl $0x0, 0x4(%rsp)
js 0x1d264
xorl %edx, %edx
movl %r14d, %eax
movb (%r10,%rdx,2), %sil
movb %sil, (%rcx,%rdx)
decl %eax
incq %rdx
testl %eax, %eax
jg 0x1d0ae
jmp 0x1d264
cmpl $0x0, 0x4(%rsp)
js 0x1d264
xorl %ecx, %ecx
movl %r14d, %edx
movb (%r10,%rcx), %al
movb %al, -0x1(%rsi,%rcx,4)
movb %al, -0x2(%rsi,%rcx,4)
movb %al, -0x3(%rsi,%rcx,4)
movb $-0x1, (%rsi,%rcx,4)
decl %edx
incq %rcx
testl %edx, %edx
jg 0x1d0d4
jmp 0x1d264
cmpl $0x0, 0x4(%rsp)
js 0x1d264
addq 0x18(%rsp), %rdx
movl %r14d, %ecx
movb (%r8), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
incq %r8
decl %ecx
addq $0x3, %rdx
testl %ecx, %ecx
jg 0x1d109
jmp 0x1d264
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x1d264
movzbl (%r8), %edx
movzbl 0x1(%r8), %esi
movzbl 0x2(%r8), %eax
imull $0x4d, %edx, %edx
imull $0x96, %esi, %esi
addl %edx, %esi
leal (%rax,%rax,8), %edx
leal (%rdx,%rdx,2), %edx
addl %eax, %eax
addl %edx, %eax
addl %esi, %eax
movb %ah, (%rbp)
addq $0x3, %r8
incq %rbp
decl %ecx
testl %ecx, %ecx
jg 0x1d134
jmp 0x1d264
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x1d264
movzbl (%r8), %edx
movzbl 0x1(%r8), %esi
movzbl 0x2(%r8), %eax
imull $0x4d, %edx, %edx
imull $0x96, %esi, %esi
addl %edx, %esi
leal (%rax,%rax,8), %edx
leal (%rdx,%rdx,2), %edx
addl %eax, %eax
addl %edx, %eax
addl %esi, %eax
movb %ah, (%rbp)
movb $-0x1, 0x1(%rbp)
addq $0x3, %r8
addq $0x2, %rbp
decl %ecx
testl %ecx, %ecx
jg 0x1d17c
jmp 0x1d264
cmpl $0x0, 0x4(%rsp)
js 0x1d264
xorl %edx, %edx
movl %r14d, %esi
movzbl (%r10,%rdx,4), %r8d
movzbl 0x1(%r10,%rdx,4), %ebp
movzbl 0x2(%r10,%rdx,4), %eax
imull $0x4d, %r8d, %r8d
imull $0x96, %ebp, %ebp
addl %r8d, %ebp
leal (%rax,%rax,8), %r8d
leal (%r8,%r8,2), %r8d
addl %eax, %eax
addl %r8d, %eax
addl %ebp, %eax
movb %ah, (%rcx,%rdx)
decl %esi
incq %rdx
testl %esi, %esi
jg 0x1d1cb
jmp 0x1d264
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x1d264
movb (%r8), %al
movb %al, (%rbp)
movb 0x1(%r8), %al
movb %al, 0x1(%rbp)
movb 0x2(%r8), %al
movb %al, 0x2(%rbp)
movb $-0x1, 0x3(%rbp)
addq $0x3, %r8
addq $0x4, %rbp
decl %ecx
testl %ecx, %ecx
jg 0x1d210
jmp 0x1d264
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x1d264
movb (%r8), %al
movb %al, (%rbp)
movb 0x1(%r8), %al
movb %al, 0x1(%rbp)
movb 0x2(%r8), %al
movb %al, 0x2(%rbp)
addq $0x4, %r8
addq $0x3, %rbp
decl %ecx
testl %ecx, %ecx
jg 0x1d242
incq %rdi
addl 0x14(%rsp), %r11d
addl 0x10(%rsp), %r9d
cmpq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rcx
jne 0x1cf6c
movq %rbx, %rdi
callq 0x83f0
movq %r12, %rbx
jmp 0x1d2a6
movq %rbx, %rdi
callq 0x83f0
leaq 0x4cea(%rip), %rax      # 0x21f87
movq %rax, 0xb164(%rip)      # 0x28408
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50da(%rip), %rdi      # 0x22399
leaq 0x4d91(%rip), %rsi      # 0x22057
leaq 0x50eb(%rip), %rcx      # 0x223b8
movl $0x52c, %edx            # imm = 0x52C
callq 0x8210
leaq 0x53dc(%rip), %rdi      # 0x226ba
leaq 0x4d72(%rip), %rsi      # 0x22057
leaq 0x50cc(%rip), %rcx      # 0x223b8
movl $0x549, %edx            # imm = 0x549
callq 0x8210