#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*/ mergeSort(int *, int);
int /*<<< orphan*/ printArray(int *, int);
int /*<<< orphan*/ printf(char *);
void test_mergeSort() {
  printf("TEST: mergeSort\n");
  int test[] = {31, 41, 59, 26, 53, 58, 97};
  printf("Before mergeSort: ");
  printArray(test, 7);
  mergeSort(test, 7);
  printf("After mergeSort: ");
  printArray(test, 7);
}


x86 assembly (clang, -O0):
<test_mergeSort>:
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)
mov    0xeed(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1050 <printArray@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1040 <mergeSort@plt>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1050 <printArray@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mergeSort>:
push   %rbx
sub    $0x20,%rsp
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
movups 0xeb4(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1060 <printArray@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1050 <mergeSort@plt>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1060 <printArray@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"TEST: mergeSort\0A\00"
@__const.test_mergeSort.test = [7 x i32] [i32 31, i32 41, i32 59, i32 26, i32 53, i32 58, i32 97]
@.str.1 = [19 x i8] c"Before mergeSort: \00"
@.str.2 = [18 x i8] c"After mergeSort: \00"
define void @test_mergeSort() {
%1 = alloca [7 x i32]
%2 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = bitcast [7 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 [7 x i32], [7 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32* %5, i32 7)
%7 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%8 = call i32 @mergeSort(i32* %7, i32 7)
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%11 = call i32 @printArray(i32* %10, i32 7)
ret void
}

LLVM IR (-O2):
@__const.test_mergeSort.test = [7 x i32] [i32 31, i32 41, i32 59, i32 26, i32 53, i32 58, i32 97]
@.str.1 = [19 x i8] c"Before mergeSort: \00"
@.str.2 = [18 x i8] c"After mergeSort: \00"
@str = [16 x i8] c"TEST: mergeSort\00"
define void @test_mergeSort() {
%1 = alloca [7 x i32]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%3 = bitcast [7 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 [7 x i32], [7 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32* %5, i32 7)
%7 = call i32 @mergeSort(i32* %5, i32 7)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printArray(i32* %5, i32 7)
ret void
}