// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
je 0x8e31
cmpl $0x2, %eax
movq %rsi, 0x8(%rsp)
je 0x8e05
xorl %edx, %edx
movl $0x0, %r12d
cmpl $0x3, %eax
jne 0x9053
movq 0x10(%rsi), %r13
testq %r13, %r13
je 0x8d68
movq 0x8(%rsi), %rax
cmpb $-0x1, -0x1(%rax,%r13,4)
jne 0x8d68
decq %r13
jne 0x8d58
xorl %r13d, %r13d
testq %r13, %r13
je 0x8e55
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 0x8dd0
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 0x1120
testq %rax, %rax
je 0x8dd4
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %rdi
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rsi
jmp 0x8de8
xorl %ecx, %ecx
jmp 0x8de8
movb $0x1, %cl
movq %r15, %rdx
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdi
testb %cl, %cl
jne 0x8df4
movb %bpl, -0x1(%rdx,%r14)
movq %r14, %r12
incq %rbx
cmpq %rbx, %r13
jne 0x8d7a
jmp 0x9053
cmpl $0x0, 0x18(%rsi)
je 0x8e55
movl 0x1c(%rsi), %ebx
movl $0x1, %r12d
movl $0x1, %edi
callq 0x10f0
movq %rax, %rdx
xorl %r13d, %r13d
testq %rax, %rax
setne %r13b
je 0x8e5f
movb %bh, (%rdx)
jmp 0x8e62
cmpl $0x0, 0x18(%rsi)
je 0x8e55
movl 0x1c(%rsi), %ebx
movl $0x1, %r12d
movl $0x1, %edi
callq 0x10f0
testq %rax, %rax
je 0x8e93
movl %ebx, %ebp
movb %bh, (%rax)
jmp 0x8e98
xorl %edx, %edx
xorl %r12d, %r12d
jmp 0x9053
xorl %r12d, %r12d
leaq 0x1(%r12), %r14
cmpq %r13, %r12
jae 0x8e70
xorl %ecx, %ecx
jmp 0x8ecf
movq %r12, %rbp
addq %r14, %r12
movq %rdx, %r15
movq %rdx, %rdi
movq %r12, %rsi
callq 0x1120
testq %rax, %rax
je 0x8ec7
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8ecc
movl %ebx, %ebp
xorl %r12d, %r12d
leaq 0x1(,%r12,2), %rsi
movq %rax, %rbx
movq %rax, %rdi
callq 0x1120
movq %rbx, %rdx
testq %rax, %rax
cmovneq %rax, %rdx
je 0x9053
incq %r12
leaq (%rdx,%r12), %rax
jmp 0x904f
movb $0x1, %cl
movq %r15, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x8ee0
movb %bl, -0x1(%rdx,%r14)
movq %r14, %r12
movb 0x21(%rax), %bl
leaq 0x1(%r12), %r15
cmpl %r12d, %r13d
jbe 0x8ef1
xorl %ecx, %ecx
jmp 0x8f3a
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 0x1120
testq %rax, %rax
je 0x8f2d
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8f32
movb $0x1, %cl
movq %r14, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x8f46
movb %bl, -0x1(%rdx,%r15)
movq %r15, %r12
movb 0x20(%rax), %bl
leaq 0x1(%r12), %r15
cmpl %r12d, %r13d
jbe 0x8f57
xorl %ecx, %ecx
jmp 0x8fa0
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 0x1120
testq %rax, %rax
je 0x8f93
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8f98
movb $0x1, %cl
movq %r14, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x8fac
movb %bl, -0x1(%rdx,%r15)
movq %r15, %r12
movb 0x25(%rax), %bl
leaq 0x1(%r12), %r15
cmpl %r15d, %r13d
jae 0x8fef
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 0x1120
testq %rax, %rax
je 0x8ff3
xorl %ecx, %ecx
movq %rax, %rdx
movq %r12, %r13
jmp 0x8ff8
xorl %ecx, %ecx
jmp 0x9000
movb $0x1, %cl
movq %r14, %rdx
movq %rbp, %r12
movq 0x8(%rsp), %rax
testb %cl, %cl
jne 0x900c
movb %bl, -0x1(%rdx,%r15)
movq %r15, %r12
movl 0x24(%rax), %ebp
leaq 0x1(%r12), %rbx
cmpl %ebx, %r13d
jae 0x9042
addl %r13d, %r13d
leal (%rbx,%rbx,2), %esi
shrl %esi
cmpl %ebx, %r13d
cmovbq %rbx, %rsi
movq %rdx, %r14
movq %rdx, %rdi
callq 0x1120
movq %r14, %rdx
testq %rax, %rax
sete %cl
cmovneq %rax, %rdx
jmp 0x9044
xorl %ecx, %ecx
testb %cl, %cl
jne 0x9053
leaq (%rdx,%rbx), %rax
movq %rbx, %r12
movb %bpl, -0x1(%rax)
movq 0x18(%rsp), %rbx
leaq 0x8(%rbx), %rsi
leaq 0x690b(%rip), %rcx      # 0xf96e
movq %rdx, %r14
movq %rbx, %rdi
movl %r12d, %edx
movq %r14, %r8
callq 0x4357
testl %eax, %eax
jne 0x9080
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