#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(int *, int);
int /*<<< orphan*/ printArray(int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  printf("*** Initializing array-to-sort ... done.\n");
  int arr[10] = {42, 0, 58, 723, (-13), 7, 999, 8, 42, 21};
  printf("   ### Array to sort:\n");
  printArray(arr);
  printf("\n   ### Size of the array: %d\n\n", 10);
  printf("*** Sorting array with bubble sort ... done.\n");
  bubble_sort(arr, 10);
  printf("   ### Sorted array:\n");
  printArray(arr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    0xf41(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <printArray@plt>
lea    0xeaa(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1060 <bubble_sort@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <printArray@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
mov    0xec8(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe90(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <printArray@plt>
lea    0xe96(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <bubble_sort@plt>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <printArray@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"*** Initializing array-to-sort ... done.\0A\00"
@__const.main.arr = [10 x i32] [i32 42, i32 0, i32 58, i32 723, i32 -13, i32 7, i32 999, i32 8, i32 42, i32 21]
@.str.1 = [23 x i8] c" ### Array to sort:\0A\00"
@.str.2 = [32 x i8] c"\0A ### Size of the array: %d\0A\0A\00"
@.str.3 = [46 x i8] c"*** Sorting array with bubble sort ... done.\0A\00"
@.str.4 = [22 x i8] c" ### Sorted array:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%8 = bitcast [10 x i32]* %6 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%11 = call i32 @printArray(i32* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 10)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%15 = call i32 @bubble_sort(i32* %14, i32 10)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%18 = call i32 @printArray(i32* %17)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [10 x i32] [i32 42, i32 0, i32 58, i32 723, i32 -13, i32 7, i32 999, i32 8, i32 42, i32 21]
@.str.2 = [32 x i8] c"\0A ### Size of the array: %d\0A\0A\00"
@str = [41 x i8] c"*** Initializing array-to-sort ... done.\00"
@str.5 = [22 x i8] c" ### Array to sort:\00"
@str.6 = [45 x i8] c"*** Sorting array with bubble sort ... done.\00"
@str.7 = [21 x i8] c" ### Sorted array:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%5 = bitcast [10 x i32]* %3 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%8 = call i32 @printArray(i32* %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 10)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @bubble_sort(i32* %7, i32 10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%13 = call i32 @printArray(i32* %7)
ret i32 0
}