// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/lodepng.c
// Function: readChunk_iCCP
static unsigned readChunk_iCCP(LodePNGInfo* info, const LodePNGDecoderSettings* decoder,
                               const unsigned char* data, size_t chunkLength) {
  unsigned error = 0;
  unsigned i;
  size_t size = 0;
  /*copy the object to change parameters in it*/
  LodePNGDecompressSettings zlibsettings = decoder->zlibsettings;

  unsigned length, string2_begin;

  info->iccp_defined = 1;
  if(info->iccp_name) lodepng_clear_icc(info);

  for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
  if(length + 2 >= chunkLength) return 75; /*no null termination, corrupt?*/
  if(length < 1 || length > 79) return 89; /*keyword too short or long*/

  info->iccp_name = (char*)lodepng_malloc(length + 1);
  if(!info->iccp_name) return 83; /*alloc fail*/

  info->iccp_name[length] = 0;
  for(i = 0; i != length; ++i) info->iccp_name[i] = (char)data[i];

  if(data[length + 1] != 0) return 72; /*the 0 byte indicating compression must be 0*/

  string2_begin = length + 2;
  if(string2_begin > chunkLength) return 75; /*no null termination, corrupt?*/

  length = (unsigned)chunkLength - string2_begin;
  zlibsettings.max_output_size = decoder->max_icc_size;
  error = zlib_decompress(&info->iccp_profile, &size, 0,
                          &data[string2_begin],
                          length, &zlibsettings);
  /*error: ICC profile larger than  decoder->max_icc_size*/
  if(error && size > zlibsettings.max_output_size) error = 113;
  info->iccp_profile_size = (unsigned)size;
  if(!error && !info->iccp_profile_size) error = 100; /*invalid ICC profile size*/
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %rbx
movq $0x0, 0x18(%rsp)
movq 0x20(%rsi), %rax
movq %rax, 0x40(%rsp)
movups (%rsi), %xmm0
movq %rsi, 0x10(%rsp)
movups 0x10(%rsi), %xmm1
movaps %xmm1, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl $0x1, 0xe8(%rdi)
movq 0xf0(%rdi), %rdi
testq %rdi, %rdi
je 0xcdcd
callq 0x2030
xorl %r12d, %r12d
movq %r12, 0xf0(%rbx)
movq 0xf8(%rbx), %rdi
callq 0x2030
movq %r12, 0xf8(%rbx)
movl %r12d, 0x100(%rbx)
movl %r12d, 0xe8(%rbx)
testq %r14, %r14
je 0xcdeb
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpb $0x0, (%r15,%rbp)
je 0xcdf0
incl %r13d
movq %r13, %rbp
cmpq %r14, %r13
jb 0xcdd7
jmp 0xcdf0
xorl %r13d, %r13d
xorl %ebp, %ebp
leal 0x2(%r13), %edx
movl $0x4b, %eax
cmpq %r14, %rdx
jae 0xcee9
leal -0x50(%r13), %ecx
movl $0x59, %eax
cmpl $-0x4f, %ecx
jb 0xcee9
movq %rdx, 0x8(%rsp)
movl %r13d, %r12d
leaq 0x1(%r12), %rdi
movq %rdi, (%rsp)
callq 0x2190
movq %rax, 0xf0(%rbx)
testq %rax, %rax
je 0xcee4
movb $0x0, (%rax,%rbp)
testl %r13d, %r13d
je 0xce5b
xorl %eax, %eax
movb (%r15,%rax), %cl
movq 0xf0(%rbx), %rdx
movb %cl, (%rdx,%rax)
incq %rax
cmpq %rax, %r12
jne 0xce45
movl $0x48, %eax
movq (%rsp), %rcx
cmpb $0x0, (%r15,%rcx)
movq 0x8(%rsp), %rcx
jne 0xcee9
movl $0x4b, %eax
cmpq %r14, %rcx
ja 0xcee9
subl %ecx, %r14d
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x20(%rsp), %r12
movq %rax, 0x8(%r12)
leaq 0xf8(%rbx), %rdi
addq %rcx, %r15
xorl %ebp, %ebp
leaq 0x18(%rsp), %r13
movq %r13, %rsi
xorl %edx, %edx
movq %r15, %rcx
movq %r14, %r8
movq %r12, %r9
callq 0x11c1f
movl %eax, %ecx
movq (%r13), %rdx
cmpq 0x8(%r12), %rdx
movl $0x71, %eax
cmovbel %ecx, %eax
testl %ecx, %ecx
cmovel %ecx, %eax
movl %edx, 0x100(%rbx)
testl %eax, %eax
jne 0xcee9
testl %edx, %edx
movl $0x64, %eax
cmovel %eax, %ebp
movl %ebp, %eax
jmp 0xcee9
movl $0x53, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq