#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*/ merge(long *, long, long, long, long);
void mergeSort(long list[], long low, long high, long n) {
  long mid;
  if (low < high) {
    mid = (low + high) / 2;
    mergeSort(list, low, mid, n);
    mergeSort(list, mid + 1, high, n);
    merge(list, low, mid, high, n);
  }
}


x86 assembly (clang, -O0):
<mergeSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11a3 <mergeSort+0x83>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <mergeSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <mergeSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1040 <merge@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergeSort>:
cmp    %rdx,%rsi
jge    1182 <mergeSort+0x62>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
lea    (%rdx,%rsi,1),%rax
mov    %rax,%rbx
shr    $0x3f,%rbx
add    %rax,%rbx
sar    %rbx
mov    %rbx,%rdx
call   1030 <mergeSort@plt>
lea    0x1(%rbx),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <mergeSort@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <merge@plt>
ret

LLVM IR (-O0):
define void @mergeSort(i64* %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i64* %0, i64** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %6
%11 = load i64, i64* %7
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %33
13: ; preds = %4
%14 = load i64, i64* %6
%15 = load i64, i64* %7
%16 = add nsw i64 %14, %15
%17 = sdiv i64 %16, 2
store i64 %17, i64* %9
%18 = load i64*, i64** %5
%19 = load i64, i64* %6
%20 = load i64, i64* %9
%21 = load i64, i64* %8
%22 = load i64*, i64** %5
%23 = load i64, i64* %9
%24 = add nsw i64 %23, 1
%25 = load i64, i64* %7
%26 = load i64, i64* %8
%27 = load i64*, i64** %5
%28 = load i64, i64* %6
%29 = load i64, i64* %9
%30 = load i64, i64* %7
%31 = load i64, i64* %8
%32 = call i32 @merge(i64* %27, i64 %28, i64 %29, i64 %30, i64 %31)
br label %33
33: ; preds = %13, %4
ret void
}

LLVM IR (-O2):
define void @mergeSort(i64* %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp slt i64 %1, %2
br i1 %5, label %7, label %6
6: ; preds = %4, %7
ret void
7: ; preds = %4
%8 = add nsw i64 %2, %1
%9 = sdiv i64 %8, 2
tail call void @mergeSort(i64* %0, i64 %1, i64 %9, i64 %3)
%10 = add nsw i64 %9, 1
tail call void @mergeSort(i64* %0, i64 %10, i64 %2, i64 %3)
%11 = tail call i32 @merge(i64* %0, i64 %1, i64 %9, i64 %2, i64 %3)
br label %6
}