#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 */
int 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 = (fabs(first) + fabs(second) + fabs(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    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %eax,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1230 <main+0x100>
movsd  -0x30(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1230 <main+0x100>
movsd  -0x10(%rbp),%xmm0
lea    0xe14(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12b5 <main+0x185>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1270 <main+0x140>
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1270 <main+0x140>
movsd  -0x18(%rbp),%xmm0
lea    0xdd4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12b0 <main+0x180>
movsd  -0x40(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ab <main+0x17b>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ab <main+0x17b>
movsd  -0x20(%rbp),%xmm0
lea    0xd94(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12b0 <main+0x180>
jmp    12b5 <main+0x185>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0x18(%rsp),%r12
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r14
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm0
call   1040 <fabs@plt>
mov    %eax,%ebx
movsd  0x10(%rsp),%xmm0
call   1040 <fabs@plt>
mov    %eax,%ebp
add    %ebx,%ebp
movsd  0x8(%rsp),%xmm0
call   1040 <fabs@plt>
add    %ebp,%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  %xmm1,%xmm0
call   1040 <fabs@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
subsd  (%rsp),%xmm0
call   1040 <fabs@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
subsd  (%rsp),%xmm0
call   1040 <fabs@plt>
cmp    %ebx,%ebp
jge    11f1 <main+0xc1>
cmp    %eax,%ebp
jl     1207 <main+0xd7>
cmp    %ebp,%ebx
jge    11fc <main+0xcc>
mov    %r15,%r12
cmp    %eax,%ebx
jl     1207 <main+0xd7>
cmp    %ebp,%eax
jge    121b <main+0xeb>
mov    %r14,%r12
cmp    %ebx,%eax
jge    121b <main+0xeb>
movsd  (%r12),%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
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 = call i32 @fabs(double %11)
%13 = load double, double* %3
%14 = call i32 @fabs(double %13)
%15 = add nsw i32 %12, %14
%16 = load double, double* %4
%17 = call i32 @fabs(double %16)
%18 = add nsw i32 %15, %17
%19 = sdiv i32 %18, 3
%20 = sitofp i32 %19 to double
store double %20, double* %5
%21 = load double, double* %2
%22 = load double, double* %5
%23 = fsub double %21, %22
%24 = call i32 @fabs(double %23)
%25 = sitofp i32 %24 to double
store double %25, double* %6
%26 = load double, double* %3
%27 = load double, double* %5
%28 = fsub double %26, %27
%29 = call i32 @fabs(double %28)
%30 = sitofp i32 %29 to double
store double %30, double* %7
%31 = load double, double* %4
%32 = load double, double* %5
%33 = fsub double %31, %32
%34 = call i32 @fabs(double %33)
%35 = sitofp i32 %34 to double
store double %35, double* %8
%36 = load double, double* %6
%37 = load double, double* %7
%38 = fcmp olt double %36, %37
br i1 %38, label %39, label %46
39: ; preds = %0
%40 = load double, double* %6
%41 = load double, double* %8
%42 = fcmp olt double %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load double, double* %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %44)
br label %70
46: ; preds = %39, %0
%47 = load double, double* %7
%48 = load double, double* %6
%49 = fcmp olt double %47, %48
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = load double, double* %7
%52 = load double, double* %8
%53 = fcmp olt double %51, %52
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load double, double* %3
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %55)
br label %69
57: ; preds = %50, %46
%58 = load double, double* %8
%59 = load double, double* %6
%60 = fcmp olt double %58, %59
br i1 %60, label %61, label %68
61: ; preds = %57
%62 = load double, double* %8
%63 = load double, double* %7
%64 = fcmp olt double %62, %63
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = load double, double* %4
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %66)
br label %68
68: ; preds = %65, %61, %57
br label %69
69: ; preds = %68, %54
br label %70
70: ; preds = %69, %43
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 = call i32 @fabs(double %9)
%11 = load double, double* %2
%12 = call i32 @fabs(double %11)
%13 = add nsw i32 %12, %10
%14 = load double, double* %3
%15 = call i32 @fabs(double %14)
%16 = add nsw i32 %13, %15
%17 = sdiv i32 %16, 3
%18 = sitofp i32 %17 to double
%19 = load double, double* %1
%20 = fsub double %19, %18
%21 = call i32 @fabs(double %20)
%22 = load double, double* %2
%23 = fsub double %22, %18
%24 = call i32 @fabs(double %23)
%25 = load double, double* %3
%26 = fsub double %25, %18
%27 = call i32 @fabs(double %26)
%28 = icmp slt i32 %21, %24
%29 = icmp slt i32 %21, %27
%30 = select i1 %28, i1 %29, i1 false
br i1 %30, label %39, label %31
31: ; preds = %0
%32 = icmp slt i32 %24, %21
%33 = icmp slt i32 %24, %27
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = icmp slt i32 %27, %21
%37 = icmp slt i32 %27, %24
%38 = select i1 %36, i1 %37, i1 false
br i1 %38, label %39, label %43
39: ; preds = %35, %31, %0
%40 = phi double* [ %1, %0 ], [ %2, %31 ], [ %3, %35 ]
%41 = load double, double* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %41)
br label %43
43: ; preds = %39, %35
ret i32 0
}