// File: /workspace/github_cpp_makefile_star2_O3/mhe[P]raytracerframework_cpp/lodepng.cpp
// Function: addChunk_bKGD(ucvector*, LodePNG_InfoPng const*)
static unsigned addChunk_bKGD(ucvector* out, const LodePNG_InfoPng* info)
{
  unsigned error = 0;
  ucvector bKGD;
  ucvector_init(&bKGD);
  if(info->color.colorType == 0 || info->color.colorType == 4)
  {
    ucvector_push_back(&bKGD, (unsigned char)(info->background_r / 256));
    ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256));
  }
  else if(info->color.colorType == 2 || info->color.colorType == 6)
  {
    ucvector_push_back(&bKGD, (unsigned char)(info->background_r / 256));
    ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256));
    ucvector_push_back(&bKGD, (unsigned char)(info->background_g / 256));
    ucvector_push_back(&bKGD, (unsigned char)(info->background_g % 256));
    ucvector_push_back(&bKGD, (unsigned char)(info->background_b / 256));
    ucvector_push_back(&bKGD, (unsigned char)(info->background_b % 256));
  }
  else if(info->color.colorType == 3)
  {
    ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256)); /*palette index*/
  }
  
  error = addChunk(out, "bKGD", bKGD.data, bKGD.size);
  ucvector_cleanup(&bKGD);
  
  return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r13
movl 0x18(%rsi), %eax
xorl %r12d, %r12d
xorl %ebx, %ebx
cmpq $0x6, %rax
ja 0x2072a
movq %rsi, %r15
leaq 0x10382(%rip), %rcx     # 0x3086c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x44(%r15), %r14d
movl $0x8, %edi
callq 0x4410
testq %rax, %rax
je 0x20706
movq %rax, %rbx
movl %r14d, %eax
movb %ah, (%rbx)
movl $0x2, %r12d
jmp 0x2071e
movl 0x44(%r15), %r14d
movl $0x8, %eax
movq %rax, -0x40(%rbp)
movl $0x8, %edi
callq 0x4410
movq %rax, %rbx
testq %rax, %rax
movq %r13, -0x50(%rbp)
je 0x205c6
rolw $0x8, %r14w
movw %r14w, (%rbx)
movl $0x2, %eax
movq %rax, -0x30(%rbp)
movl $0x3, %eax
movl $0xc, %ecx
movq %rcx, -0x38(%rbp)
leaq 0x48(%r15), %r13
movl 0x48(%r15), %ecx
movl %ecx, -0x44(%rbp)
leal (,%rax,8), %r12d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %r14
callq 0x44f0
movq %r13, %r8
movq %r14, %rdx
testq %rax, %rax
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %r13
movq -0x30(%rbp), %rdi
jne 0x205f7
jmp 0x20619
movl 0x44(%r15), %r14d
movl $0x8, %edi
callq 0x4410
testq %rax, %rax
je 0x20725
movq %rax, %rbx
movb %r14b, (%rax)
movl $0x1, %r12d
jmp 0x2072a
movl $0x8, %r12d
movl $0x8, %edi
callq 0x4410
testq %rax, %rax
je 0x20765
movb %r14b, (%rax)
leaq 0x48(%r15), %r8
movl 0x48(%r15), %ecx
movl %ecx, -0x44(%rbp)
movl $0x1, %edi
movl $0x2, %edx
movq %rdx, %rcx
movl -0x44(%rbp), %edx
movb %dh, -0x1(%rax,%rcx)
addq $0x2, %rdi
leal (,%rdi,4), %r13d
movq %rdi, %rdx
movq %r12, %rsi
movq %rcx, %rdi
movq %rax, %rbx
movb (%r8), %r14b
cmpl %esi, %r13d
jbe 0x2065c
movq %rdi, -0x30(%rbp)
movq %r13, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
leal (,%rdx,8), %r13d
movq %rbx, %rdi
movq %r13, %rsi
movq %rdx, %r12
callq 0x44f0
movq %r12, %rdx
testq %rax, %rax
jne 0x20662
movq %rdx, %r12
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %r13
movq -0x38(%rbp), %rcx
jmp 0x20676
movq %rbx, %rax
movq %rsi, %r13
movb %r14b, -0x1(%rax,%rdx)
leaq 0x1(%rdx), %r12
leal (,%r12,4), %ecx
movq %rax, %rbx
movb 0x4d(%r15), %r14b
cmpl %r13d, %ecx
jbe 0x206b8
movq %rcx, -0x38(%rbp)
movq %r13, -0x40(%rbp)
movq %rdx, -0x30(%rbp)
leal (,%r12,8), %r13d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x44f0
testq %rax, %rax
jne 0x206bb
movq %r12, %r14
movq -0x30(%rbp), %r12
movq -0x50(%rbp), %r13
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rdx
jmp 0x206d7
movq %rbx, %rax
movb %r14b, -0x1(%rax,%r12)
leaq 0x1(%r12), %r14
leal (,%r14,4), %edx
movq %r13, %rcx
movq %rax, %rbx
movq -0x50(%rbp), %r13
movb 0x4c(%r15), %r15b
cmpl %ecx, %edx
jbe 0x206f6
leal (,%r14,8), %esi
movq %rbx, %rdi
callq 0x44f0
testq %rax, %rax
jne 0x206f9
jmp 0x2072a
movq %rbx, %rax
movb %r15b, -0x1(%rax,%r14)
movq %rax, %rbx
movq %r14, %r12
jmp 0x2072a
movl $0x8, %edi
callq 0x4410
testq %rax, %rax
je 0x20725
movq %rax, %rbx
movl $0x1, %r12d
movb %r14b, -0x1(%rbx,%r12)
jmp 0x2072a
xorl %ebx, %ebx
xorl %r12d, %r12d
leaq 0x8(%r13), %rsi
leaq 0x1049e(%rip), %rcx     # 0x30bd3
movq %r13, %rdi
movl %r12d, %edx
movq %rbx, %r8
callq 0x1c3c3
testl %eax, %eax
jne 0x2074f
movq 0x8(%r13), %rax
movq %rax, 0x10(%r13)
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4380
movl $0x1, %eax
movl $0x4, %ecx
movq %rcx, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
jmp 0x20564