// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %rdi, %rbx
movl $0x1, 0xe8(%rdi)
movq 0xf0(%rdi), %rdi
testq %rdi, %rdi
je 0x6b1ef
callq 0x3a540
xorl %r15d, %r15d
movq %r15, 0xf0(%rbx)
movq 0xf8(%rbx), %rdi
callq 0x3a540
movq %r15, 0xf8(%rbx)
movl %r15d, 0x100(%rbx)
movl %r15d, 0xe8(%rbx)
testq %r14, %r14
movq %r13, 0x20(%rsp)
je 0x6b211
xorl %r13d, %r13d
xorl %eax, %eax
cmpb $0x0, (%r12,%r13)
je 0x6b216
incl %eax
movq %rax, %r13
cmpq %r14, %rax
jb 0x6b1fe
jmp 0x6b216
xorl %eax, %eax
xorl %r13d, %r13d
leal 0x2(%rax), %r15d
movl $0x4b, %ebp
cmpq %r14, %r15
jae 0x6b2df
leal -0x50(%rax), %ecx
movl $0x59, %ebp
cmpl $-0x4f, %ecx
jb 0x6b2df
movl %eax, %ebp
leaq 0x1(%rbp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x3a5b0
movq %rax, 0xf0(%rbx)
testq %rax, %rax
je 0x6b2bc
movb $0x0, (%rax,%r13)
xorl %eax, %eax
movb (%r12,%rax), %cl
movq 0xf0(%rbx), %rdx
movb %cl, (%rdx,%rax)
incq %rax
cmpq %rax, %rbp
jne 0x6b25c
movl $0x48, %ebp
movq 0x18(%rsp), %rax
cmpb $0x0, (%r12,%rax)
jne 0x6b2df
subl %r15d, %r14d
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %r13
movaps %xmm0, -0x8(%r13)
movq $0x0, 0x8(%r13)
addq %r15, %r12
movq 0x20(%rsp), %r8
movq 0x8(%r8), %rax
movq %rsp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
testq %rax, %rax
je 0x6b2c3
callq *%rax
jmp 0x6b2c8
movl $0x53, %ebp
jmp 0x6b2df
callq 0x674d9
movl %eax, %ebp
testl %eax, %eax
je 0x6b2f0
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq (%rsp), %rdi
callq 0x3a540
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0x6b328
movl %r14d, 0x100(%rbx)
movq %r14, %rdi
callq 0x3a5b0
movq %rax, 0xf8(%rbx)
testq %rax, %rax
je 0x6b32f
movq (%rsp), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x3a3b0
xorl %ebp, %ebp
jmp 0x6b2ce
movl $0x64, %ebp
jmp 0x6b2ce
movl $0x53, %ebp
jmp 0x6b2ce