// File: /workspace/github_cpp_makefile_star2_O2/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, %edx
imulq %rax, %rdx
movq %rdx, 0x8(%rsp)
testl %r8d, %r8d
je 0x10bba
movq %r9, %r14
subq $-0x80, %r14
xorl %eax, %eax
leaq 0x4f268(%rip), %rdi     # 0x5fc40
xorps %xmm4, %xmm4
cmpq 0x8(%rsp), %rax
je 0x10c42
movq %rax, 0x10(%rsp)
leaq (,%rax,4), %rbp
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x10bad
imulq $0x38, %r12, %r13
movq %r12, %r15
orq %rbp, %r15
movl (%r14,%r13), %eax
cmpq $0x6, %rax
ja 0x10adc
addq %r14, %r13
movss (%rbx,%r15,4), %xmm0
movslq (%rdi,%rax,4), %rax
addq %rdi, %rax
jmpq *%rax
ucomiss %xmm0, %xmm4
jae 0x10b9f
ucomiss 0x4f356(%rip), %xmm0    # 0x5fd90
jae 0x10b9f
movq 0x10(%r13), %rax
xorl %ecx, %ecx
cmpq %rax, %rcx
je 0x10b53
leaq 0x1(%rcx), %rdx
cmpq %rax, %rdx
je 0x10b5e
leaq (%rcx,%rax), %rdx
shrq %rdx
movq 0x8(%r13), %rsi
movss (%rsi,%rdx,4), %xmm1
ucomiss %xmm0, %xmm1
ja 0x10a76
movq %rdx, %rcx
jmp 0x10a46
movq %rdx, %rax
jmp 0x10a46
ucomiss %xmm0, %xmm4
ja 0x10b9f
movss 0x24(%r13), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x10acd
jmp 0x10b1a
ucomiss %xmm4, %xmm0
jbe 0x10b9f
movss 0x4f2eb(%rip), %xmm1    # 0x5fd90
divss 0x18(%r13), %xmm1
callq 0x11328
xorps %xmm4, %xmm4
leaq 0x4f186(%rip), %rdi     # 0x5fc40
jmp 0x10b9f
ucomiss %xmm0, %xmm4
ja 0x10b9f
ucomiss %xmm4, %xmm0
ja 0x10b1e
movss 0x20(%r13), %xmm0
xorps 0x4f346(%rip), %xmm0    # 0x5fe20
jmp 0x10b41
xorps %xmm0, %xmm0
jmp 0x10b9f
movss 0x24(%r13), %xmm1
movss 0x28(%r13), %xmm2
mulss %xmm1, %xmm2
ucomiss %xmm2, %xmm0
ja 0x10b1e
jmp 0x10b4d
movss 0x24(%r13), %xmm1
movss 0x30(%r13), %xmm2
movss 0x28(%r13), %xmm3
mulss %xmm1, %xmm3
addss %xmm2, %xmm3
ucomiss %xmm3, %xmm0
jbe 0x10b49
subss %xmm1, %xmm0
movss 0x4f26a(%rip), %xmm1    # 0x5fd90
divss 0x18(%r13), %xmm1
callq 0x11328
xorps %xmm4, %xmm4
leaq 0x4f105(%rip), %rdi     # 0x5fc40
subss 0x20(%r13), %xmm0
divss 0x1c(%r13), %xmm0
jmp 0x10b9f
subss %xmm2, %xmm0
divss %xmm1, %xmm0
jmp 0x10b9f
movq 0x8(%r13), %rcx
movss (%rcx,%rax,4), %xmm0
jmp 0x10b9f
movq 0x8(%r13), %rdx
movss (%rdx,%rcx,4), %xmm1
movss (%rdx,%rax,4), %xmm2
ucomiss %xmm2, %xmm1
jne 0x10b78
jp 0x10b78
movaps %xmm1, %xmm0
jmp 0x10b9f
subss %xmm1, %xmm0
movaps %xmm2, %xmm3
subss %xmm1, %xmm3
divss %xmm3, %xmm0
movss 0x4f201(%rip), %xmm3    # 0x5fd90
subss %xmm0, %xmm3
mulss %xmm2, %xmm0
mulss %xmm1, %xmm3
addss %xmm3, %xmm0
movss %xmm0, (%rbx,%r15,4)
incq %r12
jmp 0x109f6
movq 0x10(%rsp), %rax
incq %rax
jmp 0x109db
cmpl $0x0, 0xc8(%rcx)
je 0x10bcc
cmpl $0x0, 0xf4(%rcx)
je 0x10c35
xorl %r14d, %r14d
movss 0x4f1e1(%rip), %xmm1    # 0x5fdb8
cmpq 0x8(%rsp), %r14
je 0x10c42
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x10c2c
movss (%rbx,%r15,4), %xmm0
ucomiss %xmm0, %xmm1
jbe 0x10bfc
mulss 0x4f1ae(%rip), %xmm0    # 0x5fda8
jmp 0x10c21
movss 0x4f1b8(%rip), %xmm1    # 0x5fdbc
callq 0x11328
movss 0x4f1a7(%rip), %xmm1    # 0x5fdb8
mulss 0x4f187(%rip), %xmm0    # 0x5fda0
addss 0x4f19f(%rip), %xmm0    # 0x5fdc0
movss %xmm0, (%rbx,%r15,4)
incq %r15
jmp 0x10be1
incq %r14
addq $0x10, %rbx
jmp 0x10bd7
movl 0xcc(%rcx), %eax
cmpl $0x186a0, %eax          # imm = 0x186A0
jne 0x10c53
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %eax
cvtsi2ss %rax, %xmm0
divss 0x4f132(%rip), %xmm0    # 0x5fd94
movss %xmm0, 0x10(%rsp)
xorl %r14d, %r14d
xorps %xmm1, %xmm1
cmpq 0x8(%rsp), %r14
je 0x10c42
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x10ca2
movss (%rbx,%r15,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x10c9d
movss 0x10(%rsp), %xmm1
callq 0x11328
xorps %xmm1, %xmm1
movss %xmm0, (%rbx,%r15,4)
incq %r15
jmp 0x10c78
incq %r14
addq $0x10, %rbx
jmp 0x10c6e