// File: lvandeve[P]lodepng/lodepng.cpp
// Function: addChunk_bKGD(ucvector*, LodePNGInfo const*)
static unsigned addChunk_bKGD(ucvector* out, const LodePNGInfo* info) {
  unsigned char* chunk = 0;
  if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA) {
    CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, 2, "bKGD"));
    chunk[8] = (unsigned char)(info->background_r >> 8);
    chunk[9] = (unsigned char)(info->background_r & 255);
  } else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA) {
    CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, 6, "bKGD"));
    chunk[8] = (unsigned char)(info->background_r >> 8);
    chunk[9] = (unsigned char)(info->background_r & 255);
    chunk[10] = (unsigned char)(info->background_g >> 8);
    chunk[11] = (unsigned char)(info->background_g & 255);
    chunk[12] = (unsigned char)(info->background_b >> 8);
    chunk[13] = (unsigned char)(info->background_b & 255);
  } else if(info->color.colortype == LCT_PALETTE) {
    CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, 1, "bKGD"));
    chunk[8] = (unsigned char)(info->background_r & 255); /*palette index*/
  }
  if(chunk) lodepng_chunk_generate_crc(chunk);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x1038c
movq -0x18(%rbp), %rax
cmpl $0x4, 0x10(%rax)
jne 0x103e6
movq -0x10(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movl $0x2, %edx
leaq 0xa11ca(%rip), %rcx     # 0xb156a
callq 0x167a0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x103b9
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x10509
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x8, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x9(%rax)
jmp 0x104f2
movq -0x18(%rbp), %rax
cmpl $0x2, 0x10(%rax)
je 0x103fe
movq -0x18(%rbp), %rax
cmpl $0x6, 0x10(%rax)
jne 0x104a5
movq -0x10(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movl $0x6, %edx
leaq 0xa1158(%rip), %rcx     # 0xb156a
callq 0x167a0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x1042b
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x10509
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x8, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x9(%rax)
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
shrl $0x8, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xa(%rax)
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xb(%rax)
movq -0x18(%rbp), %rax
movl 0x44(%rax), %eax
shrl $0x8, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x18(%rbp), %rax
movl 0x44(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xd(%rax)
jmp 0x104f0
movq -0x18(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0x104ee
movq -0x10(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movl $0x1, %edx
leaq 0xa10a7(%rip), %rcx     # 0xb156a
callq 0x167a0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x104d9
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x10509
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x8(%rax)
jmp 0x104f0
jmp 0x104f2
cmpq $0x0, -0x20(%rbp)
je 0x10502
movq -0x20(%rbp), %rdi
callq 0x5020
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)