// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
leaq 0x4(%rsi), %rdx
movl $0x1e, %eax
cmpq %rcx, %rdx
ja 0xc386
addq %rsi, %rbx
movzbl (%rbx), %edx
shll $0x18, %edx
js 0xc249
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 0xc386
leaq 0x8(%rbx), %r15
leaq 0xbd53(%rip), %rsi      # 0x17f79
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc253
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xc4ac
jmp 0xc371
movl $0x3f, %eax
jmp 0xc386
leaq 0xbd24(%rip), %rsi      # 0x17f7e
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc27d
leaq 0xe0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xc580
jmp 0xc371
leaq 0xbcff(%rip), %rsi      # 0x17f83
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc2a7
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xc641
jmp 0xc371
leaq 0xbcda(%rip), %rsi      # 0x17f88
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc2d1
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xc6ed
jmp 0xc371
leaq 0xbcb5(%rip), %rsi      # 0x17f8d
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc2fb
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0xc801
jmp 0xc371
leaq 0xbc90(%rip), %rsi      # 0x17f92
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc325
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0xc95a
jmp 0xc371
leaq 0xbc6b(%rip), %rsi      # 0x17f97
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc34c
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xcc48
jmp 0xc371
leaq 0xbc49(%rip), %rsi      # 0x17f9c
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc3a4
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xcca2
movl %eax, %ebp
xorl %eax, %eax
testb %al, %al
jne 0xc384
testl %ebp, %ebp
jne 0xc384
cmpl $0x0, 0x28(%r14)
je 0xc38f
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x9285
movl %eax, %ecx
movl $0x39, %eax
testl %ecx, %ecx
jne 0xc386
jmp 0xc384
leaq 0xbbf6(%rip), %rsi      # 0x17fa1
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc3d8
xorl %ebp, %ebp
cmpl $0x4, %r12d
jne 0xc402
movl $0x1, 0x184(%r14)
movl 0x8(%rbx), %eax
bswapl %eax
movl %eax, 0x188(%r14)
jmp 0xc373
leaq 0xbbc7(%rip), %rsi      # 0x17fa6
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc40c
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xccd9
jmp 0xc371
movl $0x60, %ebp
jmp 0xc373
leaq 0xbb98(%rip), %rsi      # 0x17fab
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc442
xorl %ebp, %ebp
cmpl $0x1, %r12d
jne 0xc46f
movl $0x1, 0x1b0(%r14)
movzbl (%r15), %eax
movl %eax, 0x1b4(%r14)
jmp 0xc373
leaq 0xbb67(%rip), %rsi      # 0x17fb0
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc479
leaq 0xd0(%r14), %rdi
movl %r12d, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0xcd48
jmp 0xc371
movl $0x62, %ebp
jmp 0xc373
leaq 0xbb35(%rip), %rsi      # 0x17fb5
movq %rbx, %rdi
callq 0x921a
testb %al, %al
je 0xc4a3
leaq 0xd0(%r14), %rdi
movl %r12d, %edx
movq %r15, %rsi
callq 0xcef8
jmp 0xc371
xorl %ebp, %ebp
movb $0x1, %al
jmp 0xc375