#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*/ displaySubArray(int *, int, int);
int /*<<< orphan*/ merge(int *, int, int, int, int);
int /*<<< orphan*/ printf(char *);
void sortSubArray(int array[], int low, int high) {
  int middle1, middle2;
  if ((high - low) >= 1) {
    middle1 = (low + high) / 2;
    middle2 = middle1 + 1;
    printf("split:   ");
    displaySubArray(array, low, high);
    printf("\n         ");
    displaySubArray(array, low, middle1);
    printf("\n         ");
    displaySubArray(array, middle2, high);
    printf("\n\n");
    sortSubArray(array, low, middle1);
    sortSubArray(array, middle2, high);
    merge(array, low, middle1, middle2, high);
  }
}


x86 assembly (clang, -O0):
<sortSubArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x1,%eax
jl     120c <sortSubArray+0xcc>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <displaySubArray@plt>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <displaySubArray@plt>
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <displaySubArray@plt>
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <sortSubArray@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <sortSubArray@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%r8d
call   1050 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sortSubArray>:
cmp    %esi,%edx
jle    120d <sortSubArray+0xbd>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
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    0x1(%rbx),%ebp
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1070 <displaySubArray@plt>
lea    0xe6d(%rip),%r13
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1070 <displaySubArray@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1070 <displaySubArray@plt>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1040 <sortSubArray@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <sortSubArray@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <merge@plt>
ret

LLVM IR (-O0):
@.str = [10 x i8] c"split: \00"
@.str.1 = [11 x i8] c"\0A \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define void @sortSubArray(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = load i32, i32* %5
%11 = sub nsw i32 %9, %10
%12 = icmp sge i32 %11, 1
br i1 %12, label %13, label %48
13: ; preds = %3
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = add nsw i32 %14, %15
%17 = sdiv i32 %16, 2
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %8
%20 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%21 = load i32*, i32** %4
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 @displaySubArray(i32* %21, i32 %22, i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32*, i32** %4
%27 = load i32, i32* %5
%28 = load i32, i32* %7
%29 = call i32 @displaySubArray(i32* %26, i32 %27, i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32*, i32** %4
%32 = load i32, i32* %8
%33 = load i32, i32* %6
%34 = call i32 @displaySubArray(i32* %31, i32 %32, i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32*, i32** %4
%37 = load i32, i32* %5
%38 = load i32, i32* %7
%39 = load i32*, i32** %4
%40 = load i32, i32* %8
%41 = load i32, i32* %6
%42 = load i32*, i32** %4
%43 = load i32, i32* %5
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = load i32, i32* %6
%47 = call i32 @merge(i32* %42, i32 %43, i32 %44, i32 %45, i32 %46)
br label %48
48: ; preds = %13, %3
ret void
}

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