// File: /workspace/github_cpp_makefile_star2_O1/lvandeve[P]lodepng/lodepng.cpp
// Function: addChunk_sBIT(ucvector*, LodePNGInfo const*)
static unsigned addChunk_sBIT(ucvector* out, const LodePNGInfo* info) {
  unsigned bitdepth = (info->color.colortype == LCT_PALETTE) ? 8 : info->color.bitdepth;
  unsigned char* chunk = 0;
  if(info->color.colortype == LCT_GREY) {
    if(info->sbit_r == 0 || info->sbit_r > bitdepth) return 115;
    CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, 1, "sBIT"));
    chunk[8] = info->sbit_r;
  } else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_PALETTE) {
    if(info->sbit_r == 0 || info->sbit_g == 0 || info->sbit_b == 0) return 115;
    if(info->sbit_r > bitdepth || info->sbit_g > bitdepth || info->sbit_b > bitdepth) return 115;
    CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, 3, "sBIT"));
    chunk[8] = info->sbit_r;
    chunk[9] = info->sbit_g;
    chunk[10] = info->sbit_b;
  } else if(info->color.colortype == LCT_GREY_ALPHA) {
    if(info->sbit_r == 0 || info->sbit_a == 0) return 115;
    if(info->sbit_r > bitdepth || info->sbit_a > bitdepth) return 115;
    CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, 2, "sBIT"));
    chunk[8] = info->sbit_r;
    chunk[9] = info->sbit_a;
  } else if(info->color.colortype == LCT_RGBA) {
    if(info->sbit_r == 0 || info->sbit_g == 0 || info->sbit_b == 0 || info->sbit_a == 0 ||
       info->sbit_r > bitdepth || info->sbit_g > bitdepth ||
       info->sbit_b > bitdepth || info->sbit_a > bitdepth) {
      return 115;
    }
    CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, 4, "sBIT"));
    chunk[8] = info->sbit_r;
    chunk[9] = info->sbit_g;
    chunk[10] = info->sbit_b;
    chunk[11] = info->sbit_a;
  }
  if(chunk) lodepng_chunk_generate_crc(chunk);
  return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %rsi
movl 0x10(%rbx), %ecx
movl $0x8, %eax
cmpl $0x3, %ecx
je 0xc2cf
movl 0x14(%rbx), %eax
movq $0x0, (%rsp)
cmpl $0x6, %ecx
ja 0xc4a6
movl %ecx, %ecx
leaq 0x65e97(%rip), %rdx     # 0x72180
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x164(%rbx), %ecx
movl $0x73, %ebp
testl %ecx, %ecx
je 0xc4b6
movl 0x168(%rbx), %edx
testl %edx, %edx
je 0xc4b6
movl 0x16c(%rbx), %edi
testl %edi, %edi
je 0xc4b6
cmpl %eax, %ecx
seta %cl
cmpl %eax, %edx
seta %dl
orb %cl, %dl
cmpl %eax, %edi
seta %al
orb %dl, %al
jne 0xc4b6
leaq 0x68467(%rip), %rcx     # 0x747a8
movq %rsp, %rdi
movl $0x3, %edx
callq 0xe9f0
testl %eax, %eax
jne 0xc47a
movb 0x164(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
movb 0x168(%rbx), %al
movb %al, 0x9(%rcx)
movb 0x16c(%rbx), %al
movb %al, 0xa(%rcx)
jmp 0xc4a6
movl 0x164(%rbx), %ecx
decl %ecx
movl $0x73, %ebp
cmpl %eax, %ecx
jae 0xc4b6
leaq 0x68412(%rip), %rcx     # 0x747a8
movq %rsp, %rdi
movl $0x1, %edx
callq 0xe9f0
testl %eax, %eax
jne 0xc47a
movb 0x164(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
jmp 0xc4a6
movl 0x164(%rbx), %ecx
movl $0x73, %ebp
testl %ecx, %ecx
je 0xc4b6
movl 0x170(%rbx), %edx
testl %edx, %edx
je 0xc4b6
cmpl %eax, %ecx
seta %cl
cmpl %eax, %edx
seta %al
orb %cl, %al
jne 0xc4b6
leaq 0x683b1(%rip), %rcx     # 0x747a8
movq %rsp, %rdi
movl $0x2, %edx
callq 0xe9f0
testl %eax, %eax
jne 0xc47a
movb 0x164(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
movb 0x170(%rbx), %al
movb %al, 0x9(%rcx)
jmp 0xc4a6
movl 0x164(%rbx), %ecx
movl $0x73, %ebp
testl %ecx, %ecx
je 0xc4b6
movl 0x168(%rbx), %edx
testl %edx, %edx
je 0xc4b6
movl 0x16c(%rbx), %edi
testl %edi, %edi
je 0xc4b6
cmpl %eax, %ecx
ja 0xc4b6
cmpl %eax, %edx
ja 0xc4b6
cmpl %eax, %edi
ja 0xc4b6
movl 0x170(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jae 0xc4b6
leaq 0x6833f(%rip), %rcx     # 0x747a8
movq %rsp, %rdi
movl $0x4, %edx
callq 0xe9f0
testl %eax, %eax
je 0xc47e
movl %eax, %ebp
jmp 0xc4b6
movb 0x164(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
movb 0x168(%rbx), %al
movb %al, 0x9(%rcx)
movb 0x16c(%rbx), %al
movb %al, 0xa(%rcx)
movb 0x170(%rbx), %al
movb %al, 0xb(%rcx)
movq (%rsp), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0xc4b6
callq 0x4f2f
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq