// File: phillip-h[P]fractal-gen/lodepng.cpp
// Function: getPixelColorRGBA16(unsigned short*, unsigned short*, unsigned short*, unsigned short*, unsigned char const*, unsigned long, LodePNGColorMode const*)
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:
movq 0x8(%rsp), %rax
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq %rdx, -0x18(%rsp)
movq %rcx, -0x20(%rsp)
movq %r8, -0x28(%rsp)
movq %r9, -0x30(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jne 0xa45c
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x18(%rsp), %rax
movw %cx, (%rax)
movq -0x10(%rsp), %rax
movw %cx, (%rax)
movq -0x8(%rsp), %rax
movw %cx, (%rax)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x18(%rax)
je 0xa44d
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x8(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0xa44d
movq -0x20(%rsp), %rax
movw $0x0, (%rax)
jmp 0xa457
movq -0x20(%rsp), %rax
movw $0xffff, (%rax)         # imm = 0xFFFF
jmp 0xa728
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jne 0xa5af
movq -0x28(%rsp), %rax
imulq $0x6, -0x30(%rsp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
imulq $0x6, -0x30(%rsp), %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x8(%rsp), %rax
movw %cx, (%rax)
movq -0x28(%rsp), %rax
imulq $0x6, -0x30(%rsp), %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
imulq $0x6, -0x30(%rsp), %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x10(%rsp), %rax
movw %cx, (%rax)
movq -0x28(%rsp), %rax
imulq $0x6, -0x30(%rsp), %rcx
movzbl 0x4(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
imulq $0x6, -0x30(%rsp), %rdx
movzbl 0x5(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x18(%rsp), %rax
movw %cx, (%rax)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x18(%rax)
je 0xa5a0
movq -0x28(%rsp), %rax
imulq $0x6, -0x30(%rsp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
imulq $0x6, -0x30(%rsp), %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x8(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0xa5a0
movq -0x28(%rsp), %rax
imulq $0x6, -0x30(%rsp), %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
imulq $0x6, -0x30(%rsp), %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x8(%rsp), %rcx
cmpl 0x20(%rcx), %eax
jne 0xa5a0
movq -0x28(%rsp), %rax
imulq $0x6, -0x30(%rsp), %rcx
movzbl 0x4(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
imulq $0x6, -0x30(%rsp), %rdx
movzbl 0x5(%rcx,%rdx), %ecx
addl %ecx, %eax
movq 0x8(%rsp), %rcx
cmpl 0x24(%rcx), %eax
jne 0xa5a0
movq -0x20(%rsp), %rax
movw $0x0, (%rax)
jmp 0xa5aa
movq -0x20(%rsp), %rax
movw $0xffff, (%rax)         # imm = 0xFFFF
jmp 0xa726
movq 0x8(%rsp), %rax
cmpl $0x4, (%rax)
jne 0xa63d
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq $0x2, %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq $0x2, %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x18(%rsp), %rax
movw %cx, (%rax)
movq -0x10(%rsp), %rax
movw %cx, (%rax)
movq -0x8(%rsp), %rax
movw %cx, (%rax)
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq $0x2, %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq $0x2, %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x20(%rsp), %rax
movw %cx, (%rax)
jmp 0xa724
movq 0x8(%rsp), %rax
cmpl $0x6, (%rax)
jne 0xa722
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq $0x3, %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq $0x3, %rdx
movzbl 0x1(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x8(%rsp), %rax
movw %cx, (%rax)
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq $0x3, %rcx
movzbl 0x2(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq $0x3, %rdx
movzbl 0x3(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x10(%rsp), %rax
movw %cx, (%rax)
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq $0x3, %rcx
movzbl 0x4(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq $0x3, %rdx
movzbl 0x5(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x18(%rsp), %rax
movw %cx, (%rax)
movq -0x28(%rsp), %rax
movq -0x30(%rsp), %rcx
shlq $0x3, %rcx
movzbl 0x6(%rax,%rcx), %eax
shll $0x8, %eax
movq -0x28(%rsp), %rcx
movq -0x30(%rsp), %rdx
shlq $0x3, %rdx
movzbl 0x7(%rcx,%rdx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x20(%rsp), %rax
movw %cx, (%rax)
jmp 0xa724
jmp 0xa726
jmp 0xa728
retq
nopl (%rax)