#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_Split(int *, int /*<<< orphan*/, int, int *, int);
void MergeSort(int *p, int size, int round) {
  int i, arr[size];
  for (i = 0; i < size; i++)
    arr[i] = p[i];
  MergeSort_Split(arr, 0, size - 1, p, size);
}


x86 assembly (clang, -O0):
<MergeSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1180 <MergeSort+0x70>
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <MergeSort+0x40>
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%r8d
xor    %esi,%esi
call   1030 <MergeSort_Split@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MergeSort>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
mov    %esi,%edx
mov    %rsp,%rbx
lea    0xf(,%rdx,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
test   %esi,%esi
jle    115a <MergeSort+0x3a>
shl    $0x2,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <memcpy@plt>
lea    -0x1(%r15),%edx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rcx
mov    %r15d,%r8d
call   1040 <MergeSort_Split@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @MergeSort(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %8
%13 = alloca i32, i64 %11
store i64 %11, i64* %9
store i32 0, i32* %7
br label %14
14: ; preds = %27, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %13, i64 %25
store i32 %23, i32* %26
br label %27
27: ; preds = %18
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %14
30: ; preds = %14
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = load i32*, i32** %4
%34 = load i32, i32* %5
%35 = call i32 @MergeSort_Split(i32* %13, i32 0, i32 %32, i32* %33, i32 %34)
%36 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
define void @MergeSort(i32* %0, i32 %1, i32 %2) {
%4 = zext i32 %1 to i64
%5 = alloca i32, i64 %4
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %0 to i8*
%10 = shl nuw nsw i64 %4, 2
br label %11
11: ; preds = %7, %3
%12 = add nsw i32 %1, -1
%13 = call i32 @MergeSort_Split(i32* %5, i32 0, i32 %12, i32* %0, i32 %1)
ret void
}