#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*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ quicksort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char const *argv[]) {
  srand(time(NULL));
  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");
  quicksort(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)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    $0x4,%esi
call   1080 <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    1203 <main+0x83>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <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    11c1 <main+0x41>
lea    0xdf6(%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    124c <main+0xcc>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdd7(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1216 <main+0x96>
lea    0xdc1(%rip),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x2,%edx
xor    %esi,%esi
call   1050 <quicksort@plt>
lea    0xda6(%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    12b2 <main+0x132>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd71(%rip),%rdi
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    127c <main+0xfc>
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,%r12
mov    %edi,%r14d
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    -0x1(%r14),%r15d
mov    %r15d,%edi
mov    $0x4,%esi
call   1080 <calloc@plt>
mov    %rax,%r13
cmp    $0x1,%r14d
jle    1228 <main+0xa8>
mov    %r15d,0x4(%rsp)
mov    %r15d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rbx),%r15
mov    0x8(%r12,%rbx,8),%rdi
call   10a0 <atoi@plt>
mov    %eax,0x0(%r13,%rbx,4)
mov    %r15,%rbx
cmp    %r15,%rbp
jne    11d0 <main+0x50>
lea    0xe0e(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%r14d
jl     1288 <main+0x108>
xor    %ebx,%ebx
lea    0xe06(%rip),%r12
mov    0x4(%rsp),%r15d
nop
mov    0x0(%r13,%rbx,4),%esi
mov    %r12,%rdi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1210 <main+0x90>
jmp    1234 <main+0xb4>
lea    0xdd1(%rip),%rdi
call   1040 <puts@plt>
lea    0xdd9(%rip),%rdi
call   1040 <puts@plt>
lea    -0x2(%r14),%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1050 <quicksort@plt>
lea    0xdc1(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%r14d
jl     12b1 <main+0x131>
mov    %r15d,%ebp
xor    %ebx,%ebx
lea    0xda4(%rip),%r14
nopl   0x0(%rax)
mov    0x0(%r13,%rbx,4),%esi
mov    %r14,%rdi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1270 <main+0xf0>
jmp    12b1 <main+0x131>
lea    0xd85(%rip),%rdi
call   1040 <puts@plt>
add    $0xfffffffe,%r14d
mov    %r13,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1050 <quicksort@plt>
lea    0xd6a(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%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 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = call i32* @calloc(i32 %13, i32 4)
store i32* %14, i32** %6
store i32 0, i32* %7
br label %15
15: ; preds = %32, %2
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %35
20: ; preds = %15
%21 = load i8**, i8*** %5
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
%28 = load i32*, i32** %6
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
store i32 %27, i32* %31
br label %32
32: ; preds = %20
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %15
35: ; preds = %15
%36 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %37
37: ; preds = %49, %35
%38 = load i32, i32* %8
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 1
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %52
42: ; preds = %37
%43 = load i32*, i32** %6
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %42
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %37
52: ; preds = %37
%53 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32*, i32** %6
%55 = load i32, i32* %4
%56 = sub nsw i32 %55, 2
%57 = call i32 @quicksort(i32* %54, i32 0, i32 %56)
%58 = 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 %59
59: ; preds = %71, %52
%60 = load i32, i32* %9
%61 = load i32, i32* %4
%62 = sub nsw i32 %61, 1
%63 = icmp slt i32 %60, %62
br i1 %63, label %64, label %74
64: ; preds = %59
%65 = load i32*, i32** %6
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
%69 = load i32, i32* %68
%70 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %64
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
br label %59
74: ; preds = %59
%75 = load i32*, i32** %6
%76 = call i32 @free(i32* %75)
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 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = add nsw i32 %0, -1
%6 = tail call i32* @calloc(i32 %5, i32 4)
%7 = icmp sgt i32 %0, 1
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %24
10: ; preds = %2
%11 = zext i32 %5 to i64
br label %16
12: ; preds = %16
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br i1 %7, label %14, label %38
14: ; preds = %12
%15 = zext i32 %5 to i64
br label %31
16: ; preds = %10, %16
%17 = phi i64 [ 0, %10 ], [ %18, %16 ]
%18 = add nuw nsw i64 %17, 1
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = getelementptr inbounds i32, i32* %6, i64 %17
store i32 %21, i32* %22
%23 = icmp eq i64 %18, %11
br i1 %23, label %12, label %16
24: ; preds = %31, %8
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = add nsw i32 %0, -2
%27 = tail call i32 @quicksort(i32* %6, i32 0, i32 %26)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br i1 %7, label %29, label %43
29: ; preds = %24
%30 = zext i32 %5 to i64
br label %45
31: ; preds = %14, %31
%32 = phi i64 [ 0, %14 ], [ %36, %31 ]
%33 = getelementptr inbounds i32, i32* %6, i64 %32
%34 = load i32, i32* %33
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = add nuw nsw i64 %32, 1
%37 = icmp eq i64 %36, %15
br i1 %37, label %24, label %31
38: ; preds = %12
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = add nsw i32 %0, -2
%41 = tail call i32 @quicksort(i32* %6, i32 0, i32 %40)
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %45, %38, %24
%44 = tail call i32 @free(i32* %6)
ret i32 0
45: ; preds = %29, %45
%46 = phi i64 [ 0, %29 ], [ %50, %45 ]
%47 = getelementptr inbounds i32, i32* %6, i64 %46
%48 = load i32, i32* %47
%49 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = add nuw nsw i64 %46, 1
%51 = icmp eq i64 %50, %30
br i1 %51, label %43, label %45
}