#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 floor(int);
int /*<<< orphan*/ merge(unsigned long *, int, int, int);
void merge_sort(long unsigned *A, int e, int d) {
  int q;
  if (e < d) {
    q = floor((e + d) / 2);
    merge_sort(A, e, q);
    merge_sort(A, q + 1, d);
    merge(A, e, q, d);
  }
}


x86 assembly (clang, -O0):
<merge_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1199 <merge_sort+0x69>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <floor@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <merge_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <merge_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_sort>:
cmp    %edx,%esi
jge    1190 <merge_sort+0x60>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%r15
lea    (%r14,%rbx,1),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
call   1050 <floor@plt>
mov    %eax,%r12d
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <merge_sort@plt>
lea    0x1(%r12),%esi
mov    %r15,%rdi
mov    %r14d,%edx
call   1040 <merge_sort@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <merge@plt>
ret

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

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