#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 merge_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int read_int();
int main(int argc, char **argv) {
  int nruns, size, i;
  int inarray[100001];
  nruns = read_int();
  while (nruns >= 1) {
    size = read_int();
    for (i = 0; i < size; i++)
      inarray[i] = read_int();
    printf("%d\n", merge_sort(inarray, 0, size - 1));
    nruns--;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61aa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <read_int@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11cc <main+0x9c>
mov    $0x0,%al
call   1040 <read_int@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119c <main+0x6c>
mov    $0x0,%al
call   1040 <read_int@plt>
mov    %eax,%ecx
movslq -0x1c(%rbp),%rax
mov    %ecx,-0x61aa0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <main+0x3e>
lea    -0x61aa0(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <merge_sort@plt>
mov    %eax,%esi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <main+0x23>
mov    -0x4(%rbp),%eax
add    $0x61aa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61a88,%rsp
xor    %eax,%eax
call   1040 <read_int@plt>
test   %eax,%eax
jle    11b5 <main+0x85>
mov    %eax,%r12d
mov    %rsp,%r14
lea    0xea7(%rip),%r15
jmp    1189 <main+0x59>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%r13d
mov    %r14,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   1050 <merge_sort@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    -0x1(%r12),%eax
cmp    $0x1,%r12d
mov    %eax,%r12d
jle    11b5 <main+0x85>
xor    %eax,%eax
call   1040 <read_int@plt>
mov    %eax,%r13d
test   %eax,%eax
jle    1160 <main+0x30>
mov    %r13d,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <read_int@plt>
mov    %eax,(%rsp,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11a0 <main+0x70>
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x61a88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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