#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, small, large, median;
  printf("Please enter 3 numberss separated by spaces > ");
  scanf("%d%d%d", &A, &B, &C);
  if (A > B) {
    small = B;
    large = A;
  } else if (A < B) {
    small = A;
    large = B;
  }
  if (C > large)
    median = large;
  else if (C < small)
    median = small;
  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)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeeb(%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
jle    1172 <main+0x52>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x6f>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118a <main+0x6a>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x6f>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11a6 <main+0x86>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11c8 <main+0xa8>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bd <main+0x9d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11c3 <main+0xa3>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11c8 <main+0xa8>
mov    -0x1c(%rbp),%esi
lea    0xe64(%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    0xef6(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
cmp    %ecx,%eax
mov    %eax,%esi
cmovg  %ecx,%esi
cmovg  %eax,%ecx
mov    0xc(%rsp),%eax
cmp    %esi,%eax
cmovge %eax,%esi
cmp    %ecx,%eax
cmovg  %ecx,%esi
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Please enter 3 numberss 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
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp sgt i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* %3
store i32 %14, i32* %5
%15 = load i32, i32* %2
store i32 %15, i32* %6
br label %24
16: ; preds = %0
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %2
store i32 %21, i32* %5
%22 = load i32, i32* %3
store i32 %22, i32* %6
br label %23
23: ; preds = %20, %16
br label %24
24: ; preds = %23, %13
%25 = load i32, i32* %4
%26 = load i32, i32* %6
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load i32, i32* %6
store i32 %29, i32* %7
br label %39
30: ; preds = %24
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* %5
store i32 %35, i32* %7
br label %38
36: ; preds = %30
%37 = load i32, i32* %4
store i32 %37, i32* %7
br label %38
38: ; preds = %36, %34
br label %39
39: ; preds = %38, %28
%40 = load i32, i32* %7
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"Please enter 3 numberss 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 ([47 x i8], [47 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 sgt i32 %9, %10
%12 = icmp slt i32 %9, %10
%13 = select i1 %12, i32 %9, i32 undef
%14 = select i1 %12, i32 %10, i32 undef
%15 = select i1 %11, i32 %10, i32 %13
%16 = select i1 %11, i32 %9, i32 %14
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, %16
%19 = icmp slt i32 %17, %15
%20 = select i1 %19, i32 %15, i32 %17
%21 = select i1 %18, i32 %16, i32 %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %21)
ret i32 0
}