// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rdi, %rbx
movq %rsi, 0x18(%rsp)
cmpl %esi, %edx
jne 0xc95d
movq %rbx, %rbp
jmp 0xccc4
movl %edx, %r12d
leal -0x1(%r12), %eax
cmpl $0x4, %eax
jae 0xccf5
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 0x21f0
testq %rax, %rax
je 0xccac
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 0x377c(%rip), %xmm0     # 0x10150
xorl %r9d, %r9d
xorl %r10d, %r10d
cmpq %r14, %r10
je 0xcca2
cmpl $0x19, %eax
ja 0xccd6
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 0x3849(%rip), %r13      # 0x10274
movslq (%r13,%rax,4), %r15
addq %r13, %r15
jmpq *%r15
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0xcc91
movzwl (%rdi,%rdx), %r11d
movw %r11w, (%r8,%rdx,2)
orw $-0x1, 0x2(%r8,%rdx,2)
decl %esi
addq $0x2, %rdx
jmp 0xca3c
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0xcc91
movl (%r11), %esi
movl %esi, (%rdx)
movzwl 0x4(%r11), %esi
movw %si, 0x4(%rdx)
addq $0x8, %r11
addq $0x6, %rdx
decl %edi
jmp 0xca61
xorl %edx, %edx
movl 0x4(%rsp), %r11d
testl %r11d, %r11d
js 0xcc91
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 0xca8a
xorl %edx, %edx
movl 0x4(%rsp), %r11d
testl %r11d, %r11d
js 0xcc91
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 0xcacf
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0xcc91
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 0xcb1c
movq 0x10(%rsp), %rdx
leaq (%rdx,%rsi,2), %rdx
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0xcc91
movzwl (%r11), %esi
movw %si, (%rdx)
movw %si, -0x2(%rdx)
movw %si, -0x4(%rdx)
addq $0x4, %r11
decl %edi
addq $0x6, %rdx
jmp 0xcb50
movq 0x10(%rsp), %rdx
leaq (%rdx,%rsi,2), %rdx
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0xcc91
movzwl (%r11), %esi
movw %si, (%rdx)
movw %si, -0x2(%rdx)
movw %si, -0x4(%rdx)
addq $0x2, %r11
decl %edi
addq $0x6, %rdx
jmp 0xcb80
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0xcc91
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 0xcba9
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0xcc91
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 0xcbcf
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0xcc91
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 0xcbf8
xorl %edx, %edx
movl 0x4(%rsp), %esi
testl %esi, %esi
js 0xcc91
movzwl (%rdi,%rdx,2), %r11d
movw %r11w, (%r8,%rdx)
decl %esi
addq $0x2, %rdx
jmp 0xcc3f
movl 0x4(%rsp), %edi
testl %edi, %edi
js 0xcc91
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 0xcc59
incq %r10
addl 0x8(%rsp), %r9d
addl 0xc(%rsp), %ecx
jmp 0xc9da
movq %rbx, %rdi
callq 0x21c0
jmp 0xccc4
movq %rbx, %rdi
callq 0x21c0
leaq 0x3e1e(%rip), %rax      # 0x10ad9
movq %rax, 0x8556(%rip)      # 0x15218
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4690(%rip), %rdi      # 0x1136d
leaq 0x3c82(%rip), %rsi      # 0x10966
leaq 0x42b0(%rip), %rcx      # 0x10f9b
movl $0x681, %edx            # imm = 0x681
callq 0x20f0
leaq 0x4225(%rip), %rdi      # 0x10f21
leaq 0x3c63(%rip), %rsi      # 0x10966
leaq 0x4291(%rip), %rcx      # 0x10f9b
movl $0x664, %edx            # imm = 0x664
callq 0x20f0