#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(void) {
  int a, b, c, d;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%d%d%d", &a, &b, &c);
  if ((a < b && b < c) || (c < b && b < a))
    d = b;
  if ((c < a && a < b) || (b < a && a < c))
    d = a;
  if ((b < c && c < a) || (a < c && c < b))
    d = c;
  printf("%d is the median\n", d);
  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    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116d <main+0x4d>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1185 <main+0x65>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118b <main+0x6b>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118b <main+0x6b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a3 <main+0x83>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11bb <main+0x9b>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c1 <main+0xa1>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11c1 <main+0xa1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d9 <main+0xb9>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     11f1 <main+0xd1>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f7 <main+0xd7>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f7 <main+0xd7>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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),%edx
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%eax
cmp    %edx,%eax
jge    1161 <main+0x41>
cmp    %ecx,%edx
jl     116d <main+0x4d>
mov    %ecx,%esi
cmp    %edx,%ecx
jge    116f <main+0x4f>
mov    %ecx,%esi
cmp    %eax,%edx
jge    116f <main+0x4f>
mov    %edx,%esi
cmp    %eax,%ecx
jge    1177 <main+0x57>
cmp    %edx,%eax
jl     117f <main+0x5f>
cmp    %eax,%edx
jge    1181 <main+0x61>
cmp    %ecx,%eax
jge    1181 <main+0x61>
mov    %eax,%esi
lea    0xead(%rip),%rdi
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
%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* %2
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %23, label %15
15: ; preds = %11, %0
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19, %11
%24 = load i32, i32* %3
store i32 %24, i32* %5
br label %25
25: ; preds = %23, %19, %15
%26 = load i32, i32* %4
%27 = load i32, i32* %2
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = icmp slt i32 %30, %31
br i1 %32, label %41, label %33
33: ; preds = %29, %25
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i32, i32* %2
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37, %29
%42 = load i32, i32* %2
store i32 %42, i32* %5
br label %43
43: ; preds = %41, %37, %33
%44 = load i32, i32* %3
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32, i32* %4
%49 = load i32, i32* %2
%50 = icmp slt i32 %48, %49
br i1 %50, label %59, label %51
51: ; preds = %47, %43
%52 = load i32, i32* %2
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %61
55: ; preds = %51
%56 = load i32, i32* %4
%57 = load i32, i32* %3
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %55, %47
%60 = load i32, i32* %4
store i32 %60, i32* %5
br label %61
61: ; preds = %59, %55, %51
%62 = load i32, i32* %5
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %62)
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 slt i32 %9, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %10, %12
%14 = icmp slt i32 %12, %9
%15 = select i1 %14, i1 %11, i1 false
br i1 %15, label %20, label %16
16: ; preds = %0
%17 = icmp slt i32 %10, %9
%18 = icmp slt i32 %9, %12
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %21
20: ; preds = %16, %0
br label %21
21: ; preds = %20, %16
%22 = phi i32 [ %9, %20 ], [ %10, %16 ]
%23 = select i1 %13, i1 %14, i1 false
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = icmp slt i32 %9, %12
%26 = icmp slt i32 %12, %10
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %29
28: ; preds = %24, %21
br label %29
29: ; preds = %28, %24
%30 = phi i32 [ %12, %28 ], [ %22, %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)
ret i32 0
}