#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(void) {
  int input[5], i, tmp, count;
  printf("How many number would you like to input? \n> ");
  scanf("%d", &count);
  printf("Enter the number: \n");
  for (i = 0; i < count; i++) {
    printf("> ");
    scanf("%d", &input[i]);
  }
  for (i = 0; i < count; i++) {
    for (size_t j = i + 1; j < count; j++) {
      tmp = input[i];
      input[i] = input[j];
      input[j] = tmp;
    }
  }
  printf("The reserved number is: \n");
  for (size_t i = 0; i < count; i++) {
    printf(">> %d\n", input[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11a5 <main+0x85>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe9b(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1162 <main+0x42>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    121f <main+0xff>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmp    %rcx,%rax
jae    120c <main+0xec>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x28(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11c4 <main+0xa4>
jmp    1211 <main+0xf1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ac <main+0x8c>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmp    %rcx,%rax
jae    126d <main+0x14d>
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1235 <main+0x115>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    120b <main+0xdb>
lea    0x10(%rsp),%r12
lea    0xead(%rip),%r14
lea    0xea9(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     1190 <main+0x60>
mov    %eax,%eax
test   %eax,%eax
jle    120b <main+0xdb>
xor    %ecx,%ecx
jmp    11d5 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %rax,%rcx
je     120b <main+0xdb>
mov    %rcx,%rdx
add    $0x1,%rcx
cmp    %rax,%rcx
jae    11d0 <main+0xa0>
mov    %rcx,%rsi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp,%rdx,4),%edi
mov    0x10(%rsp,%rsi,4),%ebx
mov    %ebx,0x10(%rsp,%rdx,4)
mov    %edi,0x10(%rsp,%rsi,4)
add    $0x1,%rsi
cmp    %rax,%rsi
jb     11f0 <main+0xc0>
jmp    11d0 <main+0xa0>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
je     124c <main+0x11c>
lea    0xe0b(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jb     1230 <main+0x100>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"How many number would you like to input? \0A> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter the number: \0A\00"
@.str.3 = [3 x i8] c"> \00"
@.str.4 = [26 x i8] c"The reserved number is: \0A\00"
@.str.5 = [7 x i8] c">> %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %11
11: ; preds = %21, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
br label %21
21: ; preds = %15
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %11
24: ; preds = %11
store i32 0, i32* %3
br label %25
25: ; preds = %56, %24
%26 = load i32, i32* %3
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %59
29: ; preds = %25
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
store i64 %32, i64* %6
br label %33
33: ; preds = %52, %29
%34 = load i64, i64* %6
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = icmp ult i64 %34, %36
br i1 %37, label %38, label %55
38: ; preds = %33
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
store i32 %42, i32* %4
%43 = load i64, i64* %6
%44 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %47
store i32 %45, i32* %48
%49 = load i32, i32* %4
%50 = load i64, i64* %6
%51 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %50
store i32 %49, i32* %51
br label %52
52: ; preds = %38
%53 = load i64, i64* %6
%54 = add i64 %53, 1
store i64 %54, i64* %6
br label %33
55: ; preds = %33
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %25
59: ; preds = %25
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i64 0, i64* %7
br label %61
61: ; preds = %71, %59
%62 = load i64, i64* %7
%63 = load i32, i32* %5
%64 = sext i32 %63 to i64
%65 = icmp ult i64 %62, %64
br i1 %65, label %66, label %74
66: ; preds = %61
%67 = load i64, i64* %7
%68 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %66
%72 = load i64, i64* %7
%73 = add i64 %72, 1
store i64 %73, i64* %7
br label %61
74: ; preds = %61
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"How many number would you like to input? \0A> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"> \00"
@.str.5 = [7 x i8] c">> %d\0A\00"
@str = [19 x i8] c"Enter the number: \00"
@str.6 = [25 x i8] c"The reserved number is: \00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca i32
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %15, label %39
10: ; preds = %15
%11 = icmp sgt i32 %21, 0
br i1 %11, label %12, label %39
12: ; preds = %10
%13 = zext i32 %21 to i64
%14 = zext i32 %21 to i64
br label %26
15: ; preds = %0, %15
%16 = phi i64 [ %20, %15 ], [ 0, %0 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 %16
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = add nuw nsw i64 %16, 1
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %15, label %10
24: ; preds = %32, %26
%25 = icmp eq i64 %28, %14
br i1 %25, label %39, label %26
26: ; preds = %12, %24
%27 = phi i64 [ 0, %12 ], [ %28, %24 ]
%28 = add nuw nsw i64 %27, 1
%29 = icmp ult i64 %28, %13
br i1 %29, label %30, label %24
30: ; preds = %26
%31 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 %27
br label %32
32: ; preds = %30, %32
%33 = phi i64 [ %28, %30 ], [ %37, %32 ]
%34 = load i32, i32* %31
%35 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 %33
%36 = load i32, i32* %35
store i32 %36, i32* %31
store i32 %34, i32* %35
%37 = add nuw i64 %33, 1
%38 = icmp ult i64 %37, %13
br i1 %38, label %32, label %24
39: ; preds = %24, %0, %10
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %44, %39
ret i32 0
44: ; preds = %39, %44
%45 = phi i64 [ %49, %44 ], [ 0, %39 ]
%46 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = add nuw i64 %45, 1
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = icmp ult i64 %49, %51
br i1 %52, label %44, label %43
}