#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 frst, scnd, thrd, cmp1, cmp2, med;
  printf("Please enter 3 numbers separated by spaces > ");
  scanf("%d %d %d", &frst, &scnd, &thrd);
  if (frst <= scnd)
    cmp1 = frst;
  else
    cmp1 = scnd;
  if (scnd <= thrd)
    cmp2 = scnd;
  else
    cmp2 = thrd;
  if (cmp1 >= cmp2)
    med = cmp1;
  else
    med = cmp2;
  printf("%d is lesser of first 2\n%d is lesser of second 2\n", cmp1, cmp2);
  printf("%d is the median\n", med);
  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
jg     116c <main+0x4c>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <main+0x52>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1189 <main+0x69>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x6f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     11a6 <main+0x86>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <main+0x8c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%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    0xef4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
cmp    %edx,%esi
cmovg  %edx,%esi
mov    0x4(%rsp),%eax
cmp    %eax,%edx
cmovg  %eax,%edx
cmp    %edx,%esi
mov    %esi,%ebx
cmovl  %edx,%ebx
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [50 x i8] c"%d is lesser of first 2\0A%d is lesser of second 2\0A\00"
@.str.3 = [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 ([9 x i8], [9 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 sle i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = load i32, i32* %2
store i32 %14, i32* %5
br label %17
15: ; preds = %0
%16 = load i32, i32* %3
store i32 %16, i32* %5
br label %17
17: ; preds = %15, %13
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* %3
store i32 %22, i32* %6
br label %25
23: ; preds = %17
%24 = load i32, i32* %4
store i32 %24, i32* %6
br label %25
25: ; preds = %23, %21
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = icmp sge i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i32, i32* %5
store i32 %30, i32* %7
br label %33
31: ; preds = %25
%32 = load i32, i32* %6
store i32 %32, i32* %7
br label %33
33: ; preds = %31, %29
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %35)
%37 = load i32, i32* %7
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter 3 numbers separated by spaces > \00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [50 x i8] c"%d is lesser of first 2\0A%d is lesser of second 2\0A\00"
@.str.3 = [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 ([9 x i8], [9 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 = select i1 %11, i32 %10, i32 %9
%13 = load i32, i32* %3
%14 = icmp sgt i32 %10, %13
%15 = select i1 %14, i32 %13, i32 %10
%16 = icmp slt i32 %12, %15
%17 = select i1 %16, i32 %15, i32 %12
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %15)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %17)
ret i32 0
}