// File: /workspace/github_cpp_makefile_star2_O1/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 %rdi, %rbx
movq %rsi, 0x8(%rsp)
cmpl %esi, %edx
je 0x348bf
movl %edx, %r15d
leal -0x1(%r15), %eax
cmpl $0x4, %eax
jae 0x348d1
movl %r8d, %ebp
movl %ecx, %r14d
movl %r15d, %eax
imull %ecx, %eax
movl %eax, 0x14(%rsp)
movl %eax, %edi
imull %r8d, %edi
addl %edi, %edi
callq 0x64c0
testq %rax, %rax
je 0x348a7
movq %rax, %r13
testl %ebp, %ebp
jle 0x3489a
movq 0x8(%rsp), %rax
leal (%r15,%rax,8), %eax
cmpl $0x23, %eax
ja 0x348f0
movabsq $0xe161a1c00, %rcx      # imm = 0xE161A1C00
btq %rax, %rcx
jae 0x348f0
leal -0x1(%r14), %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x2, %ebp
movl $0x1, %ecx
cmovgel %ebp, %ecx
movq %rcx, 0x30(%rsp)
movl %r14d, %ecx
imull 0x8(%rsp), %ecx
movl %ecx, 0x10(%rsp)
leaq 0x6(%r13), %rcx
movq %rcx, 0x20(%rsp)
leaq 0x4(%r13), %rcx
movq %rcx, 0x18(%rsp)
xorl %r9d, %r9d
addl $-0xa, %eax
xorl %r11d, %r11d
xorl %ebp, %ebp
movq %rax, 0x28(%rsp)
movl %ebp, %ecx
imull %r14d, %ecx
movl %ecx, %edx
imull 0x8(%rsp), %edx
leaq (%rbx,%rdx,2), %r8
imull %r15d, %ecx
leaq (,%rcx,2), %rdi
addq %r13, %rdi
cmpl $0x18, %eax
ja 0x3484c
movl %r11d, %esi
leaq (,%rsi,2), %rcx
addq %r13, %rcx
movl %r9d, %edx
leaq (%rbx,%rdx,2), %r10
movq 0x20(%rsp), %rdx
leaq (%rdx,%rsi,2), %rdx
leaq 0x8f4f(%rip), %r12      # 0x3d4b4
movslq (%r12,%rax,4), %r12
leaq 0x8f44(%rip), %rax      # 0x3d4b4
addq %rax, %r12
jmpq *%r12
cmpl $0x0, 0x4(%rsp)
js 0x3487d
xorl %edx, %edx
movl %r14d, %esi
movzwl (%r10,%rdx), %edi
movw %di, (%rcx,%rdx,2)
movw $0xffff, 0x2(%rcx,%rdx,2) # imm = 0xFFFF
decl %esi
addq $0x2, %rdx
testl %esi, %esi
jg 0x34586
jmp 0x3487d
cmpl $0x0, 0x4(%rsp)
js 0x3487d
xorl %edx, %edx
movl %r14d, %edi
movzwl (%r10,%rdx,2), %esi
movzwl 0x2(%r10,%rdx,2), %r8d
movzwl 0x4(%r10,%rdx,2), %r12d
imull $0x4d, %esi, %esi
imull $0x96, %r8d, %r8d
addl %esi, %r8d
leal (%r12,%r12,8), %esi
leal (%rsi,%rsi,2), %esi
addl %r12d, %r12d
addl %esi, %r12d
addl %r8d, %r12d
shrl $0x8, %r12d
movw %r12w, (%rcx,%rdx)
movzwl 0x6(%r10,%rdx,2), %esi
movw %si, 0x2(%rcx,%rdx)
decl %edi
addq $0x4, %rdx
testl %edi, %edi
jg 0x345b5
jmp 0x3487d
cmpl $0x0, 0x4(%rsp)
js 0x3487d
movq 0x18(%rsp), %rcx
leaq (%rcx,%rsi,2), %rcx
movl %r14d, %edx
movzwl (%r8), %esi
movw %si, (%rcx)
movw %si, -0x2(%rcx)
movw %si, -0x4(%rcx)
addq $0x4, %r8
decl %edx
addq $0x6, %rcx
testl %edx, %edx
jg 0x3461d
jmp 0x3487d
cmpl $0x0, 0x4(%rsp)
js 0x3487d
xorl %ecx, %ecx
movl %r14d, %esi
movzwl (%r10,%rcx), %edi
movw %di, -0x2(%rdx,%rcx,2)
movw %di, -0x4(%rdx,%rcx,2)
movw %di, -0x6(%rdx,%rcx,2)
movzwl 0x2(%r10,%rcx), %edi
movw %di, (%rdx,%rcx,2)
decl %esi
addq $0x4, %rcx
testl %esi, %esi
jg 0x3464f
jmp 0x3487d
cmpl $0x0, 0x4(%rsp)
js 0x3487d
xorl %edx, %edx
movl %r14d, %esi
movzwl (%r10,%rdx,2), %edi
movw %di, (%rcx,%rdx)
decl %esi
addq $0x2, %rdx
testl %esi, %esi
jg 0x3468c
jmp 0x3487d
cmpl $0x0, 0x4(%rsp)
js 0x3487d
xorl %ecx, %ecx
movl %r14d, %esi
movzwl (%r10,%rcx), %edi
movw %di, -0x2(%rdx,%rcx,4)
movw %di, -0x4(%rdx,%rcx,4)
movw %di, -0x6(%rdx,%rcx,4)
movw $0xffff, (%rdx,%rcx,4)  # imm = 0xFFFF
decl %esi
addq $0x2, %rcx
testl %esi, %esi
jg 0x346b4
jmp 0x3487d
cmpl $0x0, 0x4(%rsp)
js 0x3487d
movq 0x18(%rsp), %rcx
leaq (%rcx,%rsi,2), %rcx
movl %r14d, %edx
movzwl (%r8), %esi
movw %si, (%rcx)
movw %si, -0x2(%rcx)
movw %si, -0x4(%rcx)
addq $0x2, %r8
decl %edx
addq $0x6, %rcx
testl %edx, %edx
jg 0x346f4
jmp 0x3487d
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x3487d
movzwl (%r8), %edx
movzwl 0x2(%r8), %esi
movzwl 0x4(%r8), %r10d
imull $0x4d, %edx, %edx
imull $0x96, %esi, %esi
addl %edx, %esi
leal (%r10,%r10,8), %edx
leal (%rdx,%rdx,2), %edx
addl %r10d, %r10d
addl %edx, %r10d
addl %esi, %r10d
shrl $0x8, %r10d
movw %r10w, (%rdi)
addq $0x6, %r8
addq $0x2, %rdi
decl %ecx
testl %ecx, %ecx
jg 0x34724
jmp 0x3487d
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x3487d
movzwl (%r8), %edx
movzwl 0x2(%r8), %esi
movzwl 0x4(%r8), %r10d
imull $0x4d, %edx, %edx
imull $0x96, %esi, %esi
addl %edx, %esi
leal (%r10,%r10,8), %edx
leal (%rdx,%rdx,2), %edx
addl %r10d, %r10d
addl %edx, %r10d
addl %esi, %r10d
shrl $0x8, %r10d
movw %r10w, (%rdi)
movw $0xffff, 0x2(%rdi)      # imm = 0xFFFF
addq $0x6, %r8
addq $0x4, %rdi
decl %ecx
testl %ecx, %ecx
jg 0x34776
jmp 0x3487d
cmpl $0x0, 0x4(%rsp)
js 0x3487d
xorl %edx, %edx
movl %r14d, %edi
movzwl (%r10,%rdx,4), %esi
movzwl 0x2(%r10,%rdx,4), %r8d
movzwl 0x4(%r10,%rdx,4), %r12d
imull $0x4d, %esi, %esi
imull $0x96, %r8d, %r8d
addl %esi, %r8d
leal (%r12,%r12,8), %esi
leal (%rsi,%rsi,2), %esi
addl %r12d, %r12d
addl %esi, %r12d
addl %r8d, %r12d
shrl $0x8, %r12d
movw %r12w, (%rcx,%rdx)
decl %edi
addq $0x2, %rdx
testl %edi, %edi
jg 0x347d0
jmp 0x3487d
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x3487d
movzwl (%r8), %edx
movw %dx, (%rdi)
movzwl 0x2(%r8), %edx
movw %dx, 0x2(%rdi)
movzwl 0x4(%r8), %edx
movw %dx, 0x4(%rdi)
movw $0xffff, 0x6(%rdi)      # imm = 0xFFFF
addq $0x6, %r8
addq $0x8, %rdi
decl %ecx
testl %ecx, %ecx
jg 0x3481d
jmp 0x3487d
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x3487d
movzwl (%r8), %edx
movw %dx, (%rdi)
movzwl 0x2(%r8), %edx
movw %dx, 0x2(%rdi)
movzwl 0x4(%r8), %edx
movw %dx, 0x4(%rdi)
addq $0x8, %r8
addq $0x6, %rdi
decl %ecx
testl %ecx, %ecx
jg 0x34856
incq %rbp
addl 0x14(%rsp), %r11d
addl 0x10(%rsp), %r9d
cmpq 0x30(%rsp), %rbp
movq 0x28(%rsp), %rax
jne 0x34517
movq %rbx, %rdi
callq 0x6490
movq %r13, %rbx
jmp 0x348bf
movq %rbx, %rdi
callq 0x6490
leaq 0xae6e(%rip), %rax      # 0x3f724
movq %rax, 0x1ac2b(%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 0xb294(%rip), %rdi      # 0x3fb6c
leaq 0xaccc(%rip), %rsi      # 0x3f5ab
leaq 0xb300(%rip), %rcx      # 0x3fbe6
movl $0x664, %edx            # imm = 0x664
callq 0x6250
leaq 0xb6c5(%rip), %rdi      # 0x3ffbc
leaq 0xacad(%rip), %rsi      # 0x3f5ab
leaq 0xb2e1(%rip), %rcx      # 0x3fbe6
movl $0x681, %edx            # imm = 0x681
callq 0x6250