#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, 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 && a > c)
    median = a;
  else if (b > a && b < c)
    median = b;
  else if (b < a && b > c)
    median = b;
  else if (c > a && c < b)
    median = c;
  else if (c < a && c > b)
    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
jle    1178 <main+0x58>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1178 <main+0x58>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    123b <main+0x11b>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119b <main+0x7b>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    119b <main+0x7b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1236 <main+0x116>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11be <main+0x9e>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11be <main+0x9e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1231 <main+0x111>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e1 <main+0xc1>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11e1 <main+0xc1>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    122c <main+0x10c>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1204 <main+0xe4>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1204 <main+0xe4>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1227 <main+0x107>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1222 <main+0x102>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1222 <main+0x102>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1227 <main+0x107>
jmp    122c <main+0x10c>
jmp    1231 <main+0x111>
jmp    1236 <main+0x116>
jmp    123b <main+0x11b>
mov    -0x14(%rbp),%esi
lea    0xdf0(%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),%esi
mov    0x10(%rsp),%eax
mov    0xc(%rsp),%ecx
cmp    %eax,%esi
jle    1161 <main+0x41>
cmp    %ecx,%esi
jl     1183 <main+0x63>
cmp    %eax,%esi
jge    1169 <main+0x49>
cmp    %ecx,%esi
jg     1183 <main+0x63>
cmp    %eax,%esi
jge    1175 <main+0x55>
cmp    %ecx,%eax
jge    1175 <main+0x55>
mov    %eax,%esi
jmp    1183 <main+0x63>
cmp    %ecx,%eax
mov    %ecx,%edx
cmovg  %eax,%edx
cmp    %eax,%esi
cmovle %ecx,%edx
mov    %edx,%esi
lea    0xeab(%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* %2
%9 = load i32, i32* %3
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i32, i32* %2
store i32 %16, i32* %5
br label %72
17: ; preds = %11, %0
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i32, i32* %2
store i32 %26, i32* %5
br label %71
27: ; preds = %21, %17
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %37
31: ; preds = %27
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i32, i32* %3
store i32 %36, i32* %5
br label %70
37: ; preds = %31, %27
%38 = load i32, i32* %3
%39 = load i32, i32* %2
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %47
41: ; preds = %37
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i32, i32* %3
store i32 %46, i32* %5
br label %69
47: ; preds = %41, %37
%48 = load i32, i32* %4
%49 = load i32, i32* %2
%50 = icmp sgt i32 %48, %49
br i1 %50, label %51, label %57
51: ; preds = %47
%52 = load i32, i32* %4
%53 = load i32, i32* %3
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = load i32, i32* %4
store i32 %56, i32* %5
br label %68
57: ; preds = %51, %47
%58 = load i32, i32* %4
%59 = load i32, i32* %2
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %67
61: ; preds = %57
%62 = load i32, i32* %4
%63 = load i32, i32* %3
%64 = icmp sgt i32 %62, %63
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = load i32, i32* %4
store i32 %66, i32* %5
br label %67
67: ; preds = %65, %61, %57
br label %68
68: ; preds = %67, %55
br label %69
69: ; preds = %68, %45
br label %70
70: ; preds = %69, %35
br label %71
71: ; preds = %70, %25
br label %72
72: ; preds = %71, %15
%73 = load i32, i32* %5
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %73)
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 sgt i32 %9, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %9, %12
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %26, label %15
15: ; preds = %0
%16 = icmp slt i32 %9, %10
%17 = icmp sgt i32 %9, %12
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %26, label %19
19: ; preds = %15
%20 = icmp slt i32 %10, %12
%21 = select i1 %16, i1 %20, i1 false
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = icmp sgt i32 %10, %12
%24 = select i1 %11, i1 %23, i1 false
%25 = select i1 %24, i32 %10, i32 %12
br label %26
26: ; preds = %22, %19, %15, %0
%27 = phi i32 [ %9, %0 ], [ %9, %15 ], [ %10, %19 ], [ %25, %22 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %27)
ret i32 0
}