#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 atoi(char const *);
int *calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ mergesort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(int argc, char const *argv[]) {
  int *nums = calloc(argc - 1, sizeof(int));
  for (int i = 0; i < argc - 1; i++)
    nums[i] = atoi(argv[i + 1]);
  puts("Your arguments:");
  for (int i = 0; i < argc - 1; i++)
    printf("%d ", nums[i]);
  puts("\n");
  mergesort(nums, 0, argc - 2);
  puts("Your arguments (sorted):");
  for (int i = 0; i < argc - 1; i++)
    printf("%d ", nums[i]);
  free(nums);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d3 <main+0x73>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1191 <main+0x31>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    121c <main+0xbc>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e6 <main+0x86>
lea    0xdf1(%rip),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x2,%edx
xor    %esi,%esi
call   1070 <mergesort@plt>
lea    0xdd6(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1282 <main+0x122>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xda1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124c <main+0xec>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r14d
lea    -0x1(%r14),%r15d
mov    %r15d,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%r12
cmp    $0x1,%r14d
jle    11f7 <main+0x97>
mov    %r15d,0x4(%rsp)
mov    %r15d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbp),%r15
mov    0x8(%r13,%rbp,8),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r12,%rbp,4)
mov    %r15,%rbp
cmp    %r15,%rbx
jne    11a0 <main+0x40>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%r14d
jl     1257 <main+0xf7>
xor    %ebp,%ebp
lea    0xe37(%rip),%r13
mov    0x4(%rsp),%r15d
xchg   %ax,%ax
mov    (%r12,%rbp,4),%esi
mov    %r13,%rdi
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11e0 <main+0x80>
jmp    1203 <main+0xa3>
lea    0xe02(%rip),%rdi
call   1040 <puts@plt>
lea    0xe0a(%rip),%rdi
call   1040 <puts@plt>
lea    -0x2(%r14),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1070 <mergesort@plt>
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%r14d
jl     1280 <main+0x120>
mov    %r15d,%ebx
xor    %ebp,%ebp
lea    0xdd5(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,4),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <main+0xe0>
jmp    1280 <main+0x120>
lea    0xdb6(%rip),%rdi
call   1040 <puts@plt>
add    $0xfffffffe,%r14d
mov    %r12,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1070 <mergesort@plt>
lea    0xd9b(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Your arguments:\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [25 x i8] c"Your arguments (sorted):\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 1
%12 = call i32* @calloc(i32 %11, i32 4)
store i32* %12, i32** %6
store i32 0, i32* %7
br label %13
13: ; preds = %30, %2
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 1
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %33
18: ; preds = %13
%19 = load i8**, i8*** %5
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %19, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
%26 = load i32*, i32** %6
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
br label %30
30: ; preds = %18
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %13
33: ; preds = %13
%34 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %35
35: ; preds = %47, %33
%36 = load i32, i32* %8
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = icmp slt i32 %36, %38
br i1 %39, label %40, label %50
40: ; preds = %35
%41 = load i32*, i32** %6
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %40
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %35
50: ; preds = %35
%51 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32*, i32** %6
%53 = load i32, i32* %4
%54 = sub nsw i32 %53, 2
%55 = call i32 @mergesort(i32* %52, i32 0, i32 %54)
%56 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %9
br label %57
57: ; preds = %69, %50
%58 = load i32, i32* %9
%59 = load i32, i32* %4
%60 = sub nsw i32 %59, 1
%61 = icmp slt i32 %58, %60
br i1 %61, label %62, label %72
62: ; preds = %57
%63 = load i32*, i32** %6
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %63, i64 %65
%67 = load i32, i32* %66
%68 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %62
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
br label %57
72: ; preds = %57
%73 = load i32*, i32** %6
%74 = call i32 @free(i32* %73)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Your arguments:\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [25 x i8] c"Your arguments (sorted):\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = tail call i32* @calloc(i32 %3, i32 4)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %22
8: ; preds = %2
%9 = zext i32 %3 to i64
br label %14
10: ; preds = %14
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br i1 %5, label %12, label %36
12: ; preds = %10
%13 = zext i32 %3 to i64
br label %29
14: ; preds = %8, %14
%15 = phi i64 [ 0, %8 ], [ %16, %14 ]
%16 = add nuw nsw i64 %15, 1
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = getelementptr inbounds i32, i32* %4, i64 %15
store i32 %19, i32* %20
%21 = icmp eq i64 %16, %9
br i1 %21, label %10, label %14
22: ; preds = %29, %6
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = add nsw i32 %0, -2
%25 = tail call i32 @mergesort(i32* %4, i32 0, i32 %24)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br i1 %5, label %27, label %41
27: ; preds = %22
%28 = zext i32 %3 to i64
br label %43
29: ; preds = %12, %29
%30 = phi i64 [ 0, %12 ], [ %34, %29 ]
%31 = getelementptr inbounds i32, i32* %4, i64 %30
%32 = load i32, i32* %31
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %30, 1
%35 = icmp eq i64 %34, %13
br i1 %35, label %22, label %29
36: ; preds = %10
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = add nsw i32 %0, -2
%39 = tail call i32 @mergesort(i32* %4, i32 0, i32 %38)
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %43, %36, %22
%42 = tail call i32 @free(i32* %4)
ret i32 0
43: ; preds = %27, %43
%44 = phi i64 [ 0, %27 ], [ %48, %43 ]
%45 = getelementptr inbounds i32, i32* %4, i64 %44
%46 = load i32, i32* %45
%47 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = add nuw nsw i64 %44, 1
%49 = icmp eq i64 %48, %28
br i1 %49, label %41, label %43
}