#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 */
struct array {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ array_merge(struct array *, struct array *, size_t, size_t,
                               size_t);
int /*<<< orphan*/ array_print(struct array *);
void array_msort(struct array *a, struct array *aux, size_t lo, size_t hi) {
  size_t mid;
  if (hi <= lo)
    return;
  mid = lo + (hi - lo) / 2;
  array_msort(a, aux, lo, mid);
  array_msort(a, aux, mid + 1, hi);
  array_merge(a, aux, lo, mid, hi);
  array_print(a);
}


x86 assembly (clang, -O0):
<array_msort>:
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
cmp    -0x18(%rbp),%rax
ja     115b <array_msort+0x2b>
jmp    11c2 <array_msort+0x92>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    -0x18(%rbp),%rcx
shr    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <array_msort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
add    $0x1,%rdx
mov    -0x20(%rbp),%rcx
call   1050 <array_msort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1040 <array_merge@plt>
mov    -0x8(%rbp),%rdi
call   1030 <array_print@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_msort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbp
sub    %rdx,%rbp
jbe    119e <array_msort+0x6e>
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r15
shr    %rbp
lea    (%rdx,%rbp,1),%r13
mov    %r13,%rcx
call   1050 <array_msort@plt>
lea    (%rbx,%rbp,1),%rdx
add    $0x1,%rdx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rcx
call   1050 <array_msort@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1040 <array_merge@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <array_print@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.array = type { i32 }
define void @array_msort(%struct.array* %0, %struct.array* %1, i64 %2, i64 %3) {
%5 = icmp ugt i64 %3, %2
br i1 %5, label %7, label %6
6: ; preds = %4, %7
ret void
7: ; preds = %4
%8 = sub i64 %3, %2
%9 = lshr i64 %8, 1
%10 = add i64 %9, %2
tail call void @array_msort(%struct.array* %0, %struct.array* %1, i64 %2, i64 %10)
%11 = add i64 %10, 1
tail call void @array_msort(%struct.array* %0, %struct.array* %1, i64 %11, i64 %3)
%12 = tail call i32 @array_merge(%struct.array* %0, %struct.array* %1, i64 %2, i64 %10, i64 %3)
%13 = tail call i32 @array_print(%struct.array* %0)
br label %6
}