#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 *, int *, int *, int *);
int main() {
  int a, b, c;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%d%d%d", &a, &b, &c);
  if ((a <= b && b <= c) || (c <= b && b <= a))
    printf("%d is the median\n", b);
  if ((b <= a && a <= c) || (c <= a && a <= b))
    printf("%d is the median\n", a);
  else
    printf("%d is the median\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     116d <main+0x4d>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1185 <main+0x65>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1196 <main+0x76>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1196 <main+0x76>
mov    -0xc(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ae <main+0x8e>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11c6 <main+0xa6>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11dc <main+0xbc>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11dc <main+0xbc>
mov    -0x8(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <main+0xcd>
mov    -0x10(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%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    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%eax
cmp    %esi,%ecx
jg     1161 <main+0x41>
cmp    %eax,%esi
jle    1169 <main+0x49>
cmp    %esi,%eax
jg     1183 <main+0x63>
cmp    %ecx,%esi
jg     1183 <main+0x63>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%ecx
mov    0xc(%rsp),%eax
cmp    %esi,%ecx
mov    %ecx,%edx
cmovg  %eax,%edx
cmp    %ecx,%eax
cmovg  %eax,%edx
mov    %ecx,%eax
cmovl  %edx,%eax
cmp    %ecx,%esi
cmovg  %edx,%eax
lea    0xe95(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
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 = [7 x i8] c"%d%d%d\00"
@.str.2 = [18 x i8] c"%d is the median\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %22, label %14
14: ; preds = %10, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18, %10
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %18, %14
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32, i32* %2
%31 = load i32, i32* %4
%32 = icmp sle i32 %30, %31
br i1 %32, label %41, label %33
33: ; preds = %29, %25
%34 = load i32, i32* %4
%35 = load i32, i32* %2
%36 = icmp sle i32 %34, %35
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37, %29
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %42)
br label %47
44: ; preds = %37, %33
%45 = load i32, i32* %4
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %41
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [18 x i8] c"%d is the median\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %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 ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
%12 = load i32, i32* %3
%13 = icmp sgt i32 %10, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = icmp sgt i32 %12, %10
%17 = icmp sgt i32 %10, %9
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %24, label %19
19: ; preds = %15, %0
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%21 = load i32, i32* %2
%22 = load i32, i32* %1
%23 = load i32, i32* %3
br label %24
24: ; preds = %19, %15
%25 = phi i32 [ %23, %19 ], [ %12, %15 ]
%26 = phi i32 [ %22, %19 ], [ %9, %15 ]
%27 = phi i32 [ %21, %19 ], [ %10, %15 ]
%28 = icmp sgt i32 %27, %26
%29 = icmp sgt i32 %26, %25
%30 = select i1 %28, i1 true, i1 %29
%31 = icmp sgt i32 %25, %26
%32 = icmp sgt i32 %26, %27
%33 = select i1 %31, i1 true, i1 %32
%34 = select i1 %30, i1 %33, i1 false
%35 = select i1 %34, i32 %25, i32 %26
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %35)
ret i32 0
}