double median(double a, double b, double c) {
  return (
      (((((a) < (b)) ? (a) : (b))) >
       (((((((a) > (b)) ? (a) : (b))) < (c)) ? ((((a) > (b)) ? (a) : (b)))
                                             : (c))))
          ? ((((a) < (b)) ? (a) : (b)))
          : (((((((a) > (b)) ? (a) : (b))) < (c)) ? ((((a) > (b)) ? (a) : (b)))
                                                  : (c))));
}


x86 assembly (clang, -O0):
<median>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1136 <median+0x36>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1140 <median+0x40>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1169 <median+0x69>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1173 <median+0x73>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bf <median+0xbf>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a6 <median+0xa6>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11b0 <median+0xb0>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11c9 <median+0xc9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1219 <median+0x119>
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1200 <median+0x100>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    120a <median+0x10a>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12a2 <median+0x1a2>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1238 <median+0x138>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1242 <median+0x142>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    128e <median+0x18e>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1275 <median+0x175>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    127f <median+0x17f>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1298 <median+0x198>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<median>:
movapd %xmm0,%xmm3
minsd  %xmm1,%xmm3
maxsd  %xmm1,%xmm0
minsd  %xmm2,%xmm0
maxsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
ret

LLVM IR (-O0):
define double @median(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* %4
%8 = load double, double* %5
%9 = fcmp olt double %7, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = load double, double* %4
br label %14
12: ; preds = %3
%13 = load double, double* %5
br label %14
14: ; preds = %12, %10
%15 = phi double [ %11, %10 ], [ %13, %12 ]
%16 = load double, double* %4
%17 = load double, double* %5
%18 = fcmp ogt double %16, %17
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load double, double* %4
br label %23
21: ; preds = %14
%22 = load double, double* %5
br label %23
23: ; preds = %21, %19
%24 = phi double [ %20, %19 ], [ %22, %21 ]
%25 = load double, double* %6
%26 = fcmp olt double %24, %25
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = load double, double* %4
%29 = load double, double* %5
%30 = fcmp ogt double %28, %29
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load double, double* %4
br label %35
33: ; preds = %27
%34 = load double, double* %5
br label %35
35: ; preds = %33, %31
%36 = phi double [ %32, %31 ], [ %34, %33 ]
br label %39
37: ; preds = %23
%38 = load double, double* %6
br label %39
39: ; preds = %37, %35
%40 = phi double [ %36, %35 ], [ %38, %37 ]
%41 = fcmp ogt double %15, %40
br i1 %41, label %42, label %52
42: ; preds = %39
%43 = load double, double* %4
%44 = load double, double* %5
%45 = fcmp olt double %43, %44
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = load double, double* %4
br label %50
48: ; preds = %42
%49 = load double, double* %5
br label %50
50: ; preds = %48, %46
%51 = phi double [ %47, %46 ], [ %49, %48 ]
br label %78
52: ; preds = %39
%53 = load double, double* %4
%54 = load double, double* %5
%55 = fcmp ogt double %53, %54
br i1 %55, label %56, label %58
56: ; preds = %52
%57 = load double, double* %4
br label %60
58: ; preds = %52
%59 = load double, double* %5
br label %60
60: ; preds = %58, %56
%61 = phi double [ %57, %56 ], [ %59, %58 ]
%62 = load double, double* %6
%63 = fcmp olt double %61, %62
br i1 %63, label %64, label %74
64: ; preds = %60
%65 = load double, double* %4
%66 = load double, double* %5
%67 = fcmp ogt double %65, %66
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = load double, double* %4
br label %72
70: ; preds = %64
%71 = load double, double* %5
br label %72
72: ; preds = %70, %68
%73 = phi double [ %69, %68 ], [ %71, %70 ]
br label %76
74: ; preds = %60
%75 = load double, double* %6
br label %76
76: ; preds = %74, %72
%77 = phi double [ %73, %72 ], [ %75, %74 ]
br label %78
78: ; preds = %76, %50
%79 = phi double [ %51, %50 ], [ %77, %76 ]
ret double %79
}

LLVM IR (-O2):
define double @median(double %0, double %1, double %2) {
%4 = fcmp olt double %0, %1
%5 = select i1 %4, double %0, double %1
%6 = fcmp ogt double %0, %1
%7 = select i1 %6, double %0, double %1
%8 = fcmp olt double %7, %2
%9 = select i1 %8, double %7, double %2
%10 = fcmp ogt double %5, %9
%11 = select i1 %10, double %5, double %9
ret double %11
}