#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, double *, double *);
int main() {
  double n1, n2, n3, median;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%lf %lf %lf", &n1, &n2, &n3);
  if (n1 >= n2 || n1 >= n3) {
    if (n1 >= n3 && n1 >= n2) {
      if (n2 >= n3)
        median = n2;
      else
        median = n3;
    } else
      median = n1;
  } else if (n2 >= n3)
    median = n3;
  else
    median = n2;
  printf("%.0lf is the median\n", median);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1175 <main+0x55>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11d2 <main+0xb2>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11c3 <main+0xa3>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11c3 <main+0xa3>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11b4 <main+0x94>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11be <main+0x9e>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11cd <main+0xad>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1200 <main+0xe0>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11f1 <main+0xd1>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11fb <main+0xdb>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1200 <main+0xe0>
movsd  -0x28(%rbp),%xmm0
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
movsd  (%rsp),%xmm2
jae    117f <main+0x5f>
ucomisd %xmm2,%xmm0
jae    119a <main+0x7a>
movapd %xmm2,%xmm0
cmplesd %xmm1,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
jmp    119a <main+0x7a>
ucomisd %xmm2,%xmm0
jb     119a <main+0x7a>
movapd %xmm2,%xmm0
cmplesd %xmm1,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
lea    0xe99(%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 = [12 x i8] c"%lf %lf %lf\00"
@.str.2 = [21 x i8] c"%.0lf is the median\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4)
%8 = load double, double* %2
%9 = load double, double* %3
%10 = fcmp oge double %8, %9
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = load double, double* %2
%13 = load double, double* %4
%14 = fcmp oge double %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11, %0
%16 = load double, double* %2
%17 = load double, double* %4
%18 = fcmp oge double %16, %17
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fcmp oge double %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load double, double* %3
%25 = load double, double* %4
%26 = fcmp oge double %24, %25
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load double, double* %3
store double %28, double* %5
br label %31
29: ; preds = %23
%30 = load double, double* %4
store double %30, double* %5
br label %31
31: ; preds = %29, %27
br label %34
32: ; preds = %19, %15
%33 = load double, double* %2
store double %33, double* %5
br label %34
34: ; preds = %32, %31
br label %44
35: ; preds = %11
%36 = load double, double* %3
%37 = load double, double* %4
%38 = fcmp oge double %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load double, double* %4
store double %40, double* %5
br label %43
41: ; preds = %35
%42 = load double, double* %3
store double %42, double* %5
br label %43
43: ; preds = %41, %39
br label %44
44: ; preds = %43, %34
%45 = load double, double* %5
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [12 x i8] c"%lf %lf %lf\00"
@.str.2 = [21 x i8] c"%.0lf 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 ([12 x i8], [12 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 = fcmp ult double %9, %10
%12 = load double, double* %3
%13 = fcmp ult double %9, %12
br i1 %11, label %14, label %15
14: ; preds = %0
br i1 %13, label %19, label %22
15: ; preds = %0
br i1 %13, label %22, label %16
16: ; preds = %15
%17 = fcmp oge double %10, %12
%18 = select i1 %17, double %10, double %12
br label %22
19: ; preds = %14
%20 = fcmp oge double %10, %12
%21 = select i1 %20, double %12, double %10
br label %22
22: ; preds = %14, %15, %19, %16
%23 = phi double [ %18, %16 ], [ %21, %19 ], [ %9, %15 ], [ %9, %14 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %23)
ret i32 0
}