// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/lodepng.cpp
// Function: readChunk_sBIT(LodePNGInfo*, unsigned char const*, unsigned long)
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 0x94a4
movl $0x72, %eax
cmpq $0x3, %rdx
jne 0x9608
movzbl (%rsi), %edx
movl $0x73, %eax
testl %edx, %edx
je 0x9608
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0x9608
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0x9608
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %r8b
orb %dl, %r8b
cmpl %r9d, %ecx
setb %cl
orb %r8b, %cl
jne 0x9608
movl $0x1, 0x160(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x164(%rdi)
movzbl 0x1(%rsi), %eax
movl %eax, 0x168(%rdi)
movzbl 0x2(%rsi), %eax
movl %eax, 0x16c(%rdi)
jmp 0x9606
xorl %eax, %eax
cmpl $0x6, %r8d
ja 0x9608
movl 0x14(%rdi), %ecx
movl %r8d, %r8d
leaq 0x68dc7(%rip), %r9      # 0x72284
movslq (%r9,%r8,4), %r8
addq %r9, %r8
jmpq *%r8
movl $0x72, %eax
cmpq $0x1, %rdx
jne 0x9608
movb (%rsi), %al
testb %al, %al
sete %dl
movzbl %al, %eax
cmpl %eax, %ecx
setb %al
orb %dl, %al
movl $0x73, %eax
jne 0x9608
movl $0x1, 0x160(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x16c(%rdi)
movl %eax, 0x168(%rdi)
movl %eax, 0x164(%rdi)
jmp 0x9606
movl $0x72, %eax
cmpq $0x2, %rdx
jne 0x9608
movzbl (%rsi), %edx
movl $0x73, %eax
testl %edx, %edx
je 0x9608
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0x9608
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %cl
orb %dl, %cl
jne 0x9608
movl $0x1, 0x160(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x16c(%rdi)
movl %eax, 0x168(%rdi)
movl %eax, 0x164(%rdi)
movzbl 0x1(%rsi), %eax
jmp 0x9600
movl $0x72, %eax
cmpq $0x4, %rdx
jne 0x9608
movzbl (%rsi), %edx
movl $0x73, %eax
testl %edx, %edx
je 0x9608
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0x9608
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0x9608
movzbl 0x3(%rsi), %r10d
testl %r10d, %r10d
je 0x9608
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 0x9608
movl $0x1, 0x160(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x164(%rdi)
movzbl 0x1(%rsi), %eax
movl %eax, 0x168(%rdi)
movzbl 0x2(%rsi), %eax
movl %eax, 0x16c(%rdi)
movzbl 0x3(%rsi), %eax
movl %eax, 0x170(%rdi)
xorl %eax, %eax
retq