void rgba2cmyk(double rgba[4], double cmyk[4]) {
  double c, m, y, k;
  c = 1.0 - rgba[0];
  m = 1.0 - rgba[1];
  y = 1.0 - rgba[2];
  k = c < m ? c : m;
  k = y < k ? y : k;
  cmyk[4] = k;
  cmyk[3] = c - k;
  cmyk[2] = m - k;
  cmyk[0] = y - k;
}


x86 assembly (clang, -O0):
<rgba2cmyk>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xee8(%rip),%xmm0
subsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xed3(%rip),%xmm0
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xebd(%rip),%xmm0
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1170 <rgba2cmyk+0x70>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    117a <rgba2cmyk+0x7a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a7 <rgba2cmyk+0xa7>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11b1 <rgba2cmyk+0xb1>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x20(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgba2cmyk>:
movupd (%rdi),%xmm0
movapd 0xef4(%rip),%xmm1
subpd  %xmm0,%xmm1
movsd  0xef8(%rip),%xmm0
subsd  0x10(%rdi),%xmm0
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
movapd %xmm1,%xmm3
minsd  %xmm2,%xmm3
movapd %xmm0,%xmm2
minsd  %xmm3,%xmm2
movsd  %xmm2,0x20(%rsi)
subsd  %xmm2,%xmm0
unpcklpd %xmm2,%xmm2
shufpd $0x1,%xmm1,%xmm1
subpd  %xmm2,%xmm1
movupd %xmm1,0x10(%rsi)
movsd  %xmm0,(%rsi)
ret

LLVM IR (-O0):
define void @rgba2cmyk(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%9 = load double*, double** %3
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = fsub double 1.000000e+00, %11
store double %12, double* %5
%13 = load double*, double** %3
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = fsub double 1.000000e+00, %15
store double %16, double* %6
%17 = load double*, double** %3
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
%20 = fsub double 1.000000e+00, %19
store double %20, double* %7
%21 = load double, double* %5
%22 = load double, double* %6
%23 = fcmp olt double %21, %22
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = load double, double* %5
br label %28
26: ; preds = %2
%27 = load double, double* %6
br label %28
28: ; preds = %26, %24
%29 = phi double [ %25, %24 ], [ %27, %26 ]
store double %29, double* %8
%30 = load double, double* %7
%31 = load double, double* %8
%32 = fcmp olt double %30, %31
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = load double, double* %7
br label %37
35: ; preds = %28
%36 = load double, double* %8
br label %37
37: ; preds = %35, %33
%38 = phi double [ %34, %33 ], [ %36, %35 ]
store double %38, double* %8
%39 = load double, double* %8
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 4
store double %39, double* %41
%42 = load double, double* %5
%43 = load double, double* %8
%44 = fsub double %42, %43
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 3
store double %44, double* %46
%47 = load double, double* %6
%48 = load double, double* %8
%49 = fsub double %47, %48
%50 = load double*, double** %4
%51 = getelementptr inbounds double, double* %50, i64 2
store double %49, double* %51
%52 = load double, double* %7
%53 = load double, double* %8
%54 = fsub double %52, %53
%55 = load double*, double** %4
%56 = getelementptr inbounds double, double* %55, i64 0
store double %54, double* %56
ret void
}

LLVM IR (-O2):
define void @rgba2cmyk(double* nocapture %0, double* nocapture writeonly %1) {
%3 = bitcast double* %0 to <2 x double>*
%4 = load <2 x double>, <2 x double>* %3
%5 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %4
%6 = getelementptr inbounds double, double* %0, i64 2
%7 = load double, double* %6
%8 = fsub double 1.000000e+00, %7
%9 = extractelement <2 x double> %5, i64 0
%10 = extractelement <2 x double> %5, i64 1
%11 = fcmp olt double %9, %10
%12 = select i1 %11, double %9, double %10
%13 = fcmp olt double %8, %12
%14 = select i1 %13, double %8, double %12
%15 = getelementptr inbounds double, double* %1, i64 4
store double %14, double* %15
%16 = insertelement <2 x double> poison, double %14, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = fsub <2 x double> %5, %17
%19 = getelementptr inbounds double, double* %1, i64 2
%20 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%21 = bitcast double* %19 to <2 x double>*
store <2 x double> %20, <2 x double>* %21
%22 = fsub double %8, %14
store double %22, double* %1
ret void
}