// File: /workspace/github_c_makefile_star2_O3/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, 0x20(%rsp)
je 0x904b
cmpl $0x2, %eax
movq %rsi, 0x10(%rsp)
je 0x9013
movq $0x0, 0x8(%rsp)
movl $0x0, %ebp
cmpl $0x3, %eax
jne 0x930e
movq 0x10(%rsi), %rbx
testq %rbx, %rbx
je 0x9085
movq 0x8(%rsi), %rax
cmpb $-0x1, -0x1(%rax,%rbx,4)
jne 0x9095
decq %rbx
jne 0x9001
jmp 0x9085
cmpl $0x0, 0x18(%rsi)
je 0x9085
movl 0x1c(%rsi), %ebx
movl $0x1, %r13d
movl $0x1, %edi
callq 0x1140
testq %rax, %rax
je 0x9111
movl %ebx, %r12d
movb %bh, (%rax)
movl $0x1, %r14d
movl $0x2, %r13d
jmp 0x9117
cmpl $0x0, 0x18(%rsi)
je 0x9085
movl 0x1c(%rsi), %ebx
movl $0x1, %r13d
movl $0x1, %edi
callq 0x1140
movq %rax, %rdi
testq %rax, %rax
je 0x92d0
movl %ebx, %r14d
movb %bh, (%rdi)
movl $0x1, %ebp
movl $0x2, %r13d
jmp 0x92d5
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x930e
xorl %r13d, %r13d
xorl %edi, %edi
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
movq 0x8(%rsi), %rax
movb 0x3(%rax,%r13,4), %r14b
leaq 0x1(%rbp), %r15
cmpq %r15, %rdi
jae 0x90ec
leaq (%rdi,%rdi), %rax
leaq (%r15,%r15,2), %r12
shrq %r12
cmpq %r15, %rax
cmovbq %r15, %r12
movq %rdi, 0x18(%rsp)
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x1160
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
testq %rax, %rax
jne 0x90f4
jmp 0x9104
movq 0x8(%rsp), %rax
movq %rdi, %r12
movb %r14b, -0x1(%rax,%r15)
movq %r12, %rdi
movq %rax, 0x8(%rsp)
movq %r15, %rbp
incq %r13
cmpq %r13, %rbx
jne 0x90a5
jmp 0x930e
movl %ebx, %r12d
xorl %r14d, %r14d
movq %rax, %rbx
leal (%r14,%r14), %eax
movl %r13d, %ecx
shrl %ecx
xorl %ebp, %ebp
cmpl %r13d, %eax
cmovaeq %rcx, %rbp
movq %rbp, %r15
addq %r13, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1160
testq %rax, %rax
je 0x9169
movb %r12b, -0x1(%rax,%r13)
movq 0x10(%rsp), %rcx
leaq 0x20(%rcx), %rdi
movl 0x20(%rcx), %r12d
movl %r12d, %r9d
shrl $0x8, %r9d
leaq 0x1(%r13), %rsi
testq %rbp, %rbp
movq %rax, %rbp
jne 0x91cf
jmp 0x918a
movq 0x10(%rsp), %rax
leaq 0x20(%rax), %rdi
movl 0x20(%rax), %r12d
movl %r12d, %r9d
shrl $0x8, %r9d
leaq 0x1(%r14), %rsi
movq %r14, %r13
movq %r14, %r15
movq %rbx, %rbp
movq %rsi, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
movq %r15, %rbx
leal (%r15,%r15), %eax
movl %esi, %ecx
shrl %ecx
xorl %r15d, %r15d
cmpl %r13d, %eax
cmovaq %rcx, %r15
addq %rsi, %r15
movq %rbp, %rdi
movq %r15, %rsi
movl %r9d, %r14d
callq 0x1160
movl %r14d, %r9d
movq 0x8(%rsp), %rdi
movl %r12d, %edx
movq 0x18(%rsp), %rsi
testq %rax, %rax
je 0x91e9
movq %rsi, %rcx
movb %r9b, -0x1(%rax,%rsi)
movl (%rdi), %edx
addq $0x2, %r13
movq %r13, %rsi
movq %r15, %rbx
movq %rax, %rbp
movq %rcx, %r13
cmpl %r13d, %ebx
jbe 0x91fb
movq %rbp, %rax
movq %rbx, %r12
movq 0x10(%rsp), %rcx
jmp 0x9234
leal (%rbx,%rbx), %eax
movl %esi, %ecx
shrl %ecx
xorl %r12d, %r12d
cmpl %r13d, %eax
cmovaq %rcx, %r12
addq %rsi, %r12
movq %rbp, %rdi
movq %rsi, %r14
movq %r12, %rsi
movl %edx, %r15d
callq 0x1160
movl %r15d, %edx
movq %r14, %rsi
testq %rax, %rax
movq 0x10(%rsp), %rcx
je 0x9352
movb %dl, -0x1(%rax,%rsi)
leaq 0x1(%rsi), %rdx
movq %r12, %rbx
movq %rax, %rbp
movb 0x25(%rcx), %r14b
cmpl %esi, %ebx
jbe 0x9252
movq %rbp, %rax
movq %rbx, %r12
jmp 0x9287
leal (%rbx,%rbx), %eax
movl %edx, %ecx
shrl %ecx
xorl %r12d, %r12d
cmpl %esi, %eax
cmovaq %rcx, %r12
addq %rdx, %r12
movq %rbp, %rdi
movq %rsi, %r13
movq %r12, %rsi
movq %rdx, %r15
callq 0x1160
movq %r15, %rdx
movq 0x10(%rsp), %rcx
testq %rax, %rax
je 0x935d
movb %r14b, -0x1(%rax,%rdx)
leaq 0x1(%rdx), %r13
movq %r12, %rbx
movq %rax, %rbp
movl 0x24(%rcx), %r14d
cmpl %edx, %ebx
jbe 0x92a3
movq %rbp, %rax
jmp 0x92ca
addl %ebx, %ebx
movl %r13d, %eax
shrl %eax
xorl %esi, %esi
cmpl %edx, %ebx
cmovaq %rax, %rsi
addq %r13, %rsi
movq %rbp, 0x8(%rsp)
movq %rbp, %rdi
movq %rdx, %rbp
callq 0x1160
testq %rax, %rax
je 0x930e
leaq (%rax,%r13), %rcx
jmp 0x9302
movl %ebx, %r14d
xorl %ebp, %ebp
leal (,%rbp,2), %eax
movl %r13d, %ecx
shrl %ecx
xorl %esi, %esi
cmpl %r13d, %eax
cmovaeq %rcx, %rsi
addq %r13, %rsi
movq %rdi, 0x8(%rsp)
callq 0x1160
testq %rax, %rax
je 0x930e
movq %rax, %rcx
addq %r13, %rcx
movb %r14b, -0x1(%rcx)
movq %rax, 0x8(%rsp)
movq %r13, %rbp
movq 0x20(%rsp), %rbx
leaq 0x8(%rbx), %rsi
leaq 0x664d(%rip), %rcx      # 0xf96b
movq %rbx, %rdi
movl %ebp, %edx
movq 0x8(%rsp), %r14
movq %r14, %r8
callq 0x47eb
testl %eax, %eax
jne 0x933c
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
movq %rsi, %rdx
movq %r13, %rsi
jmp 0x9242
movq %r13, %rax
movq %rdx, %r13
movq %rax, %rdx
jmp 0x9296