#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ fabs(double);
double Median(double a, double b, double c) {
  return (a + ((b - a) * (c - a) > 0.0
                   ? (fabs(b - a) < fabs(c - a) ? (b - a) : (c - a))
                   : 0.0));
}


x86 assembly (clang, -O0):
<Median>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ba <Median+0xaa>
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    119c <Median+0x8c>
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11ab <Median+0x9b>
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11c7 <Median+0xb7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11c7 <Median+0xb7>
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Median>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm0,%xmm4
subsd  %xmm0,%xmm1
subsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm2,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jbe    1173 <Median+0x63>
movsd  %xmm4,0x18(%rsp)
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
movsd  0x10(%rsp),%xmm0
cmp    %rax,%rbx
jl     116d <Median+0x5d>
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm4
addsd  %xmm4,%xmm0
add    $0x20,%rsp
pop    %rbx
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 = load double, double* %4
%10 = fsub double %8, %9
%11 = load double, double* %6
%12 = load double, double* %4
%13 = fsub double %11, %12
%14 = fmul double %10, %13
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %36
16: ; preds = %3
%17 = load double, double* %5
%18 = load double, double* %4
%19 = fsub double %17, %18
%20 = call i64 @fabs(double %19)
%21 = load double, double* %6
%22 = load double, double* %4
%23 = fsub double %21, %22
%24 = call i64 @fabs(double %23)
%25 = icmp slt i64 %20, %24
br i1 %25, label %26, label %30
26: ; preds = %16
%27 = load double, double* %5
%28 = load double, double* %4
%29 = fsub double %27, %28
br label %34
30: ; preds = %16
%31 = load double, double* %6
%32 = load double, double* %4
%33 = fsub double %31, %32
br label %34
34: ; preds = %30, %26
%35 = phi double [ %29, %26 ], [ %33, %30 ]
br label %37
36: ; preds = %3
br label %37
37: ; preds = %36, %34
%38 = phi double [ %35, %34 ], [ 0.000000e+00, %36 ]
%39 = fadd double %7, %38
ret double %39
}

LLVM IR (-O2):
define double @Median(double %0, double %1, double %2) {
%4 = fsub double %1, %0
%5 = fsub double %2, %0
%6 = fmul double %4, %5
%7 = fcmp ogt double %6, 0.000000e+00
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = tail call i64 @fabs(double %4)
%10 = tail call i64 @fabs(double %5)
%11 = icmp slt i64 %9, %10
%12 = select i1 %11, double %4, double %5
br label %13
13: ; preds = %8, %3
%14 = phi double [ 0.000000e+00, %3 ], [ %12, %8 ]
%15 = fadd double %14, %0
ret double %15
}