// File: /workspace/github_c_makefile_star2_O1/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 %rdi, %rbx
movq %rsi, 0x8(%rsp)
cmpl %esi, %edx
je 0x11eb2
movl %edx, %r15d
leal -0x1(%r15), %eax
cmpl $0x4, %eax
jae 0x11ec4
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 0x2210
testq %rax, %rax
je 0x11e9a
movq %rax, %r13
testl %ebp, %ebp
jle 0x11e8d
movq 0x8(%rsp), %rax
leal (%r15,%rax,8), %eax
cmpl $0x23, %eax
ja 0x11ee3
movabsq $0xe161a1c00, %rcx      # imm = 0xE161A1C00
btq %rax, %rcx
jae 0x11ee3
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 0x11e3f
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 0x5738(%rip), %r12      # 0x17290
movslq (%r12,%rax,4), %r12
leaq 0x572d(%rip), %rax      # 0x17290
addq %rax, %r12
jmpq *%r12
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11b79
jmp 0x11e70
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11ba8
jmp 0x11e70
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11c10
jmp 0x11e70
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11c42
jmp 0x11e70
cmpl $0x0, 0x4(%rsp)
js 0x11e70
xorl %edx, %edx
movl %r14d, %esi
movzwl (%r10,%rdx,2), %edi
movw %di, (%rcx,%rdx)
decl %esi
addq $0x2, %rdx
testl %esi, %esi
jg 0x11c7f
jmp 0x11e70
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11ca7
jmp 0x11e70
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11ce7
jmp 0x11e70
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11d17
jmp 0x11e70
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11d69
jmp 0x11e70
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11dc3
jmp 0x11e70
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11e10
jmp 0x11e70
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x11e70
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 0x11e49
incq %rbp
addl 0x14(%rsp), %r11d
addl 0x10(%rsp), %r9d
cmpq 0x30(%rsp), %rbp
movq 0x28(%rsp), %rax
jne 0x11b0a
movq %rbx, %rdi
callq 0x21e0
movq %r13, %rbx
jmp 0x11eb2
movq %rbx, %rdi
callq 0x21e0
leaq 0x5c50(%rip), %rax      # 0x17af9
movq %rax, 0xa378(%rip)      # 0x1c228
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6076(%rip), %rdi      # 0x17f41
leaq 0x5ab4(%rip), %rsi      # 0x17986
leaq 0x60e2(%rip), %rcx      # 0x17fbb
movl $0x664, %edx            # imm = 0x664
callq 0x2100
leaq 0x64a7(%rip), %rdi      # 0x18391
leaq 0x5a95(%rip), %rsi      # 0x17986
leaq 0x60c3(%rip), %rcx      # 0x17fbb
movl $0x681, %edx            # imm = 0x681
callq 0x2100