#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);
  else if (comp_fir == comp_sec)
    printf("%.0f is the median\n", first);
  else if (comp_fir == comp_thi)
    printf("%.0f is the median\n", first);
  else if (comp_thi == comp_sec)
    printf("%.0f is the median\n", second);
  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    1321 <main+0x201>
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    131c <main+0x1fc>
movsd  -0x40(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1283 <main+0x163>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1283 <main+0x163>
movsd  -0x20(%rbp),%xmm0
lea    0xdd9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1317 <main+0x1f7>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    12b1 <main+0x191>
jp     12b1 <main+0x191>
movsd  -0x10(%rbp),%xmm0
lea    0xdab(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1312 <main+0x1f2>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jne    12df <main+0x1bf>
jp     12df <main+0x1bf>
movsd  -0x10(%rbp),%xmm0
lea    0xd7d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    130d <main+0x1ed>
movsd  -0x40(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    1308 <main+0x1e8>
jp     1308 <main+0x1e8>
movsd  -0x18(%rbp),%xmm0
lea    0xd4f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    130d <main+0x1ed>
jmp    1312 <main+0x1f2>
jmp    1317 <main+0x1f7>
jmp    131c <main+0x1fc>
jmp    1321 <main+0x201>
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),%xmm2
movsd  0x8(%rsp),%xmm1
movapd %xmm2,%xmm5
addsd  %xmm1,%xmm5
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm5
divsd  0xe90(%rip),%xmm5
movapd %xmm1,%xmm3
subsd  %xmm5,%xmm3
movapd 0xe90(%rip),%xmm6
andpd  %xmm6,%xmm3
movapd %xmm2,%xmm4
unpcklpd %xmm0,%xmm4
unpcklpd %xmm5,%xmm5
subpd  %xmm5,%xmm4
andpd  %xmm6,%xmm4
ucomisd %xmm4,%xmm3
pshufd $0xee,%xmm4,%xmm5
jbe    11af <main+0x8f>
ucomisd %xmm4,%xmm5
jbe    11af <main+0x8f>
movapd %xmm2,%xmm0
jmp    11ed <main+0xcd>
ucomisd %xmm3,%xmm4
jbe    11c1 <main+0xa1>
ucomisd %xmm3,%xmm5
jbe    11c1 <main+0xa1>
movapd %xmm1,%xmm0
jmp    11ed <main+0xcd>
ucomisd %xmm5,%xmm4
jbe    11cd <main+0xad>
ucomisd %xmm5,%xmm3
ja     11ed <main+0xcd>
ucomisd %xmm3,%xmm4
jne    11d5 <main+0xb5>
jnp    11a9 <main+0x89>
ucomisd %xmm5,%xmm4
movapd %xmm2,%xmm0
jne    11e1 <main+0xc1>
jnp    11ed <main+0xcd>
ucomisd %xmm3,%xmm5
movapd %xmm1,%xmm0
jne    11fb <main+0xdb>
jp     11fb <main+0xdb>
lea    0xe64(%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 %87
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 %86
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 %85
61: ; preds = %54, %50
%62 = load double, double* %6
%63 = load double, double* %7
%64 = fcmp oeq double %62, %63
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = load double, double* %2
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %66)
br label %84
68: ; preds = %61
%69 = load double, double* %6
%70 = load double, double* %8
%71 = fcmp oeq double %69, %70
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = load double, double* %2
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %73)
br label %83
75: ; preds = %68
%76 = load double, double* %8
%77 = load double, double* %7
%78 = fcmp oeq double %76, %77
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = load double, double* %3
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %80)
br label %82
82: ; preds = %79, %75
br label %83
83: ; preds = %82, %72
br label %84
84: ; preds = %83, %65
br label %85
85: ; preds = %84, %58
br label %86
86: ; preds = %85, %47
br label %87
87: ; preds = %86, %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 %42, 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 %42, 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 %42, label %36
36: ; preds = %32
%37 = fcmp oeq double %23, %16
%38 = fcmp oeq double %23, %25
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = fcmp oeq double %25, %16
br i1 %41, label %42, label %45
42: ; preds = %40, %36, %32, %28, %0
%43 = phi double [ %9, %0 ], [ %10, %28 ], [ %12, %32 ], [ %9, %36 ], [ %10, %40 ]
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %43)
br label %45
45: ; preds = %42, %40
ret i32 0
}