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

/* Variables and functions */
int /*<<< orphan*/ array_copy(int *, int *, int);
int /*<<< orphan*/ array_inc(int *, int);
int /*<<< orphan*/ array_println(int /*<<< orphan*/ *, int *, int);
int /*<<< orphan*/ array_rand(int *, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ array_shuffle(int *, int);
scalar_t__ clock();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ help();
int /*<<< orphan*/ printf(char *, scalar_t__);
int /*<<< orphan*/ sort_bubble(int *, int);
int /*<<< orphan*/ sort_bucket(int *, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ sort_comb(int *, int);
int /*<<< orphan*/ sort_insert(int *, int);
int /*<<< orphan*/ sort_quick(int *, int);
int /*<<< orphan*/ sort_select(int *, int);
int /*<<< orphan*/ sort_shaker(int *, int);
int /*<<< orphan*/ sort_shell(int *, int);
int /*<<< orphan*/ srand(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  clock_t t0, t;
  FILE *fp = stdout;
  int i, out = 0, shuffle = 0;
  int arr[4096] = {0};
  int arr_sorted[4096] = {0};
  for (i = 1; i < argc; ++i) {
    if (strcmp(argv[i], "-h") == 0) {
      help();
      goto END_MAIN;
    } else if (strcmp(argv[i], "-o") == 0) {
      out = 1;
      ++i;
      if (i >= argc)
        break;
      fp = fopen(argv[i], "a");
      if (!fp) {
        fprintf(stderr, "can't open %s\n", argv[i]);
        return -1;
      }
    } else if (strcmp(argv[i], "-s") == 0) {
      shuffle = 1;
    }
  }
  srand(clock());
  if (shuffle) {
    array_inc(arr, 4096);
    array_shuffle(arr, 4096);
  } else {
    array_rand(arr, 4096, 0, 4096);
  }
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_bubble(arr_sorted, 4096);
  t = clock();
  printf("bubble: "
         "%8lu usec"
         "\n",
         (t - t0));
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_shaker(arr_sorted, 4096);
  t = clock();
  printf("shaker: "
         "%8lu usec"
         "\n",
         (t - t0));
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_comb(arr_sorted, 4096);
  t = clock();
  printf("com   : "
         "%8lu usec"
         "\n",
         (t - t0));
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_select(arr_sorted, 4096);
  t = clock();
  printf("select: "
         "%8lu usec"
         "\n",
         (t - t0));
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_insert(arr_sorted, 4096);
  t = clock();
  printf("insert: "
         "%8lu usec"
         "\n",
         (t - t0));
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_shell(arr_sorted, 4096);
  t = clock();
  printf("shell : "
         "%8lu usec"
         "\n",
         (t - t0));
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_quick(arr_sorted, 4096);
  t = clock();
  printf("quick : "
         "%8lu usec"
         "\n",
         (t - t0));
  array_copy(arr_sorted, arr, 4096);
  t0 = clock();
  sort_bucket(arr_sorted, 4096, 0, 4096);
  t = clock();
  printf("bucket: "
         "%8lu usec"
         "\n",
         (t - t0));
  if (out) {
    array_println(fp, arr, 4096);
    fprintf(fp, "\n");
    array_println(fp, arr_sorted, 4096);
    fprintf(fp, "\n");
  }
END_MAIN:
  if (fp != stdout)
    fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x4040(%rbp),%rdi
xor    %esi,%esi
mov    $0x4000,%edx
call   10d0 <memset@plt>
lea    -0x8040(%rbp),%rdi
xor    %esi,%esi
mov    $0x4000,%edx
call   10d0 <memset@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13e1 <main+0x181>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd1f(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    12fc <main+0x9c>
mov    $0x0,%al
call   1150 <help@plt>
jmp    172f <main+0x4cf>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcf4(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    139b <main+0x13b>
movl   $0x1,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     133f <main+0xdf>
jmp    13e1 <main+0x181>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcb4(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1396 <main+0x136>
mov    0x2c73(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc85(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1753 <main+0x4f3>
jmp    13c9 <main+0x169>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc69(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    13c4 <main+0x164>
movl   $0x1,-0x34(%rbp)
jmp    13c9 <main+0x169>
jmp    13ce <main+0x16e>
jmp    13d3 <main+0x173>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12c2 <main+0x62>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,%rdi
call   1100 <srand@plt>
cmpl   $0x0,-0x34(%rbp)
je     1421 <main+0x1c1>
lea    -0x4040(%rbp),%rdi
mov    $0x1000,%esi
call   1040 <array_inc@plt>
lea    -0x4040(%rbp),%rdi
mov    $0x1000,%esi
call   1180 <array_shuffle@plt>
jmp    1436 <main+0x1d6>
lea    -0x4040(%rbp),%rdi
mov    $0x1000,%ecx
xor    %edx,%edx
mov    %ecx,%esi
call   1090 <array_rand@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%esi
call   1050 <sort_bubble@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xb96(%rip),%rdi
call   10c0 <printf@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%esi
call   1130 <sort_shaker@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xb56(%rip),%rdi
call   10c0 <printf@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%esi
call   1030 <sort_comb@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xb16(%rip),%rdi
call   10c0 <printf@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%esi
call   10e0 <sort_select@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xad6(%rip),%rdi
call   10c0 <printf@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%esi
call   10b0 <sort_insert@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xa96(%rip),%rdi
call   10c0 <printf@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%esi
call   1060 <sort_shell@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xa56(%rip),%rdi
call   10c0 <printf@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%esi
call   1080 <sort_quick@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xa16(%rip),%rdi
call   10c0 <printf@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8040(%rbp),%rdi
mov    $0x1000,%ecx
xor    %edx,%edx
mov    %ecx,%esi
call   1160 <sort_bucket@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0x9d2(%rip),%rdi
call   10c0 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
je     172a <main+0x4ca>
mov    -0x28(%rbp),%rdi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   1170 <array_println@plt>
mov    -0x28(%rbp),%rdi
lea    0x955(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x8040(%rbp),%rsi
mov    $0x1000,%edx
call   1170 <array_println@plt>
mov    -0x28(%rbp),%rdi
lea    0x92e(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
jmp    172f <main+0x4cf>
mov    -0x28(%rbp),%rax
mov    0x289e(%rip),%rcx
cmp    (%rcx),%rax
je     174c <main+0x4ec>
mov    -0x28(%rbp),%rdi
call   10a0 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8018,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    0x2d4a(%rip),%rax
mov    (%rax),%rbp
lea    0x10(%rsp),%rdi
xor    %r13d,%r13d
mov    $0x4000,%edx
xor    %esi,%esi
call   10d0 <memset@plt>
lea    0x4010(%rsp),%rdi
mov    $0x4000,%edx
xor    %esi,%esi
call   10d0 <memset@plt>
cmp    $0x2,%r14d
mov    %rbp,0x8(%rsp)
jl     136b <main+0xfb>
xor    %r13d,%r13d
xor    %ebp,%ebp
mov    $0x1,%r12d
jmp    1305 <main+0x95>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%r15,8),%rdi
lea    0xd2c(%rip),%rsi
call   1120 <strcmp@plt>
test   %rax,%rax
mov    $0x1,%eax
cmove  %eax,%r13d
add    $0x1,%r12d
cmp    %r14d,%r12d
jge    136d <main+0xfd>
movslq %r12d,%r15
mov    (%rbx,%r15,8),%rdi
lea    0xced(%rip),%rsi
call   1120 <strcmp@plt>
test   %rax,%rax
je     1644 <main+0x3d4>
mov    (%rbx,%r15,8),%rdi
lea    0xcd7(%rip),%rsi
call   1120 <strcmp@plt>
test   %rax,%rax
jne    12e0 <main+0x70>
add    $0x1,%r12d
cmp    %r14d,%r12d
jge    1659 <main+0x3e9>
movslq %r12d,%rbp
mov    (%rbx,%rbp,8),%rdi
lea    0xcb5(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1663 <main+0x3f3>
mov    $0x1,%ebp
jmp    12fc <main+0x8c>
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rdi
call   1110 <srand@plt>
mov    %ebp,%r12d
test   %r13d,%r13d
je     13a5 <main+0x135>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1040 <array_inc@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1190 <array_shuffle@plt>
jmp    13bb <main+0x14b>
lea    0x10(%rsp),%rdi
mov    $0x1000,%esi
xor    %edx,%edx
mov    $0x1000,%ecx
call   1090 <array_rand@plt>
mov    0x8(%rsp),%rbp
lea    0x4010(%rsp),%r14
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
call   1050 <sort_bubble@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xc15(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
call   1140 <sort_shaker@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xbe8(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
call   1030 <sort_comb@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xbbb(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
call   10e0 <sort_select@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xb8e(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
call   10b0 <sort_insert@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xb61(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
call   1060 <sort_shell@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xb34(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
call   1080 <sort_quick@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xb07(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   10f0 <array_copy@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1000,%esi
xor    %edx,%edx
mov    $0x1000,%ecx
call   1170 <sort_bucket@plt>
xor    %eax,%eax
call   1070 <clock@plt>
sub    %rbx,%rax
lea    0xad3(%rip),%rdi
mov    %rax,%rsi
call   10c0 <printf@plt>
test   %r12d,%r12d
je     161a <main+0x3aa>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x1000,%edx
call   1180 <array_println@plt>
mov    $0xa,%edi
mov    %rbp,%rsi
call   1100 <fputc@plt>
lea    0x4010(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x1000,%edx
call   1180 <array_println@plt>
mov    $0xa,%edi
mov    %rbp,%rsi
call   1100 <fputc@plt>
mov    0x29b7(%rip),%rax
xor    %ebx,%ebx
cmp    (%rax),%rbp
je     1630 <main+0x3c0>
mov    %rbp,%rdi
call   10a0 <fclose@plt>
mov    %ebx,%eax
add    $0x8018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1160 <help@plt>
mov    0x2986(%rip),%rax
mov    0x8(%rsp),%rbp
jmp    1621 <main+0x3b1>
mov    $0x1,%ebp
jmp    136d <main+0xfd>
mov    0x2976(%rip),%rax
movslq (%rax),%rdi
mov    (%rbx,%rbp,8),%rdx
lea    0x990(%rip),%rsi
xor    %eax,%eax
call   1130 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    1630 <main+0x3c0>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [3 x i8] c"-h\00"
@.str.1 = [3 x i8] c"-o\00"
@.str.2 = [2 x i8] c"a\00"
@stderr = global i32 0
@.str.3 = [15 x i8] c"can't open %s\0A\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [19 x i8] c"bubble: %8lu usec\0A\00"
@.str.6 = [19 x i8] c"shaker: %8lu usec\0A\00"
@.str.7 = [19 x i8] c"com : %8lu usec\0A\00"
@.str.8 = [19 x i8] c"select: %8lu usec\0A\00"
@.str.9 = [19 x i8] c"insert: %8lu usec\0A\00"
@.str.10 = [19 x i8] c"shell : %8lu usec\0A\00"
@.str.11 = [19 x i8] c"quick : %8lu usec\0A\00"
@.str.12 = [19 x i8] c"bucket: %8lu usec\0A\00"
@.str.13 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4096 x i32]
%13 = alloca [4096 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32*, i32** @stdout
store i32* %14, i32** %8
store i32 0, i32* %10
store i32 0, i32* %11
%15 = bitcast [4096 x i32]* %12 to i8*
%16 = bitcast [4096 x i32]* %13 to i8*
store i32 1, i32* %9
br label %17
17: ; preds = %78, %2
%18 = load i32, i32* %9
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %81
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = call i32 (...) @help()
br label %197
31: ; preds = %21
%32 = load i8**, i8*** %5
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %66
39: ; preds = %31
store i32 1, i32* %10
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
%42 = load i32, i32* %9
%43 = load i32, i32* %4
%44 = icmp sge i32 %42, %43
br i1 %44, label %45, label %46
45: ; preds = %39
br label %81
46: ; preds = %39
%47 = load i8**, i8*** %5
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %52, i32** %8
%53 = load i32*, i32** %8
%54 = icmp ne i32* %53, null
br i1 %54, label %65, label %55
55: ; preds = %46
%56 = load i32, i32* @stderr
%57 = sext i32 %56 to i64
%58 = inttoptr i64 %57 to i32*
%59 = load i8**, i8*** %5
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %63)
store i32 -1, i32* %3
br label %205
65: ; preds = %46
br label %76
66: ; preds = %31
%67 = load i8**, i8*** %5
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = call i64 @strcmp(i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %66
store i32 1, i32* %11
br label %75
75: ; preds = %74, %66
br label %76
76: ; preds = %75, %65
br label %77
77: ; preds = %76
br label %78
78: ; preds = %77
%79 = load i32, i32* %9
%80 = add nsw i32 %79, 1
store i32 %80, i32* %9
br label %17
81: ; preds = %45, %17
%82 = call i64 (...) @clock()
%83 = call i32 @srand(i64 %82)
%84 = load i32, i32* %11
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %91
86: ; preds = %81
%87 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%88 = call i32 @array_inc(i32* %87, i32 4096)
%89 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%90 = call i32 @array_shuffle(i32* %89, i32 4096)
br label %94
91: ; preds = %81
%92 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%93 = call i32 @array_rand(i32* %92, i32 4096, i32 0, i32 4096)
br label %94
94: ; preds = %91, %86
%95 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%96 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%97 = call i32 @array_copy(i32* %95, i32* %96, i32 4096)
%98 = call i64 (...) @clock()
store i64 %98, i64* %6
%99 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%100 = call i32 @sort_bubble(i32* %99, i32 4096)
%101 = call i64 (...) @clock()
store i64 %101, i64* %7
%102 = load i64, i64* %7
%103 = load i64, i64* %6
%104 = sub nsw i64 %102, %103
%105 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i64 %104)
%106 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%107 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%108 = call i32 @array_copy(i32* %106, i32* %107, i32 4096)
%109 = call i64 (...) @clock()
store i64 %109, i64* %6
%110 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%111 = call i32 @sort_shaker(i32* %110, i32 4096)
%112 = call i64 (...) @clock()
store i64 %112, i64* %7
%113 = load i64, i64* %7
%114 = load i64, i64* %6
%115 = sub nsw i64 %113, %114
%116 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i64 %115)
%117 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%118 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%119 = call i32 @array_copy(i32* %117, i32* %118, i32 4096)
%120 = call i64 (...) @clock()
store i64 %120, i64* %6
%121 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%122 = call i32 @sort_comb(i32* %121, i32 4096)
%123 = call i64 (...) @clock()
store i64 %123, i64* %7
%124 = load i64, i64* %7
%125 = load i64, i64* %6
%126 = sub nsw i64 %124, %125
%127 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i64 %126)
%128 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%129 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%130 = call i32 @array_copy(i32* %128, i32* %129, i32 4096)
%131 = call i64 (...) @clock()
store i64 %131, i64* %6
%132 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%133 = call i32 @sort_select(i32* %132, i32 4096)
%134 = call i64 (...) @clock()
store i64 %134, i64* %7
%135 = load i64, i64* %7
%136 = load i64, i64* %6
%137 = sub nsw i64 %135, %136
%138 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i64 %137)
%139 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%140 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%141 = call i32 @array_copy(i32* %139, i32* %140, i32 4096)
%142 = call i64 (...) @clock()
store i64 %142, i64* %6
%143 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%144 = call i32 @sort_insert(i32* %143, i32 4096)
%145 = call i64 (...) @clock()
store i64 %145, i64* %7
%146 = load i64, i64* %7
%147 = load i64, i64* %6
%148 = sub nsw i64 %146, %147
%149 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i64 %148)
%150 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%151 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%152 = call i32 @array_copy(i32* %150, i32* %151, i32 4096)
%153 = call i64 (...) @clock()
store i64 %153, i64* %6
%154 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%155 = call i32 @sort_shell(i32* %154, i32 4096)
%156 = call i64 (...) @clock()
store i64 %156, i64* %7
%157 = load i64, i64* %7
%158 = load i64, i64* %6
%159 = sub nsw i64 %157, %158
%160 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i64 %159)
%161 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%162 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%163 = call i32 @array_copy(i32* %161, i32* %162, i32 4096)
%164 = call i64 (...) @clock()
store i64 %164, i64* %6
%165 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%166 = call i32 @sort_quick(i32* %165, i32 4096)
%167 = call i64 (...) @clock()
store i64 %167, i64* %7
%168 = load i64, i64* %7
%169 = load i64, i64* %6
%170 = sub nsw i64 %168, %169
%171 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i64 %170)
%172 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%173 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%174 = call i32 @array_copy(i32* %172, i32* %173, i32 4096)
%175 = call i64 (...) @clock()
store i64 %175, i64* %6
%176 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%177 = call i32 @sort_bucket(i32* %176, i32 4096, i32 0, i32 4096)
%178 = call i64 (...) @clock()
store i64 %178, i64* %7
%179 = load i64, i64* %7
%180 = load i64, i64* %6
%181 = sub nsw i64 %179, %180
%182 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i64 %181)
%183 = load i32, i32* %10
%184 = icmp ne i32 %183, 0
br i1 %184, label %185, label %196
185: ; preds = %94
%186 = load i32*, i32** %8
%187 = getelementptr inbounds [4096 x i32], [4096 x i32]* %12, i64 0, i64 0
%188 = call i32 @array_println(i32* %186, i32* %187, i32 4096)
%189 = load i32*, i32** %8
%190 = call i32 (i32*, i8*, ...) @fprintf(i32* %189, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%191 = load i32*, i32** %8
%192 = getelementptr inbounds [4096 x i32], [4096 x i32]* %13, i64 0, i64 0
%193 = call i32 @array_println(i32* %191, i32* %192, i32 4096)
%194 = load i32*, i32** %8
%195 = call i32 (i32*, i8*, ...) @fprintf(i32* %194, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %196
196: ; preds = %185, %94
br label %197
197: ; preds = %196, %29
%198 = load i32*, i32** %8
%199 = load i32*, i32** @stdout
%200 = icmp ne i32* %198, %199
br i1 %200, label %201, label %204
201: ; preds = %197
%202 = load i32*, i32** %8
%203 = call i32 @fclose(i32* %202)
br label %204
204: ; preds = %201, %197
store i32 0, i32* %3
br label %205
205: ; preds = %204, %55
%206 = load i32, i32* %3
ret i32 %206
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [3 x i8] c"-h\00"
@.str.1 = [3 x i8] c"-o\00"
@.str.2 = [2 x i8] c"a\00"
@stderr = global i32 0
@.str.3 = [15 x i8] c"can't open %s\0A\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [19 x i8] c"bubble: %8lu usec\0A\00"
@.str.6 = [19 x i8] c"shaker: %8lu usec\0A\00"
@.str.7 = [19 x i8] c"com : %8lu usec\0A\00"
@.str.8 = [19 x i8] c"select: %8lu usec\0A\00"
@.str.9 = [19 x i8] c"insert: %8lu usec\0A\00"
@.str.10 = [19 x i8] c"shell : %8lu usec\0A\00"
@.str.11 = [19 x i8] c"quick : %8lu usec\0A\00"
@.str.12 = [19 x i8] c"bucket: %8lu usec\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i32]
%4 = alloca [4096 x i32]
%5 = load i32*, i32** @stdout
%6 = bitcast [4096 x i32]* %3 to i8*
%7 = bitcast [4096 x i32]* %4 to i8*
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %53
9: ; preds = %2, %46
%10 = phi i32 [ %50, %46 ], [ 0, %2 ]
%11 = phi i32 [ %49, %46 ], [ 0, %2 ]
%12 = phi i32 [ %51, %46 ], [ 1, %2 ]
%13 = phi i32* [ %47, %46 ], [ %5, %2 ]
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %9
%20 = tail call i32 (...) @help()
br label %123
21: ; preds = %9
%22 = load i8*, i8** %15
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %41
25: ; preds = %21
%26 = add nsw i32 %12, 1
%27 = icmp slt i32 %26, %0
br i1 %27, label %28, label %53
28: ; preds = %25
%29 = sext i32 %26 to i64
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
%32 = tail call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %46
34: ; preds = %28
%35 = getelementptr inbounds i8*, i8** %1, i64 %29
%36 = load i32, i32* @stderr
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = load i8*, i8** %35
%40 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %39)
br label %129
41: ; preds = %21
%42 = load i8*, i8** %15
%43 = tail call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
%45 = select i1 %44, i32 1, i32 %10
br label %46
46: ; preds = %41, %28
%47 = phi i32* [ %32, %28 ], [ %13, %41 ]
%48 = phi i32 [ %26, %28 ], [ %12, %41 ]
%49 = phi i32 [ 1, %28 ], [ %11, %41 ]
%50 = phi i32 [ %10, %28 ], [ %45, %41 ]
%51 = add nsw i32 %48, 1
%52 = icmp slt i32 %51, %0
br i1 %52, label %9, label %53
53: ; preds = %46, %25, %2
%54 = phi i32* [ %5, %2 ], [ %13, %25 ], [ %47, %46 ]
%55 = phi i32 [ 0, %2 ], [ %10, %25 ], [ %50, %46 ]
%56 = phi i32 [ 0, %2 ], [ 1, %25 ], [ %49, %46 ]
%57 = tail call i64 (...) @clock()
%58 = tail call i32 @srand(i64 %57)
%59 = icmp eq i32 %55, 0
%60 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 0
br i1 %59, label %64, label %61
61: ; preds = %53
%62 = call i32 @array_inc(i32* %60, i32 4096)
%63 = call i32 @array_shuffle(i32* %60, i32 4096)
br label %66
64: ; preds = %53
%65 = call i32 @array_rand(i32* %60, i32 4096, i32 0, i32 4096)
br label %66
66: ; preds = %64, %61
%67 = getelementptr inbounds [4096 x i32], [4096 x i32]* %4, i64 0, i64 0
%68 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 0
%69 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%70 = call i64 (...) @clock()
%71 = call i32 @sort_bubble(i32* %67, i32 4096)
%72 = call i64 (...) @clock()
%73 = sub nsw i64 %72, %70
%74 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i64 %73)
%75 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%76 = call i64 (...) @clock()
%77 = call i32 @sort_shaker(i32* %67, i32 4096)
%78 = call i64 (...) @clock()
%79 = sub nsw i64 %78, %76
%80 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i64 %79)
%81 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%82 = call i64 (...) @clock()
%83 = call i32 @sort_comb(i32* %67, i32 4096)
%84 = call i64 (...) @clock()
%85 = sub nsw i64 %84, %82
%86 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i64 %85)
%87 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%88 = call i64 (...) @clock()
%89 = call i32 @sort_select(i32* %67, i32 4096)
%90 = call i64 (...) @clock()
%91 = sub nsw i64 %90, %88
%92 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i64 %91)
%93 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%94 = call i64 (...) @clock()
%95 = call i32 @sort_insert(i32* %67, i32 4096)
%96 = call i64 (...) @clock()
%97 = sub nsw i64 %96, %94
%98 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i64 %97)
%99 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%100 = call i64 (...) @clock()
%101 = call i32 @sort_shell(i32* %67, i32 4096)
%102 = call i64 (...) @clock()
%103 = sub nsw i64 %102, %100
%104 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i64 %103)
%105 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%106 = call i64 (...) @clock()
%107 = call i32 @sort_quick(i32* %67, i32 4096)
%108 = call i64 (...) @clock()
%109 = sub nsw i64 %108, %106
%110 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i64 %109)
%111 = call i32 @array_copy(i32* %67, i32* %68, i32 4096)
%112 = call i64 (...) @clock()
%113 = call i32 @sort_bucket(i32* %67, i32 4096, i32 0, i32 4096)
%114 = call i64 (...) @clock()
%115 = sub nsw i64 %114, %112
%116 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i64 %115)
%117 = icmp eq i32 %56, 0
br i1 %117, label %123, label %118
118: ; preds = %66
%119 = call i32 @array_println(i32* %54, i32* %68, i32 4096)
%120 = call i32 @fputc(i32 10, i32* %54)
%121 = call i32 @array_println(i32* %54, i32* %67, i32 4096)
%122 = call i32 @fputc(i32 10, i32* %54)
br label %123
123: ; preds = %66, %118, %19
%124 = phi i32* [ %54, %66 ], [ %54, %118 ], [ %13, %19 ]
%125 = load i32*, i32** @stdout
%126 = icmp eq i32* %124, %125
br i1 %126, label %129, label %127
127: ; preds = %123
%128 = call i32 @fclose(i32* %124)
br label %129
129: ; preds = %123, %127, %34
%130 = phi i32 [ -1, %34 ], [ 0, %127 ], [ 0, %123 ]
ret i32 %130
}