// File: lvandeve[P]lodepng/lodepng_util.cpp
// Function: lodepng::getChrm(float*, float*, unsigned int, lodepng::LodePNGICC const*, LodePNGInfo const*)
static unsigned getChrm(float m[9], float whitepoint[3], unsigned use_icc,
                        const LodePNGICC* icc, const LodePNGInfo* info) {
  size_t i;
  if(use_icc) {
    if(getICCChrm(m, whitepoint, icc)) return 1;  /* error in the matrix computations */
  } else if(info->chrm_defined && !info->srgb_defined) {
    float wx = info->chrm_white_x / 100000.0f, wy = info->chrm_white_y / 100000.0f;
    float rx = info->chrm_red_x / 100000.0f, ry = info->chrm_red_y / 100000.0f;
    float gx = info->chrm_green_x / 100000.0f, gy = info->chrm_green_y / 100000.0f;
    float bx = info->chrm_blue_x / 100000.0f, by = info->chrm_blue_y / 100000.0f;
    if(getChrmMatrixXY(m, wx, wy, rx, ry, gx, gy, bx, by)) return 1; /* returns if error */
    /* Output whitepoint, xyY to XYZ: */
    whitepoint[0] = wx / wy;
    whitepoint[1] = 1;
    whitepoint[2] = (1 - wx - wy) / wy;
  } else {
    /* the standard linear sRGB to XYZ matrix */
    static const float srgb[9] = {
        0.4124564f, 0.3575761f, 0.1804375f,
        0.2126729f, 0.7151522f, 0.0721750f,
        0.0193339f, 0.1191920f, 0.9503041f
    };
    for(i = 0; i < 9; i++) m[i] = srgb[i];
    /* sRGB's whitepoint xyY "0.3127,0.3290,1" in XYZ: */
    whitepoint[0] = 0.9504559270516716f;
    whitepoint[1] = 1;
    whitepoint[2] = 1.0890577507598784f;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x21988
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x21cb0
cmpl $0x0, %eax
je 0x21983
movl $0x1, -0x4(%rbp)
jmp 0x21b76
jmp 0x21b6f
movq -0x30(%rbp), %rax
cmpl $0x0, 0xd0(%rax)
je 0x21b01
movq -0x30(%rbp), %rax
cmpl $0x0, 0xf4(%rax)
jne 0x21b01
movq -0x30(%rbp), %rax
movl 0xd4(%rax), %eax
cvtsi2ss %rax, %xmm0
movss 0x91037(%rip), %xmm1    # 0xb29f8
divss %xmm1, %xmm0
movss %xmm0, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl 0xd8(%rax), %eax
cvtsi2ss %rax, %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x40(%rbp)
movq -0x30(%rbp), %rax
movl 0xdc(%rax), %eax
cvtsi2ss %rax, %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movq -0x30(%rbp), %rax
movl 0xe0(%rax), %eax
cvtsi2ss %rax, %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl 0xe4(%rax), %eax
cvtsi2ss %rax, %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x4c(%rbp)
movq -0x30(%rbp), %rax
movl 0xe8(%rax), %eax
cvtsi2ss %rax, %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x50(%rbp)
movq -0x30(%rbp), %rax
movl 0xec(%rax), %eax
cvtsi2ss %rax, %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
movq -0x30(%rbp), %rax
movl 0xf0(%rax), %eax
cvtsi2ss %rax, %xmm0
movss 0x90f87(%rip), %xmm1    # 0xb29f8
divss %xmm1, %xmm0
movss %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movss -0x3c(%rbp), %xmm0
movss -0x40(%rbp), %xmm1
movss -0x44(%rbp), %xmm2
movss -0x48(%rbp), %xmm3
movss -0x4c(%rbp), %xmm4
movss -0x50(%rbp), %xmm5
movss -0x54(%rbp), %xmm6
movss -0x58(%rbp), %xmm7
callq 0x22070
cmpl $0x0, %eax
je 0x21abc
movl $0x1, -0x4(%rbp)
jmp 0x21b76
movss -0x3c(%rbp), %xmm0
divss -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
movss %xmm0, (%rax)
movq -0x18(%rbp), %rax
movss 0x90f1a(%rip), %xmm0    # 0xb29f4
movss %xmm0, 0x4(%rax)
movss 0x90f0d(%rip), %xmm0    # 0xb29f4
subss -0x3c(%rbp), %xmm0
subss -0x40(%rbp), %xmm0
divss -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
movss %xmm0, 0x8(%rax)
jmp 0x21b6d
movq $0x0, -0x38(%rbp)
cmpq $0x9, -0x38(%rbp)
jae 0x21b3b
movq -0x38(%rbp), %rcx
leaq 0x91095(%rip), %rax     # 0xb2bb0
movss (%rax,%rcx,4), %xmm0
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x21b09
movq -0x18(%rbp), %rax
movss 0x90f4d(%rip), %xmm0    # 0xb2a94
movss %xmm0, (%rax)
movq -0x18(%rbp), %rax
movss 0x90e9d(%rip), %xmm0    # 0xb29f4
movss %xmm0, 0x4(%rax)
movq -0x18(%rbp), %rax
movss 0x90f28(%rip), %xmm0    # 0xb2a90
movss %xmm0, 0x8(%rax)
jmp 0x21b6f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop