#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 (n2 >= n3 && n1 >= n2)
      median = n2;
    else if (n2 >= n1)
      median = n1;
    else
      median = n3;
  } 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     11d7 <main+0xb7>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11a4 <main+0x84>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11a4 <main+0x84>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11d2 <main+0xb2>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11c3 <main+0xa3>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11cd <main+0xad>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11d2 <main+0xb2>
jmp    1205 <main+0xe5>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11f6 <main+0xd6>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1200 <main+0xe0>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1205 <main+0xe5>
movsd  -0x28(%rbp),%xmm0
lea    0xe29(%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),%xmm2
ucomisd %xmm2,%xmm0
movsd  (%rsp),%xmm1
jae    117f <main+0x5f>
ucomisd %xmm1,%xmm0
jae    1185 <main+0x65>
movapd %xmm1,%xmm0
cmplesd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
jmp    1195 <main+0x75>
ucomisd %xmm1,%xmm2
jae    1191 <main+0x71>
ucomisd %xmm0,%xmm2
jae    1195 <main+0x75>
movapd %xmm1,%xmm0
jmp    1195 <main+0x75>
movapd %xmm2,%xmm0
lea    0xe9e(%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* %3
%17 = load double, double* %4
%18 = fcmp oge double %16, %17
br i1 %18, label %19, label %25
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 %25
23: ; preds = %19
%24 = load double, double* %3
store double %24, double* %5
br label %34
25: ; preds = %19, %15
%26 = load double, double* %3
%27 = load double, double* %2
%28 = fcmp oge double %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load double, double* %2
store double %30, double* %5
br label %33
31: ; preds = %25
%32 = load double, double* %4
store double %32, double* %5
br label %33
33: ; preds = %31, %29
br label %34
34: ; preds = %33, %23
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
br i1 %11, label %13, label %15
13: ; preds = %0
%14 = fcmp ult double %9, %12
br i1 %14, label %20, label %17
15: ; preds = %0
%16 = fcmp ult double %10, %12
br i1 %16, label %17, label %23
17: ; preds = %13, %15
%18 = fcmp ult double %10, %9
br i1 %18, label %19, label %23
19: ; preds = %17
br label %23
20: ; preds = %13
%21 = fcmp oge double %10, %12
%22 = select i1 %21, double %12, double %10
br label %23
23: ; preds = %20, %17, %15, %19
%24 = phi double [ %12, %19 ], [ %10, %15 ], [ %9, %17 ], [ %22, %20 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %24)
ret i32 0
}