void yuv2rgb(double Y, double U, double V, double *r, double *g, double *b) {
  *r = Y + 1.13983 * V;
  *g = Y - 0.39465 * U - 0.58060 * V;
  *b = Y + 2.03211 * U;
  if (*r > 1.0) {
    *r = 1.0;
  }
  if (*g > 1.0) {
    *g = 1.0;
  }
  if (*b > 1.0) {
    *b = 1.0;
  }
  if (*r < 0.0) {
    *r = 0.0;
  }
  if (*g < 0.0) {
    *g = 0.0;
  }
  if (*b < 0.0) {
    *b = 0.0;
  }
}


x86 assembly (clang, -O0):
<yuv2rgb>:
push   %rbp
mov    %rsp,%rbp
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),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xeef(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xec5(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xea8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe56(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c4 <yuv2rgb+0xc4>
mov    -0x20(%rbp),%rax
movsd  0xe40(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe2c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ee <yuv2rgb+0xee>
mov    -0x28(%rbp),%rax
movsd  0xe16(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe02(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1218 <yuv2rgb+0x118>
mov    -0x30(%rbp),%rax
movsd  0xdec(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1234 <yuv2rgb+0x134>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1250 <yuv2rgb+0x150>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    126c <yuv2rgb+0x16c>
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<yuv2rgb>:
movsd  0xef8(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,(%rdi)
movsd  0xeec(%rip),%xmm3
mulsd  %xmm1,%xmm3
mulsd  0xee8(%rip),%xmm2
addsd  %xmm0,%xmm3
addsd  %xmm3,%xmm2
mulsd  0xee0(%rip),%xmm1
movsd  %xmm2,(%rsi)
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx)
movsd  (%rdi),%xmm0
ucomisd 0xed0(%rip),%xmm0
movabs $0x3ff0000000000000,%rax
jbe    115f <yuv2rgb+0x5f>
mov    %rax,(%rdi)
movsd  (%rsi),%xmm0
ucomisd 0xeb5(%rip),%xmm0
jbe    1170 <yuv2rgb+0x70>
mov    %rax,(%rsi)
movsd  (%rdx),%xmm0
ucomisd 0xea4(%rip),%xmm0
jbe    1181 <yuv2rgb+0x81>
mov    %rax,(%rdx)
xorpd  %xmm0,%xmm0
ucomisd (%rdi),%xmm0
jbe    1192 <yuv2rgb+0x92>
movq   $0x0,(%rdi)
ucomisd (%rsi),%xmm0
jbe    119f <yuv2rgb+0x9f>
movq   $0x0,(%rsi)
xorpd  %xmm0,%xmm0
ucomisd (%rdx),%xmm0
jbe    11b0 <yuv2rgb+0xb0>
movq   $0x0,(%rdx)
ret

LLVM IR (-O0):
define void @yuv2rgb(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*
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
%13 = load double, double* %7
%14 = load double, double* %9
%15 = call double @llvm.fmuladd.f64(double 1.139830e+00, double %14, double %13)
%16 = load double*, double** %10
store double %15, double* %16
%17 = load double, double* %7
%18 = load double, double* %8
%19 = call double @llvm.fmuladd.f64(double -3.946500e-01, double %18, double %17)
%20 = load double, double* %9
%21 = call double @llvm.fmuladd.f64(double -5.806000e-01, double %20, double %19)
%22 = load double*, double** %11
store double %21, double* %22
%23 = load double, double* %7
%24 = load double, double* %8
%25 = call double @llvm.fmuladd.f64(double 2.032110e+00, double %24, double %23)
%26 = load double*, double** %12
store double %25, double* %26
%27 = load double*, double** %10
%28 = load double, double* %27
%29 = fcmp ogt double %28, 1.000000e+00
br i1 %29, label %30, label %32
30: ; preds = %6
%31 = load double*, double** %10
store double 1.000000e+00, double* %31
br label %32
32: ; preds = %30, %6
%33 = load double*, double** %11
%34 = load double, double* %33
%35 = fcmp ogt double %34, 1.000000e+00
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load double*, double** %11
store double 1.000000e+00, double* %37
br label %38
38: ; preds = %36, %32
%39 = load double*, double** %12
%40 = load double, double* %39
%41 = fcmp ogt double %40, 1.000000e+00
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = load double*, double** %12
store double 1.000000e+00, double* %43
br label %44
44: ; preds = %42, %38
%45 = load double*, double** %10
%46 = load double, double* %45
%47 = fcmp olt double %46, 0.000000e+00
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = load double*, double** %10
store double 0.000000e+00, double* %49
br label %50
50: ; preds = %48, %44
%51 = load double*, double** %11
%52 = load double, double* %51
%53 = fcmp olt double %52, 0.000000e+00
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = load double*, double** %11
store double 0.000000e+00, double* %55
br label %56
56: ; preds = %54, %50
%57 = load double*, double** %12
%58 = load double, double* %57
%59 = fcmp olt double %58, 0.000000e+00
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load double*, double** %12
store double 0.000000e+00, double* %61
br label %62
62: ; preds = %60, %56
ret void
}

LLVM IR (-O2):
define void @yuv2rgb(double %0, double %1, double %2, double* nocapture %3, double* nocapture %4, double* nocapture %5) {
%7 = tail call double @llvm.fmuladd.f64(double %2, double 1.139830e+00, double %0)
store double %7, double* %3
%8 = tail call double @llvm.fmuladd.f64(double %1, double -3.946500e-01, double %0)
%9 = tail call double @llvm.fmuladd.f64(double %2, double -5.806000e-01, double %8)
store double %9, double* %4
%10 = tail call double @llvm.fmuladd.f64(double %1, double 2.032110e+00, double %0)
store double %10, double* %5
%11 = load double, double* %3
%12 = fcmp ogt double %11, 1.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %6
store double 1.000000e+00, double* %3
br label %14
14: ; preds = %13, %6
%15 = load double, double* %4
%16 = fcmp ogt double %15, 1.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %14
store double 1.000000e+00, double* %4
br label %18
18: ; preds = %17, %14
%19 = load double, double* %5
%20 = fcmp ogt double %19, 1.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %18
store double 1.000000e+00, double* %5
br label %22
22: ; preds = %21, %18
%23 = load double, double* %3
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %22
store double 0.000000e+00, double* %3
br label %26
26: ; preds = %25, %22
%27 = load double, double* %4
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %26
store double 0.000000e+00, double* %4
br label %30
30: ; preds = %29, %26
%31 = load double, double* %5
%32 = fcmp olt double %31, 0.000000e+00
br i1 %32, label %33, label %34
33: ; preds = %30
store double 0.000000e+00, double* %5
br label %34
34: ; preds = %33, %30
ret void
}