// File: lvandeve[P]lodepng/lodepng_util.cpp
// Function: lodepng::convertToXYZ_gamma_table(float*, unsigned long, unsigned long, LodePNGInfo const*, unsigned int, lodepng::LodePNGICC const*)
static void convertToXYZ_gamma_table(float* out, size_t n, size_t c,
                                     const LodePNGInfo* info, unsigned use_icc, const LodePNGICC* icc) {
  size_t i;
  float mul = 1.0f / (n - 1);
  if(use_icc) {
    for(i = 0; i < n; i++) {
      float v = i * mul;
      out[i] = iccForwardTRC(&icc->trc[c], v);
    }
  } else if(info->gama_defined && !info->srgb_defined) {
    /* no power needed if gamma is 1 */
    if(info->gama_gamma == 100000) {
      for(i = 0; i < n; i++) {
        out[i] = i * mul;
      }
    } else {
      float gamma = 100000.0f / info->gama_gamma;
      for(i = 0; i < n; i++) {
        float v = i * mul;
        out[i] = lodepng_powf(v, gamma);
      }
    }
  } else {
    for(i = 0; i < n; i++) {
      /* sRGB gamma expand */
      float v = i * mul;
      out[i] = (v < 0.04045f) ? (v / 12.92f) : lodepng_powf((v + 0.055f) / 1.055f, 2.4f);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
decq %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x54(%rbp)
testq %rax, %rax
movss %xmm0, -0x50(%rbp)
js 0x1f02f
movss -0x54(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x50(%rbp), %xmm1
movss 0x939b8(%rip), %xmm0    # 0xb29f4
divss %xmm1, %xmm0
movss %xmm0, -0x3c(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x1f0ed
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x1f0e8
movq -0x38(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x5c(%rbp)
testq %rax, %rax
movss %xmm0, -0x58(%rbp)
js 0x1f09e
movss -0x5c(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
mulss -0x3c(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movq -0x30(%rbp), %rdi
addq $0x80, %rdi
imulq $0x38, -0x18(%rbp), %rax
addq %rax, %rdi
movss -0x40(%rbp), %xmm0
callq 0x20c90
movq -0x8(%rbp), %rax
movq -0x38(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1f057
jmp 0x1f315
movq -0x20(%rbp), %rax
cmpl $0x0, 0xc8(%rax)
je 0x1f23f
movq -0x20(%rbp), %rax
cmpl $0x0, 0xf4(%rax)
jne 0x1f23f
movq -0x20(%rbp), %rax
cmpl $0x186a0, 0xcc(%rax)    # imm = 0x186A0
jne 0x1f194
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x1f18f
movq -0x38(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x64(%rbp)
testq %rax, %rax
movss %xmm0, -0x60(%rbp)
js 0x1f16a
movss -0x64(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x60(%rbp), %xmm0
mulss -0x3c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq -0x38(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1f127
jmp 0x1f23a
movq -0x20(%rbp), %rax
movl 0xcc(%rax), %eax
cvtsi2ss %rax, %xmm1
movss 0x9384d(%rip), %xmm0    # 0xb29f8
divss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x1f238
movq -0x38(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x6c(%rbp)
testq %rax, %rax
movss %xmm0, -0x68(%rbp)
js 0x1f1ff
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x68(%rbp), %xmm0
mulss -0x3c(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x48(%rbp), %xmm0
movss -0x44(%rbp), %xmm1
callq 0x21170
movq -0x8(%rbp), %rax
movq -0x38(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1f1bc
jmp 0x1f23a
jmp 0x1f313
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x1f311
movq -0x38(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x74(%rbp)
testq %rax, %rax
movss %xmm0, -0x70(%rbp)
js 0x1f28e
movss -0x74(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x70(%rbp), %xmm0
mulss -0x3c(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movss 0x93757(%rip), %xmm0    # 0xb29fc
ucomiss -0x4c(%rbp), %xmm0
jbe 0x1f2c3
movss -0x4c(%rbp), %xmm0
movss 0x93754(%rip), %xmm1    # 0xb2a0c
divss %xmm1, %xmm0
movss %xmm0, -0x78(%rbp)
jmp 0x1f2ee
movss 0x9373d(%rip), %xmm0    # 0xb2a08
addss -0x4c(%rbp), %xmm0
movss 0x9372c(%rip), %xmm1    # 0xb2a04
divss %xmm1, %xmm0
movss 0x9371c(%rip), %xmm1    # 0xb2a00
callq 0x21170
movss %xmm0, -0x78(%rbp)
movss -0x78(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq -0x38(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1f247
jmp 0x1f313
jmp 0x1f315
addq $0x80, %rsp
popq %rbp
retq
nop