// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/lodepng.c
// Function: readChunk_sBIT
static unsigned readChunk_sBIT(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
  unsigned bitdepth = (info->color.colortype == LCT_PALETTE) ? 8 : info->color.bitdepth;
  if(info->color.colortype == LCT_GREY) {
    /*error: this chunk must be 1 bytes for grayscale image*/
    if(chunkLength != 1) return 114;
    if(data[0] == 0 || data[0] > bitdepth) return 115;
    info->sbit_defined = 1;
    info->sbit_r = info->sbit_g = info->sbit_b = data[0]; /*setting g and b is not required, but sensible*/
  } else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_PALETTE) {
    /*error: this chunk must be 3 bytes for RGB and palette image*/
    if(chunkLength != 3) return 114;
    if(data[0] == 0 || data[1] == 0 || data[2] == 0) return 115;
    if(data[0] > bitdepth || data[1] > bitdepth || data[2] > bitdepth) return 115;
    info->sbit_defined = 1;
    info->sbit_r = data[0];
    info->sbit_g = data[1];
    info->sbit_b = data[2];
  } else if(info->color.colortype == LCT_GREY_ALPHA) {
    /*error: this chunk must be 2 byte for grayscale with alpha image*/
    if(chunkLength != 2) return 114;
    if(data[0] == 0 || data[1] == 0) return 115;
    if(data[0] > bitdepth || data[1] > bitdepth) return 115;
    info->sbit_defined = 1;
    info->sbit_r = info->sbit_g = info->sbit_b = data[0]; /*setting g and b is not required, but sensible*/
    info->sbit_a = data[1];
  } else if(info->color.colortype == LCT_RGBA) {
    /*error: this chunk must be 4 bytes for grayscale image*/
    if(chunkLength != 4) return 114;
    if(data[0] == 0 || data[1] == 0 || data[2] == 0 || data[3] == 0) return 115;
    if(data[0] > bitdepth || data[1] > bitdepth || data[2] > bitdepth || data[3] > bitdepth) return 115;
    info->sbit_defined = 1;
    info->sbit_r = data[0];
    info->sbit_g = data[1];
    info->sbit_b = data[2];
    info->sbit_a = data[3];
  }

  return 0; /* OK */
}

// Assembly:
movl 0x10(%rdi), %r8d
cmpl $0x3, %r8d
jne 0xbd39
pushq $0x8
popq %rcx
cmpq $0x3, %rdx
jne 0xbe78
movzbl (%rsi), %edx
pushq $0x73
popq %rax
testl %edx, %edx
je 0xbe9d
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0xbe9d
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0xbe9d
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %r8b
orb %dl, %r8b
cmpl %r9d, %ecx
setb %cl
orb %r8b, %cl
jne 0xbe9d
movl $0x1, 0x104(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x108(%rdi)
movzbl 0x1(%rsi), %eax
movl %eax, 0x10c(%rdi)
movzbl 0x2(%rsi), %eax
movl %eax, 0x110(%rdi)
jmp 0xbe9b
xorl %eax, %eax
cmpl $0x6, %r8d
ja 0xbe9d
movl 0x14(%rdi), %ecx
movl %r8d, %r8d
leaq 0x7c72(%rip), %r9       # 0x139c4
movslq (%r9,%r8,4), %r8
addq %r9, %r8
jmpq *%r8
cmpq $0x1, %rdx
jne 0xbe78
movb (%rsi), %al
testb %al, %al
sete %dl
movzbl %al, %eax
cmpl %eax, %ecx
setb %al
orb %dl, %al
je 0xbe7c
pushq $0x73
jmp 0xbe7a
cmpq $0x2, %rdx
jne 0xbe78
movzbl (%rsi), %edx
pushq $0x73
popq %rax
testl %edx, %edx
je 0xbe9d
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0xbe9d
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %cl
orb %dl, %cl
jne 0xbe9d
movl $0x1, 0x104(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x110(%rdi)
movl %eax, 0x10c(%rdi)
movl %eax, 0x108(%rdi)
movzbl 0x1(%rsi), %eax
jmp 0xbe70
cmpq $0x4, %rdx
jne 0xbe78
movzbl (%rsi), %edx
pushq $0x73
popq %rax
testl %edx, %edx
je 0xbe9d
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0xbe9d
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0xbe9d
movzbl 0x3(%rsi), %r10d
testl %r10d, %r10d
je 0xbe9d
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %r8b
orb %dl, %r8b
cmpl %r9d, %ecx
setb %dl
cmpl %r10d, %ecx
setb %cl
orb %dl, %cl
orb %r8b, %cl
jne 0xbe9d
movl $0x1, 0x104(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x108(%rdi)
movzbl 0x1(%rsi), %eax
movl %eax, 0x10c(%rdi)
movzbl 0x2(%rsi), %eax
movl %eax, 0x110(%rdi)
movzbl 0x3(%rsi), %eax
movl %eax, 0x114(%rdi)
jmp 0xbe9b
pushq $0x72
popq %rax
retq
movl $0x1, 0x104(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x110(%rdi)
movl %eax, 0x10c(%rdi)
movl %eax, 0x108(%rdi)
xorl %eax, %eax
retq