#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);
void MSort(int R[], int R1[], int s, int t) {
  int m;
  if (s == t)
    R1[s] = R[s];
  else {
    m = (s + t) / 2;
    MSort(R, R1, s, m);
    MSort(R, R1, m + 1, t);
    Merge(R1, R, s, m, t);
    Merge(R, R1, s, m, t);
  }
}


x86 assembly (clang, -O0):
<MSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    115d <MSort+0x3d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11c5 <MSort+0xa5>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <MSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%ecx
call   1030 <MSort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1040 <Merge@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1040 <Merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MSort>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%r12
cmp    %ecx,%edx
jne    114b <MSort+0x2b>
movslq %r13d,%rax
mov    (%r12,%rax,4),%ecx
mov    %ecx,(%r14,%rax,4)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %ecx,%r15d
lea    (%r15,%r13,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1030 <MSort@plt>
lea    0x1(%rbx),%edx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15d,%ecx
call   1030 <MSort@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r15d,%r8d
call   1040 <Merge@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r15d,%r8d
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <Merge@plt>

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

LLVM IR (-O2):
define void @MSort(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, %3
br i1 %5, label %6, label %12
6: ; preds = %4
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %1, i64 %7
store i32 %9, i32* %10
br label %11
11: ; preds = %6, %12
ret void
12: ; preds = %4
%13 = add nsw i32 %3, %2
%14 = sdiv i32 %13, 2
tail call void @MSort(i32* %0, i32* %1, i32 %2, i32 %14)
%15 = add nsw i32 %14, 1
tail call void @MSort(i32* %0, i32* %1, i32 %15, i32 %3)
%16 = tail call i32 @Merge(i32* %1, i32* %0, i32 %2, i32 %14, i32 %3)
%17 = tail call i32 @Merge(i32* %0, i32* %1, i32 %2, i32 %14, i32 %3)
br label %11
}