#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 */
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ merge(int /*<<< orphan*/ *, int /*<<< orphan*/ *, size_t,
                         size_t, size_t);
int /*<<< orphan*/ swap(int /*<<< orphan*/ **, int /*<<< orphan*/ **);
void split(int64_t *a, int64_t *b, size_t begin, size_t end) {
  if (end - begin < 2)
    return;
  swap(&a, &b);
  size_t mid = (begin + end) / 2;
#pragma omp parallel shared(a, b) firstprivate(begin, mid, end)
  {
#pragma omp sections
    {
#pragma omp section
      split(a, b, begin, mid);
#pragma omp section
      split(a, b, mid, end);
    }
  }
  merge(a, b, begin, mid, end);
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cmp    $0x2,%rax
jae    115f <split+0x2f>
jmp    11bf <split+0x8f>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <swap@plt>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <split@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <split@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1040 <merge@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
mov    %rsi,(%rsp)
mov    %rcx,%rax
sub    %rdx,%rax
cmp    $0x2,%rax
jb     11a7 <split+0x77>
mov    %rcx,%r14
mov    %rdx,%r15
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <swap@plt>
lea    (%r14,%r15,1),%rbx
shr    %rbx
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1030 <split@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <split@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1040 <merge@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @split(i32* %0, i32* %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %5
store i32* %1, i32** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %8
%11 = load i64, i64* %7
%12 = sub i64 %10, %11
%13 = icmp ult i64 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %4
br label %35
15: ; preds = %4
%16 = call i32 @swap(i32** %5, i32** %6)
%17 = load i64, i64* %7
%18 = load i64, i64* %8
%19 = add i64 %17, %18
%20 = udiv i64 %19, 2
store i64 %20, i64* %9
%21 = load i32*, i32** %5
%22 = load i32*, i32** %6
%23 = load i64, i64* %7
%24 = load i64, i64* %9
%25 = load i32*, i32** %5
%26 = load i32*, i32** %6
%27 = load i64, i64* %9
%28 = load i64, i64* %8
%29 = load i32*, i32** %5
%30 = load i32*, i32** %6
%31 = load i64, i64* %7
%32 = load i64, i64* %9
%33 = load i64, i64* %8
%34 = call i32 @merge(i32* %29, i32* %30, i64 %31, i64 %32, i64 %33)
br label %35
35: ; preds = %15, %14
ret void
}

LLVM IR (-O2):
define void @split(i32* %0, i32* %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
%7 = sub i64 %3, %2
%8 = icmp ult i64 %7, 2
br i1 %8, label %20, label %9
9: ; preds = %4
%10 = call i32 @swap(i32** %5, i32** %6)
%11 = add i64 %3, %2
%12 = lshr i64 %11, 1
%13 = load i32*, i32** %5
%14 = load i32*, i32** %6
%15 = load i32*, i32** %5
%16 = load i32*, i32** %6
%17 = load i32*, i32** %5
%18 = load i32*, i32** %6
%19 = call i32 @merge(i32* %17, i32* %18, i64 %2, i64 %12, i64 %3)
br label %20
20: ; preds = %4, %9
ret void
}