#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 a, b, c, d, max, min;
  printf("enter four integers: ");
  scanf("%d %d %d %d", &a, &b, &c, &d);
  max = a;
  min = a;
  if (b > max)
    max = b;
  else if (b < min)
    min = b;
  if (c > max)
    max = c;
  else if (c < min)
    min = c;
  if (d > max)
    max = d;
  else if (d < min)
    min = d;
  printf("Largest: %d\nSmallest: %d \n", max, min);
  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    0xed2(%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
mov    -0x1c(%rbp),%edx
lea    0xe26(%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    0xedd(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%esi
cmp    %eax,%esi
mov    %eax,%ecx
cmovl  %esi,%ecx
cmovle %eax,%esi
cmovg  %eax,%ecx
mov    0xc(%rsp),%eax
cmp    %ecx,%eax
mov    %ecx,%edi
cmovl  %eax,%edi
cmp    %esi,%eax
cmovg  %eax,%esi
cmovg  %ecx,%edi
mov    0x8(%rsp),%eax
cmp    %edi,%eax
mov    %edi,%edx
cmovl  %eax,%edx
cmp    %esi,%eax
cmovg  %eax,%esi
cmovg  %edi,%edx
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"enter four integers: \00"
@.str.1 = [12 x i8] c"%d %d %d %d\00"
@.str.2 = [27 x i8] c"Largest: %d\0ASmallest: %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 ([22 x i8], [22 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 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %51, i32 %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"enter four integers: \00"
@.str.1 = [12 x i8] c"%d %d %d %d\00"
@.str.2 = [27 x i8] c"Largest: %d\0ASmallest: %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 ([22 x i8], [22 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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %29)
ret i32 0
}