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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     116d <main+0x4d>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1185 <main+0x65>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     119b <main+0x7b>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     119b <main+0x7b>
mov    -0x8(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <main+0x11d>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11b3 <main+0x93>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cb <main+0xab>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11e1 <main+0xc1>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11e1 <main+0xc1>
mov    -0xc(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1238 <main+0x118>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     11f9 <main+0xd9>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1211 <main+0xf1>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1227 <main+0x107>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1227 <main+0x107>
mov    -0x10(%rbp),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
movl   $0x1,-0x4(%rbp)
jmp    1244 <main+0x124>
jmp    1238 <main+0x118>
jmp    123d <main+0x11d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
mov    0x4(%rsp),%esi
cmp    %ecx,%eax
jl     1162 <main+0x42>
cmp    %esi,%ecx
jge    116a <main+0x4a>
cmp    %esi,%ecx
jl     1184 <main+0x64>
cmp    %ecx,%eax
jl     1184 <main+0x64>
mov    %ecx,%esi
lea    0xec2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
cmp    %eax,%ecx
jl     118c <main+0x6c>
cmp    %esi,%eax
jge    1194 <main+0x74>
cmp    %ecx,%eax
jl     1198 <main+0x78>
cmp    %esi,%eax
jg     1198 <main+0x78>
mov    %eax,%esi
jmp    116c <main+0x4c>
cmp    %esi,%ecx
jl     11a0 <main+0x80>
cmp    %esi,%eax
jle    116c <main+0x4c>
mov    $0x1,%ebx
cmp    %esi,%ecx
jg     117c <main+0x5c>
cmp    %esi,%eax
jge    116c <main+0x4c>
jmp    117c <main+0x5c>

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
%5 = alloca i32
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 ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp sge i32 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = icmp sge i32 %12, %13
br i1 %14, label %23, label %15
15: ; preds = %11, %0
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %19, %11
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %67
26: ; preds = %19, %15
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = icmp sge i32 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = icmp sge i32 %31, %32
br i1 %33, label %42, label %34
34: ; preds = %30, %26
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %45
38: ; preds = %34
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = icmp sle i32 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38, %30
%43 = load i32, i32* %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %66
45: ; preds = %38, %34
%46 = load i32, i32* %2
%47 = load i32, i32* %4
%48 = icmp sge i32 %46, %47
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = load i32, i32* %4
%51 = load i32, i32* %3
%52 = icmp sge i32 %50, %51
br i1 %52, label %61, label %53
53: ; preds = %49, %45
%54 = load i32, i32* %2
%55 = load i32, i32* %4
%56 = icmp sle i32 %54, %55
br i1 %56, label %57, label %64
57: ; preds = %53
%58 = load i32, i32* %4
%59 = load i32, i32* %3
%60 = icmp sle i32 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %57, %49
%62 = load i32, i32* %4
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %62)
br label %65
64: ; preds = %57, %53
store i32 1, i32* %1
br label %68
65: ; preds = %61
br label %66
66: ; preds = %65, %42
br label %67
67: ; preds = %66, %23
store i32 0, i32* %1
br label %68
68: ; preds = %67, %64
%69 = load i32, i32* %1
ret i32 %69
}

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* %2
%10 = load i32, i32* %1
%11 = icmp slt i32 %9, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %10, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %29
15: ; preds = %0
%16 = select i1 %13, i1 true, i1 %11
br i1 %16, label %17, label %29
17: ; preds = %15
%18 = icmp slt i32 %10, %9
%19 = icmp slt i32 %9, %12
%20 = select i1 %18, i1 true, i1 %19
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = icmp sgt i32 %9, %12
%23 = select i1 %11, i1 true, i1 %22
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = select i1 %13, i1 true, i1 %22
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = icmp sgt i32 %10, %12
%28 = select i1 %27, i1 true, i1 %19
br i1 %28, label %32, label %29
29: ; preds = %24, %26, %17, %21, %0, %15
%30 = phi i32 [ %10, %15 ], [ %10, %0 ], [ %9, %21 ], [ %9, %17 ], [ %12, %26 ], [ %12, %24 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %26
%33 = phi i32 [ 1, %26 ], [ 0, %29 ]
ret i32 %33
}