// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/lodepng.c
// Function: addChunk_sBIT
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 0xfe2b
movl 0x14(%rbx), %eax
movq $0x0, (%rsp)
cmpl $0x6, %ecx
ja 0x10002
movl %ecx, %ecx
leaq 0x5b7b(%rip), %rdx      # 0x159c0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x108(%rbx), %ecx
movl $0x73, %ebp
testl %ecx, %ecx
je 0x10012
movl 0x10c(%rbx), %edx
testl %edx, %edx
je 0x10012
movl 0x110(%rbx), %edi
testl %edi, %edi
je 0x10012
cmpl %eax, %ecx
seta %cl
cmpl %eax, %edx
seta %dl
orb %cl, %dl
cmpl %eax, %edi
seta %al
orb %dl, %al
jne 0x10012
leaq 0x8118(%rip), %rcx      # 0x17fb5
movq %rsp, %rdi
movl $0x3, %edx
callq 0x11aa9
testl %eax, %eax
jne 0xffd6
movb 0x108(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
movb 0x10c(%rbx), %al
movb %al, 0x9(%rcx)
movb 0x110(%rbx), %al
movb %al, 0xa(%rcx)
jmp 0x10002
movl 0x108(%rbx), %ecx
decl %ecx
movl $0x73, %ebp
cmpl %eax, %ecx
jae 0x10012
leaq 0x80c3(%rip), %rcx      # 0x17fb5
movq %rsp, %rdi
movl $0x1, %edx
callq 0x11aa9
testl %eax, %eax
jne 0xffd6
movb 0x108(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
jmp 0x10002
movl 0x108(%rbx), %ecx
movl $0x73, %ebp
testl %ecx, %ecx
je 0x10012
movl 0x114(%rbx), %edx
testl %edx, %edx
je 0x10012
cmpl %eax, %ecx
seta %cl
cmpl %eax, %edx
seta %al
orb %cl, %al
jne 0x10012
leaq 0x8062(%rip), %rcx      # 0x17fb5
movq %rsp, %rdi
movl $0x2, %edx
callq 0x11aa9
testl %eax, %eax
jne 0xffd6
movb 0x108(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
movb 0x114(%rbx), %al
movb %al, 0x9(%rcx)
jmp 0x10002
movl 0x108(%rbx), %ecx
movl $0x73, %ebp
testl %ecx, %ecx
je 0x10012
movl 0x10c(%rbx), %edx
testl %edx, %edx
je 0x10012
movl 0x110(%rbx), %edi
testl %edi, %edi
je 0x10012
cmpl %eax, %ecx
ja 0x10012
cmpl %eax, %edx
ja 0x10012
cmpl %eax, %edi
ja 0x10012
movl 0x114(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jae 0x10012
leaq 0x7ff0(%rip), %rcx      # 0x17fb5
movq %rsp, %rdi
movl $0x4, %edx
callq 0x11aa9
testl %eax, %eax
je 0xffda
movl %eax, %ebp
jmp 0x10012
movb 0x108(%rbx), %al
movq (%rsp), %rcx
movb %al, 0x8(%rcx)
movb 0x10c(%rbx), %al
movb %al, 0x9(%rcx)
movb 0x110(%rbx), %al
movb %al, 0xa(%rcx)
movb 0x114(%rbx), %al
movb %al, 0xb(%rcx)
movq (%rsp), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x10012
callq 0x92a9
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq