// File: /workspace/github_c_makefile_star2_O3/zhiyb[P]png2tlg/./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 0x12692
movl %edx, %r13d
leal -0x1(%r13), %eax
cmpl $0x4, %eax
jae 0x126a4
movl %r8d, %ebp
movl %esi, %r12d
movl %r13d, %r15d
imull 0x10(%rsp), %r15d
movl %r15d, %edi
imull %r8d, %edi
addl %edi, %edi
callq 0x2200
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x1267a
movq %r13, 0x20(%rsp)
testl %ebp, %ebp
jle 0x1266b
movq 0x20(%rsp), %rax
leal (%rax,%r12,8), %eax
cmpl $0x23, %eax
ja 0x126c3
movabsq $0xe161a1c00, %rcx      # imm = 0xE161A1C00
btq %rax, %rcx
jae 0x126c3
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 0x5eca(%rip), %xmm0     # 0x18210
xorl %r11d, %r11d
xorl %edx, %edx
leaq 0x5fee(%rip), %r14      # 0x18340
movl %r9d, %ecx
leaq (%rbx,%rcx,2), %r10
movl %edx, %ebp
imull 0x10(%rsp), %ebp
cmpl $0x18, %eax
ja 0x12621
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 0x12655
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 0x12396
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x123c1
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x12425
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x12455
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
xorl %ecx, %ecx
movzwl (%r10,%rcx,4), %edi
movw %di, (%r8,%rcx,2)
incq %rcx
cmpl %ecx, %esi
jne 0x1247f
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x124a2
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x124da
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x1250b
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x1255b
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x125b2
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x125fa
jmp 0x12655
cmpl $0x0, 0x4(%rsp)
js 0x12655
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 0x12638
incq %rdx
addl %r15d, %r11d
addl 0x1c(%rsp), %r9d
cmpq 0x30(%rsp), %rdx
jne 0x12352
movq %rbx, %rdi
callq 0x21d0
movq 0x8(%rsp), %rbx
jmp 0x12692
movq %rbx, %rdi
callq 0x21d0
leaq 0x6520(%rip), %rax      # 0x18ba9
movq %rax, 0xab68(%rip)      # 0x1d1f8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6946(%rip), %rdi      # 0x18ff1
leaq 0x6384(%rip), %rsi      # 0x18a36
leaq 0x69b2(%rip), %rcx      # 0x1906b
movl $0x664, %edx            # imm = 0x664
callq 0x20f0
leaq 0x6d73(%rip), %rdi      # 0x1943d
leaq 0x6365(%rip), %rsi      # 0x18a36
leaq 0x6993(%rip), %rcx      # 0x1906b
movl $0x681, %edx            # imm = 0x681
callq 0x20f0