// File: /workspace/github_cpp_makefile_star2_O3/Lut99[P]RayTracer/src/lib/LodePNG.cpp
// Function: lodepng_inspect_chunk(LodePNGState*, unsigned long, unsigned char const*, unsigned long)
unsigned lodepng_inspect_chunk(LodePNGState* state, size_t pos,
                               const unsigned char* in, size_t insize) {
  const unsigned char* chunk = in + pos;
  unsigned chunkLength;
  const unsigned char* data;
  unsigned unhandled = 0;
  unsigned error = 0;

  if (pos + 4 > insize) return 30;
  chunkLength = lodepng_chunk_length(chunk);
  if(chunkLength > 2147483647) return 63;
  data = lodepng_chunk_data_const(chunk);
  if(data + chunkLength + 4 > in + insize) return 30;

  if(lodepng_chunk_type_equals(chunk, "PLTE")) {
    error = readChunk_PLTE(&state->info_png.color, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "tRNS")) {
    error = readChunk_tRNS(&state->info_png.color, data, chunkLength);
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
  } else if(lodepng_chunk_type_equals(chunk, "bKGD")) {
    error = readChunk_bKGD(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "tEXt")) {
    error = readChunk_tEXt(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "zTXt")) {
    error = readChunk_zTXt(&state->info_png, &state->decoder.zlibsettings, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "iTXt")) {
    error = readChunk_iTXt(&state->info_png, &state->decoder.zlibsettings, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "tIME")) {
    error = readChunk_tIME(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "pHYs")) {
    error = readChunk_pHYs(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "gAMA")) {
    error = readChunk_gAMA(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "cHRM")) {
    error = readChunk_cHRM(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "sRGB")) {
    error = readChunk_sRGB(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "iCCP")) {
    error = readChunk_iCCP(&state->info_png, &state->decoder.zlibsettings, data, chunkLength);
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
  } else {
    /* unhandled chunk is ok (is not an error) */
    unhandled = 1;
  }

  if(!error && !unhandled && !state->decoder.ignore_crc) {
    if(lodepng_chunk_check_crc(chunk)) return 57; /*invalid CRC*/
  }

  return error;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
addq $0x4, %rsi
movl $0x1e, %eax
cmpq %rcx, %rsi
ja 0x6a86a
addq %rdx, %rbx
movzbl (%rbx), %esi
shll $0x18, %esi
js 0x6a71f
movq %rdi, %r14
movzbl 0x1(%rbx), %edi
shll $0x10, %edi
movzbl 0x2(%rbx), %r8d
shll $0x8, %r8d
movzbl 0x3(%rbx), %r15d
orl %edi, %r15d
orl %r8d, %r15d
orl %esi, %r15d
leaq (%rbx,%r15), %rsi
addq $0xc, %rsi
addq %rcx, %rdx
cmpq %rdx, %rsi
ja 0x6a86a
leaq 0x8(%rbx), %r12
leaq 0x1e7cd(%rip), %rsi     # 0x88ec9
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a729
leaq 0xc8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6a946
jmp 0x6a847
movl $0x3f, %eax
jmp 0x6a86a
leaq 0x1e79e(%rip), %rsi     # 0x88ece
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a753
leaq 0xc8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6aa1e
jmp 0x6a847
leaq 0x1e779(%rip), %rsi     # 0x88ed3
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a77d
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6aadf
jmp 0x6a847
leaq 0x1e754(%rip), %rsi     # 0x88ed8
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a7a7
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6ab8b
jmp 0x6a847
leaq 0x1e72f(%rip), %rsi     # 0x88edd
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a7d1
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6ac7b
jmp 0x6a847
leaq 0x1e70a(%rip), %rsi     # 0x88ee2
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a7fb
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6adca
jmp 0x6a847
leaq 0x1e6e5(%rip), %rsi     # 0x88ee7
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a822
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b08f
jmp 0x6a847
leaq 0x1e6c3(%rip), %rsi     # 0x88eec
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a876
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b0e9
testl %eax, %eax
jne 0x6a86a
cmpl $0x0, 0x20(%r14)
je 0x6a856
xorl %eax, %eax
jmp 0x6a86a
movq %rbx, %rdi
callq 0x67877
movl %eax, %ecx
testl %eax, %eax
movl $0x39, %eax
cmovel %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1e674(%rip), %rsi     # 0x88ef1
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a8ad
movl $0x60, %eax
cmpl $0x4, %r15d
jne 0x6a86a
movl $0x1, 0x16c(%r14)
movl 0x8(%rbx), %eax
bswapl %eax
movl %eax, 0x170(%r14)
jmp 0x6a84b
leaq 0x1e642(%rip), %rsi     # 0x88ef6
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a8d7
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b120
jmp 0x6a847
leaq 0x1e61d(%rip), %rsi     # 0x88efb
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a915
movl $0x62, %eax
cmpl $0x1, %r15d
jne 0x6a86a
movl $0x1, 0x198(%r14)
movzbl (%r12), %eax
movl %eax, 0x19c(%r14)
jmp 0x6a84b
leaq 0x1e5e4(%rip), %rsi     # 0x88f00
movq %rbx, %rdi
callq 0x6780c
testb %al, %al
je 0x6a852
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6b18f
jmp 0x6a847