// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rsi, 0x8(%rsp)
cmpl %esi, %edx
je 0x343fc
movl %edx, %r15d
leal -0x1(%r15), %eax
cmpl $0x4, %eax
jae 0x3440e
movl %r8d, %ebp
movl %ecx, %r14d
movl %r15d, %edi
movl %ecx, %esi
movl %r8d, %edx
xorl %ecx, %ecx
callq 0x32255
testq %rax, %rax
je 0x343e4
movq %rax, %r12
testl %ebp, %ebp
jle 0x343d7
movq 0x8(%rsp), %rax
leal (%r15,%rax,8), %ecx
cmpl $0x23, %ecx
ja 0x3442d
movabsq $0xe161a1c00, %rax      # imm = 0xE161A1C00
btq %rcx, %rax
jae 0x3442d
cmpl $0x2, %ebp
movl $0x1, %eax
cmovgel %ebp, %eax
movq %rax, 0x30(%rsp)
leal -0x1(%r14), %eax
movl %eax, 0x4(%rsp)
movl %r14d, %eax
imull %r15d, %eax
movl %eax, 0x14(%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 %r10d, %r10d
addl $-0xa, %ecx
xorl %ebp, %ebp
xorl %r9d, %r9d
movq %rcx, 0x20(%rsp)
leaq 0x9385(%rip), %r13      # 0x3d450
movl %r9d, %edx
imull %r14d, %edx
movl %edx, %r11d
imull 0x8(%rsp), %r11d
addq %rbx, %r11
imull %r15d, %edx
addq %r12, %rdx
cmpl $0x18, %ecx
ja 0x34390
movl %ebp, %esi
leaq (%r12,%rsi), %rcx
movl %r10d, %r8d
addq %rbx, %r8
movq 0x28(%rsp), %rax
leaq (%rax,%rsi), %rdi
movq 0x20(%rsp), %rax
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
cmpl $0x0, 0x4(%rsp)
js 0x343bb
xorl %edx, %edx
movl %r14d, %eax
movb (%r8,%rdx), %sil
movb %sil, (%rcx,%rdx,2)
movb $-0x1, 0x1(%rcx,%rdx,2)
decl %eax
incq %rdx
testl %eax, %eax
jg 0x34122
jmp 0x343bb
cmpl $0x0, 0x4(%rsp)
js 0x343bb
xorl %edx, %edx
movl %r14d, %esi
movzbl (%r8,%rdx,2), %edi
movzbl 0x1(%r8,%rdx,2), %r11d
movzbl 0x2(%r8,%rdx,2), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r11d, %r11d
addl %edi, %r11d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r11d, %eax
movb %ah, (%rcx,%rdx)
movb 0x3(%r8,%rdx,2), %al
movb %al, 0x1(%rcx,%rdx)
decl %esi
addq $0x2, %rdx
testl %esi, %esi
jg 0x3414d
jmp 0x343bb
cmpl $0x0, 0x4(%rsp)
js 0x343bb
addq 0x18(%rsp), %rsi
movl %r14d, %ecx
movb (%r11), %al
movb %al, (%rsi)
movb %al, -0x1(%rsi)
movb %al, -0x2(%rsi)
addq $0x2, %r11
decl %ecx
addq $0x3, %rsi
testl %ecx, %ecx
jg 0x341a6
jmp 0x343bb
cmpl $0x0, 0x4(%rsp)
js 0x343bb
xorl %ecx, %ecx
movl %r14d, %edx
movb (%r8,%rcx), %al
movb %al, -0x1(%rdi,%rcx,2)
movb %al, -0x2(%rdi,%rcx,2)
movb %al, -0x3(%rdi,%rcx,2)
movb 0x1(%r8,%rcx), %al
movb %al, (%rdi,%rcx,2)
decl %edx
addq $0x2, %rcx
testl %edx, %edx
jg 0x341d4
jmp 0x343bb
cmpl $0x0, 0x4(%rsp)
js 0x343bb
xorl %edx, %edx
movl %r14d, %eax
movb (%r8,%rdx,2), %sil
movb %sil, (%rcx,%rdx)
decl %eax
incq %rdx
testl %eax, %eax
jg 0x3420b
jmp 0x343bb
cmpl $0x0, 0x4(%rsp)
js 0x343bb
xorl %ecx, %ecx
movl %r14d, %edx
movb (%r8,%rcx), %al
movb %al, -0x1(%rdi,%rcx,4)
movb %al, -0x2(%rdi,%rcx,4)
movb %al, -0x3(%rdi,%rcx,4)
movb $-0x1, (%rdi,%rcx,4)
decl %edx
incq %rcx
testl %edx, %edx
jg 0x34231
jmp 0x343bb
cmpl $0x0, 0x4(%rsp)
js 0x343bb
addq 0x18(%rsp), %rsi
movl %r14d, %ecx
movb (%r11), %al
movb %al, (%rsi)
movb %al, -0x1(%rsi)
movb %al, -0x2(%rsi)
incq %r11
decl %ecx
addq $0x3, %rsi
testl %ecx, %ecx
jg 0x34266
jmp 0x343bb
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x343bb
movzbl (%r11), %esi
movzbl 0x1(%r11), %edi
movzbl 0x2(%r11), %eax
imull $0x4d, %esi, %esi
imull $0x96, %edi, %edi
addl %esi, %edi
leal (%rax,%rax,8), %esi
leal (%rsi,%rsi,2), %esi
addl %eax, %eax
addl %esi, %eax
addl %edi, %eax
movb %ah, (%rdx)
addq $0x3, %r11
incq %rdx
decl %ecx
testl %ecx, %ecx
jg 0x34291
jmp 0x343bb
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x343bb
movzbl (%r11), %esi
movzbl 0x1(%r11), %edi
movzbl 0x2(%r11), %eax
imull $0x4d, %esi, %esi
imull $0x96, %edi, %edi
addl %esi, %edi
leal (%rax,%rax,8), %esi
leal (%rsi,%rsi,2), %esi
addl %eax, %eax
addl %esi, %eax
addl %edi, %eax
movb %ah, (%rdx)
movb $-0x1, 0x1(%rdx)
addq $0x3, %r11
addq $0x2, %rdx
decl %ecx
testl %ecx, %ecx
jg 0x342d8
jmp 0x343bb
cmpl $0x0, 0x4(%rsp)
js 0x343bb
xorl %edx, %edx
movl %r14d, %esi
movzbl (%r8,%rdx,4), %edi
movzbl 0x1(%r8,%rdx,4), %r11d
movzbl 0x2(%r8,%rdx,4), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r11d, %r11d
addl %edi, %r11d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r11d, %eax
movb %ah, (%rcx,%rdx)
decl %esi
incq %rdx
testl %esi, %esi
jg 0x34326
jmp 0x343bb
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x343bb
movb (%r11), %al
movb %al, (%rdx)
movb 0x1(%r11), %al
movb %al, 0x1(%rdx)
movb 0x2(%r11), %al
movb %al, 0x2(%rdx)
movb $-0x1, 0x3(%rdx)
addq $0x3, %r11
addq $0x4, %rdx
decl %ecx
testl %ecx, %ecx
jg 0x34369
jmp 0x343bb
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x343bb
movb (%r11), %al
movb %al, (%rdx)
movb 0x1(%r11), %al
movb %al, 0x1(%rdx)
movb 0x2(%r11), %al
movb %al, 0x2(%rdx)
addq $0x4, %r11
addq $0x3, %rdx
decl %ecx
testl %ecx, %ecx
jg 0x3439a
incq %r9
addl 0x14(%rsp), %ebp
addl 0x10(%rsp), %r10d
cmpq 0x30(%rsp), %r9
movq 0x20(%rsp), %rcx
jne 0x340cb
movq %rbx, %rdi
callq 0x6490
movq %r12, %rbx
jmp 0x343fc
movq %rbx, %rdi
callq 0x6490
leaq 0xb331(%rip), %rax      # 0x3f724
movq %rax, 0x1b0ee(%rip)     # 0x4f4e8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb757(%rip), %rdi      # 0x3fb6c
leaq 0xb18f(%rip), %rsi      # 0x3f5ab
leaq 0xb768(%rip), %rcx      # 0x3fb8b
movl $0x633, %edx            # imm = 0x633
callq 0x6250
leaq 0xbb88(%rip), %rdi      # 0x3ffbc
leaq 0xb170(%rip), %rsi      # 0x3f5ab
leaq 0xb749(%rip), %rcx      # 0x3fb8b
movl $0x650, %edx            # imm = 0x650
callq 0x6250