#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);
partition(int *arr, int strt, int end) {
  int med;
  if (strt < end) {
    med = (strt + end) / 2;
    partition(arr, strt, med);
    partition(arr, med + 1, end);
    merge(arr, strt, med, end);
  }
}


x86 assembly (clang, -O0):
<partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1182 <partition+0x62>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <partition@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%edx
call   1030 <partition@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <merge@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partition>:
cmp    %edx,%esi
jge    1172 <partition+0x52>
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
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
call   1040 <merge@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @partition(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** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %6
%10 = load i32, i32* %7
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %3
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = add nsw i32 %13, %14
%16 = sdiv i32 %15, 2
store i32 %16, i32* %8
%17 = load i32*, i32** %5
%18 = load i32, i32* %6
%19 = load i32, i32* %8
%20 = call i32 @partition(i32* %17, i32 %18, i32 %19)
%21 = load i32*, i32** %5
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
%24 = load i32, i32* %7
%25 = call i32 @partition(i32* %21, i32 %23, i32 %24)
%26 = load i32*, i32** %5
%27 = load i32, i32* %6
%28 = load i32, i32* %8
%29 = load i32, i32* %7
%30 = call i32 @merge(i32* %26, i32 %27, i32 %28, i32 %29)
br label %31
31: ; preds = %12, %3
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
define i32 @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 i32 undef
6: ; preds = %3
%7 = add nsw i32 %2, %1
%8 = sdiv i32 %7, 2
%9 = tail call i32 @partition(i32* %0, i32 %1, i32 %8)
%10 = add nsw i32 %8, 1
%11 = tail call i32 @partition(i32* %0, i32 %10, i32 %2)
%12 = tail call i32 @merge(i32* %0, i32 %1, i32 %8, i32 %2)
br label %5
}