// File: /workspace/github_c_makefile_star2_O3/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
movl $0x8, %ecx
cmpl $0x3, %r8d
jne 0xd50a
movl $0x72, %eax
cmpq $0x3, %rdx
jne 0xd66e
movzbl (%rsi), %edx
movl $0x73, %eax
testl %edx, %edx
je 0xd66e
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0xd66e
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0xd66e
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %r8b
orb %dl, %r8b
cmpl %r9d, %ecx
setb %cl
orb %r8b, %cl
jne 0xd66e
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 0xd66c
xorl %eax, %eax
cmpl $0x6, %r8d
ja 0xd66e
movl 0x14(%rdi), %ecx
movl %r8d, %r8d
leaq 0x85a1(%rip), %r9       # 0x15ac4
movslq (%r9,%r8,4), %r8
addq %r9, %r8
jmpq *%r8
movl $0x72, %eax
cmpq $0x1, %rdx
jne 0xd66e
movb (%rsi), %al
testb %al, %al
sete %dl
movzbl %al, %eax
cmpl %eax, %ecx
setb %al
orb %dl, %al
movl $0x73, %eax
jne 0xd66e
movl $0x1, 0x104(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x110(%rdi)
movl %eax, 0x10c(%rdi)
movl %eax, 0x108(%rdi)
jmp 0xd66c
movl $0x72, %eax
cmpq $0x2, %rdx
jne 0xd66e
movzbl (%rsi), %edx
movl $0x73, %eax
testl %edx, %edx
je 0xd66e
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0xd66e
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %cl
orb %dl, %cl
jne 0xd66e
movl $0x1, 0x104(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x110(%rdi)
movl %eax, 0x10c(%rdi)
movl %eax, 0x108(%rdi)
movzbl 0x1(%rsi), %eax
jmp 0xd666
movl $0x72, %eax
cmpq $0x4, %rdx
jne 0xd66e
movzbl (%rsi), %edx
movl $0x73, %eax
testl %edx, %edx
je 0xd66e
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0xd66e
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0xd66e
movzbl 0x3(%rsi), %r10d
testl %r10d, %r10d
je 0xd66e
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 0xd66e
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)
xorl %eax, %eax
retq