#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);
void merge_sort(int numbers[], int len) {
  if (len <= 1)
    return;
  int mid = len / 2;
  merge_sort(numbers + 0, mid);
  merge_sort(numbers + mid, len - mid);
  _merge(numbers + 0, mid, numbers + mid, len - mid);
}


x86 assembly (clang, -O0):
<merge_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jg     113e <merge_sort+0x1e>
jmp    1193 <merge_sort+0x73>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <merge_sort@plt>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
call   1040 <merge_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
call   1030 <_merge@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_sort>:
cmp    $0x1,%esi
jg     1126 <merge_sort+0x6>
ret
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%r15d
shr    %r15d
mov    %r15d,%esi
call   1040 <merge_sort@plt>
lea    (%r14,%r15,4),%r12
sub    %r15d,%ebx
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <merge_sort@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %ebx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <_merge@plt>

LLVM IR (-O0):
define void @merge_sort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp sle i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %2
br label %33
9: ; preds = %2
%10 = load i32, i32* %4
%11 = sdiv i32 %10, 2
store i32 %11, i32* %5
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %5
%15 = load i32*, i32** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = sub nsw i32 %19, %20
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32, i32* %5
%25 = load i32*, i32** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = sub nsw i32 %29, %30
%32 = call i32 @_merge(i32* %23, i32 %24, i32* %28, i32 %31)
br label %33
33: ; preds = %9, %8
ret void
}

LLVM IR (-O2):
define void @merge_sort(i32* %0, i32 %1) {
%3 = icmp slt i32 %1, 2
br i1 %3, label %4, label %5
4: ; preds = %2, %5
ret void
5: ; preds = %2
%6 = lshr i32 %1, 1
tail call void @merge_sort(i32* %0, i32 %6)
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = sub nsw i32 %1, %6
tail call void @merge_sort(i32* %8, i32 %9)
%10 = tail call i32 @_merge(i32* %0, i32 %6, i32* %8, i32 %9)
br label %4
}