// File: /workspace/github_cpp_makefile_star2_O2/Lut99[P]RayTracer/src/lib/LodePNG.cpp
// Function: readChunk_iCCP(LodePNGInfo*, LodePNGDecompressSettings const*, unsigned char const*, unsigned long)
static unsigned readChunk_iCCP(LodePNGInfo* info, const LodePNGDecompressSettings* zlibsettings,
                               const unsigned char* data, size_t chunkLength) {
  unsigned error = 0;
  unsigned i;

  unsigned length, string2_begin;
  ucvector decoded;

  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;
  ucvector_init(&decoded);
  error = zlib_decompress(&decoded.data, &decoded.size,
                          &data[string2_begin],
                          length, zlibsettings);
  if(!error) {
    if(decoded.size) {
      info->iccp_profile_size = (unsigned int) decoded.size;
      info->iccp_profile = (unsigned char*)lodepng_malloc(decoded.size);
      if(info->iccp_profile) {
        lodepng_memcpy(info->iccp_profile, decoded.data, decoded.size);
      } else {
        error = 83; /* alloc fail */
      }
    } else {
      error = 100; /*invalid ICC profile size*/
    }
  }
  ucvector_cleanup(&decoded);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, 0x8(%rsp)
movq %rdi, %rbx
movl $0x1, 0xe8(%rdi)
cmpq $0x0, 0xf0(%rdi)
je 0x78f7c
movq %rbx, %rdi
callq 0x7649f
pushq $0x2
popq %rbp
leal -0x2(%rbp), %r13d
cmpq %r14, %r13
jae 0x78f93
cmpb $0x0, (%r12,%r13)
je 0x78f93
incl %ebp
jmp 0x78f7f
movl %ebp, %r15d
cmpq %r14, %r15
jae 0x78fa7
leal -0x52(%rbp), %eax
cmpl $-0x4f, %eax
jae 0x78fbb
pushq $0x59
jmp 0x78fa9
pushq $0x4b
popq %rbp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal -0x1(%rbp), %edi
movq %rdi, (%rsp)
callq 0x525b0
movq %rax, 0xf0(%rbx)
testq %rax, %rax
je 0x79004
movb $0x0, (%rax,%r13)
movl %r13d, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x78ff5
movb (%r12,%rcx), %dl
movq 0xf0(%rbx), %rsi
movb %dl, (%rsi,%rcx)
incq %rcx
jmp 0x78fdd
movq (%rsp), %rax
cmpb $0x0, (%r12,%rax)
je 0x79008
pushq $0x48
jmp 0x78fa9
pushq $0x53
jmp 0x78fa9
subl %ebp, %r14d
xorps %xmm0, %xmm0
leaq 0x18(%rsp), %rsi
movaps %xmm0, -0x8(%rsi)
andq $0x0, 0x8(%rsi)
addq %r15, %r12
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
movq %r14, %rcx
movq 0x8(%rsp), %r8
callq 0x7bbaa
movl %eax, %ebp
testl %eax, %eax
jne 0x7907a
movq 0x18(%rsp), %r14
testq %r14, %r14
je 0x79073
movl %r14d, 0x100(%rbx)
movq %r14, %rdi
callq 0x525b0
movq %rax, 0xf8(%rbx)
testq %rax, %rax
je 0x79077
movq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x7c104
xorl %ebp, %ebp
jmp 0x7907a
pushq $0x64
jmp 0x79079
pushq $0x53
popq %rbp
leaq 0x10(%rsp), %rdi
callq 0x7d131
jmp 0x78faa