#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*/ Intercala(int, int, int, int *);
void Mergesort(int p, int r, int v[]) {
  if (p < r - 1) {
    int q = (p + r) / 2;
    Mergesort(p, q, v);
    Mergesort(q, r, v);
    Intercala(p, q, r, v);
  }
}


x86 assembly (clang, -O0):
<Mergesort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1184 <Mergesort+0x64>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <Mergesort@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <Mergesort@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1040 <Intercala@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mergesort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
lea    -0x1(%r15),%eax
cmp    %edi,%eax
jle    1171 <Mergesort+0x51>
mov    %rdx,%r14
mov    %edi,%ebx
lea    (%r15,%rbx,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %ebp,%esi
call   1030 <Mergesort@plt>
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <Mergesort@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <Intercala@plt>
add    $0x8,%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
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, 1
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %28
12: ; preds = %3
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = add nsw i32 %13, %14
%16 = sdiv i32 %15, 2
store i32 %16, i32* %7
%17 = load i32, i32* %4
%18 = load i32, i32* %7
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %5
%22 = load i32*, i32** %6
%23 = load i32, i32* %4
%24 = load i32, i32* %7
%25 = load i32, i32* %5
%26 = load i32*, i32** %6
%27 = call i32 @Intercala(i32 %23, i32 %24, i32 %25, i32* %26)
br label %28
28: ; preds = %12, %3
ret void
}

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