// File: /workspace/github_cpp_makefile_star2_O1/Lut99[P]RayTracer/src/lib/LodePNG.cpp
// Function: addChunk_iCCP(ucvector*, LodePNGInfo const*, LodePNGCompressSettings*)
static unsigned addChunk_iCCP(ucvector* out, const LodePNGInfo* info, LodePNGCompressSettings* zlibsettings) {
  unsigned error = 0;
  ucvector data, compressed;
  size_t i;

  ucvector_init(&data);
  ucvector_init(&compressed);
  for(i = 0; info->iccp_name[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)info->iccp_name[i]);
  if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/
  ucvector_push_back(&data, 0); /*0 termination char*/
  ucvector_push_back(&data, 0); /*compression method: 0*/

  error = zlib_compress(&compressed.data, &compressed.size,
                        info->iccp_profile, info->iccp_profile_size, zlibsettings);
  if(!error) {
    for(i = 0; i != compressed.size; ++i) ucvector_push_back(&data, compressed.data[i]);
    error = addChunk(out, "iCCP", data.data, data.size);
  }

  ucvector_cleanup(&compressed);
  ucvector_cleanup(&data);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x30(%rsp)
movq %rsi, %r12
movq %rdi, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0xf0(%rsi), %rax
movb (%rax), %r14b
testb %r14b, %r14b
je 0x6e26c
movq $-0x1, %r15
xorl %ebp, %ebp
xorl %edx, %edx
xorl %edi, %edi
movq %r12, 0x20(%rsp)
leaq 0x1(%rdx), %rbx
cmpq %rbx, %rbp
jae 0x6e22c
movq %rdx, 0x18(%rsp)
leaq (,%rbp,2), %rax
leaq (%rbx,%rbx,2), %r13
shrq %r13
cmpq %rbx, %rax
cmovbq %rbx, %r13
movq %r13, %rsi
movq %rbp, %r12
movq %rdi, %rbp
callq 0x3a720
testq %rax, %rax
je 0x6e233
xorl %ecx, %ecx
movq %rax, %rdi
movq %rbx, %rdx
movq %r13, %rbp
movq 0x20(%rsp), %r12
jmp 0x6e245
xorl %ecx, %ecx
movq %rbx, %rdx
jmp 0x6e245
movb $0x1, %cl
movq %rbp, %rdi
movq %r12, %rbp
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rdx
testb %cl, %cl
jne 0x6e24e
movb %r14b, -0x1(%rdi,%rdx)
movq 0xf0(%r12), %rax
movb 0x2(%r15,%rax), %r14b
incq %r15
testb %r14b, %r14b
jne 0x6e1e3
cmpq $0x4f, %r15
setae %al
jmp 0x6e274
movb $0x1, %al
xorl %edi, %edi
xorl %edx, %edx
xorl %ebp, %ebp
testb %al, %al
jne 0x6e44d
leaq 0x1(%rdx), %r14
cmpq %r14, %rbp
jae 0x6e2b8
movq %rdx, %r15
leaq (,%rbp,2), %rax
leaq (%r14,%r14,2), %r13
shrq %r13
cmpq %r14, %rax
cmovbq %r14, %r13
movq %r13, %rsi
movq %rdi, %rbx
callq 0x3a720
testq %rax, %rax
je 0x6e2bc
xorl %ecx, %ecx
movq %rax, %rdi
movq %r13, %rbp
jmp 0x6e2c4
xorl %ecx, %ecx
jmp 0x6e2c4
movb $0x1, %cl
movq %r15, %r14
movq %rbx, %rdi
testb %cl, %cl
jne 0x6e2ce
movb $0x0, -0x1(%rdi,%r14)
leaq 0x1(%r14), %rbx
cmpq %rbx, %rbp
jae 0x6e316
movq %rbx, %rcx
movq %r12, %rbx
leaq (,%rbp,2), %rax
leaq (%rcx,%rcx,2), %r15
shrq %r15
cmpq %rcx, %rax
movq %rcx, %r13
cmovbq %rcx, %r15
movq %r15, %rsi
movq %rdi, %r12
callq 0x3a720
testq %rax, %rax
je 0x6e31a
xorl %ecx, %ecx
movq %rax, %rdi
movq %r15, %rbp
movq %rbx, %r12
movq %r13, %rbx
jmp 0x6e325
xorl %ecx, %ecx
jmp 0x6e325
movb $0x1, %cl
movq %r12, %rdi
movq %rbx, %r12
movq %r14, %rbx
testb %cl, %cl
movq 0x30(%rsp), %r8
jne 0x6e333
movb $0x0, -0x1(%rdi,%rbx)
movq %rdi, %r15
leaq 0x8(%rsp), %r14
movq 0xf8(%r12), %rdx
movl 0x100(%r12), %ecx
movq 0x18(%r8), %rax
movq %rsp, %rdi
movq %r14, %rsi
testq %rax, %rax
je 0x6e35e
callq *%rax
jmp 0x6e363
callq 0x67c2b
testl %eax, %eax
jne 0x6e42d
cmpq $0x0, 0x8(%rsp)
je 0x6e3fc
xorl %r14d, %r14d
movq %r15, %r8
movq (%rsp), %rax
movb (%rax,%r14), %r12b
leaq 0x1(%rbx), %r13
cmpq %r13, %rbp
jae 0x6e3d3
movq %rbx, 0x18(%rsp)
leaq (,%rbp,2), %rax
leaq (,%r13,2), %r15
addq %r13, %r15
shrq %r15
cmpq %r13, %rax
cmovbq %r13, %r15
movq %r8, %rdi
movq %r15, %rsi
movq %rbp, %rbx
movq %r8, %rbp
callq 0x3a720
testq %rax, %rax
je 0x6e3da
xorl %ecx, %ecx
movq %rax, %r8
movq %r13, %rbx
movq %r15, %rbp
jmp 0x6e3e7
xorl %ecx, %ecx
movq %r13, %rbx
jmp 0x6e3e7
movb $0x1, %cl
movq %rbp, %r8
movq %rbx, %rbp
movq 0x18(%rsp), %rbx
testb %cl, %cl
jne 0x6e3f0
movb %r12b, -0x1(%r8,%rbx)
incq %r14
cmpq 0x8(%rsp), %r14
jne 0x6e37d
jmp 0x6e3ff
movq %r15, %r8
movq 0x28(%rsp), %r14
leaq 0x8(%r14), %rsi
leaq 0x1bad1(%rip), %rcx     # 0x89ee0
movq %r14, %rdi
movl %ebx, %edx
movq %r8, %r15
callq 0x68168
testl %eax, %eax
jne 0x6e428
movq 0x8(%r14), %rax
movq %rax, 0x10(%r14)
leaq 0x8(%rsp), %r14
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq (%rsp), %rdi
callq 0x3a530
movq $0x0, (%rsp)
movq %r15, %rdi
callq 0x3a530
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq