// File: phillip-h[P]fractal-gen/lodepng.cpp
// Function: rgba16ToPixel(unsigned char*, unsigned long, LodePNGColorMode const*, unsigned short, unsigned short, unsigned short, unsigned short)
static void rgba16ToPixel(unsigned char* out, size_t i,
                         const LodePNGColorMode* mode,
                         unsigned short r, unsigned short g, unsigned short b, unsigned short a)
{
  if(mode->colortype == LCT_GREY)
  {
    unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
    out[i * 2 + 0] = (grey >> 8) & 255;
    out[i * 2 + 1] = grey & 255;
  }
  else if(mode->colortype == LCT_RGB)
  {
    out[i * 6 + 0] = (r >> 8) & 255;
    out[i * 6 + 1] = r & 255;
    out[i * 6 + 2] = (g >> 8) & 255;
    out[i * 6 + 3] = g & 255;
    out[i * 6 + 4] = (b >> 8) & 255;
    out[i * 6 + 5] = b & 255;
  }
  else if(mode->colortype == LCT_GREY_ALPHA)
  {
    unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
    out[i * 4 + 0] = (grey >> 8) & 255;
    out[i * 4 + 1] = grey & 255;
    out[i * 4 + 2] = (a >> 8) & 255;
    out[i * 4 + 3] = a & 255;
  }
  else if(mode->colortype == LCT_RGBA)
  {
    out[i * 8 + 0] = (r >> 8) & 255;
    out[i * 8 + 1] = r & 255;
    out[i * 8 + 2] = (g >> 8) & 255;
    out[i * 8 + 3] = g & 255;
    out[i * 8 + 4] = (b >> 8) & 255;
    out[i * 8 + 5] = b & 255;
    out[i * 8 + 6] = (a >> 8) & 255;
    out[i * 8 + 7] = a & 255;
  }
}

// Assembly:
movl %r8d, -0x40(%rsp)
movl %ecx, %eax
movl -0x40(%rsp), %ecx
movl %eax, -0x3c(%rsp)
movq %rdx, %rax
movl -0x3c(%rsp), %edx
movq %rax, -0x38(%rsp)
movq %rsi, %rax
movq -0x38(%rsp), %rsi
movq %rax, -0x30(%rsp)
movq %rdi, %r8
movq -0x30(%rsp), %rdi
movw %r9w, %ax
movw 0x8(%rsp), %r9w
movq %r8, -0x8(%rsp)
movq %rdi, -0x10(%rsp)
movq %rsi, -0x18(%rsp)
movw %dx, -0x1a(%rsp)
movw %cx, -0x1c(%rsp)
movw %ax, -0x1e(%rsp)
movq -0x18(%rsp), %rax
cmpl $0x0, (%rax)
jne 0xa7dd
movw -0x1a(%rsp), %ax
movw %ax, -0x20(%rsp)
movzwl -0x20(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq %rcx
movb %dl, (%rax,%rcx)
movzwl -0x20(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq %rcx
movb %dl, 0x1(%rax,%rcx)
jmp 0xaa43
movq -0x18(%rsp), %rax
cmpl $0x2, (%rax)
jne 0xa89a
movzwl -0x1a(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
imulq $0x6, -0x10(%rsp), %rcx
movb %dl, (%rax,%rcx)
movzwl -0x1a(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
imulq $0x6, -0x10(%rsp), %rcx
movb %dl, 0x1(%rax,%rcx)
movzwl -0x1c(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
imulq $0x6, -0x10(%rsp), %rcx
movb %dl, 0x2(%rax,%rcx)
movzwl -0x1c(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
imulq $0x6, -0x10(%rsp), %rcx
movb %dl, 0x3(%rax,%rcx)
movzwl -0x1e(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
imulq $0x6, -0x10(%rsp), %rcx
movb %dl, 0x4(%rax,%rcx)
movzwl -0x1e(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
imulq $0x6, -0x10(%rsp), %rcx
movb %dl, 0x5(%rax,%rcx)
jmp 0xaa41
movq -0x18(%rsp), %rax
cmpl $0x4, (%rax)
jne 0xa934
movw -0x1a(%rsp), %ax
movw %ax, -0x22(%rsp)
movzwl -0x22(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x2, %rcx
movb %dl, (%rax,%rcx)
movzwl -0x22(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x2, %rcx
movb %dl, 0x1(%rax,%rcx)
movzwl 0x8(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x2, %rcx
movb %dl, 0x2(%rax,%rcx)
movzwl 0x8(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x2, %rcx
movb %dl, 0x3(%rax,%rcx)
jmp 0xaa3f
movq -0x18(%rsp), %rax
cmpl $0x6, (%rax)
jne 0xaa3d
movzwl -0x1a(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, (%rax,%rcx)
movzwl -0x1a(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, 0x1(%rax,%rcx)
movzwl -0x1c(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, 0x2(%rax,%rcx)
movzwl -0x1c(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, 0x3(%rax,%rcx)
movzwl -0x1e(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, 0x4(%rax,%rcx)
movzwl -0x1e(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, 0x5(%rax,%rcx)
movzwl 0x8(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, 0x6(%rax,%rcx)
movzwl 0x8(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x8(%rsp), %rax
movq -0x10(%rsp), %rcx
shlq $0x3, %rcx
movb %dl, 0x7(%rax,%rcx)
jmp 0xaa3f
jmp 0xaa41
jmp 0xaa43
retq
nopw %cs:(%rax,%rax)