#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quick_sort(int *, int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("\nERROR: Insufficient arguments!\n");
    exit(-1);
  }
  FILE *fp;
  fp = fopen(argv[1], "w");
  int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1};
  int n = sizeof a / sizeof a[0];
  int i;
  for (i = 0; i < n; i++) {
  }
  quick_sort(a, n);
  for (i = 0; i < n; i++) {
    fprintf(fp, "%d\n", a[i]);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11a6 <main+0x36>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
movl   $0xa,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1200 <main+0x90>
jmp    11f2 <main+0x82>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11e1 <main+0x71>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1070 <quick_sort@plt>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1245 <main+0xd5>
mov    -0x18(%rbp),%rdi
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xdf1(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1213 <main+0xa3>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jne    1261 <main+0x101>
mov    0x8(%rsi),%rdi
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    0xec6(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8e(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1060 <quick_sort@plt>
mov    (%rsp),%edx
lea    0xe45(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd9e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"\0AERROR: Insufficient arguments!\0A\00"
@.str.1 = [2 x i8] c"w\00"
@__const.main.a = [10 x i32] [i32 4, i32 65, i32 2, i32 -31, i32 0, i32 99, i32 2, i32 83, i32 782, i32 1]
@.str.2 = [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 [10 x 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 = icmp ne i32 %10, 2
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %6
%20 = bitcast [10 x i32]* %7 to i8*
store i32 10, i32* %8
store i32 0, i32* %9
br label %21
21: ; preds = %26, %15
%22 = load i32, i32* %9
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21
br label %26
26: ; preds = %25
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %21
29: ; preds = %21
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%31 = load i32, i32* %8
%32 = call i32 @quick_sort(i32* %30, i32 %31)
store i32 0, i32* %9
br label %33
33: ; preds = %44, %29
%34 = load i32, i32* %9
%35 = load i32, i32* %8
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load i32*, i32** %6
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 @fprintf(i32* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %37
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %33
47: ; preds = %33
%48 = load i32*, i32** %6
%49 = call i32 @fclose(i32* %48)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"w\00"
@__const.main.a = [10 x i32] [i32 4, i32 65, i32 2, i32 -31, i32 0, i32 99, i32 2, i32 83, i32 782, i32 1]
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [32 x i8] c"\0AERROR: Insufficient arguments!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i32]
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = bitcast [10 x i32]* %3 to i8*
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%14 = call i32 @quick_sort(i32* %13, i32 10)
%15 = load i32, i32* %13
%16 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
%18 = load i32, i32* %17
%19 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
%21 = load i32, i32* %20
%22 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
%24 = load i32, i32* %23
%25 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
%27 = load i32, i32* %26
%28 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
%30 = load i32, i32* %29
%31 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
%33 = load i32, i32* %32
%34 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 7
%36 = load i32, i32* %35
%37 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
%39 = load i32, i32* %38
%40 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
%42 = load i32, i32* %41
%43 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = call i32 @fclose(i32* %11)
ret i32 0
}