#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 main() {
  int x, i, smallest, j, k, temp;
  int numbers[4];
  printf("Please enter 4 numbers separated by spaces > ");
  for (i = 0; i < 3; i++) {
    scanf("%d", &x);
    numbers[i] = x;
  }
  for (k = 3; k > 0; k--) {
    for (j = 1; j <= k; j++) {
      if (numbers[j - 1] > numbers[j]) {
        temp = numbers[j - 1];
        numbers[j - 1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
  smallest = numbers[0];
  printf("%d is the smallest\n", smallest);
  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>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1177 <main+0x57>
lea    0xed9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1144 <main+0x24>
movl   $0x3,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1209 <main+0xe9>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11f6 <main+0xd6>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x14(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    11e3 <main+0xc3>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x1c(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11e8 <main+0xc8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x6f>
jmp    11fb <main+0xdb>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    117e <main+0x5e>
mov    -0x30(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef2(%rip),%r15
lea    0x4(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebp
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
cmp    %ebx,%ebp
mov    %ebp,%eax
cmovg  %ebx,%eax
cmovg  %ebp,%ebx
mov    0x4(%rsp),%ecx
cmp    %ecx,%ebx
mov    %ebx,%esi
cmovg  %ecx,%esi
cmovle %ecx,%ebx
cmp    %esi,%eax
mov    %eax,%ecx
cmovg  %esi,%ecx
cmovg  %eax,%esi
cmp    %ebx,%esi
cmovg  %ebx,%esi
cmp    %esi,%ecx
cmovle %ecx,%esi
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Please enter 4 numbers separated by spaces > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"%d is the smallest\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 [4 x i32]
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %17
store i32 %15, i32* %18
br label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %10
22: ; preds = %10
store i32 3, i32* %6
br label %23
23: ; preds = %65, %22
%24 = load i32, i32* %6
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %68
26: ; preds = %23
store i32 1, i32* %5
br label %27
27: ; preds = %61, %26
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %64
31: ; preds = %27
%32 = load i32, i32* %5
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp sgt i32 %36, %40
br i1 %41, label %42, label %60
42: ; preds = %31
%43 = load i32, i32* %5
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %45
%47 = load i32, i32* %46
store i32 %47, i32* %7
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %5
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %54
store i32 %51, i32* %55
%56 = load i32, i32* %7
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %58
store i32 %56, i32* %59
br label %60
60: ; preds = %42, %31
br label %61
61: ; preds = %60
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %27
64: ; preds = %27
br label %65
65: ; preds = %64
%66 = load i32, i32* %6
%67 = add nsw i32 %66, -1
store i32 %67, i32* %6
br label %23
68: ; preds = %23
%69 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%70 = load i32, i32* %69
store i32 %70, i32* %4
%71 = load i32, i32* %4
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %71)
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter 4 numbers separated by spaces > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"%d is the smallest\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %5, %7
%11 = select i1 %10, i32 %7, i32 %5
%12 = select i1 %10, i32 %5, i32 %7
%13 = icmp sgt i32 %12, %9
%14 = select i1 %13, i32 %9, i32 %12
%15 = select i1 %13, i32 %12, i32 %9
%16 = icmp sgt i32 %11, %14
%17 = select i1 %16, i32 %14, i32 %11
%18 = select i1 %16, i32 %11, i32 %14
%19 = icmp sgt i32 %18, %15
%20 = select i1 %19, i32 %15, i32 %18
%21 = icmp sgt i32 %17, %20
%22 = select i1 %21, i32 %20, i32 %17
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}