// File: /workspace/github_cpp_makefile_star2_O1/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 0x136e9
testq %r12, %r12
je 0x13763
movq %r9, %r14
subq $-0x80, %r14
xorl %ebp, %ebp
leaq 0x62723(%rip), %r13     # 0x75c20
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 0x135f5
addq %r14, %r12
movss (%rbp,%r15,4), %xmm0
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
ucomiss %xmm0, %xmm4
jae 0x136bd
ucomiss 0x6281a(%rip), %xmm0    # 0x75d64
jae 0x136bd
movq 0x10(%r12), %rax
testq %rax, %rax
je 0x1366d
xorl %ecx, %ecx
leaq 0x1(%rcx), %rdx
cmpq %rax, %rdx
je 0x1367b
leaq (%rax,%rcx), %rdx
shrq %rdx
movq 0x8(%r12), %rsi
movss (%rsi,%rdx,4), %xmm1
ucomiss %xmm0, %xmm1
ja 0x13588
movq %rdx, %rcx
jmp 0x1358e
movq %rdx, %rax
movq %rcx, %rdx
cmpq %rax, %rdx
jne 0x13560
jmp 0x1366f
ucomiss %xmm0, %xmm4
ja 0x136bd
movss 0x24(%r12), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x135e5
jmp 0x13638
ucomiss %xmm4, %xmm0
jbe 0x136bd
movss 0x627a1(%rip), %xmm1    # 0x75d64
divss 0x18(%r12), %xmm1
callq 0x13e86
xorps %xmm4, %xmm4
jmp 0x136bd
ucomiss %xmm0, %xmm4
ja 0x136bd
ucomiss %xmm4, %xmm0
ja 0x1363c
movss 0x20(%r12), %xmm0
xorps 0x6281d(%rip), %xmm0    # 0x75e10
jmp 0x1365a
xorps %xmm0, %xmm0
jmp 0x136bd
movss 0x24(%r12), %xmm1
movss 0x28(%r12), %xmm2
mulss %xmm1, %xmm2
ucomiss %xmm2, %xmm0
ja 0x1363c
jmp 0x13667
movss 0x24(%r12), %xmm1
movss 0x30(%r12), %xmm2
movss 0x28(%r12), %xmm3
mulss %xmm1, %xmm3
addss %xmm2, %xmm3
ucomiss %xmm3, %xmm0
jbe 0x13663
subss %xmm1, %xmm0
movss 0x62720(%rip), %xmm1    # 0x75d64
divss 0x18(%r12), %xmm1
callq 0x13e86
xorps %xmm4, %xmm4
subss 0x20(%r12), %xmm0
divss 0x1c(%r12), %xmm0
jmp 0x136bd
subss %xmm2, %xmm0
divss %xmm1, %xmm0
jmp 0x136bd
xorl %edx, %edx
movq 0x8(%r12), %rax
movss (%rax,%rdx,4), %xmm0
jmp 0x136bd
movq 0x8(%r12), %rdx
movss (%rdx,%rcx,4), %xmm1
movss (%rdx,%rax,4), %xmm2
ucomiss %xmm2, %xmm1
jne 0x13696
jp 0x13696
movaps %xmm1, %xmm0
jmp 0x136bd
subss %xmm1, %xmm0
movaps %xmm2, %xmm3
subss %xmm1, %xmm3
divss %xmm3, %xmm0
movss 0x626b7(%rip), %xmm3    # 0x75d64
subss %xmm0, %xmm3
mulss %xmm2, %xmm0
mulss %xmm1, %xmm3
addss %xmm3, %xmm0
movss %xmm0, (%rbp,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x13514
movq 0x8(%rsp), %rbp
incq %rbp
movq 0x10(%rsp), %r12
cmpq %r12, %rbp
jne 0x13505
jmp 0x13763
cmpl $0x0, 0xc8(%rcx)
je 0x136fb
cmpl $0x0, 0xf4(%rcx)
je 0x13774
testq %r12, %r12
je 0x13763
xorl %r14d, %r14d
movss 0x62691(%rip), %xmm1    # 0x75d9c
xorl %r15d, %r15d
movss (%rbx,%r15,4), %xmm0
ucomiss %xmm0, %xmm1
jbe 0x13723
mulss 0x6266b(%rip), %xmm0    # 0x75d8c
jmp 0x13748
movss 0x62675(%rip), %xmm1    # 0x75da0
callq 0x13e86
movss 0x62664(%rip), %xmm1    # 0x75d9c
mulss 0x62644(%rip), %xmm0    # 0x75d84
addss 0x6265c(%rip), %xmm0    # 0x75da4
movss %xmm0, (%rbx,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x1370e
incq %r14
addq $0x10, %rbx
cmpq %r12, %r14
jne 0x1370b
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 0x13763
testq %r12, %r12
je 0x13763
movl %eax, %eax
cvtsi2ss %rax, %xmm0
divss 0x625e3(%rip), %xmm0    # 0x75d78
movss %xmm0, 0x8(%rsp)
xorl %r14d, %r14d
xorps %xmm1, %xmm1
xorl %r15d, %r15d
movss (%rbx,%r15,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x137c3
movss 0x8(%rsp), %xmm1
callq 0x13e86
xorps %xmm1, %xmm1
movss %xmm0, (%rbx,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x137a4
incq %r14
addq $0x10, %rbx
cmpq %r12, %r14
jne 0x137a1
jmp 0x13763