// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
leaq 0x4(%rsi), %rdx
movl $0x1e, %eax
cmpq %rcx, %rdx
ja 0x872e
addq %rsi, %rbx
movzbl (%rbx), %edx
shll $0x18, %edx
js 0x85e3
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 0x872e
leaq 0x8(%rbx), %r15
leaq 0x6c2bc(%rip), %rsi     # 0x7487c
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x85ed
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x890f
jmp 0x870b
movl $0x3f, %eax
jmp 0x872e
leaq 0x6c28d(%rip), %rsi     # 0x74881
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x8617
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x89e7
jmp 0x870b
leaq 0x6c268(%rip), %rsi     # 0x74886
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x8641
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8aae
jmp 0x870b
leaq 0x6c243(%rip), %rsi     # 0x7488b
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x866b
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x8b5a
jmp 0x870b
leaq 0x6c21e(%rip), %rsi     # 0x74890
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x8695
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0x8c52
jmp 0x870b
leaq 0x6c1f9(%rip), %rsi     # 0x74895
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x86bf
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0x8db3
jmp 0x870b
leaq 0x6c1d4(%rip), %rsi     # 0x7489a
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x86e6
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x908e
jmp 0x870b
leaq 0x6c1b2(%rip), %rsi     # 0x7489f
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x873a
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x90e8
testl %eax, %eax
jne 0x872e
cmpl $0x0, 0x28(%r14)
je 0x871a
xorl %eax, %eax
jmp 0x872e
movq %rbx, %rdi
callq 0x54d0
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 0x6c163(%rip), %rsi     # 0x748a4
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x8771
movl $0x60, %eax
cmpl $0x4, %r12d
jne 0x872e
movl $0x1, 0x198(%r14)
movl 0x8(%rbx), %eax
bswapl %eax
movl %eax, 0x19c(%r14)
jmp 0x870f
leaq 0x6c131(%rip), %rsi     # 0x748a9
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x879b
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x911f
jmp 0x870b
leaq 0x6c10c(%rip), %rsi     # 0x748ae
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x87d8
movl $0x62, %eax
cmpl $0x1, %r12d
jne 0x872e
movl $0x1, 0x1c4(%r14)
movzbl (%r15), %eax
movl %eax, 0x1c8(%r14)
jmp 0x870f
leaq 0x6c0d4(%rip), %rsi     # 0x748b3
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x8805
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0x918e
jmp 0x870b
leaq 0x6c0ac(%rip), %rsi     # 0x748b8
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x8863
movl $0x75, %eax
cmpl $0x4, %r12d
jne 0x872e
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 0x870f
leaq 0x6c053(%rip), %rsi     # 0x748bd
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x888d
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x9326
jmp 0x870b
leaq 0x6c02e(%rip), %rsi     # 0x748c2
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x88b7
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x93df
jmp 0x870b
leaq 0x6c009(%rip), %rsi     # 0x748c7
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x88e1
leaq 0xd0(%r14), %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x5fff
jmp 0x870b
leaq 0x6bfe4(%rip), %rsi     # 0x748cc
movq %rbx, %rdi
callq 0x5465
testb %al, %al
je 0x8716
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0x940c
jmp 0x870b