#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*/ bubSort(int *, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ impBsort(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int i, myarray[4000], myarray2[4000];
  int n = 4000;
  for (i = 0; i < n; i++) {
    myarray[i] = n - i;
    myarray2[i] = (rand() % (n * 2)) + 1;
  }
  printf("N = %d", n);
  bubSort(myarray, n);
  impBsort(myarray2, n);
  printf("\n\n[Press Enter to close]");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7d20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0xfa0,-0x7d14(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x7d14(%rbp),%eax
jge    11f5 <main+0x85>
mov    -0x7d14(%rbp),%ecx
sub    -0x8(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x3e90(%rbp,%rax,4)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x7d14(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
movslq -0x8(%rbp),%rax
mov    %edx,-0x7d10(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a3 <main+0x33>
mov    -0x7d14(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x3e90(%rbp),%rdi
mov    -0x7d14(%rbp),%esi
call   1040 <bubSort@plt>
lea    -0x7d10(%rbp),%rdi
mov    -0x7d14(%rbp),%esi
call   1030 <impBsort@plt>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x7d20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7d08,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0xfa0,%r14d
xor    %ebx,%ebx
mov    %r14d,0x3e80(%rsp,%rbx,1)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x29,%rcx
add    %edx,%ecx
imul   $0x1f40,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%rsp,%rbx,1)
add    $0x4,%rbx
add    $0xffffffffffffffff,%r14
jne    1190 <main+0x20>
lea    0xe2a(%rip),%rdi
mov    $0xfa0,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x3e80(%rsp),%rdi
mov    $0xfa0,%esi
call   1040 <bubSort@plt>
mov    %rsp,%rdi
mov    $0xfa0,%esi
call   1030 <impBsort@plt>
lea    0xdff(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x7d08,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"N = %d\00"
@.str.1 = [25 x i8] c"\0A\0A[Press Enter to close]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4000 x i32]
%4 = alloca [4000 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
store i32 4000, i32* %5
store i32 0, i32* %2
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = sub nsw i32 %13, %14
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4000 x i32], [4000 x i32]* %3, i64 0, i64 %17
store i32 %15, i32* %18
%19 = call i32 (...) @rand()
%20 = load i32, i32* %5
%21 = mul nsw i32 %20, 2
%22 = srem i32 %19, %21
%23 = add nsw i32 %22, 1
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4000 x i32], [4000 x i32]* %4, i64 0, i64 %25
store i32 %23, i32* %26
br label %27
27: ; preds = %12
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %8
30: ; preds = %8
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [4000 x i32], [4000 x i32]* %3, i64 0, i64 0
%34 = load i32, i32* %5
%35 = call i32 @bubSort(i32* %33, i32 %34)
%36 = getelementptr inbounds [4000 x i32], [4000 x i32]* %4, i64 0, i64 0
%37 = load i32, i32* %5
%38 = call i32 @impBsort(i32* %36, i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"N = %d\00"
@.str.1 = [25 x i8] c"\0A\0A[Press Enter to close]\00"
define i32 @main() {
%1 = alloca [4000 x i32]
%2 = alloca [4000 x i32]
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = bitcast [4000 x i32]* %1 to i8*
%6 = bitcast [4000 x i32]* %2 to i8*
br label %7
7: ; preds = %0, %7
%8 = phi i64 [ 0, %0 ], [ %16, %7 ]
%9 = getelementptr inbounds [4000 x i32], [4000 x i32]* %1, i64 0, i64 %8
%10 = trunc i64 %8 to i32
%11 = sub i32 4000, %10
store i32 %11, i32* %9
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 8000
%14 = add nsw i32 %13, 1
%15 = getelementptr inbounds [4000 x i32], [4000 x i32]* %2, i64 0, i64 %8
store i32 %14, i32* %15
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, 4000
br i1 %17, label %18, label %7
18: ; preds = %7
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 4000)
%20 = getelementptr inbounds [4000 x i32], [4000 x i32]* %1, i64 0, i64 0
%21 = call i32 @bubSort(i32* %20, i32 4000)
%22 = getelementptr inbounds [4000 x i32], [4000 x i32]* %2, i64 0, i64 0
%23 = call i32 @impBsort(i32* %22, i32 4000)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 (...) @getchar()
ret i32 0
}