// File: /workspace/github_c_makefile_star2_O3/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: getPixelColorRGBA16
static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a,
                                const unsigned char* in, size_t i, const LodePNGColorMode* mode)
{
  if(mode->colortype == LCT_GREY)
  {
    *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1];
    if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;
    else *a = 65535;
  }
  else if(mode->colortype == LCT_RGB)
  {
    *r = 256u * in[i * 6 + 0] + in[i * 6 + 1];
    *g = 256u * in[i * 6 + 2] + in[i * 6 + 3];
    *b = 256u * in[i * 6 + 4] + in[i * 6 + 5];
    if(mode->key_defined
       && 256u * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
       && 256u * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
       && 256u * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
    else *a = 65535;
  }
  else if(mode->colortype == LCT_GREY_ALPHA)
  {
    *r = *g = *b = 256u * in[i * 4 + 0] + in[i * 4 + 1];
    *a = 256u * in[i * 4 + 2] + in[i * 4 + 3];
  }
  else if(mode->colortype == LCT_RGBA)
  {
    *r = 256u * in[i * 8 + 0] + in[i * 8 + 1];
    *g = 256u * in[i * 8 + 2] + in[i * 8 + 3];
    *b = 256u * in[i * 8 + 4] + in[i * 8 + 5];
    *a = 256u * in[i * 8 + 6] + in[i * 8 + 7];
  }
}

// Assembly:
pushq %rbx
movq 0x10(%rsp), %rax
movl (%rax), %r10d
cmpq $0x6, %r10
ja 0x5bde
leaq 0x86ed(%rip), %r11      # 0xe168
movslq (%r11,%r10,4), %r10
addq %r11, %r10
jmpq *%r10
movzbl (%r8,%r9,2), %r10d
shll $0x8, %r10d
movzbl 0x1(%r8,%r9,2), %r11d
orl %r10d, %r11d
movw %r11w, (%rdx)
movw %r11w, (%rsi)
movw %r11w, (%rdi)
cmpl $0x0, 0x18(%rax)
je 0x5b87
leaq 0x1(,%r9,2), %rdx
addq %r9, %r9
movzbl (%r8,%r9), %esi
shll $0x8, %esi
movzbl (%r8,%rdx), %edx
orl %esi, %edx
cmpl 0x1c(%rax), %edx
jne 0x5b87
xorl %eax, %eax
jmp 0x5bdb
movzbl (%r8,%r9,4), %eax
shll $0x8, %eax
movzbl 0x1(%r8,%r9,4), %r10d
orl %eax, %r10d
movw %r10w, (%rdx)
movw %r10w, (%rsi)
movw %r10w, (%rdi)
movzbl 0x2(%r8,%r9,4), %edx
shll $0x8, %edx
movzbl 0x3(%r8,%r9,4), %eax
jmp 0x5bd9
addq %r9, %r9
leaq (%r9,%r9,2), %r10
movzbl (%r8,%r10), %r11d
shll $0x8, %r11d
movzbl 0x1(%r8,%r10), %ebx
orl %r11d, %ebx
movw %bx, (%rdi)
movzwl 0x2(%r8,%r10), %edi
rolw $0x8, %di
movw %di, (%rsi)
movzwl 0x4(%r8,%r10), %esi
rolw $0x8, %si
movw %si, (%rdx)
cmpl $0x0, 0x18(%rax)
je 0x5b87
leaq (%r9,%r9,2), %rdx
incq %rdx
movzbl (%r8,%r10), %esi
shll $0x8, %esi
movzbl (%r8,%rdx), %edx
orl %esi, %edx
cmpl 0x1c(%rax), %edx
jne 0x5b87
movzwl 0x2(%r8,%r10), %edx
rolw $0x8, %dx
movzwl %dx, %edx
cmpl 0x20(%rax), %edx
jne 0x5b87
movzwl 0x4(%r8,%r10), %edx
rolw $0x8, %dx
movzwl %dx, %edx
cmpl 0x24(%rax), %edx
je 0x5ad0
movw $0xffff, %ax            # imm = 0xFFFF
jmp 0x5bdb
movzbl (%r8,%r9,8), %eax
shll $0x8, %eax
movzbl 0x1(%r8,%r9,8), %r10d
orl %eax, %r10d
movw %r10w, (%rdi)
movzbl 0x2(%r8,%r9,8), %eax
shll $0x8, %eax
movzbl 0x3(%r8,%r9,8), %edi
orl %eax, %edi
movw %di, (%rsi)
movzbl 0x4(%r8,%r9,8), %eax
shll $0x8, %eax
movzbl 0x5(%r8,%r9,8), %esi
orl %eax, %esi
movw %si, (%rdx)
movzbl 0x6(%r8,%r9,8), %edx
shll $0x8, %edx
movzbl 0x7(%r8,%r9,8), %eax
orl %edx, %eax
movw %ax, (%rcx)
popq %rbx
retq