// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %rdi, %r14
movq %rsi, 0x20(%rsp)
cmpl %esi, %edx
jne 0x2a23f
movq %r14, %rax
jmp 0x2a5bf
movl %edx, %r12d
leal -0x1(%r12), %eax
cmpl $0x4, %eax
jae 0x2a5ed
movl %r8d, %r13d
movl %ecx, %r8d
xorl %r15d, %r15d
movl %r12d, %edi
movl %ecx, %esi
movl %r13d, %edx
xorl %ecx, %ecx
movq %r8, %rbx
callq 0x28eb4
testq %rax, %rax
je 0x2a5a7
testl %r13d, %r13d
cmovlel %r15d, %r13d
movq 0x20(%rsp), %rcx
leal (%r12,%rcx,8), %ebp
leal -0x1(%rbx), %edx
movl %edx, 0x4(%rsp)
movl %ebx, %edx
imull %ecx, %edx
movl %edx, 0xc(%rsp)
movq %rbx, %rcx
movq %rbx, 0x30(%rsp)
imull %r12d, %ecx
movl %ecx, 0x8(%rsp)
leaq 0x3(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq %rax, 0x18(%rsp)
leaq 0x2(%rax), %rcx
movq %rcx, 0x10(%rsp)
addl $-0xa, %ebp
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpq %r13, %r11
je 0x2a598
cmpl $0x19, %ebp
ja 0x2a5ce
movq %r13, %rbx
movl %r10d, %r9d
addq %r14, %r9
movl %r15d, %edx
movq 0x18(%rsp), %rax
leaq (%rax,%rdx), %rdi
movq 0x28(%rsp), %rcx
leaq (%rcx,%rdx), %rsi
movl %r11d, %ecx
imull 0x30(%rsp), %ecx
movl %ecx, %r8d
imull 0x20(%rsp), %r8d
addq %r14, %r8
imull %r12d, %ecx
addq %rax, %rcx
leaq 0x729a(%rip), %rax      # 0x315b0
movslq (%rax,%rbp,4), %r13
addq %rax, %r13
jmpq *%r13
xorl %ecx, %ecx
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movb (%r9,%rcx), %sil
movb %sil, (%rdi,%rcx,2)
movb $-0x1, 0x1(%rdi,%rcx,2)
decl %edx
incq %rcx
jmp 0x2a329
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movb (%r8), %sil
movb %sil, (%rcx)
movb 0x1(%r8), %sil
movb %sil, 0x1(%rcx)
movb 0x2(%r8), %sil
movb %sil, 0x2(%rcx)
addq $0x4, %r8
addq $0x3, %rcx
decl %edx
jmp 0x2a34c
xorl %ecx, %ecx
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movzbl (%r9,%rcx,4), %esi
movzbl 0x1(%r9,%rcx,4), %r8d
movzbl 0x2(%r9,%rcx,4), %ebx
imull $0x4d, %esi, %esi
imull $0x96, %r8d, %r8d
addl %esi, %r8d
imull $0x1d, %ebx, %ebx
addl %r8d, %ebx
movb %bh, (%rdi,%rcx)
decl %edx
incq %rcx
jmp 0x2a37f
xorl %ecx, %ecx
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movzbl (%r9,%rcx,2), %esi
movzbl 0x1(%r9,%rcx,2), %r8d
movzbl 0x2(%r9,%rcx,2), %ebx
imull $0x4d, %esi, %esi
imull $0x96, %r8d, %r8d
addl %esi, %r8d
imull $0x1d, %ebx, %ebx
addl %r8d, %ebx
movb %bh, (%rdi,%rcx)
movb 0x3(%r9,%rcx,2), %sil
movb %sil, 0x1(%rdi,%rcx)
decl %edx
addq $0x2, %rcx
jmp 0x2a3be
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movb (%r8), %sil
movb %sil, (%rcx)
movb 0x1(%r8), %sil
movb %sil, 0x1(%rcx)
movb 0x2(%r8), %sil
movb %sil, 0x2(%rcx)
movb $-0x1, 0x3(%rcx)
addq $0x3, %r8
addq $0x4, %rcx
decl %edx
jmp 0x2a406
addq 0x10(%rsp), %rdx
movl 0x4(%rsp), %ecx
movq %rbx, %r13
testl %ecx, %ecx
js 0x2a586
movb (%r8), %sil
movb %sil, (%rdx)
movb %sil, -0x1(%rdx)
movb %sil, -0x2(%rdx)
addq $0x2, %r8
decl %ecx
addq $0x3, %rdx
jmp 0x2a440
addq 0x10(%rsp), %rdx
movl 0x4(%rsp), %ecx
movq %rbx, %r13
testl %ecx, %ecx
js 0x2a586
movb (%r8), %sil
movb %sil, (%rdx)
movb %sil, -0x1(%rdx)
movb %sil, -0x2(%rdx)
incq %r8
decl %ecx
addq $0x3, %rdx
jmp 0x2a46e
xorl %ecx, %ecx
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movb (%r9,%rcx), %dil
movb %dil, -0x1(%rsi,%rcx,2)
movb %dil, -0x2(%rsi,%rcx,2)
movb %dil, -0x3(%rsi,%rcx,2)
movb 0x1(%r9,%rcx), %dil
movb %dil, (%rsi,%rcx,2)
decl %edx
addq $0x2, %rcx
jmp 0x2a498
xorl %ecx, %ecx
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movb (%r9,%rcx), %dil
movb %dil, -0x1(%rsi,%rcx,4)
movb %dil, -0x2(%rsi,%rcx,4)
movb %dil, -0x3(%rsi,%rcx,4)
movb $-0x1, (%rsi,%rcx,4)
decl %edx
incq %rcx
jmp 0x2a4cd
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movzbl (%r8), %esi
movzbl 0x1(%r8), %edi
movzbl 0x2(%r8), %r9d
imull $0x4d, %esi, %esi
imull $0x96, %edi, %edi
addl %esi, %edi
imull $0x1d, %r9d, %ebx
addl %edi, %ebx
movb %bh, (%rcx)
movb $-0x1, 0x1(%rcx)
addq $0x3, %r8
addq $0x2, %rcx
decl %edx
jmp 0x2a4fa
xorl %ecx, %ecx
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movb (%r9,%rcx,2), %sil
movb %sil, (%rdi,%rcx)
decl %edx
incq %rcx
jmp 0x2a53c
movl 0x4(%rsp), %edx
movq %rbx, %r13
testl %edx, %edx
js 0x2a586
movzbl (%r8), %esi
movzbl 0x1(%r8), %edi
movzbl 0x2(%r8), %r9d
imull $0x4d, %esi, %esi
imull $0x96, %edi, %edi
addl %esi, %edi
imull $0x1d, %r9d, %ebx
addl %edi, %ebx
movb %bh, (%rcx)
addq $0x3, %r8
incq %rcx
decl %edx
jmp 0x2a556
incq %r11
addl 0xc(%rsp), %r10d
addl 0x8(%rsp), %r15d
jmp 0x2a2c4
movq %r14, %rdi
callq 0x64d0
movq 0x18(%rsp), %rax
jmp 0x2a5bf
movq %r14, %rdi
callq 0x64d0
leaq 0x92de(%rip), %rax      # 0x33894
movq %rax, 0x1df5b(%rip)     # 0x48518
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9b53(%rip), %rdi      # 0x34128
leaq 0x913f(%rip), %rsi      # 0x3371b
leaq 0x9718(%rip), %rcx      # 0x33cfb
movl $0x650, %edx            # imm = 0x650
callq 0x6280
leaq 0x96e8(%rip), %rdi      # 0x33cdc
leaq 0x9120(%rip), %rsi      # 0x3371b
leaq 0x96f9(%rip), %rcx      # 0x33cfb
movl $0x633, %edx            # imm = 0x633
callq 0x6280