#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicks(int *, int, int);
int /*<<< orphan*/ simples(int *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fp;
  int i, j, num;
  int n[50000];
  if (argc < 2) {
    fprintf(stderr, "Arguments\n");
    return -1;
  }
  fp = fopen(argv[1], "r");
  if (fp == NULL) {
    fprintf(stderr, "CAN NOT OPEN\n");
    return -1;
  }
  for (j = 0; j < 50000 && (fscanf(fp, "%d", &i) != EOF); j++)
    n[j] = i;
  fclose(fp);
  i = 0;
  if (j <= 5) {
    simples(n, j);
    printf("Use simple sort\n");
  } else {
    quicks(n, i, j - 1);
    printf("Use quick sort\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30d80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b4 <main+0x44>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cc <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f8 <main+0x88>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cc <main+0x15c>
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0xc350,-0x20(%rbp)
mov    %al,-0x30d71(%rbp)
jge    123b <main+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xdfc(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <fscanf@plt>
mov    0x2db9(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
mov    %al,-0x30d71(%rbp)
mov    -0x30d71(%rbp),%al
test   $0x1,%al
jne    124e <main+0xde>
jmp    126a <main+0xfa>
mov    -0x1c(%rbp),%ecx
movslq -0x20(%rbp),%rax
mov    %ecx,-0x30d70(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ff <main+0x8f>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x20(%rbp)
jg     12a4 <main+0x134>
lea    -0x30d70(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <simples@plt>
lea    0xd84(%rip),%rdi
call   1050 <printf@plt>
jmp    12c5 <main+0x155>
lea    -0x30d70(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
sub    $0x1,%edx
call   1080 <quicks@plt>
lea    0xd6f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30d80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30d50,%rsp
cmp    $0x1,%edi
jg     1199 <main+0x29>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
jmp    1220 <main+0xb0>
mov    0x8(%rsi),%rdi
lea    0xe67(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1210 <main+0xa0>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xe61(%rip),%r15
lea    0xc(%rsp),%r12
mov    0x2e22(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
cmp    0x0(%rbp),%rax
je     122c <main+0xbc>
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0xc350,%rbx
jne    11d0 <main+0x60>
mov    %r14,%rdi
call   1050 <fclose@plt>
movl   $0x0,0xc(%rsp)
mov    $0xc350,%ebx
jmp    125d <main+0xed>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    127c <main+0x10c>
mov    %r14,%rdi
call   1050 <fclose@plt>
movl   $0x0,0xc(%rsp)
cmp    $0x6,%ebx
jae    125d <main+0xed>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1030 <simples@plt>
lea    0xdd9(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
jmp    127c <main+0x10c>
add    $0xffffffff,%ebx
lea    0x10(%rsp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    %ebx,%edx
call   1080 <quicks@plt>
lea    0xda7(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x30d50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"Arguments\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"CAN NOT OPEN\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.4 = [17 x i8] c"Use simple sort\0A\00"
@.str.5 = [16 x i8] c"Use quick sort\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 i32
%10 = alloca [50000 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %63
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %63
26: ; preds = %16
store i32 0, i32* %8
br label %27
27: ; preds = %42, %26
%28 = load i32, i32* %8
%29 = icmp slt i32 %28, 50000
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32*, i32** %6
%32 = call i64 @fscanf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%33 = load i64, i64* @EOF
%34 = icmp ne i64 %32, %33
br label %35
35: ; preds = %30, %27
%36 = phi i1 [ false, %27 ], [ %34, %30 ]
br i1 %36, label %37, label %45
37: ; preds = %35
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [50000 x i32], [50000 x i32]* %10, i64 0, i64 %40
store i32 %38, i32* %41
br label %42
42: ; preds = %37
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %27
45: ; preds = %35
%46 = load i32*, i32** %6
%47 = call i32 @fclose(i32* %46)
store i32 0, i32* %7
%48 = load i32, i32* %8
%49 = icmp sle i32 %48, 5
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = getelementptr inbounds [50000 x i32], [50000 x i32]* %10, i64 0, i64 0
%52 = load i32, i32* %8
%53 = call i32 @simples(i32* %51, i32 %52)
%54 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %62
55: ; preds = %45
%56 = getelementptr inbounds [50000 x i32], [50000 x i32]* %10, i64 0, i64 0
%57 = load i32, i32* %7
%58 = load i32, i32* %8
%59 = sub nsw i32 %58, 1
%60 = call i32 @quicks(i32* %56, i32 %57, i32 %59)
%61 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %55, %50
store i32 0, i32* %3
br label %63
63: ; preds = %62, %23, %13
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"Arguments\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"CAN NOT OPEN\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@EOF = global i64 0
@str = [15 x i8] c"Use quick sort\00"
@str.6 = [16 x i8] c"Use simple sort\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [50000 x i32]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [50000 x i32]* %4 to i8*
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %45
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %45
19: ; preds = %26
%20 = call i32 @fclose(i32* %14)
store i32 0, i32* %3
br label %39
21: ; preds = %11, %26
%22 = phi i64 [ %29, %26 ], [ 0, %11 ]
%23 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%24 = load i64, i64* @EOF
%25 = icmp eq i64 %23, %24
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = load i32, i32* %3
%28 = getelementptr inbounds [50000 x i32], [50000 x i32]* %4, i64 0, i64 %22
store i32 %27, i32* %28
%29 = add nuw nsw i64 %22, 1
%30 = icmp eq i64 %29, 50000
br i1 %30, label %19, label %21
31: ; preds = %21
%32 = trunc i64 %22 to i32
%33 = call i32 @fclose(i32* %14)
store i32 0, i32* %3
%34 = icmp ult i32 %32, 6
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = getelementptr inbounds [50000 x i32], [50000 x i32]* %4, i64 0, i64 0
%37 = call i32 @simples(i32* %36, i32 %32)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
br label %45
39: ; preds = %19, %31
%40 = phi i32 [ 50000, %19 ], [ %32, %31 ]
%41 = getelementptr inbounds [50000 x i32], [50000 x i32]* %4, i64 0, i64 0
%42 = add nsw i32 %40, -1
%43 = call i32 @quicks(i32* %41, i32 0, i32 %42)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %45
45: ; preds = %35, %39, %16, %8
%46 = phi i32 [ -1, %8 ], [ -1, %16 ], [ 0, %39 ], [ 0, %35 ]
ret i32 %46
}