#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*/ bubble_sort(unsigned long *, unsigned long);
unsigned long *malloc(unsigned long);
int /*<<< orphan*/ print_array(unsigned long *, unsigned long);
int /*<<< orphan*/ printf(char *);
int random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  unsigned long c = 0;
  unsigned long elements = 10000;
  unsigned long *numray = malloc(elements * sizeof(unsigned long));
  srandom(time(NULL));
  for (; c < elements; c++)
    numray[c] = (random() % 9999999999) * 1000000000000000000;
  print_array(numray, elements);
  printf("====================\n");
  bubble_sort(numray, elements);
  print_array(numray, elements);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x2710,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1208 <main+0x98>
mov    $0x0,%al
call   1070 <random@plt>
cltq
movabs $0x2540be3ff,%rcx
cqto
idiv   %rcx
movabs $0xde0b6b3a7640000,%rax
b6 e0 0d
imul   %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11b7 <main+0x47>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <print_array@plt>
lea    0xde4(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <bubble_sort@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <print_array@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x13880,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movabs $0xde0b6b3a7640000,%r14
b6 e0 0d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <random@plt>
cltq
imul   %r14,%rax
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x2710,%rbx
jne    11a0 <main+0x30>
mov    $0x2710,%esi
mov    %r15,%rdi
call   1050 <print_array@plt>
lea    0xe2e(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2710,%esi
mov    %r15,%rdi
call   1090 <bubble_sort@plt>
mov    $0x2710,%esi
mov    %r15,%rdi
call   1050 <print_array@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"====================\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64 10000, i64* %7
%9 = load i64, i64* %7
%10 = mul i64 %9, 8
%11 = call i64* @malloc(i64 %10)
store i64* %11, i64** %8
%12 = call i32 @time(i32* null)
%13 = call i32 @srandom(i32 %12)
br label %14
14: ; preds = %26, %2
%15 = load i64, i64* %6
%16 = load i64, i64* %7
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = call i32 (...) @random()
%20 = sext i32 %19 to i64
%21 = srem i64 %20, 9999999999
%22 = mul nsw i64 %21, 1000000000000000000
%23 = load i64*, i64** %8
%24 = load i64, i64* %6
%25 = getelementptr inbounds i64, i64* %23, i64 %24
store i64 %22, i64* %25
br label %26
26: ; preds = %18
%27 = load i64, i64* %6
%28 = add i64 %27, 1
store i64 %28, i64* %6
br label %14
29: ; preds = %14
%30 = load i64*, i64** %8
%31 = load i64, i64* %7
%32 = call i32 @print_array(i64* %30, i64 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%34 = load i64*, i64** %8
%35 = load i64, i64* %7
%36 = call i32 @bubble_sort(i64* %34, i64 %35)
%37 = load i64*, i64** %8
%38 = load i64, i64* %7
%39 = call i32 @print_array(i64* %37, i64 %38)
ret i32 0
}

LLVM IR (-O2):
@str = [21 x i8] c"====================\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64* @malloc(i64 80000)
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srandom(i32 %4)
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %12, %6 ]
%8 = tail call i32 (...) @random()
%9 = sext i32 %8 to i64
%10 = mul nsw i64 %9, 1000000000000000000
%11 = getelementptr inbounds i64, i64* %3, i64 %7
store i64 %10, i64* %11
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, 10000
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = tail call i32 @print_array(i64* %3, i64 10000)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 @bubble_sort(i64* %3, i64 10000)
%18 = tail call i32 @print_array(i64* %3, i64 10000)
ret i32 0
}