#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*/ optimalSum(int *, int *, int, int, int);
void partition(int *arr, int n, int low, int high, int *brr) {
  if (low <= high) {
    if (low == high) {
      brr[low] = arr[low];
    } else {
      int m = low + (high - low) / 2;
      partition(arr, n, low, m, brr);
      partition(arr, n, m + 1, high, brr);
      optimalSum(arr, brr, low, m, high);
    }
  }
}


x86 assembly (clang, -O0):
<partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11d5 <partition+0xb5>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    116c <partition+0x4c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11d0 <partition+0xb0>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1040 <partition@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1040 <partition@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1030 <optimalSum@plt>
jmp    11d5 <partition+0xb5>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partition>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%eax
sub    %edx,%eax
jl     1146 <partition+0x26>
mov    %r8,%r14
mov    %ecx,%ebp
mov    %rdi,%r15
jne    1155 <partition+0x35>
movslq %ebp,%rax
mov    (%r15,%rax,4),%ecx
mov    %ecx,(%r14,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edx,%ebx
mov    %esi,%r12d
mov    %eax,%r13d
shr    $0x1f,%r13d
add    %eax,%r13d
sar    %r13d
lea    (%rbx,%r13,1),%ecx
mov    %ecx,0x4(%rsp)
mov    %r15,%rdi
mov    %r14,%r8
call   1040 <partition@plt>
lea    (%rbx,%r13,1),%edx
add    $0x1,%edx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebp,%ecx
mov    %r14,%r8
call   1040 <partition@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    0x4(%rsp),%ecx
mov    %ebp,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <optimalSum@plt>

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

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