#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, temp1, temp2;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%d %d %d", &a, &b, &c);
  temp1 = a;
  temp2 = b;
  if (a > b) {
    a = b;
    b = temp1;
  }
  if (b > c) {
    b = c;
    c = temp2;
  }
  if (a > b) {
    a = b;
    b = temp1;
  }
  printf("%d is the median", b);
  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
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1179 <main+0x59>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1191 <main+0x71>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11a9 <main+0x89>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe84(%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),%esi
mov    0xc(%rsp),%eax
mov    %esi,%ecx
mov    %eax,%edx
cmp    %eax,%esi
jle    1169 <main+0x49>
mov    %eax,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %eax,%ecx
mov    %esi,%edx
mov    0x14(%rsp),%edi
cmp    %edi,%edx
jle    117b <main+0x5b>
mov    %edi,0xc(%rsp)
mov    %eax,0x14(%rsp)
mov    %edi,%edx
cmp    %edx,%ecx
jle    1189 <main+0x69>
mov    %edx,0x10(%rsp)
mov    %esi,0xc(%rsp)
jmp    118b <main+0x6b>
mov    %edx,%esi
lea    0xea5(%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 = [9 x i8] c"%d %d %d\00"
@.str.2 = [17 x i8] c"%d is the median\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
%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 ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%9 = load i32, i32* %2
store i32 %9, i32* %5
%10 = load i32, i32* %3
store i32 %10, i32* %6
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i32, i32* %3
store i32 %15, i32* %2
%16 = load i32, i32* %5
store i32 %16, i32* %3
br label %17
17: ; preds = %14, %0
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %4
store i32 %22, i32* %3
%23 = load i32, i32* %6
store i32 %23, i32* %4
br label %24
24: ; preds = %21, %17
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %3
store i32 %29, i32* %2
%30 = load i32, i32* %5
store i32 %30, i32* %3
br label %31
31: ; preds = %28, %24
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %32)
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 = [17 x i8] c"%d is the median\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 ([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
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 %10, i32* %1
store i32 %9, i32* %2
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 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 %16, i32* %2
store i32 %10, i32* %3
br label %19
19: ; preds = %18, %13
%20 = phi i32 [ %16, %18 ], [ %15, %13 ]
%21 = icmp sgt i32 %14, %20
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 %20, i32* %1
store i32 %9, i32* %2
br label %23
23: ; preds = %22, %19
%24 = phi i32 [ %9, %22 ], [ %20, %19 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %24)
ret i32 0
}