// File: /workspace/github_cpp_makefile_star2_O1/lvandeve[P]lodepng/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(chunkLength + 12 > insize - pos) 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, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "iTXt")) {
    error = readChunk_iTXt(&state->info_png, &state->decoder, 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, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "cICP")) {
    error = readChunk_cICP(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "mDCV")) {
    error = readChunk_mDCV(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "cLLI")) {
    error = readChunk_cLLI(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "eXIf")) {
    error = readChunk_eXIf(&state->info_png, data, chunkLength);
  } else if(lodepng_chunk_type_equals(chunk, "sBIT")) {
    error = readChunk_sBIT(&state->info_png, 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 %rdx, %rbx
leaq 0x4(%rsi), %rdx
movl $0x1e, %eax
cmpq %rcx, %rdx
ja 0x8172
addq %rsi, %rbx
movzbl (%rbx), %edx
shll $0x18, %edx
js 0x8035
movq %rdi, %r14
movzbl 0x1(%rbx), %edi
shll $0x10, %edi
movzbl 0x2(%rbx), %r8d
shll $0x8, %r8d
movzbl 0x3(%rbx), %r12d
orl %edi, %r12d
orl %r8d, %r12d
orl %edx, %r12d
leal 0xc(%r12), %edx
subq %rsi, %rcx
cmpq %rdx, %rcx
jb 0x8172
leaq 0x8(%rbx), %r15
leaq 0x6c746(%rip), %rsi     # 0x74758
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x803f
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8377
jmp 0x815d
movl $0x3f, %eax
jmp 0x8172
leaq 0x6c717(%rip), %rsi     # 0x7475d
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x8069
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x844b
jmp 0x815d
leaq 0x6c6f2(%rip), %rsi     # 0x74762
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x8093
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8512
jmp 0x815d
leaq 0x6c6cd(%rip), %rsi     # 0x74767
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x80bd
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x85be
jmp 0x815d
leaq 0x6c6a8(%rip), %rsi     # 0x7476c
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x80e7
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0x86d2
jmp 0x815d
leaq 0x6c683(%rip), %rsi     # 0x74771
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x8111
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0x882b
jmp 0x815d
leaq 0x6c65e(%rip), %rsi     # 0x74776
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x8138
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8b19
jmp 0x815d
leaq 0x6c63c(%rip), %rsi     # 0x7477b
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x8190
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8b73
movl %eax, %ebp
xorl %eax, %eax
testb %al, %al
jne 0x8170
testl %ebp, %ebp
jne 0x8170
cmpl $0x0, 0x28(%r14)
je 0x817b
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x4f0b
movl %eax, %ecx
movl $0x39, %eax
testl %ecx, %ecx
jne 0x8172
jmp 0x8170
leaq 0x6c5e9(%rip), %rsi     # 0x74780
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x81c4
xorl %ebp, %ebp
cmpl $0x4, %r12d
jne 0x81ee
movl $0x1, 0x198(%r14)
movl 0x8(%rbx), %eax
bswapl %eax
movl %eax, 0x19c(%r14)
jmp 0x815f
leaq 0x6c5ba(%rip), %rsi     # 0x74785
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x81f8
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8baa
jmp 0x815d
movl $0x60, %ebp
jmp 0x815f
leaq 0x6c58b(%rip), %rsi     # 0x7478a
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x822e
xorl %ebp, %ebp
cmpl $0x1, %r12d
jne 0x825b
movl $0x1, 0x1c4(%r14)
movzbl (%r15), %eax
movl %eax, 0x1c8(%r14)
jmp 0x815f
leaq 0x6c55a(%rip), %rsi     # 0x7478f
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x8265
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0x8c19
jmp 0x815d
movl $0x62, %ebp
jmp 0x815f
leaq 0x6c528(%rip), %rsi     # 0x74794
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x82bc
xorl %ebp, %ebp
cmpl $0x4, %r12d
jne 0x82e6
movl $0x1, 0x1e4(%r14)
movzbl 0x8(%rbx), %eax
movl %eax, 0x1e8(%r14)
movzbl 0x9(%rbx), %eax
movl %eax, 0x1ec(%r14)
movzbl 0xa(%rbx), %eax
movl %eax, 0x1f0(%r14)
movzbl 0xb(%rbx), %eax
movl %eax, 0x1f4(%r14)
jmp 0x815f
leaq 0x6c4d6(%rip), %rsi     # 0x74799
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x82f0
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8dcd
jmp 0x815d
movl $0x75, %ebp
jmp 0x815f
leaq 0x6c4a7(%rip), %rsi     # 0x7479e
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x831a
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8e86
jmp 0x815d
leaq 0x6c482(%rip), %rsi     # 0x747a3
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x8344
leaq 0xd0(%r14), %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x5a2b
jmp 0x815d
leaq 0x6c45d(%rip), %rsi     # 0x747a8
movq %rbx, %rdi
callq 0x4ea0
testb %al, %al
je 0x836e
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8eb3
jmp 0x815d
xorl %ebp, %ebp
movb $0x1, %al
jmp 0x8161