#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*/ printArray(int *, int);
int /*<<< orphan*/ printf(char *);
void test_bubbleSort(void) {
  printf("TEST: bubbleSort\n");
  int test[] = {34, 8, 64, 51, 32, 21};
  printf("Befor bubbleSort: ");
  printArray(test, 6);
  bubbleSort(test, 6);
  printf("After bubbleSort: ");
  printArray(test, 6);
}


x86 assembly (clang, -O0):
<test_bubbleSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0xef5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xef2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeef(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1050 <printArray@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1040 <bubbleSort@plt>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1050 <printArray@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bubbleSort>:
push   %rbx
sub    $0x20,%rsp
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
mov    0xeb8(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <printArray@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1050 <bubbleSort@plt>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <printArray@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"TEST: bubbleSort\0A\00"
@__const.test_bubbleSort.test = [6 x i32] [i32 34, i32 8, i32 64, i32 51, i32 32, i32 21]
@.str.1 = [19 x i8] c"Befor bubbleSort: \00"
@.str.2 = [19 x i8] c"After bubbleSort: \00"
define void @test_bubbleSort() {
%1 = alloca [6 x i32]
%2 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = bitcast [6 x i32]* %1 to i8*
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32* %5, i32 6)
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%8 = call i32 @bubbleSort(i32* %7, i32 6)
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%11 = call i32 @printArray(i32* %10, i32 6)
ret void
}

LLVM IR (-O2):
@__const.test_bubbleSort.test = [6 x i32] [i32 34, i32 8, i32 64, i32 51, i32 32, i32 21]
@.str.1 = [19 x i8] c"Befor bubbleSort: \00"
@.str.2 = [19 x i8] c"After bubbleSort: \00"
@str = [17 x i8] c"TEST: bubbleSort\00"
define void @test_bubbleSort() {
%1 = alloca [6 x i32]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%3 = bitcast [6 x i32]* %1 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32* %5, i32 6)
%7 = call i32 @bubbleSort(i32* %5, i32 6)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printArray(i32* %5, i32 6)
ret void
}