#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;
  int Small, Large;
  int Median;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%d%d%d", &A, &B, &C);
  if (A == B && A == C)
    Median = A;
  else if (A > B) {
    Large = A;
    Small = B;
  } else {
    Large = B;
    Small = A;
  }
  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    0xeea(%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
jne    1178 <main+0x58>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1178 <main+0x58>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a6 <main+0x86>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1195 <main+0x75>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <main+0x81>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <main+0x86>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11bd <main+0x9d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11df <main+0xbf>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d4 <main+0xb4>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11da <main+0xba>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11df <main+0xbf>
mov    -0x1c(%rbp),%esi
lea    0xe4c(%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    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    0xec1(%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
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 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 eq i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i32, i32* %2
store i32 %18, i32* %7
br label %30
19: ; preds = %13, %0
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %2
store i32 %24, i32* %6
%25 = load i32, i32* %3
store i32 %25, i32* %5
br label %29
26: ; preds = %19
%27 = load i32, i32* %3
store i32 %27, i32* %6
%28 = load i32, i32* %2
store i32 %28, i32* %5
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29, %17
%31 = load i32, i32* %4
%32 = load i32, i32* %6
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* %6
store i32 %35, i32* %7
br label %45
36: ; preds = %30
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = load i32, i32* %5
store i32 %41, i32* %7
br label %44
42: ; preds = %36
%43 = load i32, i32* %4
store i32 %43, i32* %7
br label %44
44: ; preds = %42, %40
br label %45
45: ; preds = %44, %34
%46 = load i32, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %46)
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 eq i32 %9, %10
%12 = load i32, i32* %3
%13 = icmp eq i32 %9, %12
%14 = select i1 %11, i1 %13, i1 false
%15 = icmp sgt i32 %9, %10
%16 = select i1 %15, i32 %10, i32 %9
%17 = select i1 %15, i32 %9, i32 %10
%18 = select i1 %14, i32 undef, i32 %16
%19 = select i1 %14, i32 undef, i32 %17
%20 = icmp sgt i32 %12, %19
%21 = icmp slt i32 %12, %18
%22 = select i1 %21, i32 %18, i32 %12
%23 = select i1 %20, i32 %19, i32 %22
%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
}