#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
float const lab_f(float const);
void dt_XYZ_to_Lab(const float *XYZ, float *Lab) {
  const float d50[3] = {0.9642, 1.0, 0.8249};
  const float f[3] = {lab_f(XYZ[0] / d50[0]), lab_f(XYZ[1] / d50[1]),
                      lab_f(XYZ[2] / d50[2])};
  Lab[0] = 116.0f * f[1] - 16.0f;
  Lab[1] = 500.0f * (f[0] - f[1]);
  Lab[2] = 200.0f * (f[1] - f[2]);
}


x86 assembly (clang, -O0):
<dt_XYZ_to_Lab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xee9(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xee7(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x1c(%rbp),%xmm0
call   1030 <lab_f@plt>
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  -0x18(%rbp),%xmm0
call   1030 <lab_f@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  -0x14(%rbp),%xmm0
call   1030 <lab_f@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x24(%rbp),%xmm0
movss  0xe80(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe78(%rip),%xmm1
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x28(%rbp),%xmm1
subss  -0x24(%rbp),%xmm1
movss  0xe52(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x24(%rbp),%xmm1
subss  -0x20(%rbp),%xmm1
movss  0xe2f(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dt_XYZ_to_Lab>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movss  (%rdi),%xmm0
divss  0xeda(%rip),%xmm0
call   1030 <lab_f@plt>
movss  %xmm0,0x4(%rsp)
movss  0x4(%rbx),%xmm0
call   1030 <lab_f@plt>
movss  %xmm0,(%rsp)
movss  0x8(%rbx),%xmm0
divss  0xeb7(%rip),%xmm0
call   1030 <lab_f@plt>
movss  0xeae(%rip),%xmm1
movss  (%rsp),%xmm2
mulss  %xmm2,%xmm1
addss  0xea1(%rip),%xmm1
movss  %xmm1,(%r14)
movss  0x4(%rsp),%xmm1
subss  %xmm2,%xmm1
mulss  0xe8e(%rip),%xmm1
movss  %xmm1,0x4(%r14)
subss  %xmm0,%xmm2
mulss  0xe80(%rip),%xmm2
movss  %xmm2,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.dt_XYZ_to_Lab.d50 = [3 x float] [float 0x3FEEDABA00000000, float 1.000000e+00, float 0x3FEA6594A0000000]
define void @dt_XYZ_to_Lab(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca [3 x float]
%6 = alloca [3 x float]
store float* %0, float** %3
store float* %1, float** %4
%7 = bitcast [3 x float]* %5 to i8*
%8 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%9 = load float*, float** %3
%10 = getelementptr inbounds float, float* %9, i64 0
%11 = load float, float* %10
%12 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%13 = load float, float* %12
%14 = fdiv float %11, %13
%15 = call float @lab_f(float %14)
store float %15, float* %8
%16 = getelementptr inbounds float, float* %8, i64 1
%17 = load float*, float** %3
%18 = getelementptr inbounds float, float* %17, i64 1
%19 = load float, float* %18
%20 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
%21 = load float, float* %20
%22 = fdiv float %19, %21
%23 = call float @lab_f(float %22)
store float %23, float* %16
%24 = getelementptr inbounds float, float* %16, i64 1
%25 = load float*, float** %3
%26 = getelementptr inbounds float, float* %25, i64 2
%27 = load float, float* %26
%28 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
%29 = load float, float* %28
%30 = fdiv float %27, %29
%31 = call float @lab_f(float %30)
store float %31, float* %24
%32 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%33 = load float, float* %32
%34 = call float @llvm.fmuladd.f32(float 1.160000e+02, float %33, float -1.600000e+01)
%35 = load float*, float** %4
%36 = getelementptr inbounds float, float* %35, i64 0
store float %34, float* %36
%37 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%38 = load float, float* %37
%39 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%40 = load float, float* %39
%41 = fsub float %38, %40
%42 = fmul float 5.000000e+02, %41
%43 = load float*, float** %4
%44 = getelementptr inbounds float, float* %43, i64 1
store float %42, float* %44
%45 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%46 = load float, float* %45
%47 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
%48 = load float, float* %47
%49 = fsub float %46, %48
%50 = fmul float 2.000000e+02, %49
%51 = load float*, float** %4
%52 = getelementptr inbounds float, float* %51, i64 2
store float %50, float* %52
ret void
}

LLVM IR (-O2):
define void @dt_XYZ_to_Lab(float* nocapture %0, float* nocapture writeonly %1) {
%3 = load float, float* %0
%4 = fdiv float %3, 0x3FEEDABA00000000
%5 = tail call float @lab_f(float %4)
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = tail call float @lab_f(float %7)
%9 = getelementptr inbounds float, float* %0, i64 2
%10 = load float, float* %9
%11 = fdiv float %10, 0x3FEA6594A0000000
%12 = tail call float @lab_f(float %11)
%13 = tail call float @llvm.fmuladd.f32(float %8, float 1.160000e+02, float -1.600000e+01)
store float %13, float* %1
%14 = fsub float %5, %8
%15 = fmul float %14, 5.000000e+02
%16 = getelementptr inbounds float, float* %1, i64 1
store float %15, float* %16
%17 = fsub float %8, %12
%18 = fmul float %17, 2.000000e+02
%19 = getelementptr inbounds float, float* %1, i64 2
store float %18, float* %19
ret void
}