// File: 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 %rbp
movq %rsp, %rbp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x10, 0x4(%rax)
je 0x6776
movl $0x55, -0x4(%rbp)
jmp 0x6aa5
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x680f
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movq 0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x6801
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0x6801
movq -0x28(%rbp), %rax
movw $0x0, (%rax)
jmp 0x680a
movq -0x28(%rbp), %rax
movw $0xffff, (%rax)         # imm = 0xFFFF
jmp 0x6a9e
movq 0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x6940
movq -0x30(%rbp), %rax
imulq $0x6, -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
imulq $0x6, -0x38(%rbp), %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movq -0x30(%rbp), %rax
imulq $0x6, -0x38(%rbp), %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
imulq $0x6, -0x38(%rbp), %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x30(%rbp), %rax
imulq $0x6, -0x38(%rbp), %rcx
movzbl 0x4(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
imulq $0x6, -0x38(%rbp), %rdx
movzbl 0x5(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
movq 0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x6932
movq -0x30(%rbp), %rax
imulq $0x6, -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
imulq $0x6, -0x38(%rbp), %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0x6932
movq -0x30(%rbp), %rax
imulq $0x6, -0x38(%rbp), %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
imulq $0x6, -0x38(%rbp), %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x10(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jne 0x6932
movq -0x30(%rbp), %rax
imulq $0x6, -0x38(%rbp), %rcx
movzbl 0x4(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
imulq $0x6, -0x38(%rbp), %rdx
movzbl 0x5(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x10(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jne 0x6932
movq -0x28(%rbp), %rax
movw $0x0, (%rax)
jmp 0x693b
movq -0x28(%rbp), %rax
movw $0xffff, (%rax)         # imm = 0xFFFF
jmp 0x6a9c
movq 0x10(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x69bd
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x2, %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x2, %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x2, %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x2, %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
jmp 0x6a9a
movq 0x10(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x6a8f
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x3, %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x3, %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x3, %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x3, %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x3, %rcx
movzbl 0x4(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x3, %rdx
movzbl 0x5(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x3, %rcx
movzbl 0x6(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x3, %rdx
movzbl 0x7(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
jmp 0x6a98
movl $0x55, -0x4(%rbp)
jmp 0x6aa5
jmp 0x6a9a
jmp 0x6a9c
jmp 0x6a9e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)