// File: /workspace/github_cpp_makefile_star2_O3/alan0201tw[P]RayTracer/include/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_mad3(req_comp, x, y, 0);
   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 STBI__COMBO(a,b)  ((a)*8+(b))
      #define STBI__CASE(a,b)   case STBI__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 (STBI__COMBO(img_n, req_comp)) {
         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255;                                     } break;
         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255;                     } break;
         STBI__CASE(2,1) { dest[0]=src[0];                                                  } break;
         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                  } break;
         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255;        } break;
         STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
         STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255;    } break;
         STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
         STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break;
         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                    } break;
         default: STBI_ASSERT(0);
      }
      #undef STBI__CASE
   }

   STBI_FREE(data);
   return good;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq %rsi, 0x18(%rsp)
cmpl %esi, %edx
je 0x34131
movl %edx, %r15d
leal -0x1(%r15), %eax
cmpl $0x4, %eax
jae 0x34143
movl %r8d, %ebp
movl %ecx, %r14d
movl %r15d, %edi
movl %ecx, %esi
movl %r8d, %edx
xorl %ecx, %ecx
callq 0x31ec4
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x34119
movq %r15, 0x28(%rsp)
testl %ebp, %ebp
jle 0x3410a
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %rax
leal (%rcx,%rax,8), %r13d
cmpl $0x23, %r13d
ja 0x34162
movabsq $0xe161a1c00, %rax      # imm = 0xE161A1C00
btq %r13, %rax
jae 0x34162
leal -0x1(%r14), %eax
movl %eax, 0xc(%rsp)
movl %ebp, %eax
movq %rax, 0x40(%rsp)
movl %r14d, %esi
movl %r14d, %eax
imull %ecx, %eax
movl %eax, 0x24(%rsp)
movl %r14d, %eax
imull 0x18(%rsp), %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 %r11d, %r11d
addl $-0xa, %r13d
xorl %r10d, %r10d
xorl %r8d, %r8d
leaq 0x9894(%rip), %r12      # 0x3d6c0
movl %r11d, %ebp
addq %rbx, %rbp
movl %r8d, %r15d
imull %r14d, %r15d
cmpl $0x18, %r13d
ja 0x340bc
movl %r10d, %edx
movq 0x10(%rsp), %rax
leaq (%rax,%rdx), %rcx
movq 0x38(%rsp), %rax
leaq (%rax,%rdx), %rdi
movl %r15d, %r9d
imull 0x18(%rsp), %r9d
addq %rbx, %r9
movslq (%r12,%r13,4), %rax
addq %r12, %rax
jmpq *%rax
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %eax, %eax
movb (%rbp,%rax), %dl
movb %dl, (%rcx,%rax,2)
movb $-0x1, 0x1(%rcx,%rax,2)
incq %rax
cmpl %eax, %esi
jne 0x33e7a
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %edx, %edx
movzbl (%rbp,%rdx,4), %edi
movzbl 0x1(%rbp,%rdx,4), %r9d
movzbl 0x2(%rbp,%rdx,4), %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 0x3(%rbp,%rdx,4), %al
movb %al, 0x1(%rcx,%rdx,2)
incq %rdx
cmpl %edx, %esi
jne 0x33e9f
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
addq 0x30(%rsp), %rdx
xorl %ecx, %ecx
movb (%rbp,%rcx,2), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
incq %rcx
addq $0x3, %rdx
cmpl %ecx, %esi
jne 0x33ef2
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %ecx, %ecx
movb (%rbp,%rcx,2), %al
movb %al, -0x1(%rdi,%rcx,4)
movb %al, -0x2(%rdi,%rcx,4)
movb %al, -0x3(%rdi,%rcx,4)
movb 0x1(%rbp,%rcx,2), %al
movb %al, (%rdi,%rcx,4)
incq %rcx
cmpl %ecx, %esi
jne 0x33f1b
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %eax, %eax
movb (%rbp,%rax,2), %dl
movb %dl, (%rcx,%rax)
incq %rax
cmpl %eax, %esi
jne 0x33f4b
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %eax, %eax
movb (%rbp,%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 0x33f6b
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
addq 0x30(%rsp), %rdx
xorl %ecx, %ecx
movb (%rbp,%rcx), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
incq %rcx
addq $0x3, %rdx
cmpl %ecx, %esi
jne 0x33f9d
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %edx, %edx
movzbl (%r9), %edi
movzbl 0x1(%r9), %ebp
movzbl 0x2(%r9), %eax
imull $0x4d, %edi, %edi
imull $0x96, %ebp, %ebp
addl %edi, %ebp
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %ebp, %eax
movb %ah, (%rcx,%rdx)
incq %rdx
addq $0x3, %r9
cmpl %edx, %esi
jne 0x33fc6
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %edx, %edx
movzbl (%r9), %edi
movzbl 0x1(%r9), %ebp
movzbl 0x2(%r9), %eax
imull $0x4d, %edi, %edi
imull $0x96, %ebp, %ebp
addl %edi, %ebp
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %ebp, %eax
movb %ah, (%rcx,%rdx,2)
movb $-0x1, 0x1(%rcx,%rdx,2)
incq %rdx
addq $0x3, %r9
cmpl %edx, %esi
jne 0x3400b
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %edx, %edx
movzbl (%rbp,%rdx,4), %edi
movzbl 0x1(%rbp,%rdx,4), %r9d
movzbl 0x2(%rbp,%rdx,4), %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
cmpl %edx, %esi
jne 0x34055
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
xorl %edx, %edx
movb (%r9), %al
movb %al, (%rcx,%rdx,4)
movb 0x1(%r9), %al
movb %al, 0x1(%rcx,%rdx,4)
movb 0x2(%r9), %al
movb %al, 0x2(%rcx,%rdx,4)
movb $-0x1, 0x3(%rcx,%rdx,4)
incq %rdx
addq $0x3, %r9
cmpl %edx, %esi
jne 0x34094
jmp 0x340f2
cmpl $0x0, 0xc(%rsp)
js 0x340f2
imull 0x28(%rsp), %r15d
addq 0x10(%rsp), %r15
xorl %ecx, %ecx
movb (%rbp,%rcx,4), %al
movb %al, (%r15)
movb 0x1(%rbp,%rcx,4), %al
movb %al, 0x1(%r15)
movb 0x2(%rbp,%rcx,4), %al
movb %al, 0x2(%r15)
incq %rcx
addq $0x3, %r15
cmpl %ecx, %esi
jne 0x340d0
incq %r8
addl 0x24(%rsp), %r10d
addl 0x20(%rsp), %r11d
cmpq 0x40(%rsp), %r8
jne 0x33e2c
movq %rbx, %rdi
callq 0x6490
movq 0x10(%rsp), %rbx
jmp 0x34131
movq %rbx, %rdi
callq 0x6490
leaq 0xb864(%rip), %rax      # 0x3f98c
movq %rax, 0x1b399(%rip)     # 0x4f4c8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbc8a(%rip), %rdi      # 0x3fdd4
leaq 0xb6c2(%rip), %rsi      # 0x3f813
leaq 0xbc9b(%rip), %rcx      # 0x3fdf3
movl $0x633, %edx            # imm = 0x633
callq 0x6250
leaq 0xc0b7(%rip), %rdi      # 0x40220
leaq 0xb6a3(%rip), %rsi      # 0x3f813
leaq 0xbc7c(%rip), %rcx      # 0x3fdf3
movl $0x650, %edx            # imm = 0x650
callq 0x6250