// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rdi, %rbx
movq %rsi, 0x18(%rsp)
cmpl %esi, %edx
jne 0x2a62e
movq %rbx, %rbp
jmp 0x2a995
movl %edx, %r12d
leal -0x1(%r12), %eax
cmpl $0x4, %eax
jae 0x2a9c6
movl %r8d, %r14d
movl %r12d, %eax
imull %ecx, %eax
movl %eax, 0xc(%rsp)
movl %eax, %edi
imull %r8d, %edi
addl %edi, %edi
movq %rcx, %r15
callq 0x6510
testq %rax, %rax
je 0x2a97d
movq %rax, %rbp
movq 0x18(%rsp), %rsi
leal (%r12,%rsi,8), %eax
xorl %ecx, %ecx
testl %r14d, %r14d
cmovlel %ecx, %r14d
leal -0x1(%r15), %edx
movl %edx, 0x4(%rsp)
movq %r15, %rdx
movq %r15, 0x20(%rsp)
imull %esi, %edx
movl %edx, 0x8(%rsp)
leaq 0x4(%rbp), %rdx
movq %rdx, 0x10(%rsp)
addl $-0xa, %eax
movdqa 0x6eab(%rip), %xmm0     # 0x31550
xorl %r9d, %r9d
xorl %r10d, %r10d
cmpq %r14, %r10
je 0x2a973
cmpl $0x19, %eax
ja 0x2a9a7
movl %r9d, %edx
leaq (%rbx,%rdx,2), %rdi
movl %ecx, %esi
leaq (,%rsi,2), %r8
addq %rbp, %r8
movl %r10d, %edx
imull 0x20(%rsp), %edx
movl %edx, %r11d
imull 0x18(%rsp), %r11d
leaq (%rbx,%r11,2), %r11
imull %r12d, %edx
leaq (,%rdx,2), %rdx
addq %rbp, %rdx
leaq 0x6f1c(%rip), %r13      # 0x31618
movslq (%r13,%rax,4), %r15
addq %r13, %r15
jmpq *%r15
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0x2a962
movzwl (%rdi,%rdx), %r11d
movw %r11w, (%r8,%rdx,2)
orw $-0x1, 0x2(%r8,%rdx,2)
decl %esi
addq $0x2, %rdx
jmp 0x2a70d
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0x2a962
movl (%r11), %esi
movl %esi, (%rdx)
movzwl 0x4(%r11), %esi
movw %si, 0x4(%rdx)
addq $0x8, %r11
addq $0x6, %rdx
decl %edi
jmp 0x2a732
xorl %edx, %edx
movl 0x4(%rsp), %r11d
testl %r11d, %r11d
js 0x2a962
movzwl (%rdi,%rdx,4), %esi
movzwl 0x2(%rdi,%rdx,4), %r15d
movzwl 0x4(%rdi,%rdx,4), %r13d
imull $0x4d, %esi, %esi
imull $0x96, %r15d, %r15d
addl %esi, %r15d
imull $0x1d, %r13d, %esi
addl %r15d, %esi
shrl $0x8, %esi
movw %si, (%r8,%rdx)
decl %r11d
addq $0x2, %rdx
jmp 0x2a75b
xorl %edx, %edx
movl 0x4(%rsp), %r11d
testl %r11d, %r11d
js 0x2a962
movzwl (%rdi,%rdx,2), %esi
movzwl 0x2(%rdi,%rdx,2), %r15d
movzwl 0x4(%rdi,%rdx,2), %r13d
imull $0x4d, %esi, %esi
imull $0x96, %r15d, %r15d
addl %esi, %r15d
imull $0x1d, %r13d, %esi
addl %r15d, %esi
shrl $0x8, %esi
movw %si, (%r8,%rdx)
movzwl 0x6(%rdi,%rdx,2), %esi
movw %si, 0x2(%r8,%rdx)
decl %r11d
addq $0x4, %rdx
jmp 0x2a7a0
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0x2a962
movl (%r11), %esi
movl %esi, (%rdx)
movzwl 0x4(%r11), %esi
movw %si, 0x4(%rdx)
orw $-0x1, 0x6(%rdx)
addq $0x6, %r11
addq $0x8, %rdx
decl %edi
jmp 0x2a7ed
movq 0x10(%rsp), %rdx
leaq (%rdx,%rsi,2), %rdx
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0x2a962
movzwl (%r11), %esi
movw %si, (%rdx)
movw %si, -0x2(%rdx)
movw %si, -0x4(%rdx)
addq $0x4, %r11
decl %edi
addq $0x6, %rdx
jmp 0x2a821
movq 0x10(%rsp), %rdx
leaq (%rdx,%rsi,2), %rdx
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0x2a962
movzwl (%r11), %esi
movw %si, (%rdx)
movw %si, -0x2(%rdx)
movw %si, -0x4(%rdx)
addq $0x2, %r11
decl %edi
addq $0x6, %rdx
jmp 0x2a851
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0x2a962
movd (%rdi,%rdx), %xmm1
pshuflw $0x40, %xmm1, %xmm1     # xmm1 = xmm1[0,0,0,1,4,5,6,7]
movq %xmm1, (%r8,%rdx,2)
decl %esi
addq $0x4, %rdx
jmp 0x2a87a
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0x2a962
movdqa %xmm0, %xmm1
pinsrw $0x0, (%rdi,%rdx), %xmm1
pshuflw $0x40, %xmm1, %xmm1     # xmm1 = xmm1[0,0,0,1,4,5,6,7]
movq %xmm1, (%r8,%rdx,4)
decl %esi
addq $0x2, %rdx
jmp 0x2a8a0
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0x2a962
movzwl (%r11), %esi
movzwl 0x2(%r11), %r8d
movzwl 0x4(%r11), %r15d
imull $0x4d, %esi, %esi
imull $0x96, %r8d, %r8d
addl %esi, %r8d
imull $0x1d, %r15d, %esi
addl %r8d, %esi
shrl $0x8, %esi
movw %si, (%rdx)
orw $-0x1, 0x2(%rdx)
addq $0x6, %r11
addq $0x4, %rdx
decl %edi
jmp 0x2a8c9
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0x2a962
movzwl (%rdi,%rdx,2), %r11d
movw %r11w, (%r8,%rdx)
decl %esi
addq $0x2, %rdx
jmp 0x2a910
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0x2a962
movzwl (%r11), %esi
movzwl 0x2(%r11), %r8d
movzwl 0x4(%r11), %r15d
imull $0x4d, %esi, %esi
imull $0x96, %r8d, %r8d
addl %esi, %r8d
imull $0x1d, %r15d, %esi
addl %r8d, %esi
shrl $0x8, %esi
movw %si, (%rdx)
addq $0x6, %r11
addq $0x2, %rdx
decl %edi
jmp 0x2a92a
incq %r10
addl 0x8(%rsp), %r9d
addl 0xc(%rsp), %ecx
jmp 0x2a6ab
movq %rbx, %rdi
callq 0x64d0
jmp 0x2a995
movq %rbx, %rdi
callq 0x64d0
leaq 0x8f08(%rip), %rax      # 0x33894
movq %rax, 0x1db85(%rip)     # 0x48518
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x977a(%rip), %rdi      # 0x34128
leaq 0x8d66(%rip), %rsi      # 0x3371b
leaq 0x939a(%rip), %rcx      # 0x33d56
movl $0x681, %edx            # imm = 0x681
callq 0x6280
leaq 0x930f(%rip), %rdi      # 0x33cdc
leaq 0x8d47(%rip), %rsi      # 0x3371b
leaq 0x937b(%rip), %rcx      # 0x33d56
movl $0x664, %edx            # imm = 0x664
callq 0x6280