#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, median, temp;
  median = 0;
  temp = 0;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%d%d%d", &a, &b, &c);
  if (a >= b) {
    temp = b;
    b = a;
    a = temp;
  }
  if (c > b)
    median = b;
  else if (c < b && c > a)
    median = c;
  else
    median = a;
  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,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%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
jl     1181 <main+0x61>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1198 <main+0x78>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11c6 <main+0xa6>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bb <main+0x9b>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11bb <main+0x9b>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <main+0xa1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11c6 <main+0xa6>
mov    -0x14(%rbp),%esi
lea    0xe65(%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    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
mov    0xc(%rsp),%edx
cmp    %edx,%eax
jge    115f <main+0x3f>
mov    %eax,%ecx
mov    %edx,%eax
jmp    1169 <main+0x49>
mov    %eax,0xc(%rsp)
mov    %edx,0x10(%rsp)
mov    %edx,%ecx
mov    0x14(%rsp),%edx
cmp    %ecx,%edx
mov    %ecx,%esi
cmovg  %edx,%esi
cmp    %eax,%edx
cmovge %ecx,%esi
cmovg  %eax,%esi
lea    0xeb2(%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
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* 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* %2, i32* %3, i32* %4)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = icmp sge i32 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load i32, i32* %3
store i32 %13, i32* %6
%14 = load i32, i32* %2
store i32 %14, i32* %3
%15 = load i32, i32* %6
store i32 %15, i32* %2
br label %16
16: ; preds = %12, %0
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = icmp sgt i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i32, i32* %3
store i32 %21, i32* %5
br label %35
22: ; preds = %16
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32, i32* %4
%28 = load i32, i32* %2
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i32, i32* %4
store i32 %31, i32* %5
br label %34
32: ; preds = %26, %22
%33 = load i32, i32* %2
store i32 %33, i32* %5
br label %34
34: ; preds = %32, %30
br label %35
35: ; preds = %34, %20
%36 = load i32, i32* %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %36)
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
br i1 %11, label %13, label %12
12: ; preds = %0
store i32 %9, i32* %2
store i32 %10, i32* %1
br label %13
13: ; preds = %12, %0
%14 = phi i32 [ %10, %12 ], [ %9, %0 ]
%15 = phi i32 [ %9, %12 ], [ %10, %0 ]
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, %15
%18 = icmp slt i32 %16, %15
%19 = icmp sgt i32 %16, %14
%20 = select i1 %18, i1 %19, i1 false
%21 = select i1 %20, i32 %16, i32 %14
%22 = select i1 %17, i32 %15, i32 %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}