#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 /*<<< orphan*/ print_int_array(char *, int *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
void merge_sort_(int *unsorted, int p, int r) {
  char s[100];
  extern int n;
  sprintf(s, "P/Q/R :: %2.d/%2.d/%2.d\n", p, (p + r) / 2, r);
  print_int_array(s, unsorted, n);
  int q;
  if (p < r) {
    q = (p + r) / 2;
    merge_sort_(unsorted, p, q);
    merge_sort_(unsorted, q + 1, r);
    merge(unsorted, p, q, r);
  }
}


x86 assembly (clang, -O0):
<merge_sort_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x88(%rbp),%edx
mov    %eax,%ecx
mov    -0x10(%rbp),%r8d
lea    0xe7d(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
call   1060 <print_int_array@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11fa <merge_sort_+0xba>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x84(%rbp),%edx
call   1040 <merge_sort_@plt>
mov    -0x8(%rbp),%rdi
mov    -0x84(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <merge_sort_@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x84(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <merge@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_sort_>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%r15
lea    (%r14,%r12,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
lea    0xe96(%rip),%rsi
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r12d,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1050 <sprintf@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <print_int_array@plt>
cmp    %r14d,%r12d
jge    11c1 <merge_sort_+0x81>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1040 <merge_sort_@plt>
lea    0x1(%rbx),%esi
mov    %r15,%rdi
mov    %r14d,%edx
call   1040 <merge_sort_@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
call   1030 <merge@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"P/Q/R :: %2.d/%2.d/%2.d\0A\00"
@n = external global i32
define void @merge_sort_(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%10 = load i32, i32* %5
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = add nsw i32 %11, %12
%14 = sdiv i32 %13, 2
%15 = load i32, i32* %6
%16 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %14, i32 %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%18 = load i32*, i32** %4
%19 = load i32, i32* @n
%20 = call i32 @print_int_array(i8* %17, i32* %18, i32 %19)
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %41
24: ; preds = %3
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = add nsw i32 %25, %26
%28 = sdiv i32 %27, 2
store i32 %28, i32* %8
%29 = load i32*, i32** %4
%30 = load i32, i32* %5
%31 = load i32, i32* %8
%32 = load i32*, i32** %4
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %6
%36 = load i32*, i32** %4
%37 = load i32, i32* %5
%38 = load i32, i32* %8
%39 = load i32, i32* %6
%40 = call i32 @merge(i32* %36, i32 %37, i32 %38, i32 %39)
br label %41
41: ; preds = %24, %3
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"P/Q/R :: %2.d/%2.d/%2.d\0A\00"
@n = external global i32
define void @merge_sort_(i32* %0, i32 %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = add nsw i32 %2, %1
%7 = sdiv i32 %6, 2
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %7, i32 %2)
%9 = load i32, i32* @n
%10 = call i32 @print_int_array(i8* %5, i32* %0, i32 %9)
%11 = icmp slt i32 %1, %2
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = add nsw i32 %7, 1
%14 = call i32 @merge(i32* %0, i32 %1, i32 %7, i32 %2)
br label %15
15: ; preds = %12, %3
ret void
}