// File: /workspace/github_c_makefile_star2_O3/aap[P]pdp11/lodepng.c
// Function: lodepng_inspect_chunk
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, "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 0xc95c
addq %rsi, %rbx
movzbl (%rbx), %edx
shll $0x18, %edx
js 0xc811
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 0xc95c
leaq 0x8(%rbx), %r15
leaq 0xb8af(%rip), %rsi      # 0x1809d
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc81b
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xca61
jmp 0xc939
movl $0x3f, %eax
jmp 0xc95c
leaq 0xb880(%rip), %rsi      # 0x180a2
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc845
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xcb39
jmp 0xc939
leaq 0xb85b(%rip), %rsi      # 0x180a7
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc86f
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xcbfa
jmp 0xc939
leaq 0xb836(%rip), %rsi      # 0x180ac
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc899
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xcca6
jmp 0xc939
leaq 0xb811(%rip), %rsi      # 0x180b1
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc8c3
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0xcd9e
jmp 0xc939
leaq 0xb7ec(%rip), %rsi      # 0x180b6
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc8ed
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0xceff
jmp 0xc939
leaq 0xb7c7(%rip), %rsi      # 0x180bb
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc914
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xd1da
jmp 0xc939
leaq 0xb7a5(%rip), %rsi      # 0x180c0
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc968
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xd234
testl %eax, %eax
jne 0xc95c
cmpl $0x0, 0x28(%r14)
je 0xc948
xorl %eax, %eax
jmp 0xc95c
movq %rbx, %rdi
callq 0x995d
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 0xb756(%rip), %rsi      # 0x180c5
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc99f
movl $0x60, %eax
cmpl $0x4, %r12d
jne 0xc95c
movl $0x1, 0x184(%r14)
movl 0x8(%rbx), %eax
bswapl %eax
movl %eax, 0x188(%r14)
jmp 0xc93d
leaq 0xb724(%rip), %rsi      # 0x180ca
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc9c9
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xd26b
jmp 0xc939
leaq 0xb6ff(%rip), %rsi      # 0x180cf
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xca06
movl $0x62, %eax
cmpl $0x1, %r12d
jne 0xc95c
movl $0x1, 0x1b0(%r14)
movzbl (%r15), %eax
movl %eax, 0x1b4(%r14)
jmp 0xc93d
leaq 0xb6c7(%rip), %rsi      # 0x180d4
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xca33
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0xd2da
jmp 0xc939
leaq 0xb69f(%rip), %rsi      # 0x180d9
movq %rbx, %rdi
callq 0x98f2
testb %al, %al
je 0xc944
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xd472
jmp 0xc939