#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ merge_sort(int *, int);
int /*<<< orphan*/ printf(char *, int);
int readnum();
int main() {
  int length = readnum();
  int *arr;
  arr = malloc(sizeof(int) * length);
  for (int i = 0; i < length; i++) {
    arr[i] = readnum();
  }
  merge_sort(arr, length);
  for (int i = 0; i < length; i++) {
    printf("%d ", arr[i]);
  }
  free(arr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <readnum@plt>
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <main+0x61>
mov    $0x0,%al
call   1040 <readnum@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <main+0x33>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <merge_sort@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f5 <main+0xa5>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe1e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c4 <main+0x74>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <readnum@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    11c7 <main+0x77>
mov    %r14d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <readnum@plt>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <main+0x30>
mov    %r15,%rdi
mov    %r14d,%esi
call   1070 <merge_sort@plt>
test   %r14d,%r14d
jle    11d2 <main+0x82>
xor    %ebx,%ebx
lea    0xe53(%rip),%r14
nopl   (%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <main+0x60>
jmp    11d2 <main+0x82>
mov    %r15,%rdi
mov    %r14d,%esi
call   1070 <merge_sort@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @readnum()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = mul i64 4, %8
%10 = trunc i64 %9 to i32
%11 = call i32* @malloc(i32 %10)
store i32* %11, i32** %3
store i32 0, i32* %4
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i32 (...) @readnum()
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
%26 = load i32*, i32** %3
%27 = load i32, i32* %2
%28 = call i32 @merge_sort(i32* %26, i32 %27)
store i32 0, i32* %5
br label %29
29: ; preds = %40, %25
%30 = load i32, i32* %5
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %43
33: ; preds = %29
%34 = load i32*, i32** %3
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %29
43: ; preds = %29
%44 = load i32*, i32** %3
%45 = call i32 @free(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = tail call i32 (...) @readnum()
%2 = shl i32 %1, 2
%3 = tail call i32* @malloc(i32 %2)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @merge_sort(i32* %3, i32 %1)
br label %19
7: ; preds = %0
%8 = zext i32 %1 to i64
br label %13
9: ; preds = %13
%10 = tail call i32 @merge_sort(i32* %3, i32 %1)
br i1 %4, label %11, label %19
11: ; preds = %9
%12 = zext i32 %1 to i64
br label %21
13: ; preds = %7, %13
%14 = phi i64 [ 0, %7 ], [ %17, %13 ]
%15 = tail call i32 (...) @readnum()
%16 = getelementptr inbounds i32, i32* %3, i64 %14
store i32 %15, i32* %16
%17 = add nuw nsw i64 %14, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %9, label %13
19: ; preds = %21, %5, %9
%20 = tail call i32 @free(i32* %3)
ret i32 0
21: ; preds = %11, %21
%22 = phi i64 [ 0, %11 ], [ %26, %21 ]
%23 = getelementptr inbounds i32, i32* %3, i64 %22
%24 = load i32, i32* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %12
br i1 %27, label %19, label %21
}