// File: /workspace/github_cpp_makefile_star2_O3/srajangarg[P]raytracer/src/core/stb_image.hpp
// 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 $0x48, %rsp
movq %rcx, 0x18(%rsp)
movq %rdi, %rbx
cmpl %esi, %edx
je 0x209f6
movl %edx, %r14d
leal -0x1(%r14), %eax
cmpl $0x4, %eax
jae 0x20a08
movl %r8d, %ebp
movl %esi, %r12d
movq 0x18(%rsp), %rax
imull %r14d, %eax
movl %eax, 0x24(%rsp)
movl %eax, %edi
imull %r8d, %edi
callq 0x43f0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x209de
movq %r14, 0x28(%rsp)
testl %ebp, %ebp
jle 0x209cf
movq 0x28(%rsp), %rax
leal (%rax,%r12,8), %r14d
cmpl $0x23, %r14d
ja 0x20a27
movabsq $0xe161a1c00, %rax      # imm = 0xE161A1C00
btq %r14, %rax
jae 0x20a27
movq 0x18(%rsp), %rax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rsp)
movl %ebp, %ecx
movq %rcx, 0x40(%rsp)
movl %eax, %esi
imull %r12d, %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 %r10d, %r10d
addl $-0xa, %r14d
xorl %ebp, %ebp
xorl %r13d, %r13d
leaq 0xb679(%rip), %r15      # 0x2bd60
movl %r10d, %r11d
addq %rbx, %r11
movl %r13d, %r9d
imull 0x18(%rsp), %r9d
cmpl $0x18, %r14d
ja 0x20980
movl %ebp, %edx
movq 0x10(%rsp), %rax
leaq (%rax,%rdx), %rcx
movq 0x38(%rsp), %rax
leaq (%rax,%rdx), %rdi
movl %r9d, %r8d
imull %r12d, %r8d
addq %rbx, %r8
movslq (%r15,%r14,4), %rax
addq %r15, %rax
jmpq *%rax
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %eax, %eax
movb (%r11,%rax), %dl
movb %dl, (%rcx,%rax,2)
movb $-0x1, 0x1(%rcx,%rax,2)
incq %rax
cmpl %eax, %esi
jne 0x20734
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %edx, %edx
movzbl (%r11,%rdx,4), %edi
movzbl 0x1(%r11,%rdx,4), %r8d
movzbl 0x2(%r11,%rdx,4), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r8d, %r8d
addl %edi, %r8d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r8d, %eax
movb %ah, (%rcx,%rdx,2)
movb 0x3(%r11,%rdx,4), %al
movb %al, 0x1(%rcx,%rdx,2)
incq %rdx
cmpl %edx, %esi
jne 0x20759
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
addq 0x30(%rsp), %rdx
xorl %ecx, %ecx
movb (%r11,%rcx,2), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
incq %rcx
addq $0x3, %rdx
cmpl %ecx, %esi
jne 0x207ae
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %ecx, %ecx
movb (%r11,%rcx,2), %al
movb %al, -0x1(%rdi,%rcx,4)
movb %al, -0x2(%rdi,%rcx,4)
movb %al, -0x3(%rdi,%rcx,4)
movb 0x1(%r11,%rcx,2), %al
movb %al, (%rdi,%rcx,4)
incq %rcx
cmpl %ecx, %esi
jne 0x207d7
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %eax, %eax
movb (%r11,%rax,2), %dl
movb %dl, (%rcx,%rax)
incq %rax
cmpl %eax, %esi
jne 0x20808
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %eax, %eax
movb (%r11,%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 0x20828
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
addq 0x30(%rsp), %rdx
xorl %ecx, %ecx
movb (%r11,%rcx), %al
movb %al, (%rdx)
movb %al, -0x1(%rdx)
movb %al, -0x2(%rdx)
incq %rcx
addq $0x3, %rdx
cmpl %ecx, %esi
jne 0x2085a
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %edx, %edx
movzbl (%r8), %edi
movzbl 0x1(%r8), %r9d
movzbl 0x2(%r8), %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
addq $0x3, %r8
cmpl %edx, %esi
jne 0x20883
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %edx, %edx
movzbl (%r8), %edi
movzbl 0x1(%r8), %r9d
movzbl 0x2(%r8), %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 $-0x1, 0x1(%rcx,%rdx,2)
incq %rdx
addq $0x3, %r8
cmpl %edx, %esi
jne 0x208cb
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %edx, %edx
movzbl (%r11,%rdx,4), %edi
movzbl 0x1(%r11,%rdx,4), %r8d
movzbl 0x2(%r11,%rdx,4), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r8d, %r8d
addl %edi, %r8d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r8d, %eax
movb %ah, (%rcx,%rdx)
incq %rdx
cmpl %edx, %esi
jne 0x20918
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
xorl %edx, %edx
movb (%r8), %al
movb %al, (%rcx,%rdx,4)
movb 0x1(%r8), %al
movb %al, 0x1(%rcx,%rdx,4)
movb 0x2(%r8), %al
movb %al, 0x2(%rcx,%rdx,4)
movb $-0x1, 0x3(%rcx,%rdx,4)
incq %rdx
addq $0x3, %r8
cmpl %edx, %esi
jne 0x20958
jmp 0x209b8
cmpl $0x0, 0xc(%rsp)
js 0x209b8
imull 0x28(%rsp), %r9d
addq 0x10(%rsp), %r9
xorl %ecx, %ecx
movb (%r11,%rcx,4), %al
movb %al, (%r9)
movb 0x1(%r11,%rcx,4), %al
movb %al, 0x1(%r9)
movb 0x2(%r11,%rcx,4), %al
movb %al, 0x2(%r9)
incq %rcx
addq $0x3, %r9
cmpl %ecx, %esi
jne 0x20994
incq %r13
addl 0x24(%rsp), %ebp
addl 0x20(%rsp), %r10d
cmpq 0x40(%rsp), %r13
jne 0x206e7
movq %rbx, %rdi
callq 0x4380
movq 0x10(%rsp), %rbx
jmp 0x209f6
movq %rbx, %rdi
callq 0x4380
leaq 0xb8dc(%rip), %rax      # 0x2c2c9
movq %rax, 0x1699c(%rip)     # 0x37390
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbccb(%rip), %rdi      # 0x2c6da
leaq 0xb983(%rip), %rsi      # 0x2c399
leaq 0xbcdc(%rip), %rcx      # 0x2c6f9
movl $0x542, %edx            # imm = 0x542
callq 0x41f0
leaq 0xbfc5(%rip), %rdi      # 0x2c9f3
leaq 0xb964(%rip), %rsi      # 0x2c399
leaq 0xbcbd(%rip), %rcx      # 0x2c6f9
movl $0x55f, %edx            # imm = 0x55F
callq 0x41f0