// File: /workspace/github_cpp_makefile_star2_O3/alan0201tw[P]RayTracer/include/stb_image.h
// Function: stbi__convert_format16(unsigned short*, int, int, unsigned int, unsigned int)
static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)
{
   int i,j;
   stbi__uint16 *good;

   if (req_comp == img_n) return data;
   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);

   good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2);
   if (good == NULL) {
      STBI_FREE(data);
      return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
   }

   for (j=0; j < (int) y; ++j) {
      stbi__uint16 *src  = data + j * x * img_n   ;
      stbi__uint16 *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]=0xffff;                                     } 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]=0xffff;                     } 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]=0xffff;        } break;
         STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
         STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break;
         STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
         STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(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 %rcx, 0x10(%rsp)
movq %rdi, %rbx
cmpl %esi, %edx
je 0x34594
movl %edx, %r13d
leal -0x1(%r13), %eax
cmpl $0x4, %eax
jae 0x345a6
movl %r8d, %ebp
movl %esi, %r12d
movl %r13d, %r15d
imull 0x10(%rsp), %r15d
movl %r15d, %edi
imull %r8d, %edi
addl %edi, %edi
callq 0x64c0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3457c
movq %r13, 0x20(%rsp)
testl %ebp, %ebp
jle 0x3456d
movq 0x20(%rsp), %rax
leal (%rax,%r12,8), %eax
cmpl $0x23, %eax
ja 0x345c5
movabsq $0xe161a1c00, %rcx      # imm = 0xE161A1C00
btq %rax, %rcx
jae 0x345c5
movq 0x10(%rsp), %rdx
leal -0x1(%rdx), %ecx
movl %ecx, 0x4(%rsp)
movl %ebp, %ecx
movq %rcx, 0x30(%rsp)
movl %edx, %esi
movl %edx, %ecx
imull %r12d, %ecx
movl %ecx, 0x1c(%rsp)
movq 0x8(%rsp), %rcx
addq $0x4, %rcx
movq %rcx, 0x28(%rsp)
xorl %r9d, %r9d
addl $-0xa, %eax
movdqa 0x9408(%rip), %xmm0     # 0x3d650
xorl %r11d, %r11d
xorl %edx, %edx
leaq 0x94d0(%rip), %r14      # 0x3d724
movl %r9d, %ecx
leaq (%rbx,%rcx,2), %r10
movl %edx, %ebp
imull 0x10(%rsp), %ebp
cmpl $0x18, %eax
ja 0x34523
movl %r11d, %edi
movq 0x8(%rsp), %rcx
leaq (%rcx,%rdi,2), %r8
movl %ebp, %ecx
imull %r12d, %ecx
leaq (%rbx,%rcx,2), %rcx
movslq (%r14,%rax,4), %r13
addq %r14, %r13
jmpq *%r13
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %ecx, %ecx
movzwl (%r10,%rcx,2), %edi
movw %di, (%r8,%rcx,4)
movw $0xffff, 0x2(%r8,%rcx,4) # imm = 0xFFFF
incq %rcx
cmpl %ecx, %esi
jne 0x34298
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %ecx, %ecx
movzwl (%r10,%rcx,8), %edi
movzwl 0x2(%r10,%rcx,8), %ebp
movzwl 0x4(%r10,%rcx,8), %r13d
imull $0x4d, %edi, %edi
imull $0x96, %ebp, %ebp
addl %edi, %ebp
leal (%r13,%r13,8), %edi
leal (%rdi,%rdi,2), %edi
addl %r13d, %r13d
addl %edi, %r13d
addl %ebp, %r13d
shrl $0x8, %r13d
movw %r13w, (%r8,%rcx,4)
movzwl 0x6(%r10,%rcx,8), %edi
movw %di, 0x2(%r8,%rcx,4)
incq %rcx
cmpl %ecx, %esi
jne 0x342c3
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
movq 0x28(%rsp), %rcx
leaq (%rcx,%rdi,2), %rcx
xorl %edi, %edi
movzwl (%r10,%rdi,4), %r8d
movw %r8w, (%rcx)
movw %r8w, -0x2(%rcx)
movw %r8w, -0x4(%rcx)
incq %rdi
addq $0x6, %rcx
cmpl %edi, %esi
jne 0x34327
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %ecx, %ecx
movd (%r10,%rcx,4), %xmm1
pshuflw $0x40, %xmm1, %xmm1     # xmm1 = xmm1[0,0,0,1,4,5,6,7]
movq %xmm1, (%r8,%rcx,8)
incq %rcx
cmpl %ecx, %esi
jne 0x34357
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %ecx, %ecx
movzwl (%r10,%rcx,4), %edi
movw %di, (%r8,%rcx,2)
incq %rcx
cmpl %ecx, %esi
jne 0x34381
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %ecx, %ecx
movdqa %xmm0, %xmm1
pinsrw $0x0, (%r10,%rcx,2), %xmm1
pshuflw $0x40, %xmm1, %xmm1     # xmm1 = xmm1[0,0,0,1,4,5,6,7]
movq %xmm1, (%r8,%rcx,8)
incq %rcx
cmpl %ecx, %esi
jne 0x343a4
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
movq 0x28(%rsp), %rcx
leaq (%rcx,%rdi,2), %rcx
xorl %edi, %edi
movzwl (%r10,%rdi,2), %r8d
movw %r8w, (%rcx)
movw %r8w, -0x2(%rcx)
movw %r8w, -0x4(%rcx)
incq %rdi
addq $0x6, %rcx
cmpl %edi, %esi
jne 0x343dc
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %r10d, %r10d
movzwl (%rcx), %edi
movzwl 0x2(%rcx), %ebp
movzwl 0x4(%rcx), %r13d
imull $0x4d, %edi, %edi
imull $0x96, %ebp, %ebp
addl %edi, %ebp
leal (%r13,%r13,8), %edi
leal (%rdi,%rdi,2), %edi
addl %r13d, %r13d
addl %edi, %r13d
addl %ebp, %r13d
shrl $0x8, %r13d
movw %r13w, (%r8,%r10,2)
incq %r10
addq $0x6, %rcx
cmpl %r10d, %esi
jne 0x3440d
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %r10d, %r10d
movzwl (%rcx), %edi
movzwl 0x2(%rcx), %ebp
movzwl 0x4(%rcx), %r13d
imull $0x4d, %edi, %edi
imull $0x96, %ebp, %ebp
addl %edi, %ebp
leal (%r13,%r13,8), %edi
leal (%rdi,%rdi,2), %edi
addl %r13d, %r13d
addl %edi, %r13d
addl %ebp, %r13d
shrl $0x8, %r13d
movw %r13w, (%r8,%r10,4)
movw $0xffff, 0x2(%r8,%r10,4) # imm = 0xFFFF
incq %r10
addq $0x6, %rcx
cmpl %r10d, %esi
jne 0x3445d
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %ecx, %ecx
movzwl (%r10,%rcx,8), %edi
movzwl 0x2(%r10,%rcx,8), %ebp
movzwl 0x4(%r10,%rcx,8), %r13d
imull $0x4d, %edi, %edi
imull $0x96, %ebp, %ebp
addl %edi, %ebp
leal (%r13,%r13,8), %edi
leal (%rdi,%rdi,2), %edi
addl %r13d, %r13d
addl %edi, %r13d
addl %ebp, %r13d
shrl $0x8, %r13d
movw %r13w, (%r8,%rcx,2)
incq %rcx
cmpl %ecx, %esi
jne 0x344b4
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
xorl %edi, %edi
movl (%rcx), %r10d
movl %r10d, (%r8,%rdi,8)
movzwl 0x4(%rcx), %r10d
movw %r10w, 0x4(%r8,%rdi,8)
movw $0xffff, 0x6(%r8,%rdi,8) # imm = 0xFFFF
incq %rdi
addq $0x6, %rcx
cmpl %edi, %esi
jne 0x344fc
jmp 0x34557
cmpl $0x0, 0x4(%rsp)
js 0x34557
imull 0x20(%rsp), %ebp
movq 0x8(%rsp), %rcx
leaq (%rcx,%rbp,2), %rcx
xorl %edi, %edi
movl (%r10,%rdi,8), %r8d
movl %r8d, (%rcx)
movzwl 0x4(%r10,%rdi,8), %r8d
movw %r8w, 0x4(%rcx)
incq %rdi
addq $0x6, %rcx
cmpl %edi, %esi
jne 0x3453a
incq %rdx
addl %r15d, %r11d
addl 0x1c(%rsp), %r9d
cmpq 0x30(%rsp), %rdx
jne 0x34254
movq %rbx, %rdi
callq 0x6490
movq 0x8(%rsp), %rbx
jmp 0x34594
movq %rbx, %rdi
callq 0x6490
leaq 0xb401(%rip), %rax      # 0x3f98c
movq %rax, 0x1af36(%rip)     # 0x4f4c8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb827(%rip), %rdi      # 0x3fdd4
leaq 0xb25f(%rip), %rsi      # 0x3f813
leaq 0xb893(%rip), %rcx      # 0x3fe4e
movl $0x664, %edx            # imm = 0x664
callq 0x6250
leaq 0xbc54(%rip), %rdi      # 0x40220
leaq 0xb240(%rip), %rsi      # 0x3f813
leaq 0xb874(%rip), %rcx      # 0x3fe4e
movl $0x681, %edx            # imm = 0x681
callq 0x6250