#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 *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ system(char *);
void Mergesort(int p, int r, int v[]) {
  if (p < r - 1) {
    int q = (p + r) / 2;
    printf("Mergesort(%2d, %2d, v)\n", p, q);
    printf("Mergesort(%2d, %2d, v)\n", q, r);
    system("pause");
    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    11d4 <Mergesort+0x94>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe79(%rip),%rdi
call   1040 <system@plt>
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   1060 <Intercala@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mergesort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
lea    -0x1(%r15),%eax
cmp    %edi,%eax
jle    11c1 <Mergesort+0x81>
mov    %rdx,%r14
mov    %edi,%ebx
lea    (%r15,%rbx,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
lea    0xe94(%rip),%r12
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1050 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1040 <system@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14,%rdx
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
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <Intercala@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Mergesort(%2d, %2d, v)\0A\00"
@.str.1 = [6 x i8] c"pause\00"
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 %35
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 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %7
%21 = load i32, i32* %5
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
%23 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = load i32*, i32** %6
%27 = load i32, i32* %7
%28 = load i32, i32* %5
%29 = load i32*, i32** %6
%30 = load i32, i32* %4
%31 = load i32, i32* %7
%32 = load i32, i32* %5
%33 = load i32*, i32** %6
%34 = call i32 @Intercala(i32 %30, i32 %31, i32 %32, i32* %33)
br label %35
35: ; preds = %12, %3
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Mergesort(%2d, %2d, v)\0A\00"
@.str.1 = [6 x i8] c"pause\00"
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
%10 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %1)
%12 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
tail call void @Mergesort(i32 %0, i32 %9, i32* %2)
tail call void @Mergesort(i32 %9, i32 %1, i32* %2)
%13 = tail call i32 @Intercala(i32 %0, i32 %9, i32 %1, i32* %2)
br label %6
}