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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%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     1189 <main+0x69>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a1 <main+0x81>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11ac <main+0x8c>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11ac <main+0x8c>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0xd2>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c4 <main+0xa4>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11dc <main+0xbc>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     11e7 <main+0xc7>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11e7 <main+0xc7>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11ed <main+0xcd>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0xd2>
mov    -0x14(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0xc(%rsp),%rbx
lea    0x4(%rsp),%r15
lea    0x8(%rsp),%r14
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%edx
cmp    %ecx,%eax
jg     1187 <main+0x67>
cmp    %edx,%eax
jge    11ab <main+0x8b>
cmp    %ecx,%eax
jl     118f <main+0x6f>
cmp    %edx,%eax
jle    11ab <main+0x8b>
cmp    %ecx,%eax
jl     119a <main+0x7a>
mov    %r15,%rbx
cmp    %edx,%ecx
jge    11ab <main+0x8b>
cmp    %edx,%ecx
lea    0x4(%rsp),%rbx
cmovg  %r14,%rbx
cmp    %ecx,%eax
cmovg  %r14,%rbx
mov    (%rbx),%esi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [9 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
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%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 ([9 x i8], [9 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 sle 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* %2
%17 = load i32, i32* %3
%18 = icmp sge i32 %16, %17
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19, %11
%24 = load i32, i32* %2
store i32 %24, i32* %5
br label %46
25: ; preds = %19, %15
%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* %3
%31 = load i32, i32* %4
%32 = icmp sge 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 sge i32 %34, %35
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37, %29
%42 = load i32, i32* %3
store i32 %42, i32* %5
br label %45
43: ; preds = %37, %33
%44 = load i32, i32* %4
store i32 %44, i32* %5
br label %45
45: ; preds = %43, %41
br label %46
46: ; preds = %45, %23
%47 = load i32, i32* %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [9 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*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%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 ([9 x i8], [9 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 slt i32 %9, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %26
15: ; preds = %0
%16 = icmp slt i32 %9, %10
%17 = icmp sgt i32 %9, %12
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = icmp slt i32 %10, %12
%21 = select i1 %16, i1 true, i1 %20
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = icmp sgt i32 %10, %12
%24 = select i1 %11, i1 true, i1 %23
%25 = select i1 %24, i32* %3, i32* %2
br label %26
26: ; preds = %22, %19, %0, %15
%27 = phi i32* [ %1, %15 ], [ %1, %0 ], [ %2, %19 ], [ %25, %22 ]
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %28)
ret i32 0
}