// File: /workspace/github_cpp_makefile_star2_O2/drummyfish[P]flowchart/src/lodepng.cpp
// Function: getPixelColorRGBA16(unsigned short*, unsigned short*, unsigned short*, unsigned short*, unsigned char const*, unsigned long, LodePNGColorMode const*)
static unsigned 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->bitdepth != 16) return 85; /*error: this function only supports 16-bit input*/

  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 = 256 * in[i * 6 + 0] + in[i * 6 + 1];
    *g = 256 * in[i * 6 + 2] + in[i * 6 + 3];
    *b = 256 * 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 = 256 * in[i * 4 + 0] + in[i * 4 + 1];
    *a = 256 * in[i * 4 + 2] + in[i * 4 + 3];
  }
  else if(mode->colortype == LCT_RGBA)
  {
    *r = 256 * in[i * 8 + 0] + in[i * 8 + 1];
    *g = 256 * in[i * 8 + 2] + in[i * 8 + 3];
    *b = 256 * in[i * 8 + 4] + in[i * 8 + 5];
    *a = 256 * in[i * 8 + 6] + in[i * 8 + 7];
  }
  else return 85; /*error: this function only supports 16-bit input*/

  return 0; /*no error*/
}

// Assembly:
pushq %rbx
movq 0x10(%rsp), %r10
movl $0x55, %eax
cmpl $0x10, 0x4(%r10)
jne 0x5396
movl (%r10), %r11d
cmpq $0x6, %r11
ja 0x5396
leaq 0x8e57(%rip), %rbx      # 0xe088
movslq (%rbx,%r11,4), %r11
addq %rbx, %r11
jmpq *%r11
movzbl (%r8,%r9,2), %eax
shll $0x8, %eax
movzbl 0x1(%r8,%r9,2), %r11d
orl %eax, %r11d
movw %r11w, (%rdx)
movw %r11w, (%rsi)
movw %r11w, (%rdi)
cmpl $0x0, 0x18(%r10)
je 0x533d
leaq 0x1(,%r9,2), %rax
addq %r9, %r9
movzbl (%r8,%r9), %edx
shll $0x8, %edx
movzbl (%r8,%rax), %eax
orl %edx, %eax
cmpl 0x1c(%r10), %eax
jne 0x533d
xorl %eax, %eax
jmp 0x5391
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 0x538f
imulq $0x6, %r9, %rax
movzbl (%r8,%rax), %r9d
shll $0x8, %r9d
movzbl 0x1(%r8,%rax), %r11d
orl %r9d, %r11d
movw %r11w, (%rdi)
movzwl 0x2(%r8,%rax), %edi
rolw $0x8, %di
movw %di, (%rsi)
movzwl 0x4(%r8,%rax), %esi
rolw $0x8, %si
movw %si, (%rdx)
cmpl $0x0, 0x18(%r10)
je 0x533d
leaq 0x1(%rax), %rdx
movzbl (%r8,%rax), %esi
shll $0x8, %esi
movzbl (%r8,%rdx), %edx
orl %esi, %edx
cmpl 0x1c(%r10), %edx
jne 0x533d
movzwl 0x2(%r8,%rax), %edx
rolw $0x8, %dx
movzwl %dx, %edx
cmpl 0x20(%r10), %edx
jne 0x533d
movzwl 0x4(%r8,%rax), %eax
rolw $0x8, %ax
movzwl %ax, %eax
cmpl 0x24(%r10), %eax
je 0x5287
movw $0xffff, %ax            # imm = 0xFFFF
jmp 0x5391
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)
xorl %eax, %eax
popq %rbx
retq