void XYZ_to_xyY(double *XYZ, double *xyY) {
  xyY[0] = XYZ[0] / (XYZ[0] + XYZ[1] + XYZ[2]);
  xyY[1] = XYZ[1] / (XYZ[0] + XYZ[1] + XYZ[2]);
  xyY[2] = XYZ[1];
}


x86 assembly (clang, -O0):
<XYZ_to_xyY>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<XYZ_to_xyY>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
addsd  %xmm0,%xmm1
addsd  0x10(%rdi),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsi)
movsd  0x8(%rdi),%xmm0
movsd  (%rdi),%xmm1
addsd  %xmm0,%xmm1
addsd  0x10(%rdi),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  0x8(%rdi),%xmm0
movsd  %xmm0,0x10(%rsi)
ret

LLVM IR (-O0):
define void @XYZ_to_xyY(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
%5 = load double*, double** %3
%6 = getelementptr inbounds double, double* %5, i64 0
%7 = load double, double* %6
%8 = load double*, double** %3
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = load double*, double** %3
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %12
%14 = fadd double %10, %13
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 2
%17 = load double, double* %16
%18 = fadd double %14, %17
%19 = fdiv double %7, %18
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 0
store double %19, double* %21
%22 = load double*, double** %3
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = load double*, double** %3
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = load double*, double** %3
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = fadd double %27, %30
%32 = load double*, double** %3
%33 = getelementptr inbounds double, double* %32, i64 2
%34 = load double, double* %33
%35 = fadd double %31, %34
%36 = fdiv double %24, %35
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 1
store double %36, double* %38
%39 = load double*, double** %3
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = load double*, double** %4
%43 = getelementptr inbounds double, double* %42, i64 2
store double %41, double* %43
ret void
}

LLVM IR (-O2):
define void @XYZ_to_xyY(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = fadd double %3, %5
%7 = getelementptr inbounds double, double* %0, i64 2
%8 = load double, double* %7
%9 = fadd double %6, %8
%10 = fdiv double %3, %9
store double %10, double* %1
%11 = load double, double* %4
%12 = load double, double* %0
%13 = fadd double %11, %12
%14 = load double, double* %7
%15 = fadd double %13, %14
%16 = fdiv double %11, %15
%17 = getelementptr inbounds double, double* %1, i64 1
store double %16, double* %17
%18 = load double, double* %4
%19 = getelementptr inbounds double, double* %1, i64 2
store double %18, double* %19
ret void
}