void clampv(const double *mi, double *l, const double *ma) {
  l[0] = (l[0] < mi[0] ? mi[0] : (l[0] > ma[0] ? ma[0] : l[0]));
  l[1] = (l[1] < mi[1] ? mi[1] : (l[1] > ma[1] ? ma[1] : l[1]));
  l[2] = (l[2] < mi[2] ? mi[2] : (l[2] > ma[2] ? ma[2] : l[2]));
}


x86 assembly (clang, -O0):
<clampv>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    113c <clampv+0x3c>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    117b <clampv+0x7b>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1164 <clampv+0x64>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1171 <clampv+0x71>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b7 <clampv+0xb7>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11fa <clampv+0xfa>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
ucomisd 0x8(%rax),%xmm0
jbe    11e2 <clampv+0xe2>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11f0 <clampv+0xf0>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1237 <clampv+0x137>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    127a <clampv+0x17a>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
ucomisd 0x10(%rax),%xmm0
jbe    1262 <clampv+0x162>
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1270 <clampv+0x170>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<clampv>:
movsd  (%rsi),%xmm1
movsd  (%rdi),%xmm0
ucomisd %xmm1,%xmm0
ja     1116 <clampv+0x16>
movsd  (%rdx),%xmm0
minsd  %xmm1,%xmm0
movsd  %xmm0,(%rsi)
movsd  0x8(%rsi),%xmm1
movsd  0x8(%rdi),%xmm0
ucomisd %xmm1,%xmm0
ja     1133 <clampv+0x33>
movsd  0x8(%rdx),%xmm0
minsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  0x10(%rsi),%xmm1
movsd  0x10(%rdi),%xmm0
ucomisd %xmm1,%xmm0
ja     1151 <clampv+0x51>
movsd  0x10(%rdx),%xmm0
minsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsi)
ret

LLVM IR (-O0):
define void @clampv(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%7 = load double*, double** %5
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = fcmp olt double %9, %12
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
br label %36
18: ; preds = %3
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
%25 = fcmp ogt double %21, %24
br i1 %25, label %26, label %30
26: ; preds = %18
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
br label %34
30: ; preds = %18
%31 = load double*, double** %5
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
br label %34
34: ; preds = %30, %26
%35 = phi double [ %29, %26 ], [ %33, %30 ]
br label %36
36: ; preds = %34, %14
%37 = phi double [ %17, %14 ], [ %35, %34 ]
%38 = load double*, double** %5
%39 = getelementptr inbounds double, double* %38, i64 0
store double %37, double* %39
%40 = load double*, double** %5
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = fcmp olt double %42, %45
br i1 %46, label %47, label %51
47: ; preds = %36
%48 = load double*, double** %4
%49 = getelementptr inbounds double, double* %48, i64 1
%50 = load double, double* %49
br label %69
51: ; preds = %36
%52 = load double*, double** %5
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = load double*, double** %6
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = fcmp ogt double %54, %57
br i1 %58, label %59, label %63
59: ; preds = %51
%60 = load double*, double** %6
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
br label %67
63: ; preds = %51
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 1
%66 = load double, double* %65
br label %67
67: ; preds = %63, %59
%68 = phi double [ %62, %59 ], [ %66, %63 ]
br label %69
69: ; preds = %67, %47
%70 = phi double [ %50, %47 ], [ %68, %67 ]
%71 = load double*, double** %5
%72 = getelementptr inbounds double, double* %71, i64 1
store double %70, double* %72
%73 = load double*, double** %5
%74 = getelementptr inbounds double, double* %73, i64 2
%75 = load double, double* %74
%76 = load double*, double** %4
%77 = getelementptr inbounds double, double* %76, i64 2
%78 = load double, double* %77
%79 = fcmp olt double %75, %78
br i1 %79, label %80, label %84
80: ; preds = %69
%81 = load double*, double** %4
%82 = getelementptr inbounds double, double* %81, i64 2
%83 = load double, double* %82
br label %102
84: ; preds = %69
%85 = load double*, double** %5
%86 = getelementptr inbounds double, double* %85, i64 2
%87 = load double, double* %86
%88 = load double*, double** %6
%89 = getelementptr inbounds double, double* %88, i64 2
%90 = load double, double* %89
%91 = fcmp ogt double %87, %90
br i1 %91, label %92, label %96
92: ; preds = %84
%93 = load double*, double** %6
%94 = getelementptr inbounds double, double* %93, i64 2
%95 = load double, double* %94
br label %100
96: ; preds = %84
%97 = load double*, double** %5
%98 = getelementptr inbounds double, double* %97, i64 2
%99 = load double, double* %98
br label %100
100: ; preds = %96, %92
%101 = phi double [ %95, %92 ], [ %99, %96 ]
br label %102
102: ; preds = %100, %80
%103 = phi double [ %83, %80 ], [ %101, %100 ]
%104 = load double*, double** %5
%105 = getelementptr inbounds double, double* %104, i64 2
store double %103, double* %105
ret void
}

LLVM IR (-O2):
define void @clampv(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %1
%5 = load double, double* %0
%6 = fcmp olt double %4, %5
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = load double, double* %2
%9 = fcmp ogt double %4, %8
%10 = select i1 %9, double %8, double %4
br label %11
11: ; preds = %7, %3
%12 = phi double [ %5, %3 ], [ %10, %7 ]
store double %12, double* %1
%13 = getelementptr inbounds double, double* %1, i64 1
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %0, i64 1
%16 = load double, double* %15
%17 = fcmp olt double %14, %16
br i1 %17, label %23, label %18
18: ; preds = %11
%19 = getelementptr inbounds double, double* %2, i64 1
%20 = load double, double* %19
%21 = fcmp ogt double %14, %20
%22 = select i1 %21, double %20, double %14
br label %23
23: ; preds = %18, %11
%24 = phi double [ %16, %11 ], [ %22, %18 ]
store double %24, double* %13
%25 = getelementptr inbounds double, double* %1, i64 2
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %0, i64 2
%28 = load double, double* %27
%29 = fcmp olt double %26, %28
br i1 %29, label %35, label %30
30: ; preds = %23
%31 = getelementptr inbounds double, double* %2, i64 2
%32 = load double, double* %31
%33 = fcmp ogt double %26, %32
%34 = select i1 %33, double %32, double %26
br label %35
35: ; preds = %30, %23
%36 = phi double [ %28, %23 ], [ %34, %30 ]
store double %36, double* %25
ret void
}