#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*/ printf(char *, ...);
void split(int arr[], int start, int end, char *type) {
  if (start < end) {
    int mid = (start + end) / 2;
    printf("------------------------\n");
    printf("MID ----> %d\n", mid);
    printf("TYPE ---> %s\n\n", type);
    printf("------------------------\n\n");
    split(arr, start, mid, "Left Function");
    split(arr, mid + 1, end, "Right Function");
    merge(arr, start, mid, end);
  } else
    return;
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e8 <split+0xb8>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe9f(%rip),%rcx
call   1040 <split@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
lea    0xe94(%rip),%rcx
call   1040 <split@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1050 <merge@plt>
jmp    11ed <split+0xbd>
jmp    11ed <split+0xbd>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
cmp    %edx,%esi
jge    11e5 <split+0xa5>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r13
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    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%rcx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1050 <split@plt>
lea    0x1(%rbx),%esi
lea    0xe6a(%rip),%rcx
mov    %r15,%rdi
mov    %r14d,%edx
call   1050 <split@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <merge@plt>
ret

LLVM IR (-O0):
@.str = [26 x i8] c"------------------------\0A\00"
@.str.1 = [14 x i8] c"MID ----> %d\0A\00"
@.str.2 = [15 x i8] c"TYPE ---> %s\0A\0A\00"
@.str.3 = [27 x i8] c"------------------------\0A\0A\00"
@.str.4 = [14 x i8] c"Left Function\00"
@.str.5 = [15 x i8] c"Right Function\00"
define void @split(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %36
13: ; preds = %4
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = add nsw i32 %14, %15
%17 = sdiv i32 %16, 2
store i32 %17, i32* %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %9
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i8*, i8** %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32*, i32** %5
%25 = load i32, i32* %6
%26 = load i32, i32* %9
%27 = load i32*, i32** %5
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
%30 = load i32, i32* %7
%31 = load i32*, i32** %5
%32 = load i32, i32* %6
%33 = load i32, i32* %9
%34 = load i32, i32* %7
%35 = call i32 @merge(i32* %31, i32 %32, i32 %33, i32 %34)
br label %37
36: ; preds = %4
br label %37
37: ; preds = %36, %13
ret void
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"MID ----> %d\0A\00"
@.str.2 = [15 x i8] c"TYPE ---> %s\0A\0A\00"
@.str.4 = [14 x i8] c"Left Function\00"
@.str.5 = [15 x i8] c"Right Function\00"
@str = [25 x i8] c"------------------------\00"
@str.6 = [26 x i8] c"------------------------\0A\00"
define void @split(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = icmp slt i32 %1, %2
br i1 %5, label %7, label %6
6: ; preds = %4, %7
ret void
7: ; preds = %4
%8 = add nsw i32 %2, %1
%9 = sdiv i32 %8, 2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
tail call void @split(i32* %0, i32 %1, i32 %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%14 = add nsw i32 %9, 1
tail call void @split(i32* %0, i32 %14, i32 %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32 @merge(i32* %0, i32 %1, i32 %9, i32 %2)
br label %6
}