#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printArray(int *, int);
int randInt(int, int);
int /*<<< orphan*/ sort(int *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int n = 20;
  int *intArray = malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++)
    intArray[i] = randInt(1, 100);
  printArray(intArray, n);
  sort(intArray, n);
  printArray(intArray, n);
  free(intArray);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x14,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e6 <main+0x76>
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b0 <main+0x40>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <printArray@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <sort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <printArray@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x50,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x4(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x8(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0xc(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x10(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x14(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x18(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x1c(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x20(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x24(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x28(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x2c(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x30(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x34(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x38(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x3c(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x40(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x44(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x48(%rbx)
mov    $0x1,%edi
mov    $0x64,%esi
call   1080 <randInt@plt>
mov    %eax,0x4c(%rbx)
mov    %rbx,%rdi
mov    $0x14,%esi
call   1090 <printArray@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1040 <sort@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1090 <printArray@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 20, i32* %2
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = mul i64 4, %8
%10 = trunc i64 %9 to i32
%11 = call i32* @malloc(i32 %10)
store i32* %11, i32** %3
store i32 0, i32* %4
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i32 @randInt(i32 1, i32 100)
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
%26 = load i32*, i32** %3
%27 = load i32, i32* %2
%28 = call i32 @printArray(i32* %26, i32 %27)
%29 = load i32*, i32** %3
%30 = load i32, i32* %2
%31 = call i32 @sort(i32* %29, i32 %30)
%32 = load i32*, i32** %3
%33 = load i32, i32* %2
%34 = call i32 @printArray(i32* %32, i32 %33)
%35 = load i32*, i32** %3
%36 = call i32 @free(i32* %35)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32* @malloc(i32 80)
%4 = tail call i32 @randInt(i32 1, i32 100)
store i32 %4, i32* %3
%5 = tail call i32 @randInt(i32 1, i32 100)
%6 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %5, i32* %6
%7 = tail call i32 @randInt(i32 1, i32 100)
%8 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %7, i32* %8
%9 = tail call i32 @randInt(i32 1, i32 100)
%10 = getelementptr inbounds i32, i32* %3, i64 3
store i32 %9, i32* %10
%11 = tail call i32 @randInt(i32 1, i32 100)
%12 = getelementptr inbounds i32, i32* %3, i64 4
store i32 %11, i32* %12
%13 = tail call i32 @randInt(i32 1, i32 100)
%14 = getelementptr inbounds i32, i32* %3, i64 5
store i32 %13, i32* %14
%15 = tail call i32 @randInt(i32 1, i32 100)
%16 = getelementptr inbounds i32, i32* %3, i64 6
store i32 %15, i32* %16
%17 = tail call i32 @randInt(i32 1, i32 100)
%18 = getelementptr inbounds i32, i32* %3, i64 7
store i32 %17, i32* %18
%19 = tail call i32 @randInt(i32 1, i32 100)
%20 = getelementptr inbounds i32, i32* %3, i64 8
store i32 %19, i32* %20
%21 = tail call i32 @randInt(i32 1, i32 100)
%22 = getelementptr inbounds i32, i32* %3, i64 9
store i32 %21, i32* %22
%23 = tail call i32 @randInt(i32 1, i32 100)
%24 = getelementptr inbounds i32, i32* %3, i64 10
store i32 %23, i32* %24
%25 = tail call i32 @randInt(i32 1, i32 100)
%26 = getelementptr inbounds i32, i32* %3, i64 11
store i32 %25, i32* %26
%27 = tail call i32 @randInt(i32 1, i32 100)
%28 = getelementptr inbounds i32, i32* %3, i64 12
store i32 %27, i32* %28
%29 = tail call i32 @randInt(i32 1, i32 100)
%30 = getelementptr inbounds i32, i32* %3, i64 13
store i32 %29, i32* %30
%31 = tail call i32 @randInt(i32 1, i32 100)
%32 = getelementptr inbounds i32, i32* %3, i64 14
store i32 %31, i32* %32
%33 = tail call i32 @randInt(i32 1, i32 100)
%34 = getelementptr inbounds i32, i32* %3, i64 15
store i32 %33, i32* %34
%35 = tail call i32 @randInt(i32 1, i32 100)
%36 = getelementptr inbounds i32, i32* %3, i64 16
store i32 %35, i32* %36
%37 = tail call i32 @randInt(i32 1, i32 100)
%38 = getelementptr inbounds i32, i32* %3, i64 17
store i32 %37, i32* %38
%39 = tail call i32 @randInt(i32 1, i32 100)
%40 = getelementptr inbounds i32, i32* %3, i64 18
store i32 %39, i32* %40
%41 = tail call i32 @randInt(i32 1, i32 100)
%42 = getelementptr inbounds i32, i32* %3, i64 19
store i32 %41, i32* %42
%43 = tail call i32 @printArray(i32* %3, i32 20)
%44 = tail call i32 @sort(i32* %3, i32 20)
%45 = tail call i32 @printArray(i32* %3, i32 20)
%46 = tail call i32 @free(i32* %3)
ret i32 0
}