#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 n1, n2, n3, temp;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%d%d%d", &n1, &n2, &n3);
  if (n2 < n1) {
    temp = n2;
    n2 = n1;
    n1 = temp;
  }
  if (n3 <= n1)
    n2 = n1;
  else if (n3 < n2) {
    temp = n2;
    n2 = n3;
    n3 = temp;
  }
  printf("%d is the median\n", n2);
  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
jge    1173 <main+0x53>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     118a <main+0x6a>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11ad <main+0x8d>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <main+0x88>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11ad <main+0x8d>
mov    -0xc(%rbp),%esi
lea    0xe7e(%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    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x14(%rsp),%ecx
cmp    %ecx,%esi
jge    1165 <main+0x45>
mov    %ecx,0xc(%rsp)
mov    %esi,0x14(%rsp)
mov    %ecx,%eax
jmp    1169 <main+0x49>
mov    %esi,%eax
mov    %ecx,%esi
mov    0x10(%rsp),%ecx
cmp    %esi,%ecx
jle    1181 <main+0x61>
cmp    %eax,%ecx
jge    1187 <main+0x67>
mov    %ecx,0xc(%rsp)
mov    %eax,0x10(%rsp)
mov    %ecx,%esi
jmp    1189 <main+0x69>
mov    %esi,0xc(%rsp)
jmp    1189 <main+0x69>
mov    %eax,%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 = [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 slt i32 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* %3
store i32 %12, i32* %5
%13 = load i32, i32* %2
store i32 %13, i32* %3
%14 = load i32, i32* %5
store i32 %14, i32* %2
br 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 %21
19: ; preds = %15
%20 = load i32, i32* %2
store i32 %20, i32* %3
br label %30
21: ; preds = %15
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* %3
store i32 %26, i32* %5
%27 = load i32, i32* %4
store i32 %27, i32* %3
%28 = load i32, i32* %5
store i32 %28, i32* %4
br label %29
29: ; preds = %25, %21
br label %30
30: ; preds = %29, %19
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %31)
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* %2
%10 = load i32, i32* %1
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 %10, i32* %2
store i32 %9, 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
br i1 %17, label %19, label %18
18: ; preds = %13
store i32 %15, i32* %2
br label %22
19: ; preds = %13
%20 = icmp slt i32 %16, %14
br i1 %20, label %21, label %22
21: ; preds = %19
store i32 %16, i32* %2
store i32 %14, i32* %3
br label %22
22: ; preds = %19, %21, %18
%23 = phi i32 [ %14, %19 ], [ %16, %21 ], [ %15, %18 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret i32 0
}