// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, 0x30(%rsp)
movq %rdi, %rbx
movl $0x1, 0xe8(%rdi)
movq 0xf0(%rdi), %rdi
testq %rdi, %rdi
je 0x6b905
callq 0x3a530
xorl %r15d, %r15d
movq %r15, 0xf0(%rbx)
movq 0xf8(%rbx), %rdi
callq 0x3a530
movq %r15, 0xf8(%rbx)
movl %r15d, 0x100(%rbx)
movl %r15d, 0xe8(%rbx)
testq %r14, %r14
je 0x6b924
xorl %r15d, %r15d
xorl %r13d, %r13d
cmpb $0x0, (%r12,%r15)
je 0x6b92a
incl %r13d
movq %r13, %r15
cmpq %r14, %r13
jb 0x6b910
jmp 0x6b92a
xorl %r13d, %r13d
xorl %r15d, %r15d
leal 0x2(%r13), %ecx
movl $0x4b, %ebp
cmpq %r14, %rcx
jae 0x6ba16
leal -0x50(%r13), %eax
movl $0x59, %ebp
cmpl $-0x4f, %eax
jb 0x6ba16
movq %rcx, 0x28(%rsp)
movl %r13d, %ebp
leaq 0x1(%rbp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x3a5a0
movq %rax, 0xf0(%rbx)
testq %rax, %rax
je 0x6b9eb
movb $0x0, (%rax,%r15)
testl %r13d, %r13d
je 0x6b992
xorl %eax, %eax
movb (%r12,%rax), %cl
movq 0xf0(%rbx), %rdx
movb %cl, (%rdx,%rax)
incq %rax
cmpq %rax, %rbp
jne 0x6b97c
movl $0x48, %ebp
movq 0x20(%rsp), %rax
cmpb $0x0, (%r12,%rax)
movq 0x28(%rsp), %rax
jne 0x6ba16
movl $0x4b, %ebp
cmpq %r14, %rax
ja 0x6ba16
subl %eax, %r14d
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %r13
movaps %xmm0, -0x8(%r13)
movq $0x0, 0x8(%r13)
addq %rax, %r12
movq 0x30(%rsp), %r8
movq 0x8(%r8), %rax
movq %rsp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
testq %rax, %rax
je 0x6b9f2
callq *%rax
jmp 0x6b9f7
movl $0x53, %ebp
jmp 0x6ba16
callq 0x67ad3
movl %eax, %ebp
testl %eax, %eax
je 0x6ba27
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq (%rsp), %rdi
callq 0x3a530
movq $0x0, (%rsp)
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0x6ba5f
movl %r14d, 0x100(%rbx)
movq %r14, %rdi
callq 0x3a5a0
movq %rax, 0xf8(%rbx)
testq %rax, %rax
je 0x6ba66
movq (%rsp), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x3a3a0
xorl %ebp, %ebp
jmp 0x6b9fd
movl $0x64, %ebp
jmp 0x6b9fd
movl $0x53, %ebp
jmp 0x6b9fd