#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*/ bubbleSort(int *, int);
int /*<<< orphan*/ count_frequency(int *, int *);
int /*<<< orphan*/ create_random(int *);
int /*<<< orphan*/ draw_histogram(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int table[100];
  int frequency[100] = {0};
  create_random(table);
  for (int i = 0; i < 100; i++) {
    printf("%d\n", table[i]);
  }
  printf("new \n");
  bubbleSort(table, 100);
  for (int i = 0; i < 100; i++) {
    printf("%d\n", table[i]);
  }
  count_frequency(table, frequency);
  draw_histogram(frequency, table);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x330(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1050 <memset@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <create_random@plt>
movl   $0x0,-0x334(%rbp)
cmpl   $0x64,-0x334(%rbp)
jge    11df <main+0x7f>
movslq -0x334(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    11a2 <main+0x42>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1060 <bubbleSort@plt>
movl   $0x0,-0x338(%rbp)
cmpl   $0x64,-0x338(%rbp)
jge    1245 <main+0xe5>
movslq -0x338(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x338(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x338(%rbp)
jmp    1208 <main+0xa8>
lea    -0x1a0(%rbp),%rdi
lea    -0x330(%rbp),%rsi
call   1070 <count_frequency@plt>
lea    -0x330(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1080 <draw_histogram@plt>
xor    %eax,%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x328,%rsp
lea    0x190(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rsp,%rdi
call   1040 <create_random@plt>
lea    0xe63(%rip),%r14
xor    %ebx,%ebx
nop
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11a0 <main+0x30>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1070 <bubbleSort@plt>
lea    0xe29(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11e0 <main+0x70>
mov    %rsp,%r14
lea    0x190(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <count_frequency@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <draw_histogram@plt>
xor    %eax,%eax
add    $0x328,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [6 x i8] c"new \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i32]
%7 = alloca [100 x i32]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [100 x i32]* %7 to i8*
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 0
%12 = call i32 @create_random(i32* %11)
store i32 0, i32* %8
br label %13
13: ; preds = %22, %2
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %16
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 1
store i32 %24, i32* %8
br label %13
25: ; preds = %13
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 0
%28 = call i32 @bubbleSort(i32* %27, i32 100)
store i32 0, i32* %9
br label %29
29: ; preds = %38, %25
%30 = load i32, i32* %9
%31 = icmp slt i32 %30, 100
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %32
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %29
41: ; preds = %29
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 0
%43 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 0
%44 = call i32 @count_frequency(i32* %42, i32* %43)
%45 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 0
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 0
%47 = call i32 @draw_histogram(i32* %45, i32* %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@str = [5 x i8] c"new \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i32]
%4 = alloca [100 x i32]
%5 = bitcast [100 x i32]* %3 to i8*
%6 = bitcast [100 x i32]* %4 to i8*
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%8 = call i32 @create_random(i32* %7)
br label %12
9: ; preds = %12
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%11 = call i32 @bubbleSort(i32* %7, i32 100)
br label %23
12: ; preds = %2, %12
%13 = phi i64 [ 0, %2 ], [ %17, %12 ]
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, 100
br i1 %18, label %9, label %12
19: ; preds = %23
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%21 = call i32 @count_frequency(i32* %7, i32* %20)
%22 = call i32 @draw_histogram(i32* %20, i32* %7)
ret i32 0
23: ; preds = %9, %23
%24 = phi i64 [ 0, %9 ], [ %28, %23 ]
%25 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %24, 1
%29 = icmp eq i64 %28, 100
br i1 %29, label %19, label %23
}