#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(int, int, int, int (*)(int, int), int *, int *);
void Mergesortd(int p, int q, int (*CFun)(int, int), int *order, int *t) {
  int m;
  m = (p + q) / 2;
  if (p < m)
    Mergesortd(p, m, CFun, order, t);
  if (m + 1 < q)
    Mergesortd(m + 1, q, CFun, order, t);
  Merge(p, m, q, CFun, order, t);
}


x86 assembly (clang, -O0):
<Mergesortd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    116e <Mergesortd+0x4e>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1030 <Mergesortd@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    1197 <Mergesortd+0x77>
mov    -0x24(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1030 <Mergesortd@plt>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
call   1040 <Merge@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mergesortd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %esi,%r13d
mov    %edi,%ebx
lea    (%rbx,%r13,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
cmp    %edi,%ebp
jle    115c <Mergesortd+0x3c>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <Mergesortd@plt>
lea    0x1(%rbp),%edi
cmp    %r13d,%edi
jge    1175 <Mergesortd+0x55>
mov    %r13d,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <Mergesortd@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <Merge@plt>

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

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