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


x86 assembly (clang, -O0):
<test_mergeSortNonRecursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0xf05(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf02(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeff(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xefd(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    0xeac(%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 <mergeSortNonRecursive@plt>
lea    0xe97(%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_mergeSortNonRecursive>:
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 <mergeSortNonRecursive@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 = [33 x i8] c"TEST: mergeSort (non-Recursive)\0A\00"
@__const.test_mergeSortNonRecursive.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_mergeSortNonRecursive() {
%1 = alloca [7 x i32]
%2 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 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 @mergeSortNonRecursive(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_mergeSortNonRecursive.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 = [32 x i8] c"TEST: mergeSort (non-Recursive)\00"
define void @test_mergeSortNonRecursive() {
%1 = alloca [7 x i32]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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 @mergeSortNonRecursive(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
}