// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x4(%rsi), %rax
pushq $0x1e
popq %r12
cmpq %rcx, %rax
ja 0x786fa
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
addq %rdx, %rbx
movq %rbx, %rdi
callq 0x759b6
testl %eax, %eax
js 0x7855a
movl %eax, %ebp
movl %eax, %ecx
leaq (%rbx,%rcx), %rax
addq $0xc, %rax
addq %r15, %r13
cmpq %r13, %rax
ja 0x786fa
movq %rcx, %r15
leaq 0x8(%rbx), %r12
leaq 0x18a32(%rip), %rsi     # 0x90f69
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x78563
leaq 0xc8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x78771
jmp 0x786d5
pushq $0x3f
popq %r12
jmp 0x786fa
leaq 0x18a04(%rip), %rsi     # 0x90f6e
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x7858d
leaq 0xc8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x7882a
jmp 0x786d5
leaq 0x189df(%rip), %rsi     # 0x90f73
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x785b7
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x788d4
jmp 0x786d5
leaq 0x189ba(%rip), %rsi     # 0x90f78
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x785e1
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x78975
jmp 0x786d5
leaq 0x18995(%rip), %rsi     # 0x90f7d
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x7860e
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x78a7e
jmp 0x786d5
leaq 0x1896d(%rip), %rsi     # 0x90f82
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x7863b
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x78b87
jmp 0x786d5
leaq 0x18945(%rip), %rsi     # 0x90f87
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x78662
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x78e26
jmp 0x786d5
leaq 0x18923(%rip), %rsi     # 0x90f8c
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x78689
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x78e7f
jmp 0x786d5
leaq 0x18901(%rip), %rsi     # 0x90f91
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x786b0
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x78eb5
jmp 0x786d5
leaq 0x188df(%rip), %rsi     # 0x90f96
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x7870c
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x78ed6
movl %eax, %r12d
testl %eax, %eax
jne 0x786fa
cmpl $0x0, 0x20(%r14)
je 0x786e8
xorl %r12d, %r12d
jmp 0x786fa
movq %rbx, %rdi
callq 0x75be4
testl %eax, %eax
pushq $0x39
popq %r12
cmovel %eax, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18888(%rip), %rsi     # 0x90f9b
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x7873d
cmpl $0x1, %ebp
jne 0x7876a
movl $0x1, 0x198(%r14)
movzbl (%r12), %eax
movl %eax, 0x19c(%r14)
jmp 0x786dc
leaq 0x1885c(%rip), %rsi     # 0x90fa0
movq %rbx, %rdi
callq 0x75b58
testb %al, %al
je 0x786e3
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x78f44
jmp 0x786d5
pushq $0x62
jmp 0x7855c