// File: /workspace/github_cpp_makefile_star2_O2/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
cmpl $0x3, %r8d
jne 0x800c
pushq $0x8
popq %rcx
cmpq $0x3, %rdx
jne 0x814b
movzbl (%rsi), %edx
pushq $0x73
popq %rax
testl %edx, %edx
je 0x8170
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0x8170
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0x8170
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %r8b
orb %dl, %r8b
cmpl %r9d, %ecx
setb %cl
orb %r8b, %cl
jne 0x8170
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 0x816e
xorl %eax, %eax
cmpl $0x6, %r8d
ja 0x8170
movl 0x14(%rdi), %ecx
movl %r8d, %r8d
leaq 0x5415f(%rip), %r9      # 0x5c184
movslq (%r9,%r8,4), %r8
addq %r9, %r8
jmpq *%r8
cmpq $0x1, %rdx
jne 0x814b
movb (%rsi), %al
testb %al, %al
sete %dl
movzbl %al, %eax
cmpl %eax, %ecx
setb %al
orb %dl, %al
je 0x814f
pushq $0x73
jmp 0x814d
cmpq $0x2, %rdx
jne 0x814b
movzbl (%rsi), %edx
pushq $0x73
popq %rax
testl %edx, %edx
je 0x8170
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0x8170
cmpl %edx, %ecx
setb %dl
cmpl %r8d, %ecx
setb %cl
orb %dl, %cl
jne 0x8170
movl $0x1, 0x160(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x16c(%rdi)
movl %eax, 0x168(%rdi)
movl %eax, 0x164(%rdi)
movzbl 0x1(%rsi), %eax
jmp 0x8143
cmpq $0x4, %rdx
jne 0x814b
movzbl (%rsi), %edx
pushq $0x73
popq %rax
testl %edx, %edx
je 0x8170
movzbl 0x1(%rsi), %r8d
testl %r8d, %r8d
je 0x8170
movzbl 0x2(%rsi), %r9d
testl %r9d, %r9d
je 0x8170
movzbl 0x3(%rsi), %r10d
testl %r10d, %r10d
je 0x8170
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 0x8170
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)
jmp 0x816e
pushq $0x72
popq %rax
retq
movl $0x1, 0x160(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x16c(%rdi)
movl %eax, 0x168(%rdi)
movl %eax, 0x164(%rdi)
xorl %eax, %eax
retq