#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
      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     11b3 <main+0x93>
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    11ae <main+0x8e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11e1 <main+0xc1>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11d2 <main+0xb2>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11dc <main+0xbc>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11e1 <main+0xc1>
movsd  -0x28(%rbp),%xmm0
lea    0xe4d(%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),%xmm2
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm2
movsd  (%rsp),%xmm0
jae    117f <main+0x5f>
ucomisd %xmm0,%xmm2
jae    117f <main+0x5f>
movapd %xmm0,%xmm2
cmplesd %xmm1,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm2,%xmm0
jmp    11ad <main+0x8d>
movapd %xmm1,%xmm3
cmpnlesd %xmm2,%xmm3
movapd %xmm3,%xmm4
andpd  %xmm2,%xmm4
andnpd %xmm1,%xmm3
orpd   %xmm4,%xmm3
cmpnlesd %xmm1,%xmm0
movapd %xmm0,%xmm1
andnpd %xmm3,%xmm1
andpd  %xmm2,%xmm0
orpd   %xmm1,%xmm0
lea    0xe86(%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 = [22 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 %28
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 %27
25: ; preds = %19, %15
%26 = load double, double* %2
store double %26, double* %5
br label %27
27: ; preds = %25, %23
br label %37
28: ; preds = %11
%29 = load double, double* %3
%30 = load double, double* %4
%31 = fcmp oge double %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load double, double* %4
store double %33, double* %5
br label %36
34: ; preds = %28
%35 = load double, double* %3
store double %35, double* %5
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36, %27
%38 = load double, double* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %38)
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 = [22 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
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %19, label %15
15: ; preds = %0
%16 = fcmp ult double %10, %12
%17 = select i1 %16, i1 true, i1 %11
%18 = select i1 %17, double %9, double %10
br label %22
19: ; preds = %0
%20 = fcmp oge double %10, %12
%21 = select i1 %20, double %12, double %10
br label %22
22: ; preds = %15, %19
%23 = phi double [ %21, %19 ], [ %18, %15 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %23)
ret i32 0
}