// File: /workspace/github_c_makefile_star2_O1/pje[P]pixelsort/lodepng.c
// Function: addChunk_tRNS
static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info)
{
  unsigned error = 0;
  size_t i;
  ucvector tRNS;
  ucvector_init(&tRNS);
  if(info->colortype == LCT_PALETTE)
  {
    size_t amount = info->palettesize;
    /*the tail of palette values that all have 255 as alpha, does not have to be encoded*/
    for(i = info->palettesize; i > 0; i--)
    {
      if(info->palette[4 * (i - 1) + 3] == 255) amount--;
      else break;
    }
    /*add only alpha channel*/
    for(i = 0; i < amount; i++) ucvector_push_back(&tRNS, info->palette[4 * i + 3]);
  }
  else if(info->colortype == LCT_GREY)
  {
    if(info->key_defined)
    {
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r / 256));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r % 256));
    }
  }
  else if(info->colortype == LCT_RGB)
  {
    if(info->key_defined)
    {
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r / 256));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r % 256));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_g / 256));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_g % 256));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_b / 256));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_b % 256));
    }
  }

  error = addChunk(out, "tRNS", tRNS.data, tRNS.size);
  ucvector_cleanup(&tRNS);

  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl (%rsi), %eax
testl %eax, %eax
movq %rdi, 0x18(%rsp)
je 0x8b84
cmpl $0x2, %eax
movq %rsi, 0x8(%rsp)
je 0x8b58
xorl %edx, %edx
movl $0x0, %r12d
cmpl $0x3, %eax
jne 0x8da6
movq 0x10(%rsi), %r13
testq %r13, %r13
je 0x8abb
movq 0x8(%rsi), %rax
cmpb $-0x1, -0x1(%rax,%r13,4)
jne 0x8abb
decq %r13
jne 0x8aab
xorl %r13d, %r13d
testq %r13, %r13
je 0x8ba8
xorl %ebx, %ebx
xorl %edi, %edi
xorl %r12d, %r12d
xorl %edx, %edx
movq 0x8(%rsi), %rax
movb 0x3(%rax,%rbx,4), %bpl
leaq 0x1(%r12), %r14
cmpq %r14, %rdi
jae 0x8b23
movq %r12, 0x10(%rsp)
leaq (%rdi,%rdi), %rax
leaq (%r14,%r14,2), %r12
shrq %r12
cmpq %r14, %rax
cmovbq %r14, %r12
movq %rdx, %r15
movq %rdi, 0x20(%rsp)
movq %rdx, %rdi
movq %r12, %rsi
callq 0x1150
testq %rax, %rax
je 0x8b27
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %rdi
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rsi
jmp 0x8b3b
xorl %ecx, %ecx
jmp 0x8b3b
movb $0x1, %cl
movq %r15, %rdx
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdi
testb %cl, %cl
jne 0x8b47
movb %bpl, -0x1(%rdx,%r14)
movq %r14, %r12
incq %rbx
cmpq %rbx, %r13
jne 0x8acd
jmp 0x8da6
cmpl $0x0, 0x18(%rsi)
je 0x8ba8
movl 0x1c(%rsi), %ebx
movl $0x1, %r12d
movl $0x1, %edi
callq 0x1130
movq %rax, %rdx
xorl %r13d, %r13d
testq %rax, %rax
setne %r13b
je 0x8bb2
movb %bh, (%rdx)
jmp 0x8bb5
cmpl $0x0, 0x18(%rsi)
je 0x8ba8
movl 0x1c(%rsi), %ebx
movl $0x1, %r12d
movl $0x1, %edi
callq 0x1130
testq %rax, %rax
je 0x8be6
movl %ebx, %ebp
movb %bh, (%rax)
jmp 0x8beb
xorl %edx, %edx
xorl %r12d, %r12d
jmp 0x8da6
xorl %r12d, %r12d
leaq 0x1(%r12), %r14
cmpq %r13, %r12
jae 0x8bc3
xorl %ecx, %ecx
jmp 0x8c22
movq %r12, %rbp
addq %r14, %r12
movq %rdx, %r15
movq %rdx, %rdi
movq %r12, %rsi
callq 0x1150
testq %rax, %rax
je 0x8c1a
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8c1f
movl %ebx, %ebp
xorl %r12d, %r12d
leaq 0x1(,%r12,2), %rsi
movq %rax, %rbx
movq %rax, %rdi
callq 0x1150
movq %rbx, %rdx
testq %rax, %rax
cmovneq %rax, %rdx
je 0x8da6
incq %r12
leaq (%rdx,%r12), %rax
jmp 0x8da2
movb $0x1, %cl
movq %r15, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x8c33
movb %bl, -0x1(%rdx,%r14)
movq %r14, %r12
movb 0x21(%rax), %bl
leaq 0x1(%r12), %r15
cmpl %r12d, %r13d
jbe 0x8c44
xorl %ecx, %ecx
jmp 0x8c8d
leal (,%r13,2), %eax
movl %r15d, %ecx
shrl %ecx
movq %r12, %rsi
xorl %r12d, %r12d
movq %rsi, %rbp
cmpl %esi, %eax
cmovaq %rcx, %r12
addq %r15, %r12
movq %rdx, %r14
movq %rdx, %rdi
movq %r12, %rsi
callq 0x1150
testq %rax, %rax
je 0x8c80
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8c85
movb $0x1, %cl
movq %r14, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x8c99
movb %bl, -0x1(%rdx,%r15)
movq %r15, %r12
movb 0x20(%rax), %bl
leaq 0x1(%r12), %r15
cmpl %r12d, %r13d
jbe 0x8caa
xorl %ecx, %ecx
jmp 0x8cf3
leal (,%r13,2), %eax
movl %r15d, %ecx
shrl %ecx
movq %r12, %rsi
xorl %r12d, %r12d
movq %rsi, %rbp
cmpl %esi, %eax
cmovaq %rcx, %r12
addq %r15, %r12
movq %rdx, %r14
movq %rdx, %rdi
movq %r12, %rsi
callq 0x1150
testq %rax, %rax
je 0x8ce6
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8ceb
movb $0x1, %cl
movq %r14, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x8cff
movb %bl, -0x1(%rdx,%r15)
movq %r15, %r12
movb 0x25(%rax), %bl
leaq 0x1(%r12), %r15
cmpl %r15d, %r13d
jae 0x8d42
movq %r12, %rbp
leal (,%r13,2), %eax
leal (%r15,%r15,2), %r12d
shrl %r12d
cmpl %r15d, %eax
cmovbq %r15, %r12
movq %rdx, %r14
movq %rdx, %rdi
movq %r12, %rsi
callq 0x1150
testq %rax, %rax
je 0x8d46
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8d4b
xorl %ecx, %ecx
jmp 0x8d53
movb $0x1, %cl
movq %r14, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x8d5f
movb %bl, -0x1(%rdx,%r15)
movq %r15, %r12
movl 0x24(%rax), %ebp
leaq 0x1(%r12), %rbx
cmpl %ebx, %r13d
jae 0x8d95
addl %r13d, %r13d
leal (%rbx,%rbx,2), %esi
shrl %esi
cmpl %ebx, %r13d
cmovbq %rbx, %rsi
movq %rdx, %r14
movq %rdx, %rdi
callq 0x1150
movq %r14, %rdx
testq %rax, %rax
sete %cl
cmovneq %rax, %rdx
jmp 0x8d97
xorl %ecx, %ecx
testb %cl, %cl
jne 0x8da6
leaq (%rdx,%rbx), %rax
movq %rbx, %r12
movb %bpl, -0x1(%rax)
movq 0x18(%rsp), %rbx
leaq 0x8(%rbx), %rsi
leaq 0x6af5(%rip), %rcx      # 0xf8ab
movq %rdx, %r14
movq %rbx, %rdi
movl %r12d, %edx
movq %r14, %r8
callq 0x4237
testl %eax, %eax
jne 0x8dd3
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rbx)
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030