// File: /workspace/github_c_makefile_star2_O3/Joy-Division[P]tools-mgs/lodepng/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 >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
    }
  }
  else if(info->colortype == LCT_RGB)
  {
    if(info->key_defined)
    {
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_g >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_g & 255));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_b >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_b & 255));
    }
  }

  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 0x947b
cmpl $0x2, %eax
movq %rsi, 0x10(%rsp)
je 0x9443
movq $0x0, 0x8(%rsp)
movl $0x0, %ebp
cmpl $0x3, %eax
jne 0x973e
movq 0x10(%rsi), %rbx
testq %rbx, %rbx
je 0x94b5
movq 0x8(%rsi), %rax
cmpb $-0x1, -0x1(%rax,%rbx,4)
jne 0x94c5
decq %rbx
jne 0x9431
jmp 0x94b5
cmpl $0x0, 0x18(%rsi)
je 0x94b5
movl 0x1c(%rsi), %ebx
movl $0x1, %r13d
movl $0x1, %edi
callq 0x1100
testq %rax, %rax
je 0x9541
movl %ebx, %r12d
movb %bh, (%rax)
movl $0x1, %r14d
movl $0x2, %r13d
jmp 0x9547
cmpl $0x0, 0x18(%rsi)
je 0x94b5
movl 0x1c(%rsi), %ebx
movl $0x1, %r13d
movl $0x1, %edi
callq 0x1100
movq %rax, %rdi
testq %rax, %rax
je 0x9700
movl %ebx, %r14d
movb %bh, (%rdi)
movl $0x1, %ebp
movl $0x2, %r13d
jmp 0x9705
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x973e
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 0x951c
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 0x1130
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
testq %rax, %rax
jne 0x9524
jmp 0x9534
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 0x94d5
jmp 0x973e
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 0x1130
testq %rax, %rax
je 0x9599
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 0x95ff
jmp 0x95ba
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 0x1130
movl %r14d, %r9d
movq 0x8(%rsp), %rdi
movl %r12d, %edx
movq 0x18(%rsp), %rsi
testq %rax, %rax
je 0x9619
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 0x962b
movq %rbp, %rax
movq %rbx, %r12
movq 0x10(%rsp), %rcx
jmp 0x9664
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 0x1130
movl %r15d, %edx
movq %r14, %rsi
testq %rax, %rax
movq 0x10(%rsp), %rcx
je 0x9782
movb %dl, -0x1(%rax,%rsi)
leaq 0x1(%rsi), %rdx
movq %r12, %rbx
movq %rax, %rbp
movb 0x25(%rcx), %r14b
cmpl %esi, %ebx
jbe 0x9682
movq %rbp, %rax
movq %rbx, %r12
jmp 0x96b7
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 0x1130
movq %r15, %rdx
movq 0x10(%rsp), %rcx
testq %rax, %rax
je 0x978d
movb %r14b, -0x1(%rax,%rdx)
leaq 0x1(%rdx), %r13
movq %r12, %rbx
movq %rax, %rbp
movl 0x24(%rcx), %r14d
cmpl %edx, %ebx
jbe 0x96d3
movq %rbp, %rax
jmp 0x96fa
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 0x1130
testq %rax, %rax
je 0x973e
leaq (%rax,%r13), %rcx
jmp 0x9732
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 0x1130
testq %rax, %rax
je 0x973e
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 0x6300(%rip), %rcx      # 0xfa4e
movq %rbx, %rdi
movl %ebp, %edx
movq 0x8(%rsp), %r14
movq %r14, %r8
callq 0x4a14
testl %eax, %eax
jne 0x976c
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 0x9672
movq %r13, %rax
movq %rdx, %r13
movq %rax, %rdx
jmp 0x96c6