#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*/ copy_argv_to_array(int *, char **, int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ merge_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int len = 0;
  int *array = 0;
  if (argc < 2) {
    usage(argv[0]);
    return 1;
  }
  len = argc - 1;
  array = (int *)malloc(len * sizeof(int));
  copy_argv_to_array(array, &argv[1], len);
  merge_sort(array, 0, len - 1);
  print_array(array, len);
  free(array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a7 <main+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1204 <main+0xa4>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x14(%rbp),%edx
call   1070 <copy_argv_to_array@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1060 <merge_sort@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <print_array@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x1,%edi
jg     117f <main+0x1f>
mov    0x0(%rbp),%rdi
call   1080 <usage@plt>
mov    $0x1,%ebp
jmp    11ca <main+0x6a>
mov    %edi,%ebx
lea    -0x1(%rbx),%r14d
lea    -0x4(,%rbx,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
add    $0x8,%rbp
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1070 <copy_argv_to_array@plt>
add    $0xfffffffe,%ebx
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1060 <merge_sort@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <print_array@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32* null, i32** %7
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @usage(i8* %13)
store i32 1, i32* %3
br label %38
15: ; preds = %2
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 4
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i32, i32* %6
%28 = call i32 @copy_argv_to_array(i32* %24, i8** %26, i32 %27)
%29 = load i32*, i32** %7
%30 = load i32, i32* %6
%31 = sub nsw i32 %30, 1
%32 = call i32 @merge_sort(i32* %29, i32 0, i32 %31)
%33 = load i32*, i32** %7
%34 = load i32, i32* %6
%35 = call i32 @print_array(i32* %33, i32 %34)
%36 = load i32*, i32** %7
%37 = call i32 @free(i32* %36)
store i32 0, i32* %3
br label %38
38: ; preds = %15, %10
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %18
7: ; preds = %2
%8 = add nsw i32 %0, -1
%9 = shl i32 %8, 2
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = tail call i32 @copy_argv_to_array(i32* %11, i8** %12, i32 %8)
%14 = add nsw i32 %0, -2
%15 = tail call i32 @merge_sort(i32* %11, i32 0, i32 %14)
%16 = tail call i32 @print_array(i32* %11, i32 %8)
%17 = tail call i32 @free(i32* %11)
br label %18
18: ; preds = %7, %4
%19 = phi i32 [ 1, %4 ], [ 0, %7 ]
ret i32 %19
}