#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;
  int max1, max2;
  int min1, min2;
  int max, min;
  printf("Enter 4 integers (x, x, x, x): ");
  scanf("%d, %d, %d, %d", &a, &b, &c, &d);
  if (a > b) {
    max1 = a;
    min1 = b;
  } else {
    max1 = b;
    min1 = a;
  }
  if (c > d) {
    max2 = c;
    min2 = d;
  } else {
    max2 = d;
    min2 = c;
  }
  if (max1 > max2) {
    max = max1;
  } else {
    max = max2;
  }
  if (min1 > min2) {
    min = min2;
  } else {
    min = min1;
  }
  printf("Largest: %d\n", max);
  printf("Smallest: %d\n", min);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%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
jle    1176 <main+0x56>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1182 <main+0x62>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    119f <main+0x7f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11ab <main+0x8b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11c2 <main+0xa2>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11c8 <main+0xa8>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    11df <main+0xbf>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    11e5 <main+0xc5>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%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    0xee6(%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),%ecx
cmp    %ecx,%eax
mov    %ecx,%edx
cmovg  %eax,%edx
cmovg  %ecx,%eax
mov    0x4(%rsp),%ebx
mov    (%rsp),%ecx
cmp    %ecx,%ebx
mov    %ecx,%esi
cmovg  %ebx,%esi
cmovg  %ecx,%ebx
cmp    %esi,%edx
cmovg  %edx,%esi
cmp    %ebx,%eax
cmovle %eax,%ebx
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea9(%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 = [32 x i8] c"Enter 4 integers (x, x, x, x): \00"
@.str.1 = [15 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
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = load i32, i32* %2
store i32 %18, i32* %6
%19 = load i32, i32* %3
store i32 %19, i32* %8
br label %23
20: ; preds = %0
%21 = load i32, i32* %3
store i32 %21, i32* %6
%22 = load i32, i32* %2
store i32 %22, i32* %8
br label %23
23: ; preds = %20, %17
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %4
store i32 %28, i32* %7
%29 = load i32, i32* %5
store i32 %29, i32* %9
br label %33
30: ; preds = %23
%31 = load i32, i32* %5
store i32 %31, i32* %7
%32 = load i32, i32* %4
store i32 %32, i32* %9
br label %33
33: ; preds = %30, %27
%34 = load i32, i32* %6
%35 = load i32, i32* %7
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i32, i32* %6
store i32 %38, i32* %10
br label %41
39: ; preds = %33
%40 = load i32, i32* %7
store i32 %40, i32* %10
br label %41
41: ; preds = %39, %37
%42 = load i32, i32* %8
%43 = load i32, i32* %9
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i32, i32* %9
store i32 %46, i32* %11
br label %49
47: ; preds = %41
%48 = load i32, i32* %8
store i32 %48, i32* %11
br label %49
49: ; preds = %47, %45
%50 = load i32, i32* %10
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %11
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter 4 integers (x, x, x, x): \00"
@.str.1 = [15 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 ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 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 %11, %12
%14 = select i1 %13, i32 %11, i32 %12
%15 = select i1 %13, i32 %12, i32 %11
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = icmp sgt i32 %16, %17
%19 = select i1 %18, i32 %16, i32 %17
%20 = select i1 %18, i32 %17, i32 %16
%21 = icmp sgt i32 %14, %19
%22 = select i1 %21, i32 %14, i32 %19
%23 = icmp sgt i32 %15, %20
%24 = select i1 %23, i32 %20, i32 %15
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %24)
ret i32 0
}