#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*/ result;
typedef int /*<<< orphan*/ output;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ arr3;
typedef int /*<<< orphan*/ arr2;
typedef int /*<<< orphan*/ arr;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ merge2i(int *, int, int *, int, int *);
int /*<<< orphan*/ mergei(int *, int /*<<< orphan*/, int, int, int *);
int /*<<< orphan*/ mergei_v2(int *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printvinl(int *, int);
int /*<<< orphan*/ simple_top_down_merge_sorti(int *, int);
int /*<<< orphan*/ simple_top_down_merge_sorti_v2(int *, int);
int main() {
  int arr[] = {3, 4, 5, -1, 0, 1};
  int arr2[] = {5, 4, 3, 1, 0, -1};
  int arr3[] = {5, 4, 3, 1, 0, -1, 99, 72, 42, 2};
  int output[(sizeof(arr) / sizeof(arr[0]))];
  int a[] = {3, 4, 5, 6};
  int b[] = {2, 3, 7, 9};
  int result[(sizeof(a) / sizeof(a[0])) + (sizeof(b) / sizeof(b[0]))];
  mergei(arr, 0, (sizeof(arr) / sizeof(arr[0])) / 2,
         (sizeof(arr) / sizeof(arr[0])), output);
  printvinl(output, (sizeof(output) / sizeof(output[0])));
  merge2i(a, (sizeof(a) / sizeof(a[0])), b, (sizeof(b) / sizeof(b[0])), result);
  printvinl(result, (sizeof(result) / sizeof(result[0])));
  merge2i(a, (sizeof(a) / sizeof(a[0])), b, 0, result);
  printvinl(result, (sizeof(a) / sizeof(a[0])));
  merge2i(a, 0, b, (sizeof(b) / sizeof(b[0])), result);
  printvinl(result, (sizeof(b) / sizeof(b[0])));
  simple_top_down_merge_sorti(arr2, (sizeof(arr2) / sizeof(arr2[0])));
  printvinl(arr2, (sizeof(arr2) / sizeof(arr2[0])));
  mergei_v2(arr, 0, (sizeof(arr) / sizeof(arr[0])) / 2,
            (sizeof(arr) / sizeof(arr[0])));
  printvinl(arr, (sizeof(arr) / sizeof(arr[0])));
  simple_top_down_merge_sorti_v2(arr3, (sizeof(arr3) / sizeof(arr3[0])));
  printvinl(arr3, (sizeof(arr3) / sizeof(arr3[0])));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe74(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe71(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe76(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe73(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
mov    0xe90(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe7e(%rip),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%r8
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x6,%ecx
call   1040 <mergei@plt>
lea    -0x90(%rbp),%rdi
mov    $0x6,%esi
call   1080 <printvinl@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    -0xd0(%rbp),%r8
mov    $0x4,%ecx
mov    %ecx,%esi
call   1070 <merge2i@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x8,%esi
call   1080 <printvinl@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    -0xd0(%rbp),%r8
mov    $0x4,%esi
xor    %ecx,%ecx
call   1070 <merge2i@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x4,%esi
call   1080 <printvinl@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    -0xd0(%rbp),%r8
xor    %esi,%esi
mov    $0x4,%ecx
call   1070 <merge2i@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x4,%esi
call   1080 <printvinl@plt>
lea    -0x40(%rbp),%rdi
mov    $0x6,%esi
call   1060 <simple_top_down_merge_sorti@plt>
lea    -0x40(%rbp),%rdi
mov    $0x6,%esi
call   1080 <printvinl@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x6,%ecx
call   1090 <mergei_v2@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1080 <printvinl@plt>
lea    -0x70(%rbp),%rdi
mov    $0xa,%esi
call   1030 <simple_top_down_merge_sorti_v2@plt>
lea    -0x70(%rbp),%rdi
mov    $0xa,%esi
call   1080 <printvinl@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    0xe9b(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    0xea3(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xe87(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xebb(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe80(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x40(%rsp),%r14
lea    0x90(%rsp),%rbx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x6,%ecx
mov    %rbx,%r8
call   1040 <mergei@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <printvinl@plt>
lea    0x10(%rsp),%r12
mov    %rsp,%r15
lea    0xb0(%rsp),%rbx
mov    %r12,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    $0x4,%ecx
mov    %rbx,%r8
call   1060 <merge2i@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1070 <printvinl@plt>
mov    %r12,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1060 <merge2i@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <printvinl@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    %r15,%rdx
mov    $0x4,%ecx
mov    %rbx,%r8
call   1060 <merge2i@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <printvinl@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1050 <simple_top_down_merge_sorti@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <printvinl@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x6,%ecx
call   1080 <mergei_v2@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1070 <printvinl@plt>
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <simple_top_down_merge_sorti_v2@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <printvinl@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.arr = [6 x i32] [i32 3, i32 4, i32 5, i32 -1, i32 0, i32 1]
@__const.main.arr2 = [6 x i32] [i32 5, i32 4, i32 3, i32 1, i32 0, i32 -1]
@__const.main.arr3 = [10 x i32] [i32 5, i32 4, i32 3, i32 1, i32 0, i32 -1, i32 99, i32 72, i32 42, i32 2]
@__const.main.a = [4 x i32] [i32 3, i32 4, i32 5, i32 6]
@__const.main.b = [4 x i32] [i32 2, i32 3, i32 7, i32 9]
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i32]
%3 = alloca [6 x i32]
%4 = alloca [10 x i32]
%5 = alloca [6 x i32]
%6 = alloca [4 x i32]
%7 = alloca [4 x i32]
%8 = alloca [8 x i32]
store i32 0, i32* %1
%9 = bitcast [6 x i32]* %2 to i8*
%10 = bitcast [6 x i32]* %3 to i8*
%11 = bitcast [10 x i32]* %4 to i8*
%12 = bitcast [4 x i32]* %6 to i8*
%13 = bitcast [4 x i32]* %7 to i8*
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%16 = call i32 @mergei(i32* %14, i32 0, i32 3, i32 6, i32* %15)
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%18 = call i32 @printvinl(i32* %17, i32 6)
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%22 = call i32 @merge2i(i32* %19, i32 4, i32* %20, i32 4, i32* %21)
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%24 = call i32 @printvinl(i32* %23, i32 8)
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%28 = call i32 @merge2i(i32* %25, i32 4, i32* %26, i32 0, i32* %27)
%29 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%30 = call i32 @printvinl(i32* %29, i32 4)
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%33 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%34 = call i32 @merge2i(i32* %31, i32 0, i32* %32, i32 4, i32* %33)
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%36 = call i32 @printvinl(i32* %35, i32 4)
%37 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%38 = call i32 @simple_top_down_merge_sorti(i32* %37, i32 6)
%39 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%40 = call i32 @printvinl(i32* %39, i32 6)
%41 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%42 = call i32 @mergei_v2(i32* %41, i32 0, i32 3, i32 6)
%43 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%44 = call i32 @printvinl(i32* %43, i32 6)
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%46 = call i32 @simple_top_down_merge_sorti_v2(i32* %45, i32 10)
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%48 = call i32 @printvinl(i32* %47, i32 10)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [6 x i32] [i32 3, i32 4, i32 5, i32 -1, i32 0, i32 1]
@__const.main.arr2 = [6 x i32] [i32 5, i32 4, i32 3, i32 1, i32 0, i32 -1]
@__const.main.arr3 = [10 x i32] [i32 5, i32 4, i32 3, i32 1, i32 0, i32 -1, i32 99, i32 72, i32 42, i32 2]
@__const.main.a = [4 x i32] [i32 3, i32 4, i32 5, i32 6]
@__const.main.b = [4 x i32] [i32 2, i32 3, i32 7, i32 9]
define i32 @main() {
%1 = alloca [6 x i32]
%2 = alloca [6 x i32]
%3 = alloca [10 x i32]
%4 = alloca [6 x i32]
%5 = alloca [4 x i32]
%6 = alloca [4 x i32]
%7 = alloca [8 x i32]
%8 = bitcast [6 x i32]* %1 to i8*
%9 = bitcast [6 x i32]* %2 to i8*
%10 = bitcast [10 x i32]* %3 to i8*
%11 = bitcast [6 x i32]* %4 to i8*
%12 = bitcast [4 x i32]* %5 to i8*
%13 = bitcast [4 x i32]* %6 to i8*
%14 = bitcast [8 x i32]* %7 to i8*
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%17 = call i32 @mergei(i32* %15, i32 0, i32 3, i32 6, i32* %16)
%18 = call i32 @printvinl(i32* %16, i32 6)
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%22 = call i32 @merge2i(i32* %19, i32 4, i32* %20, i32 4, i32* %21)
%23 = call i32 @printvinl(i32* %21, i32 8)
%24 = call i32 @merge2i(i32* %19, i32 4, i32* %20, i32 0, i32* %21)
%25 = call i32 @printvinl(i32* %21, i32 4)
%26 = call i32 @merge2i(i32* %19, i32 0, i32* %20, i32 4, i32* %21)
%27 = call i32 @printvinl(i32* %21, i32 4)
%28 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%29 = call i32 @simple_top_down_merge_sorti(i32* %28, i32 6)
%30 = call i32 @printvinl(i32* %28, i32 6)
%31 = call i32 @mergei_v2(i32* %15, i32 0, i32 3, i32 6)
%32 = call i32 @printvinl(i32* %15, i32 6)
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%34 = call i32 @simple_top_down_merge_sorti_v2(i32* %33, i32 10)
%35 = call i32 @printvinl(i32* %33, i32 10)
ret i32 0
}