// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
movq %rsi, %rbx
addq $0x4, %rsi
movl $0x1e, %eax
cmpq %rcx, %rsi
ja 0x6aef8
addq %rdx, %rbx
movzbl (%rbx), %esi
shll $0x18, %esi
js 0x6adbb
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 0x6aef8
leaq 0x8(%rbx), %r12
leaq 0x1f111(%rip), %rsi     # 0x89ea9
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6adc5
leaq 0xc8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6aff5
jmp 0x6aee3
movl $0x3f, %eax
jmp 0x6aef8
leaq 0x1f0e2(%rip), %rsi     # 0x89eae
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6adef
leaq 0xc8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b0c9
jmp 0x6aee3
leaq 0x1f0bd(%rip), %rsi     # 0x89eb3
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6ae19
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b18a
jmp 0x6aee3
leaq 0x1f098(%rip), %rsi     # 0x89eb8
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6ae43
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b236
jmp 0x6aee3
leaq 0x1f073(%rip), %rsi     # 0x89ebd
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6ae6d
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6b326
jmp 0x6aee3
leaq 0x1f04e(%rip), %rsi     # 0x89ec2
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6ae97
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6b491
jmp 0x6aee3
leaq 0x1f029(%rip), %rsi     # 0x89ec7
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6aebe
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b7a3
jmp 0x6aee3
leaq 0x1f007(%rip), %rsi     # 0x89ecc
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6af16
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b7fd
movl %eax, %ebp
xorl %eax, %eax
testb %al, %al
jne 0x6aef6
testl %ebp, %ebp
jne 0x6aef6
cmpl $0x0, 0x20(%r14)
je 0x6af01
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x67e7b
movl %eax, %ecx
movl $0x39, %eax
testl %ecx, %ecx
jne 0x6aef8
jmp 0x6aef6
leaq 0x1efb4(%rip), %rsi     # 0x89ed1
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6af4a
xorl %ebp, %ebp
cmpl $0x4, %r15d
jne 0x6af74
movl $0x1, 0x16c(%r14)
movl 0x8(%rbx), %eax
bswapl %eax
movl %eax, 0x170(%r14)
jmp 0x6aee5
leaq 0x1ef85(%rip), %rsi     # 0x89ed6
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6af7e
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6b834
jmp 0x6aee3
movl $0x60, %ebp
jmp 0x6aee5
leaq 0x1ef56(%rip), %rsi     # 0x89edb
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6afb5
xorl %ebp, %ebp
cmpl $0x1, %r15d
jne 0x6afe2
movl $0x1, 0x198(%r14)
movzbl (%r12), %eax
movl %eax, 0x19c(%r14)
jmp 0x6aee5
leaq 0x1ef24(%rip), %rsi     # 0x89ee0
movq %rbx, %rdi
callq 0x67e10
testb %al, %al
je 0x6afec
leaq 0xb8(%r14), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6b8a3
jmp 0x6aee3
movl $0x62, %ebp
jmp 0x6aee5
xorl %ebp, %ebp
movb $0x1, %al
jmp 0x6aee7