#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 */
double fabs(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, double *, double *);
int main() {
  double first, second, third;
  double median;
  double comp_fir, comp_sec, comp_thi;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%lf"
        "%lf"
        "%lf",
        &first, &second, &third);
  median = (first + second + third) / 3;
  comp_fir = fabs(first - median);
  comp_sec = fabs(second - median);
  comp_thi = fabs(third - median);
  if (comp_fir < comp_sec && comp_fir < comp_thi)
    printf("%.0f is the median\n", first);
  else if (comp_sec < comp_fir && comp_sec < comp_thi)
    printf("%.0f is the median\n", second);
  else if (comp_thi < comp_fir && comp_thi < comp_sec)
    printf("%.0f is the median\n", third);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xea4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movaps 0xe7a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movaps 0xe60(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movaps 0xe46(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1203 <main+0xe3>
movsd  -0x30(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1203 <main+0xe3>
movsd  -0x10(%rbp),%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1288 <main+0x168>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1243 <main+0x123>
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1243 <main+0x123>
movsd  -0x18(%rbp),%xmm0
lea    0xe19(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1283 <main+0x163>
movsd  -0x40(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    127e <main+0x15e>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    127e <main+0x15e>
movsd  -0x20(%rbp),%xmm0
lea    0xdd9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1283 <main+0x163>
jmp    1288 <main+0x168>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xef5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm5
addsd  %xmm2,%xmm5
movsd  (%rsp),%xmm1
addsd  %xmm1,%xmm5
divsd  0xe90(%rip),%xmm5
movapd %xmm2,%xmm3
subsd  %xmm5,%xmm3
movapd 0xe90(%rip),%xmm6
andpd  %xmm6,%xmm3
movapd %xmm0,%xmm4
unpcklpd %xmm1,%xmm4
unpcklpd %xmm5,%xmm5
subpd  %xmm5,%xmm4
andpd  %xmm6,%xmm4
ucomisd %xmm4,%xmm3
pshufd $0xee,%xmm4,%xmm5
jbe    11a9 <main+0x89>
ucomisd %xmm4,%xmm5
ja     11c9 <main+0xa9>
ucomisd %xmm3,%xmm4
jbe    11b9 <main+0x99>
ucomisd %xmm3,%xmm5
movapd %xmm2,%xmm0
ja     11c9 <main+0xa9>
ucomisd %xmm5,%xmm4
jbe    11d7 <main+0xb7>
ucomisd %xmm5,%xmm3
movapd %xmm1,%xmm0
jbe    11d7 <main+0xb7>
lea    0xe88(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [10 x i8] c"%lf%lf%lf\00"
@.str.2 = [20 x i8] c"%.0f is the median\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4)
%11 = load double, double* %2
%12 = load double, double* %3
%13 = fadd double %11, %12
%14 = load double, double* %4
%15 = fadd double %13, %14
%16 = fdiv double %15, 3.000000e+00
store double %16, double* %5
%17 = load double, double* %2
%18 = load double, double* %5
%19 = fsub double %17, %18
%20 = call double @llvm.fabs.f64(double %19)
store double %20, double* %6
%21 = load double, double* %3
%22 = load double, double* %5
%23 = fsub double %21, %22
%24 = call double @llvm.fabs.f64(double %23)
store double %24, double* %7
%25 = load double, double* %4
%26 = load double, double* %5
%27 = fsub double %25, %26
%28 = call double @llvm.fabs.f64(double %27)
store double %28, double* %8
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fcmp olt double %29, %30
br i1 %31, label %32, label %39
32: ; preds = %0
%33 = load double, double* %6
%34 = load double, double* %8
%35 = fcmp olt double %33, %34
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load double, double* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %37)
br label %63
39: ; preds = %32, %0
%40 = load double, double* %7
%41 = load double, double* %6
%42 = fcmp olt double %40, %41
br i1 %42, label %43, label %50
43: ; preds = %39
%44 = load double, double* %7
%45 = load double, double* %8
%46 = fcmp olt double %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load double, double* %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %48)
br label %62
50: ; preds = %43, %39
%51 = load double, double* %8
%52 = load double, double* %6
%53 = fcmp olt double %51, %52
br i1 %53, label %54, label %61
54: ; preds = %50
%55 = load double, double* %8
%56 = load double, double* %7
%57 = fcmp olt double %55, %56
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load double, double* %4
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %59)
br label %61
61: ; preds = %58, %54, %50
br label %62
62: ; preds = %61, %47
br label %63
63: ; preds = %62, %36
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [10 x i8] c"%lf%lf%lf\00"
@.str.2 = [20 x i8] c"%.0f is the median\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, double* %3)
%9 = load double, double* %1
%10 = load double, double* %2
%11 = fadd double %9, %10
%12 = load double, double* %3
%13 = fadd double %11, %12
%14 = fdiv double %13, 3.000000e+00
%15 = fsub double %10, %14
%16 = call double @llvm.fabs.f64(double %15)
%17 = insertelement <2 x double> poison, double %9, i64 0
%18 = insertelement <2 x double> %17, double %12, i64 1
%19 = insertelement <2 x double> poison, double %14, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = fsub <2 x double> %18, %20
%22 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %21)
%23 = extractelement <2 x double> %22, i64 0
%24 = fcmp olt double %23, %16
%25 = extractelement <2 x double> %22, i64 1
%26 = fcmp olt double %23, %25
%27 = select i1 %24, i1 %26, i1 false
br i1 %27, label %36, label %28
28: ; preds = %0
%29 = fcmp olt double %16, %23
%30 = fcmp olt double %16, %25
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = fcmp olt double %25, %23
%34 = fcmp olt double %25, %16
%35 = select i1 %33, i1 %34, i1 false
br i1 %35, label %36, label %39
36: ; preds = %32, %28, %0
%37 = phi double [ %9, %0 ], [ %10, %28 ], [ %12, %32 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %37)
br label %39
39: ; preds = %36, %32
ret i32 0
}