#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 n1, n2, n3, n4, min = 0, max = 0;
  printf("Enter four integers: ");
  scanf("%d %d %d %d", &n1, &n2, &n3, &n4);
  if (n1 >= n2) {
    max = n1;
  } else {
    max = n2;
    min = n1;
  }
  if (n3 > max) {
    max = n3;
  } else if (n3 < min) {
    min = n3;
  }
  if (n4 > max) {
    max = n4;
  } else if (n4 < min) {
    min = n4;
  }
  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)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%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
cmp    -0xc(%rbp),%eax
jl     117e <main+0x5e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    118a <main+0x6a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11a1 <main+0x81>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11b8 <main+0x98>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b3 <main+0x93>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11b8 <main+0x98>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11cf <main+0xaf>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11e6 <main+0xc6>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e1 <main+0xc1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <main+0xc6>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe2f(%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),%esi
mov    0x10(%rsp),%eax
cmp    %eax,%esi
mov    $0x0,%ecx
cmovl  %esi,%ecx
cmovl  %eax,%esi
mov    0xc(%rsp),%eax
cmp    %ecx,%eax
mov    %ecx,%edi
cmovl  %eax,%edi
cmp    %esi,%eax
cmovg  %ecx,%edi
cmovg  %eax,%esi
mov    0x8(%rsp),%eax
cmp    %edi,%eax
mov    %edi,%edx
cmovl  %eax,%edx
cmp    %esi,%eax
cmovg  %edi,%edx
cmovg  %eax,%esi
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 = [25 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
store i32 0, i32* %6
store i32 0, i32* %7
%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
%11 = load i32, i32* %3
%12 = icmp sge i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = load i32, i32* %2
store i32 %14, i32* %7
br label %18
15: ; preds = %0
%16 = load i32, i32* %3
store i32 %16, i32* %7
%17 = load i32, i32* %2
store i32 %17, i32* %6
br label %18
18: ; preds = %15, %13
%19 = load i32, i32* %4
%20 = load i32, i32* %7
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = load i32, i32* %4
store i32 %23, i32* %7
br label %31
24: ; preds = %18
%25 = load i32, i32* %4
%26 = load i32, i32* %6
%27 = icmp slt 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 %30
30: ; preds = %28, %24
br label %31
31: ; preds = %30, %22
%32 = load i32, i32* %5
%33 = load i32, i32* %7
%34 = icmp sgt i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i32, i32* %5
store i32 %36, i32* %7
br label %44
37: ; preds = %31
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = icmp slt 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 %43
43: ; preds = %41, %37
br label %44
44: ; preds = %43, %35
%45 = load i32, i32* %7
%46 = load i32, i32* %6
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %46)
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 = [25 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 slt i32 %11, %12
%14 = select i1 %13, i32 %11, i32 0
%15 = select i1 %13, i32 %12, i32 %11
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, %15
%18 = icmp slt i32 %16, %14
%19 = select i1 %18, i32 %16, i32 %14
%20 = select i1 %17, i32 %14, i32 %19
%21 = select i1 %17, i32 %16, i32 %15
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, %21
%24 = icmp slt i32 %22, %20
%25 = select i1 %24, i32 %22, i32 %20
%26 = select i1 %23, i32 %20, i32 %25
%27 = select i1 %23, i32 %22, i32 %21
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %26)
ret i32 0
}