#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 */
typedef int /*<<< orphan*/ A;

/* Variables and functions */
int /*<<< orphan*/ MergeSort(int *, int);
int /*<<< orphan*/ printArray(char *, int *, int);
int main() {
  int A[] = {9, 2, 1, 4, 8, 6, 7, 2, 3, 5, 6, 2, 3, 1, 9, 10, 15, 13, 12, 17};
  int numberOfElements;
  numberOfElements = sizeof(A) / sizeof(A[0]);
  printArray("Original Array: ", A, numberOfElements);
  MergeSort(A, numberOfElements);
  printArray("sorted Array: ", A, numberOfElements);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x50,%edx
call   1030 <memcpy@plt>
movl   $0x14,-0x64(%rbp)
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
lea    0xee7(%rip),%rdi
call   1050 <printArray@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1040 <MergeSort@plt>
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
lea    0xed9(%rip),%rdi
call   1050 <printArray@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movaps 0xf14(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xef8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee9(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x14,%edx
call   1040 <printArray@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <MergeSort@plt>
lea    0xed6(%rip),%rdi
mov    %rbx,%rsi
mov    $0x14,%edx
call   1040 <printArray@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.A = [20 x i32] [i32 9, i32 2, i32 1, i32 4, i32 8, i32 6, i32 7, i32 2, i32 3, i32 5, i32 6, i32 2, i32 3, i32 1, i32 9, i32 10, i32 15, i32 13, i32 12, i32 17]
@.str = [17 x i8] c"Original Array: \00"
@.str.1 = [15 x i8] c"sorted Array: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [20 x i32]* %2 to i8*
store i32 20, i32* %3
%5 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%6 = load i32, i32* %3
%7 = call i32 @printArray(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* %5, i32 %6)
%8 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call i32 @MergeSort(i32* %8, i32 %9)
%11 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%12 = load i32, i32* %3
%13 = call i32 @printArray(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %11, i32 %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.A = [20 x i32] [i32 9, i32 2, i32 1, i32 4, i32 8, i32 6, i32 7, i32 2, i32 3, i32 5, i32 6, i32 2, i32 3, i32 1, i32 9, i32 10, i32 15, i32 13, i32 12, i32 17]
@.str = [17 x i8] c"Original Array: \00"
@.str.1 = [15 x i8] c"sorted Array: \00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%4 = call i32 @printArray(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* %3, i32 20)
%5 = call i32 @MergeSort(i32* %3, i32 20)
%6 = call i32 @printArray(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32 20)
ret i32 0
}