#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 /*<<< orphan*/, int);
int /*<<< orphan*/ printarray(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int alist[15] = {2, 190, 10, -1, 29, 24, 3, 120, 31, 2, 0, 9, 21, 2, 65};
  int *lptr = alist;
  printf("\nBefore sorting array was: \n");
  printarray(lptr, 0, (int)(sizeof alist / sizeof *lptr) - 1);
  mergesort(lptr, 0, (int)(sizeof alist / sizeof *lptr) - 1);
  printf("\nAfter calling mergesort sort procedure \n");
  printarray(lptr, 0, (int)(sizeof alist / sizeof *lptr) - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x3c,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1050 <printarray@plt>
mov    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1060 <mergesort@plt>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1050 <printarray@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movups 0xef0(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1040 <printarray@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1050 <mergesort@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1040 <printarray@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.alist = [15 x i32] [i32 2, i32 190, i32 10, i32 -1, i32 29, i32 24, i32 3, i32 120, i32 31, i32 2, i32 0, i32 9, i32 21, i32 2, i32 65]
@.str = [29 x i8] c"\0ABefore sorting array was: \0A\00"
@.str.1 = [42 x i8] c"\0AAfter calling mergesort sort procedure \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i32]
%3 = alloca i32*
store i32 0, i32* %1
%4 = bitcast [15 x i32]* %2 to i8*
%5 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
store i32* %5, i32** %3
%6 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = load i32*, i32** %3
%8 = call i32 @printarray(i32* %7, i32 0, i32 14)
%9 = load i32*, i32** %3
%10 = call i32 @mergesort(i32* %9, i32 0, i32 14)
%11 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = call i32 @printarray(i32* %12, i32 0, i32 14)
ret i32 0
}

LLVM IR (-O2):
@__const.main.alist = [15 x i32] [i32 2, i32 190, i32 10, i32 -1, i32 29, i32 24, i32 3, i32 120, i32 31, i32 2, i32 0, i32 9, i32 21, i32 2, i32 65]
@str = [28 x i8] c"\0ABefore sorting array was: \00"
@str.2 = [41 x i8] c"\0AAfter calling mergesort sort procedure \00"
define i32 @main() {
%1 = alloca [15 x i32]
%2 = bitcast [15 x i32]* %1 to i8*
%3 = getelementptr inbounds [15 x i32], [15 x i32]* %1, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%5 = call i32 @printarray(i32* %3, i32 0, i32 14)
%6 = call i32 @mergesort(i32* %3, i32 0, i32 14)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.2, i64 0, i64 0))
%8 = call i32 @printarray(i32* %3, i32 0, i32 14)
ret i32 0
}