// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %rsi
movl 0x10(%rbx), %edx
cmpl $0x3, %edx
jne 0xc604
movq $0x0, 0x8(%rsp)
movl $0x8, %ecx
movl 0x164(%rbx), %edx
movl $0x73, %eax
testl %edx, %edx
je 0xc768
movl 0x168(%rbx), %edi
testl %edi, %edi
je 0xc768
movl 0x16c(%rbx), %r8d
testl %r8d, %r8d
je 0xc768
cmpl %ecx, %edx
seta %dl
cmpl %ecx, %edi
seta %dil
orb %dl, %dil
cmpl %ecx, %r8d
seta %cl
orb %dil, %cl
jne 0xc768
leaq 0x68304(%rip), %rcx     # 0x748cc
leaq 0x8(%rsp), %rdi
movl $0x3, %edx
callq 0xebd0
testl %eax, %eax
jne 0xc768
movb 0x164(%rbx), %al
movq 0x8(%rsp), %rdi
movb %al, 0x8(%rdi)
movb 0x168(%rbx), %al
movb %al, 0x9(%rdi)
movb 0x16c(%rbx), %al
movb %al, 0xa(%rdi)
jmp 0xc761
movl 0x14(%rbx), %ecx
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
cmpl $0x6, %edx
ja 0xc768
movl %edx, %edx
leaq 0x65c7c(%rip), %rdi     # 0x722a0
movslq (%rdi,%rdx,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
movl 0x164(%rbx), %edx
decl %edx
movl $0x73, %eax
cmpl %ecx, %edx
jae 0xc768
leaq 0x68283(%rip), %rcx     # 0x748cc
leaq 0x8(%rsp), %rdi
movl $0x1, %edx
callq 0xebd0
testl %eax, %eax
jne 0xc768
movb 0x164(%rbx), %al
movq 0x8(%rsp), %rdi
movb %al, 0x8(%rdi)
jmp 0xc761
movl 0x164(%rbx), %edx
movl $0x73, %eax
testl %edx, %edx
je 0xc768
movl 0x170(%rbx), %edi
testl %edi, %edi
je 0xc768
cmpl %ecx, %edx
seta %dl
cmpl %ecx, %edi
seta %cl
orb %dl, %cl
jne 0xc768
leaq 0x6821f(%rip), %rcx     # 0x748cc
leaq 0x8(%rsp), %rdi
movl $0x2, %edx
callq 0xebd0
testl %eax, %eax
jne 0xc768
movb 0x164(%rbx), %al
movq 0x8(%rsp), %rdi
movb %al, 0x8(%rdi)
movb 0x170(%rbx), %al
movb %al, 0x9(%rdi)
jmp 0xc761
movl 0x164(%rbx), %edx
movl $0x73, %eax
testl %edx, %edx
je 0xc768
movl 0x168(%rbx), %edi
testl %edi, %edi
je 0xc768
movl 0x16c(%rbx), %r8d
testl %r8d, %r8d
je 0xc768
cmpl %ecx, %edx
ja 0xc768
cmpl %ecx, %edi
ja 0xc768
cmpl %ecx, %r8d
ja 0xc768
movl 0x170(%rbx), %edx
decl %edx
cmpl %ecx, %edx
jae 0xc768
leaq 0x681a7(%rip), %rcx     # 0x748cc
leaq 0x8(%rsp), %rdi
movl $0x4, %edx
callq 0xebd0
testl %eax, %eax
jne 0xc768
movb 0x164(%rbx), %al
movq 0x8(%rsp), %rdi
movb %al, 0x8(%rdi)
movb 0x168(%rbx), %al
movb %al, 0x9(%rdi)
movb 0x16c(%rbx), %al
movb %al, 0xa(%rdi)
movb 0x170(%rbx), %al
movb %al, 0xb(%rdi)
callq 0x54f4
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq