#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 */
double pow(double, double);
void XYZ2Lab(double X, double Y, double Z, double *L, double *a, double *b) {
  double fX, fY, fZ;
  X /= (255 * 0.950456);
  Y /= 255;
  Z /= (255 * 1.088754);
  if (Y > 0.008856)
    fY = pow(Y, 1.0 / 3.0);
  else
    fY = 7.787 * Y + 16.0 / 116.0;
  *L = 116.0 * fY - 16.0;
  if (X > 0.008856)
    fX = pow(X, 1.0 / 3.0);
  else
    fX = 7.787 * X + 16.0 / 116.0;
  if (Z > 0.008856)
    fZ = pow(Z, 1.0 / 3.0);
  else
    fZ = 7.787 * Z + 16.0 / 116.0;
  *a = 500.0 * (fX - fY);
  *b = 200.0 * (fY - fZ);
}


x86 assembly (clang, -O0):
<XYZ2Lab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xed8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeba(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe9c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a8 <XYZ2Lab+0x98>
movsd  -0x10(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    11ca <XYZ2Lab+0xba>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe67(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe5d(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  0xe04(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1222 <XYZ2Lab+0x112>
movsd  -0x8(%rbp),%xmm0
movsd  0xe1d(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
jmp    1244 <XYZ2Lab+0x134>
movsd  -0x8(%rbp),%xmm0
movsd  0xdf1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xded(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdaf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1277 <XYZ2Lab+0x167>
movsd  -0x18(%rbp),%xmm0
movsd  0xdc8(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    1299 <XYZ2Lab+0x189>
movsd  -0x18(%rbp),%xmm0
movsd  0xd9c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd98(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  0xda5(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
movsd  0xd7f(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XYZ2Lab>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movapd %xmm1,%xmm3
movapd %xmm0,%xmm4
divsd  0xed7(%rip),%xmm4
divsd  0xed7(%rip),%xmm3
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
ucomisd 0xed6(%rip),%xmm3
jbe    1173 <XYZ2Lab+0x63>
movsd  0xee4(%rip),%xmm1
movapd %xmm3,%xmm0
movsd  %xmm4,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm4
movapd %xmm0,%xmm3
jmp    1183 <XYZ2Lab+0x73>
mulsd  0xea5(%rip),%xmm3
addsd  0xea5(%rip),%xmm3
divsd  0xe85(%rip),%xmm2
movsd  0xea5(%rip),%xmm0
mulsd  %xmm3,%xmm0
addsd  0xea1(%rip),%xmm0
movsd  %xmm0,(%rbx)
ucomisd 0xe6d(%rip),%xmm4
movsd  %xmm3,0x18(%rsp)
jbe    11f0 <XYZ2Lab+0xe0>
movsd  0xe75(%rip),%xmm1
movapd %xmm4,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm4
ucomisd 0xe3c(%rip),%xmm2
ja     120a <XYZ2Lab+0xfa>
mulsd  0xe3a(%rip),%xmm2
addsd  0xe3a(%rip),%xmm2
jmp    122b <XYZ2Lab+0x11b>
mulsd  0xe28(%rip),%xmm4
addsd  0xe28(%rip),%xmm4
ucomisd 0xe10(%rip),%xmm2
jbe    11de <XYZ2Lab+0xce>
movsd  0xe1e(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm4,0x10(%rsp)
call   1030 <pow@plt>
movsd  0x10(%rsp),%xmm4
movapd %xmm0,%xmm2
movsd  0x18(%rsp),%xmm0
subsd  %xmm0,%xmm4
mulsd  0xe0b(%rip),%xmm4
movsd  %xmm4,(%r15)
subsd  %xmm2,%xmm0
mulsd  0xe02(%rip),%xmm0
movsd  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @XYZ2Lab(double %0, double %1, double %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%16 = load double, double* %7
%17 = fdiv double %16, 0x406E4BB890D5A5B9
store double %17, double* %7
%18 = load double, double* %8
%19 = fdiv double %18, 2.550000e+02
store double %19, double* %8
%20 = load double, double* %9
%21 = fdiv double %20, 0x40715A1DC725C3DF
store double %21, double* %9
%22 = load double, double* %8
%23 = fcmp ogt double %22, 8.856000e-03
br i1 %23, label %24, label %27
24: ; preds = %6
%25 = load double, double* %8
%26 = call double @pow(double %25, double 0x3FD5555555555555)
store double %26, double* %14
br label %30
27: ; preds = %6
%28 = load double, double* %8
%29 = call double @llvm.fmuladd.f64(double 0x401F25E353F7CED9, double %28, double 0x3FC1A7B9611A7B96)
store double %29, double* %14
br label %30
30: ; preds = %27, %24
%31 = load double, double* %14
%32 = call double @llvm.fmuladd.f64(double 1.160000e+02, double %31, double -1.600000e+01)
%33 = load double*, double** %10
store double %32, double* %33
%34 = load double, double* %7
%35 = fcmp ogt double %34, 8.856000e-03
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load double, double* %7
%38 = call double @pow(double %37, double 0x3FD5555555555555)
store double %38, double* %13
br label %42
39: ; preds = %30
%40 = load double, double* %7
%41 = call double @llvm.fmuladd.f64(double 0x401F25E353F7CED9, double %40, double 0x3FC1A7B9611A7B96)
store double %41, double* %13
br label %42
42: ; preds = %39, %36
%43 = load double, double* %9
%44 = fcmp ogt double %43, 8.856000e-03
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load double, double* %9
%47 = call double @pow(double %46, double 0x3FD5555555555555)
store double %47, double* %15
br label %51
48: ; preds = %42
%49 = load double, double* %9
%50 = call double @llvm.fmuladd.f64(double 0x401F25E353F7CED9, double %49, double 0x3FC1A7B9611A7B96)
store double %50, double* %15
br label %51
51: ; preds = %48, %45
%52 = load double, double* %13
%53 = load double, double* %14
%54 = fsub double %52, %53
%55 = fmul double 5.000000e+02, %54
%56 = load double*, double** %11
store double %55, double* %56
%57 = load double, double* %14
%58 = load double, double* %15
%59 = fsub double %57, %58
%60 = fmul double 2.000000e+02, %59
%61 = load double*, double** %12
store double %60, double* %61
ret void
}

LLVM IR (-O2):
define void @XYZ2Lab(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fdiv double %0, 0x406E4BB890D5A5B9
%8 = fdiv double %1, 2.550000e+02
%9 = fdiv double %2, 0x40715A1DC725C3DF
%10 = fcmp ogt double %8, 8.856000e-03
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call double @pow(double %8, double 0x3FD5555555555555)
br label %15
13: ; preds = %6
%14 = tail call double @llvm.fmuladd.f64(double %8, double 0x401F25E353F7CED9, double 0x3FC1A7B9611A7B96)
br label %15
15: ; preds = %13, %11
%16 = phi double [ %12, %11 ], [ %14, %13 ]
%17 = tail call double @llvm.fmuladd.f64(double %16, double 1.160000e+02, double -1.600000e+01)
store double %17, double* %3
%18 = fcmp ogt double %7, 8.856000e-03
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call double @pow(double %7, double 0x3FD5555555555555)
br label %23
21: ; preds = %15
%22 = tail call double @llvm.fmuladd.f64(double %7, double 0x401F25E353F7CED9, double 0x3FC1A7B9611A7B96)
br label %23
23: ; preds = %21, %19
%24 = phi double [ %20, %19 ], [ %22, %21 ]
%25 = fcmp ogt double %9, 8.856000e-03
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call double @pow(double %9, double 0x3FD5555555555555)
br label %30
28: ; preds = %23
%29 = tail call double @llvm.fmuladd.f64(double %9, double 0x401F25E353F7CED9, double 0x3FC1A7B9611A7B96)
br label %30
30: ; preds = %28, %26
%31 = phi double [ %27, %26 ], [ %29, %28 ]
%32 = fsub double %24, %16
%33 = fmul double %32, 5.000000e+02
store double %33, double* %4
%34 = fsub double %16, %31
%35 = fmul double %34, 2.000000e+02
store double %35, double* %5
ret void
}