#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*/ bubbleSortArray(int *, int);
int /*<<< orphan*/ populateRandomArray(int *, int);
int /*<<< orphan*/ printArray(int *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  srand(time(NULL));
  int array[20] = {0};
  populateRandomArray(array, 20);
  puts("\nUn-sorted randomly generated array of values:");
  printArray(array, 20);
  bubbleSortArray(array, 20);
  puts("\n\nSorted previously generated matrix of values:");
  printArray(array, 20);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1070 <populateRandomArray@plt>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1090 <printArray@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1040 <bubbleSortArray@plt>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1090 <printArray@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1060 <populateRandomArray@plt>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1080 <printArray@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1040 <bubbleSortArray@plt>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1080 <printArray@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0AUn-sorted randomly generated array of values:\00"
@.str.1 = [48 x i8] c"\0A\0ASorted previously generated matrix of values:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
store i32 0, i32* %1
%3 = call i32 @time(i32* null)
%4 = call i32 @srand(i32 %3)
%5 = bitcast [20 x i32]* %2 to i8*
%6 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%7 = call i32 @populateRandomArray(i32* %6, i32 20)
%8 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%10 = call i32 @printArray(i32* %9, i32 20)
%11 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%12 = call i32 @bubbleSortArray(i32* %11, i32 20)
%13 = call i32 @puts(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%15 = call i32 @printArray(i32* %14, i32 20)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"\0AUn-sorted randomly generated array of values:\00"
@.str.1 = [48 x i8] c"\0A\0ASorted previously generated matrix of values:\00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast [20 x i32]* %1 to i8*
%5 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%6 = call i32 @populateRandomArray(i32* %5, i32 20)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printArray(i32* %5, i32 20)
%9 = call i32 @bubbleSortArray(i32* %5, i32 20)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printArray(i32* %5, i32 20)
ret i32 0
}