#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*/ mergeSort(int *, int, int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
void partition(int arr[], int low, int high) {
  int mid;
  if (low < high) {
    mid = (low + high) / 2;
    printf("part low = %d, mid = %d, high = %d\n", low, mid, high);
    partition(arr, low, mid);
    partition(arr, mid + 1, high);
    mergeSort(arr, low, mid, high);
  }
}


x86 assembly (clang, -O0):
<partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a7 <partition+0x77>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <partition@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <partition@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1050 <mergeSort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partition>:
cmp    %edx,%esi
jge    1199 <partition+0x69>
push   %r15
push   %r14
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    0xea7(%rip),%rdi
mov    %ebx,%edx
mov    %r14d,%ecx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1030 <partition@plt>
lea    0x1(%rbx),%esi
mov    %r15,%rdi
mov    %r14d,%edx
call   1030 <partition@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <mergeSort@plt>
ret

LLVM IR (-O0):
@.str = [36 x i8] c"part low = %d, mid = %d, high = %d\0A\00"
define void @partition(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* %5
%9 = load i32, i32* %6
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %3
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = add nsw i32 %12, %13
%15 = sdiv i32 %14, 2
store i32 %15, i32* %7
%16 = load i32, i32* %5
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i32 %18)
%20 = load i32*, i32** %4
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = load i32*, i32** %4
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %6
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = call i32 @mergeSort(i32* %27, i32 %28, i32 %29, i32 %30)
br label %32
32: ; preds = %11, %3
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"part low = %d, mid = %d, high = %d\0A\00"
define void @partition(i32* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, %2
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 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %8, i32 %2)
tail call void @partition(i32* %0, i32 %1, i32 %8)
%10 = add nsw i32 %8, 1
tail call void @partition(i32* %0, i32 %10, i32 %2)
%11 = tail call i32 @mergeSort(i32* %0, i32 %1, i32 %8, i32 %2)
br label %5
}