#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 main() {
  int a, b, c, median;
  printf("Enter first integer > ");
  scanf("%d", &a);
  printf("Enter second integer > ");
  scanf("%d", &b);
  printf("Enter third integer > ");
  scanf("%d", &c);
  if ((a >= b && b >= c) || (a <= b && b <= c))
    printf("%d is the median\n", b);
  else if ((b >= a && a >= c) || (c <= a && a <= b))
    printf("%d is the median\n", a);
  else if ((a >= c && c >= b) || (a <= c && c <= b))
    printf("%d is the median\n", c);
  else
    return 1;
  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    0xed3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11a1 <main+0x81>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b9 <main+0x99>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11cf <main+0xaf>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11cf <main+0xaf>
mov    -0xc(%rbp),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1271 <main+0x151>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     11e7 <main+0xc7>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ff <main+0xdf>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1215 <main+0xf5>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1215 <main+0xf5>
mov    -0x8(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126c <main+0x14c>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     122d <main+0x10d>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1245 <main+0x125>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     125b <main+0x13b>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     125b <main+0x13b>
mov    -0x10(%rbp),%esi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1267 <main+0x147>
movl   $0x1,-0x4(%rbp)
jmp    1278 <main+0x158>
jmp    126c <main+0x14c>
jmp    1271 <main+0x151>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedd(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%eax
mov    0x4(%rsp),%esi
cmp    %eax,%ecx
jl     1191 <main+0x71>
cmp    %esi,%eax
jge    1199 <main+0x79>
cmp    %eax,%ecx
jg     11b3 <main+0x93>
cmp    %esi,%eax
jg     11b3 <main+0x93>
mov    %eax,%esi
lea    0xea7(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
cmp    %eax,%ecx
jg     11bb <main+0x9b>
cmp    %esi,%ecx
jge    11c3 <main+0xa3>
cmp    %esi,%ecx
jl     11c7 <main+0xa7>
cmp    %eax,%ecx
jg     11c7 <main+0xa7>
mov    %ecx,%esi
jmp    119b <main+0x7b>
cmp    %esi,%ecx
jl     11cf <main+0xaf>
cmp    %esi,%eax
jle    119b <main+0x7b>
mov    $0x1,%ebx
cmp    %esi,%ecx
jg     11ab <main+0x8b>
cmp    %esi,%eax
jge    119b <main+0x7b>
jmp    11ab <main+0x8b>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter first integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter second integer > \00"
@.str.3 = [23 x i8] c"Enter third integer > \00"
@.str.4 = [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 ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = icmp sge i32 %16, %17
br i1 %18, label %27, label %19
19: ; preds = %15, %0
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23, %15
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %71
30: ; preds = %23, %19
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = icmp sge i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* %2
%36 = load i32, i32* %4
%37 = icmp sge i32 %35, %36
br i1 %37, label %46, label %38
38: ; preds = %34, %30
%39 = load i32, i32* %4
%40 = load i32, i32* %2
%41 = icmp sle i32 %39, %40
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = icmp sle i32 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %42, %34
%47 = load i32, i32* %2
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %47)
br label %70
49: ; preds = %42, %38
%50 = load i32, i32* %2
%51 = load i32, i32* %4
%52 = icmp sge i32 %50, %51
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load i32, i32* %4
%55 = load i32, i32* %3
%56 = icmp sge i32 %54, %55
br i1 %56, label %65, label %57
57: ; preds = %53, %49
%58 = load i32, i32* %2
%59 = load i32, i32* %4
%60 = icmp sle i32 %58, %59
br i1 %60, label %61, label %68
61: ; preds = %57
%62 = load i32, i32* %4
%63 = load i32, i32* %3
%64 = icmp sle i32 %62, %63
br i1 %64, label %65, label %68
65: ; preds = %61, %53
%66 = load i32, i32* %4
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %66)
br label %69
68: ; preds = %61, %57
store i32 1, i32* %1
br label %72
69: ; preds = %65
br label %70
70: ; preds = %69, %46
br label %71
71: ; preds = %70, %27
store i32 0, i32* %1
br label %72
72: ; preds = %71, %68
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter first integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter second integer > \00"
@.str.3 = [23 x i8] c"Enter third integer > \00"
@.str.4 = [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 ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
%16 = load i32, i32* %3
%17 = icmp slt i32 %14, %16
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %33
19: ; preds = %0
%20 = icmp sgt i32 %13, %14
%21 = icmp sgt i32 %14, %16
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = icmp slt i32 %13, %16
%25 = select i1 %20, i1 true, i1 %24
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = select i1 %24, i1 true, i1 %20
br i1 %27, label %28, label %33
28: ; preds = %26
%29 = select i1 %24, i1 true, i1 %21
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = icmp sgt i32 %13, %16
%32 = select i1 %31, i1 true, i1 %17
br i1 %32, label %36, label %33
33: ; preds = %28, %30, %23, %26, %0, %19
%34 = phi i32 [ %14, %19 ], [ %14, %0 ], [ %13, %26 ], [ %13, %23 ], [ %16, %30 ], [ %16, %28 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %30
%37 = phi i32 [ 1, %30 ], [ 0, %33 ]
ret i32 %37
}