// File: 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:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0xbff4
movl $0x8, %eax
movl %eax, -0x28(%rbp)
jmp 0xbffe
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xc07d
cmpq $0x1, -0x20(%rbp)
je 0xc021
movl $0x72, -0x4(%rbp)
jmp 0xc307
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0xc039
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl -0x24(%rbp), %eax
jbe 0xc045
movl $0x73, -0x4(%rbp)
jmp 0xc307
movq -0x10(%rbp), %rax
movl $0x1, 0x160(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x16c(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x168(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x164(%rax)
jmp 0xc300
movq -0x10(%rbp), %rax
cmpl $0x2, 0x10(%rax)
je 0xc095
movq -0x10(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0xc154
cmpq $0x3, -0x20(%rbp)
je 0xc0a8
movl $0x72, -0x4(%rbp)
jmp 0xc307
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0xc0ce
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0xc0ce
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0xc0da
movl $0x73, -0x4(%rbp)
jmp 0xc307
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl -0x24(%rbp), %eax
ja 0xc100
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl -0x24(%rbp), %eax
ja 0xc100
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl -0x24(%rbp), %eax
jbe 0xc10c
movl $0x73, -0x4(%rbp)
jmp 0xc307
movq -0x10(%rbp), %rax
movl $0x1, 0x160(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x164(%rax)
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x168(%rax)
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x16c(%rax)
jmp 0xc2fe
movq -0x10(%rbp), %rax
cmpl $0x4, 0x10(%rax)
jne 0xc209
cmpq $0x2, -0x20(%rbp)
je 0xc175
movl $0x72, -0x4(%rbp)
jmp 0xc307
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0xc18e
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0xc19a
movl $0x73, -0x4(%rbp)
jmp 0xc307
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl -0x24(%rbp), %eax
ja 0xc1b3
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl -0x24(%rbp), %eax
jbe 0xc1bf
movl $0x73, -0x4(%rbp)
jmp 0xc307
movq -0x10(%rbp), %rax
movl $0x1, 0x160(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x16c(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x168(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x164(%rax)
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x170(%rax)
jmp 0xc2fc
movq -0x10(%rbp), %rax
cmpl $0x6, 0x10(%rax)
jne 0xc2fa
cmpq $0x4, -0x20(%rbp)
je 0xc22a
movl $0x72, -0x4(%rbp)
jmp 0xc307
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0xc25d
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0xc25d
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x0, %eax
je 0xc25d
movq -0x18(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x0, %eax
jne 0xc269
movl $0x73, -0x4(%rbp)
jmp 0xc307
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl -0x24(%rbp), %eax
ja 0xc29c
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl -0x24(%rbp), %eax
ja 0xc29c
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl -0x24(%rbp), %eax
ja 0xc29c
movq -0x18(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl -0x24(%rbp), %eax
jbe 0xc2a5
movl $0x73, -0x4(%rbp)
jmp 0xc307
movq -0x10(%rbp), %rax
movl $0x1, 0x160(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x164(%rax)
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x168(%rax)
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x16c(%rax)
movq -0x18(%rbp), %rax
movzbl 0x3(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x170(%rax)
jmp 0xc2fc
jmp 0xc2fe
jmp 0xc300
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)