// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/lodepng_util.cpp
// Function: lodepng::convertFromXYZ_gamma(float*, unsigned int, unsigned int, LodePNGInfo const*, unsigned int, lodepng::LodePNGICC const*)
static unsigned convertFromXYZ_gamma(float* im, unsigned w, unsigned h,
                                     const LodePNGInfo* info, unsigned use_icc, const LodePNGICC* icc) {
  size_t i, c, n;
  if(lodepng_mulofl((size_t)w, (size_t)h, &n)) return 92;
  if(use_icc) {
    for(i = 0; i < n; i++) {
      for(c = 0; c < 3; c++) {
        /* TODO: this is likely very slow */
        im[i * 4 + c] = iccBackwardTRC(&icc->trc[c], im[i * 4 + c]);
      }
    }
  } else if(info->gama_defined && !info->srgb_defined) {
    /* nothing to do if gamma is 1 */
    if(info->gama_gamma != 100000) {
      float gamma = info->gama_gamma / 100000.0f;
      for(i = 0; i < n; i++) {
        for(c = 0; c < 3; c++) {
          if(im[i * 4 + c] > 0) im[i * 4 + c] = lodepng_powf(im[i * 4 + c], gamma);
        }
      }
    }
  } else {
    for(i = 0; i < n; i++) {
      for(c = 0; c < 3; c++) {
        /* sRGB gamma compress */
        float* v = &im[i * 4 + c];
        *v = (*v < 0.0031308f) ? (*v * 12.92f) : (1.055f * lodepng_powf(*v, 1 / 2.4f) - 0.055f);
      }
    }
  }
  return 0; /* no error */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl %esi, %eax
movl %edx, %r12d
imulq %rax, %r12
testl %r8d, %r8d
je 0x13489
testq %r12, %r12
je 0x13503
movq %r9, %r14
subq $-0x80, %r14
xorl %ebp, %ebp
leaq 0x62bb3(%rip), %r13     # 0x75e50
xorps %xmm4, %xmm4
movq %r12, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
shlq $0x4, %rbp
addq %rbx, %rbp
xorl %r15d, %r15d
imulq $0x38, %r15, %r12
movl (%r14,%r12), %eax
cmpq $0x6, %rax
ja 0x13395
addq %r14, %r12
movss (%rbp,%r15,4), %xmm0
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
ucomiss %xmm0, %xmm4
jae 0x1345d
ucomiss 0x62caa(%rip), %xmm0    # 0x75f94
jae 0x1345d
movq 0x10(%r12), %rax
testq %rax, %rax
je 0x1340d
xorl %ecx, %ecx
leaq 0x1(%rcx), %rdx
cmpq %rax, %rdx
je 0x1341b
leaq (%rax,%rcx), %rsi
shrq %rsi
movq 0x8(%r12), %rdx
movss (%rdx,%rsi,4), %xmm1
ucomiss %xmm0, %xmm1
ja 0x13328
movq %rsi, %rcx
jmp 0x1332e
movq %rsi, %rax
movq %rcx, %rsi
cmpq %rax, %rsi
jne 0x13300
jmp 0x13414
ucomiss %xmm0, %xmm4
ja 0x1345d
movss 0x24(%r12), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x13385
jmp 0x133d8
ucomiss %xmm4, %xmm0
jbe 0x1345d
movss 0x62c31(%rip), %xmm1    # 0x75f94
divss 0x18(%r12), %xmm1
callq 0x13c26
xorps %xmm4, %xmm4
jmp 0x1345d
ucomiss %xmm0, %xmm4
ja 0x1345d
ucomiss %xmm4, %xmm0
ja 0x133dc
movss 0x20(%r12), %xmm0
xorps 0x5ecbd(%rip), %xmm0    # 0x72050
jmp 0x133fa
xorps %xmm0, %xmm0
jmp 0x1345d
movss 0x24(%r12), %xmm1
movss 0x28(%r12), %xmm2
mulss %xmm1, %xmm2
ucomiss %xmm2, %xmm0
ja 0x133dc
jmp 0x13407
movss 0x24(%r12), %xmm1
movss 0x30(%r12), %xmm2
movss 0x28(%r12), %xmm3
mulss %xmm1, %xmm3
addss %xmm2, %xmm3
ucomiss %xmm3, %xmm0
jbe 0x13403
subss %xmm1, %xmm0
movss 0x62bb0(%rip), %xmm1    # 0x75f94
divss 0x18(%r12), %xmm1
callq 0x13c26
xorps %xmm4, %xmm4
subss 0x20(%r12), %xmm0
divss 0x1c(%r12), %xmm0
jmp 0x1345d
subss %xmm2, %xmm0
divss %xmm1, %xmm0
jmp 0x1345d
movq 0x8(%r12), %rdx
xorl %eax, %eax
movss (%rdx,%rax,4), %xmm0
jmp 0x1345d
movq 0x8(%r12), %rdx
movss (%rdx,%rcx,4), %xmm1
movss (%rdx,%rax,4), %xmm2
ucomiss %xmm2, %xmm1
jne 0x13436
jp 0x13436
movaps %xmm1, %xmm0
jmp 0x1345d
subss %xmm1, %xmm0
movaps %xmm2, %xmm3
subss %xmm1, %xmm3
divss %xmm3, %xmm0
movss 0x62b47(%rip), %xmm3    # 0x75f94
subss %xmm0, %xmm3
mulss %xmm2, %xmm0
mulss %xmm1, %xmm3
addss %xmm3, %xmm0
movss %xmm0, (%rbp,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x132b4
movq 0x8(%rsp), %rbp
incq %rbp
movq 0x10(%rsp), %r12
cmpq %r12, %rbp
jne 0x132a5
jmp 0x13503
cmpl $0x0, 0xc8(%rcx)
je 0x1349b
cmpl $0x0, 0xf4(%rcx)
je 0x13514
testq %r12, %r12
je 0x13503
xorl %r14d, %r14d
movss 0x62b15(%rip), %xmm1    # 0x75fc0
xorl %r15d, %r15d
movss (%rbx,%r15,4), %xmm0
ucomiss %xmm0, %xmm1
jbe 0x134c3
mulss 0x62afb(%rip), %xmm0    # 0x75fbc
jmp 0x134e8
movss 0x62af9(%rip), %xmm1    # 0x75fc4
callq 0x13c26
movss 0x62ae8(%rip), %xmm1    # 0x75fc0
mulss 0x62ad4(%rip), %xmm0    # 0x75fb4
addss 0x62ae0(%rip), %xmm0    # 0x75fc8
movss %xmm0, (%rbx,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x134ae
incq %r14
addq $0x10, %rbx
cmpq %r12, %r14
jne 0x134ab
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xcc(%rcx), %eax
cmpl $0x186a0, %eax          # imm = 0x186A0
je 0x13503
testq %r12, %r12
je 0x13503
movl %eax, %eax
cvtsi2ss %rax, %xmm0
divss 0x62a73(%rip), %xmm0    # 0x75fa8
movss %xmm0, 0x8(%rsp)
xorl %r14d, %r14d
xorps %xmm1, %xmm1
xorl %r15d, %r15d
movss (%rbx,%r15,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x13563
movss 0x8(%rsp), %xmm1
callq 0x13c26
xorps %xmm1, %xmm1
movss %xmm0, (%rbx,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x13544
incq %r14
addq $0x10, %rbx
cmpq %r12, %r14
jne 0x13541
jmp 0x13503