// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: rgba8ToPixel
static unsigned rgba8ToPixel(unsigned char* out, size_t i,
                             const LodePNGColorMode* mode, ColorTree* tree /*for palette*/,
                             unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
  if(mode->colortype == LCT_GREY)
  {
    unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
    if(mode->bitdepth == 8) out[i] = grey;
    else if(mode->bitdepth == 16) out[i * 2 + 0] = out[i * 2 + 1] = grey;
    else
    {
      /*take the most significant bits of grey*/
      grey = (grey >> (8 - mode->bitdepth)) & ((1 << mode->bitdepth) - 1);
      addColorBits(out, i, mode->bitdepth, grey);
    }
  }
  else if(mode->colortype == LCT_RGB)
  {
    if(mode->bitdepth == 8)
    {
      out[i * 3 + 0] = r;
      out[i * 3 + 1] = g;
      out[i * 3 + 2] = b;
    }
    else
    {
      out[i * 6 + 0] = out[i * 6 + 1] = r;
      out[i * 6 + 2] = out[i * 6 + 3] = g;
      out[i * 6 + 4] = out[i * 6 + 5] = b;
    }
  }
  else if(mode->colortype == LCT_PALETTE)
  {
    int index = color_tree_get(tree, r, g, b, a);
    if(index < 0) return 82; /*color not in palette*/
    if(mode->bitdepth == 8) out[i] = index;
    else addColorBits(out, i, mode->bitdepth, (unsigned)index);
  }
  else if(mode->colortype == LCT_GREY_ALPHA)
  {
    unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
    if(mode->bitdepth == 8)
    {
      out[i * 2 + 0] = grey;
      out[i * 2 + 1] = a;
    }
    else if(mode->bitdepth == 16)
    {
      out[i * 4 + 0] = out[i * 4 + 1] = grey;
      out[i * 4 + 2] = out[i * 4 + 3] = a;
    }
  }
  else if(mode->colortype == LCT_RGBA)
  {
    if(mode->bitdepth == 8)
    {
      out[i * 4 + 0] = r;
      out[i * 4 + 1] = g;
      out[i * 4 + 2] = b;
      out[i * 4 + 3] = a;
    }
    else
    {
      out[i * 8 + 0] = out[i * 8 + 1] = r;
      out[i * 8 + 2] = out[i * 8 + 3] = g;
      out[i * 8 + 4] = out[i * 8 + 5] = b;
      out[i * 8 + 6] = out[i * 8 + 7] = a;
    }
  }

  return 0; /*no error*/
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %r8d, -0x54(%rbp)
movq %rcx, %rax
movl -0x54(%rbp), %ecx
movq %rax, -0x50(%rbp)
movq %rdx, %rax
movq -0x50(%rbp), %rdx
movq %rax, -0x48(%rbp)
movq %rsi, %rax
movq -0x48(%rbp), %rsi
movq %rax, -0x40(%rbp)
movq %rdi, %r8
movq -0x40(%rbp), %rdi
movb %r9b, %al
movb 0x18(%rbp), %r9b
movb 0x10(%rbp), %r9b
movq %r8, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movb %cl, -0x29(%rbp)
movb %al, -0x2a(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x5ae6
movb -0x29(%rbp), %al
movb %al, -0x2b(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0x5a71
movb -0x2b(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x5ae1
movq -0x20(%rbp), %rax
cmpl $0x10, 0x4(%rax)
jne 0x5a9d
movb -0x2b(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq %rcx
movb %dl, 0x1(%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq %rcx
movb %dl, (%rax,%rcx)
jmp 0x5adf
movzbl -0x2b(%rbp), %eax
movq -0x20(%rbp), %rdx
movl $0x8, %ecx
subl 0x4(%rdx), %ecx
sarl %cl, %eax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
subl $0x1, %ecx
andl %ecx, %eax
movb %al, -0x2b(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edx
movzbl -0x2b(%rbp), %ecx
callq 0xe100
jmp 0x5ae1
jmp 0x5d93
movq -0x20(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x5b89
movq -0x20(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0x5b2e
movb -0x29(%rbp), %dl
movq -0x10(%rbp), %rax
imulq $0x3, -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movb -0x2a(%rbp), %dl
movq -0x10(%rbp), %rax
imulq $0x3, -0x18(%rbp), %rcx
movb %dl, 0x1(%rax,%rcx)
movb 0x10(%rbp), %dl
movq -0x10(%rbp), %rax
imulq $0x3, -0x18(%rbp), %rcx
movb %dl, 0x2(%rax,%rcx)
jmp 0x5b84
movb -0x29(%rbp), %dl
movq -0x10(%rbp), %rax
imulq $0x6, -0x18(%rbp), %rcx
movb %dl, 0x1(%rax,%rcx)
movq -0x10(%rbp), %rax
imulq $0x6, -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movb -0x2a(%rbp), %dl
movq -0x10(%rbp), %rax
imulq $0x6, -0x18(%rbp), %rcx
movb %dl, 0x3(%rax,%rcx)
movq -0x10(%rbp), %rax
imulq $0x6, -0x18(%rbp), %rcx
movb %dl, 0x2(%rax,%rcx)
movb 0x10(%rbp), %dl
movq -0x10(%rbp), %rax
imulq $0x6, -0x18(%rbp), %rcx
movb %dl, 0x5(%rax,%rcx)
movq -0x10(%rbp), %rax
imulq $0x6, -0x18(%rbp), %rcx
movb %dl, 0x4(%rax,%rcx)
jmp 0x5d91
movq -0x20(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x5bff
movq -0x28(%rbp), %rdi
movb -0x29(%rbp), %dl
movb -0x2a(%rbp), %cl
movb 0x10(%rbp), %al
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
movzbl 0x18(%rbp), %r8d
callq 0xe1c0
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x5bc7
movl $0x52, -0x4(%rbp)
jmp 0x5d9a
movq -0x20(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0x5be3
movl -0x30(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x5bfa
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edx
movl -0x30(%rbp), %ecx
callq 0xe100
jmp 0x5d8f
movq -0x20(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x5c97
movb -0x29(%rbp), %al
movb %al, -0x31(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0x5c41
movb -0x31(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq %rcx
movb %dl, (%rax,%rcx)
movb 0x18(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq %rcx
movb %dl, 0x1(%rax,%rcx)
jmp 0x5c92
movq -0x20(%rbp), %rax
cmpl $0x10, 0x4(%rax)
jne 0x5c90
movb -0x31(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, 0x1(%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, (%rax,%rcx)
movb 0x18(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, 0x3(%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, 0x2(%rax,%rcx)
jmp 0x5c92
jmp 0x5d8d
movq -0x20(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x5d8b
movq -0x20(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0x5cfe
movb -0x29(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, (%rax,%rcx)
movb -0x2a(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, 0x1(%rax,%rcx)
movb 0x10(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, 0x2(%rax,%rcx)
movb 0x18(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x2, %rcx
movb %dl, 0x3(%rax,%rcx)
jmp 0x5d89
movb -0x29(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, 0x1(%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, (%rax,%rcx)
movb -0x2a(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, 0x3(%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, 0x2(%rax,%rcx)
movb 0x10(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, 0x5(%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, 0x4(%rax,%rcx)
movb 0x18(%rbp), %dl
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, 0x7(%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
movb %dl, 0x6(%rax,%rcx)
jmp 0x5d8b
jmp 0x5d8d
jmp 0x5d8f
jmp 0x5d91
jmp 0x5d93
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)