#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 *);
int main(void) {
  int i1, i2, i3, i4, current_max, current_min;
  printf("Enter four numbers seperated by spaces: ");
  scanf("%d %d %d %d", &i1, &i2, &i3, &i4);
  current_max = i1;
  current_min = i1;
  if (i2 > current_max) {
    current_max = i2;
  } else if (i2 < current_min) {
    current_min = i2;
  }
  if (i3 > current_max) {
    current_max = i3;
  } else if (i3 < current_min) {
    current_min = i3;
  }
  if (i4 > current_max) {
    current_max = i4;
  } else if (i4 < current_min) {
    current_min = i4;
  }
  printf("Largest: %d\n", current_max);
  printf("Smallest: %d\n", current_min);
}


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    0xee5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    117c <main+0x5c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1193 <main+0x73>
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    118e <main+0x6e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1193 <main+0x73>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11aa <main+0x8a>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11c1 <main+0xa1>
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bc <main+0x9c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11c1 <main+0xa1>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11d8 <main+0xb8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11ef <main+0xcf>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ea <main+0xca>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11ef <main+0xcf>
mov    -0x18(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    0xeef(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rsp,%r8
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%esi
cmp    %eax,%esi
mov    %eax,%ecx
cmovl  %esi,%ecx
cmovle %eax,%esi
cmovg  %eax,%ecx
mov    0x4(%rsp),%eax
cmp    %ecx,%eax
mov    %ecx,%edx
cmovl  %eax,%edx
cmp    %esi,%eax
cmovg  %eax,%esi
cmovg  %ecx,%edx
mov    (%rsp),%eax
cmp    %edx,%eax
mov    %edx,%ebx
cmovl  %eax,%ebx
cmp    %esi,%eax
cmovg  %eax,%esi
cmovg  %edx,%ebx
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea2(%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 = [41 x i8] c"Enter four numbers seperated by spaces: \00"
@.str.1 = [12 x i8] c"%d %d %d %d\00"
@.str.2 = [13 x i8] c"Largest: %d\0A\00"
@.str.3 = [14 x i8] c"Smallest: %d\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 ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%10 = load i32, i32* %2
store i32 %10, i32* %6
%11 = load i32, i32* %2
store i32 %11, i32* %7
%12 = load i32, i32* %3
%13 = load i32, i32* %6
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = load i32, i32* %3
store i32 %16, i32* %6
br label %24
17: ; preds = %0
%18 = load i32, i32* %3
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* %3
store i32 %22, i32* %7
br label %23
23: ; preds = %21, %17
br label %24
24: ; preds = %23, %15
%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* %4
store i32 %29, i32* %6
br label %37
30: ; preds = %24
%31 = load i32, i32* %4
%32 = load i32, i32* %7
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* %4
store i32 %35, i32* %7
br label %36
36: ; preds = %34, %30
br label %37
37: ; preds = %36, %28
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = load i32, i32* %5
store i32 %42, i32* %6
br label %50
43: ; preds = %37
%44 = load i32, i32* %5
%45 = load i32, i32* %7
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = load i32, i32* %5
store i32 %48, i32* %7
br label %49
49: ; preds = %47, %43
br label %50
50: ; preds = %49, %41
%51 = load i32, i32* %6
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %7
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter four numbers seperated by spaces: \00"
@.str.1 = [12 x i8] c"%d %d %d %d\00"
@.str.2 = [13 x i8] c"Largest: %d\0A\00"
@.str.3 = [14 x i8] c"Smallest: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, %11
%14 = icmp slt i32 %12, %11
%15 = select i1 %14, i32 %12, i32 %11
%16 = select i1 %13, i32 %12, i32 %11
%17 = select i1 %13, i32 %11, i32 %15
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, %16
%20 = icmp slt i32 %18, %17
%21 = select i1 %20, i32 %18, i32 %17
%22 = select i1 %19, i32 %18, i32 %16
%23 = select i1 %19, i32 %17, i32 %21
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, %22
%26 = icmp slt i32 %24, %23
%27 = select i1 %26, i32 %24, i32 %23
%28 = select i1 %25, i32 %24, i32 %22
%29 = select i1 %25, i32 %23, i32 %27
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %29)
ret i32 0
}