#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 /*<<< orphan*/ Rpermute_wKS(int *, int *, double *, int *, double *, int *,
                                int *, double *, double *, int *);
double abs(int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ permute_wKS(int, int *, double *, int, double *, int, int,
                               double *, double *, int *);
int /*<<< orphan*/ printf(char *, ...);
int time(int /*<<< orphan*/ *);
int /*<<< orphan*/ weighted_KS(int, int *, double *, int, double *, double *,
                               int *);
int main() {
  int n_gene = 12;
  int m = 3;
  double *r = (double *)malloc(n_gene * sizeof(double));
  double *w = (double *)malloc(n_gene * sizeof(double));
  int *g = (int *)malloc(m * sizeof(int));
  int *iwrk = (int *)malloc(n_gene * sizeof(int));
  double *res = (double *)malloc(2 * sizeof(double));
  double *rp = (double *)malloc(2 * sizeof(double));
  for (int i = 0; i < n_gene; i++) {
    r[i] = i + 1;
    w[i] = abs(i - (n_gene - 1) / 2) / (double)(n_gene - 1);
    w[i] = 1.0;
  }
  for (int i = 0; i < m; i++) {
    g[i] = 600 * i + 4;
  }
  g[0] = 0;
  g[1] = 2;
  g[2] = 3;
  g[0] = 1;
  g[1] = 3;
  g[2] = 5;
  weighted_KS(m, g, r, n_gene, w, res, iwrk);
  printf("KS pos: %f\n", res[0]);
  printf("KS neg: %f\n", res[1]);
  printf("=======================\n");
  int nperm = 10000;
  int seed = time(NULL);
  seed = 1;
  printf("======== standard interface ==========\n");
  permute_wKS(m, g, r, n_gene, w, nperm, seed, res, rp, iwrk);
  printf("KS pos: %f\n", res[0]);
  printf("KS neg: %f\n", res[1]);
  printf("p.value pos: %f\n", rp[0]);
  printf("p.value neg: %f\n", rp[1]);
  printf("======== R interface ==========\n");
  Rpermute_wKS(&m, g, r, &n_gene, w, &nperm, &seed, res, rp, iwrk);
  printf("KS pos: %f\n", res[0]);
  printf("KS neg: %f\n", res[1]);
  printf("p.value pos: %f\n", rp[0]);
  printf("p.value neg: %f\n", rp[1]);
  free(iwrk);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0xc,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x10,%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x10,%edi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1286 <main+0x106>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%edi
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%edi
call   1040 <abs@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  0xd8d(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    120d <main+0x8d>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12bc <main+0x13c>
imul   $0x258,-0x50(%rbp),%edx
add    $0x4,%edx
mov    -0x30(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    128d <main+0x10d>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x30(%rbp),%rax
movl   $0x3,0x8(%rax)
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x3,0x4(%rax)
mov    -0x30(%rbp),%rax
movl   $0x5,0x8(%rax)
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x40(%rbp),%r9
mov    -0x38(%rbp),%rax
mov    %rax,(%rsp)
call   1060 <weighted_KS@plt>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xcda(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
movsd  0x8(%rax),%xmm0
lea    0xccf(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2710,-0x54(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x58(%rbp)
movl   $0x1,-0x58(%rbp)
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x54(%rbp),%r9d
mov    -0x58(%rbp),%ebx
mov    -0x40(%rbp),%r11
mov    -0x48(%rbp),%r10
mov    -0x38(%rbp),%rax
mov    %ebx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1090 <permute_wKS@plt>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xc3b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
movsd  0x8(%rax),%xmm0
lea    0xc30(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xc67(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rax
movsd  0x8(%rax),%xmm0
lea    0xc61(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xc64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    -0x40(%rbp),%r11
mov    -0x48(%rbp),%r10
mov    -0x38(%rbp),%rax
lea    -0x14(%rbp),%rdi
lea    -0x10(%rbp),%rcx
lea    -0x54(%rbp),%r9
lea    -0x58(%rbp),%rbx
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   10a0 <Rpermute_wKS@plt>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xb93(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
movsd  0x8(%rax),%xmm0
lea    0xb88(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xbbf(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rax
movsd  0x8(%rax),%xmm0
lea    0xbb9(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0xc,0x10(%rsp)
movl   $0x3,0xc(%rsp)
mov    $0x60,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    $0x60,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    $0xc,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    $0x30,%edi
call   1090 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,0x28(%rsp)
movabs $0x3ff0000000000000,%r14
mov    %r14,(%r12)
mov    $0xfffffffb,%edi
call   1050 <abs@plt>
mov    %r14,0x0(%r13)
movabs $0x4000000000000000,%rax
mov    %rax,0x8(%r12)
mov    $0xfffffffc,%edi
call   1050 <abs@plt>
mov    %r14,0x8(%r13)
movabs $0x4008000000000000,%rax
mov    %rax,0x10(%r12)
mov    $0xfffffffd,%edi
call   1050 <abs@plt>
mov    %r14,0x10(%r13)
movabs $0x4010000000000000,%rax
mov    %rax,0x18(%r12)
mov    $0xfffffffe,%edi
call   1050 <abs@plt>
mov    %r14,0x18(%r13)
movabs $0x4014000000000000,%rax
mov    %rax,0x20(%r12)
mov    $0xffffffff,%edi
call   1050 <abs@plt>
mov    %r14,0x20(%r13)
movabs $0x4018000000000000,%rax
mov    %rax,0x28(%r12)
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <abs@plt>
mov    %r14,0x28(%r13)
movabs $0x401c000000000000,%rax
mov    %rax,0x30(%r12)
mov    $0x1,%edi
call   1050 <abs@plt>
mov    %r14,0x30(%r13)
movabs $0x4020000000000000,%rax
mov    %rax,0x38(%r12)
mov    $0x2,%edi
call   1050 <abs@plt>
mov    %r14,0x38(%r13)
movabs $0x4022000000000000,%rax
mov    %rax,0x40(%r12)
mov    $0x3,%edi
call   1050 <abs@plt>
mov    %r14,0x40(%r13)
movabs $0x4024000000000000,%rax
mov    %rax,0x48(%r12)
mov    $0x4,%ebp
mov    $0x4,%edi
call   1050 <abs@plt>
mov    %r14,0x48(%r13)
movabs $0x4026000000000000,%rax
mov    %rax,0x50(%r12)
mov    $0x5,%edi
call   1050 <abs@plt>
mov    %r14,0x50(%r13)
movabs $0x4028000000000000,%rax
mov    %rax,0x58(%r12)
mov    $0x6,%edi
call   1050 <abs@plt>
mov    %r14,0x58(%r13)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,(%r15,%rbx,4)
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x258,%ebp
cmp    %rax,%rbx
jl     1370 <main+0x1e0>
movabs $0x300000001,%rax
mov    %rax,(%r15)
movl   $0x5,0x8(%r15)
mov    0xc(%rsp),%ebx
mov    0x10(%rsp),%ecx
mov    %ecx,0x14(%rsp)
sub    $0x8,%rsp
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%r8
mov    0x28(%rsp),%rbp
mov    %rbp,%r9
mov    0x38(%rsp),%r14
push   %r14
call   1070 <weighted_KS@plt>
add    $0x10,%rsp
movsd  0x0(%rbp),%xmm0
lea    0xc24(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x8(%rbp),%xmm0
lea    0xc1d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xc3d(%rip),%rdi
call   1040 <puts@plt>
movl   $0x2710,0x1c(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
movl   $0x1,0x18(%rsp)
lea    0xc32(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
mov    0x14(%rsp),%ecx
mov    %r13,%r8
mov    $0x2710,%r9d
push   %r14
mov    0x30(%rsp),%rbx
push   %rbx
push   %rbp
push   $0x1
call   10a0 <permute_wKS@plt>
add    $0x20,%rsp
movsd  0x0(%rbp),%xmm0
lea    0xba6(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x8(%rbp),%xmm0
lea    0xb9f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  (%rbx),%xmm0
lea    0xb99(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x8(%rbx),%xmm0
lea    0xb97(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xbd9(%rip),%rdi
call   1040 <puts@plt>
lea    0x18(%rsp),%rax
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rcx
lea    0x1c(%rsp),%r9
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%r8
push   %r14
push   %rbx
push   %rbp
push   %rax
call   10b0 <Rpermute_wKS@plt>
add    $0x20,%rsp
movsd  0x0(%rbp),%xmm0
lea    0xb24(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x8(%rbp),%xmm0
lea    0xb1d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  (%rbx),%xmm0
lea    0xb17(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x8(%rbx),%xmm0
lea    0xb15(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"KS pos: %f\0A\00"
@.str.1 = [12 x i8] c"KS neg: %f\0A\00"
@.str.2 = [25 x i8] c"=======================\0A\00"
@.str.3 = [40 x i8] c"======== standard interface ==========\0A\00"
@.str.4 = [17 x i8] c"p.value pos: %f\0A\00"
@.str.5 = [17 x i8] c"p.value neg: %f\0A\00"
@.str.6 = [33 x i8] c"======== R interface ==========\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i32 12, i32* %2
store i32 3, i32* %3
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %4
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to double*
store double* %25, double** %5
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i32*
store i32* %31, i32** %6
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 4
%35 = trunc i64 %34 to i32
%36 = call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to i32*
store i32* %37, i32** %7
%38 = call i64 @malloc(i32 16)
%39 = inttoptr i64 %38 to double*
store double* %39, double** %8
%40 = call i64 @malloc(i32 16)
%41 = inttoptr i64 %40 to double*
store double* %41, double** %9
store i32 0, i32* %10
br label %42
42: ; preds = %72, %0
%43 = load i32, i32* %10
%44 = load i32, i32* %2
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %75
46: ; preds = %42
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
%49 = sitofp i32 %48 to double
%50 = load double*, double** %4
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
store double %49, double* %53
%54 = load i32, i32* %10
%55 = load i32, i32* %2
%56 = sub nsw i32 %55, 1
%57 = sdiv i32 %56, 2
%58 = sub nsw i32 %54, %57
%59 = call double @abs(i32 %58)
%60 = load i32, i32* %2
%61 = sub nsw i32 %60, 1
%62 = sitofp i32 %61 to double
%63 = fdiv double %59, %62
%64 = load double*, double** %5
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
store double %63, double* %67
%68 = load double*, double** %5
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double 1.000000e+00, double* %71
br label %72
72: ; preds = %46
%73 = load i32, i32* %10
%74 = add nsw i32 %73, 1
store i32 %74, i32* %10
br label %42
75: ; preds = %42
store i32 0, i32* %11
br label %76
76: ; preds = %88, %75
%77 = load i32, i32* %11
%78 = load i32, i32* %3
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %91
80: ; preds = %76
%81 = load i32, i32* %11
%82 = mul nsw i32 600, %81
%83 = add nsw i32 %82, 4
%84 = load i32*, i32** %6
%85 = load i32, i32* %11
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %84, i64 %86
store i32 %83, i32* %87
br label %88
88: ; preds = %80
%89 = load i32, i32* %11
%90 = add nsw i32 %89, 1
store i32 %90, i32* %11
br label %76
91: ; preds = %76
%92 = load i32*, i32** %6
%93 = getelementptr inbounds i32, i32* %92, i64 0
store i32 0, i32* %93
%94 = load i32*, i32** %6
%95 = getelementptr inbounds i32, i32* %94, i64 1
store i32 2, i32* %95
%96 = load i32*, i32** %6
%97 = getelementptr inbounds i32, i32* %96, i64 2
store i32 3, i32* %97
%98 = load i32*, i32** %6
%99 = getelementptr inbounds i32, i32* %98, i64 0
store i32 1, i32* %99
%100 = load i32*, i32** %6
%101 = getelementptr inbounds i32, i32* %100, i64 1
store i32 3, i32* %101
%102 = load i32*, i32** %6
%103 = getelementptr inbounds i32, i32* %102, i64 2
store i32 5, i32* %103
%104 = load i32, i32* %3
%105 = load i32*, i32** %6
%106 = load double*, double** %4
%107 = load i32, i32* %2
%108 = load double*, double** %5
%109 = load double*, double** %8
%110 = load i32*, i32** %7
%111 = call i32 @weighted_KS(i32 %104, i32* %105, double* %106, i32 %107, double* %108, double* %109, i32* %110)
%112 = load double*, double** %8
%113 = getelementptr inbounds double, double* %112, i64 0
%114 = load double, double* %113
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %114)
%116 = load double*, double** %8
%117 = getelementptr inbounds double, double* %116, i64 1
%118 = load double, double* %117
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 10000, i32* %12
%121 = call i32 @time(i32* null)
store i32 %121, i32* %13
store i32 1, i32* %13
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%123 = load i32, i32* %3
%124 = load i32*, i32** %6
%125 = load double*, double** %4
%126 = load i32, i32* %2
%127 = load double*, double** %5
%128 = load i32, i32* %12
%129 = load i32, i32* %13
%130 = load double*, double** %8
%131 = load double*, double** %9
%132 = load i32*, i32** %7
%133 = call i32 @permute_wKS(i32 %123, i32* %124, double* %125, i32 %126, double* %127, i32 %128, i32 %129, double* %130, double* %131, i32* %132)
%134 = load double*, double** %8
%135 = getelementptr inbounds double, double* %134, i64 0
%136 = load double, double* %135
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %136)
%138 = load double*, double** %8
%139 = getelementptr inbounds double, double* %138, i64 1
%140 = load double, double* %139
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %140)
%142 = load double*, double** %9
%143 = getelementptr inbounds double, double* %142, i64 0
%144 = load double, double* %143
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %144)
%146 = load double*, double** %9
%147 = getelementptr inbounds double, double* %146, i64 1
%148 = load double, double* %147
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %148)
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%151 = load i32*, i32** %6
%152 = load double*, double** %4
%153 = load double*, double** %5
%154 = load double*, double** %8
%155 = load double*, double** %9
%156 = load i32*, i32** %7
%157 = call i32 @Rpermute_wKS(i32* %3, i32* %151, double* %152, i32* %2, double* %153, i32* %12, i32* %13, double* %154, double* %155, i32* %156)
%158 = load double*, double** %8
%159 = getelementptr inbounds double, double* %158, i64 0
%160 = load double, double* %159
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %160)
%162 = load double*, double** %8
%163 = getelementptr inbounds double, double* %162, i64 1
%164 = load double, double* %163
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %164)
%166 = load double*, double** %9
%167 = getelementptr inbounds double, double* %166, i64 0
%168 = load double, double* %167
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %168)
%170 = load double*, double** %9
%171 = getelementptr inbounds double, double* %170, i64 1
%172 = load double, double* %171
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %172)
%174 = load i32*, i32** %7
%175 = call i32 @free(i32* %174)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"KS pos: %f\0A\00"
@.str.1 = [12 x i8] c"KS neg: %f\0A\00"
@.str.4 = [17 x i8] c"p.value pos: %f\0A\00"
@.str.5 = [17 x i8] c"p.value neg: %f\0A\00"
@str = [24 x i8] c"=======================\00"
@str.7 = [39 x i8] c"======== standard interface ==========\00"
@str.8 = [32 x i8] c"======== R interface ==========\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 12, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 3, i32* %2
%7 = tail call i64 @malloc(i32 96)
%8 = inttoptr i64 %7 to double*
%9 = tail call i64 @malloc(i32 96)
%10 = inttoptr i64 %9 to double*
%11 = tail call i64 @malloc(i32 12)
%12 = inttoptr i64 %11 to i32*
%13 = tail call i64 @malloc(i32 48)
%14 = inttoptr i64 %13 to i32*
%15 = tail call i64 @malloc(i32 16)
%16 = inttoptr i64 %15 to double*
%17 = tail call i64 @malloc(i32 16)
%18 = inttoptr i64 %17 to double*
store double 1.000000e+00, double* %8
%19 = tail call double @abs(i32 -5)
store double 1.000000e+00, double* %10
%20 = getelementptr inbounds double, double* %8, i64 1
store double 2.000000e+00, double* %20
%21 = tail call double @abs(i32 -4)
%22 = getelementptr inbounds double, double* %10, i64 1
store double 1.000000e+00, double* %22
%23 = getelementptr inbounds double, double* %8, i64 2
store double 3.000000e+00, double* %23
%24 = tail call double @abs(i32 -3)
%25 = getelementptr inbounds double, double* %10, i64 2
store double 1.000000e+00, double* %25
%26 = getelementptr inbounds double, double* %8, i64 3
store double 4.000000e+00, double* %26
%27 = tail call double @abs(i32 -2)
%28 = getelementptr inbounds double, double* %10, i64 3
store double 1.000000e+00, double* %28
%29 = getelementptr inbounds double, double* %8, i64 4
store double 5.000000e+00, double* %29
%30 = tail call double @abs(i32 -1)
%31 = getelementptr inbounds double, double* %10, i64 4
store double 1.000000e+00, double* %31
%32 = getelementptr inbounds double, double* %8, i64 5
store double 6.000000e+00, double* %32
%33 = tail call double @abs(i32 0)
%34 = getelementptr inbounds double, double* %10, i64 5
store double 1.000000e+00, double* %34
%35 = getelementptr inbounds double, double* %8, i64 6
store double 7.000000e+00, double* %35
%36 = tail call double @abs(i32 1)
%37 = getelementptr inbounds double, double* %10, i64 6
store double 1.000000e+00, double* %37
%38 = getelementptr inbounds double, double* %8, i64 7
store double 8.000000e+00, double* %38
%39 = tail call double @abs(i32 2)
%40 = getelementptr inbounds double, double* %10, i64 7
store double 1.000000e+00, double* %40
%41 = getelementptr inbounds double, double* %8, i64 8
store double 9.000000e+00, double* %41
%42 = tail call double @abs(i32 3)
%43 = getelementptr inbounds double, double* %10, i64 8
store double 1.000000e+00, double* %43
%44 = getelementptr inbounds double, double* %8, i64 9
store double 1.000000e+01, double* %44
%45 = tail call double @abs(i32 4)
%46 = getelementptr inbounds double, double* %10, i64 9
store double 1.000000e+00, double* %46
%47 = getelementptr inbounds double, double* %8, i64 10
store double 1.100000e+01, double* %47
%48 = tail call double @abs(i32 5)
%49 = getelementptr inbounds double, double* %10, i64 10
store double 1.000000e+00, double* %49
%50 = getelementptr inbounds double, double* %8, i64 11
store double 1.200000e+01, double* %50
%51 = tail call double @abs(i32 6)
%52 = getelementptr inbounds double, double* %10, i64 11
store double 1.000000e+00, double* %52
br label %90
53: ; preds = %90
%54 = getelementptr inbounds i32, i32* %12, i64 1
%55 = getelementptr inbounds i32, i32* %12, i64 2
store i32 1, i32* %12
store i32 3, i32* %54
store i32 5, i32* %55
%56 = load i32, i32* %2
%57 = load i32, i32* %1
%58 = tail call i32 @weighted_KS(i32 %56, i32* %12, double* %8, i32 %57, double* %10, double* %16, i32* %14)
%59 = load double, double* %16
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %59)
%61 = getelementptr inbounds double, double* %16, i64 1
%62 = load double, double* %61
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %62)
%64 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%65 = bitcast i32* %3 to i8*
store i32 10000, i32* %3
%66 = bitcast i32* %4 to i8*
%67 = tail call i32 @time(i32* null)
store i32 1, i32* %4
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.7, i64 0, i64 0))
%69 = tail call i32 @permute_wKS(i32 %56, i32* %12, double* %8, i32 %57, double* %10, i32 10000, i32 1, double* %16, double* %18, i32* %14)
%70 = load double, double* %16
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %70)
%72 = load double, double* %61
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %72)
%74 = load double, double* %18
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %74)
%76 = getelementptr inbounds double, double* %18, i64 1
%77 = load double, double* %76
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %77)
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%80 = call i32 @Rpermute_wKS(i32* %2, i32* %12, double* %8, i32* %1, double* %10, i32* %3, i32* %4, double* %16, double* %18, i32* %14)
%81 = load double, double* %16
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %81)
%83 = load double, double* %61
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %83)
%85 = load double, double* %18
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %85)
%87 = load double, double* %76
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %87)
%89 = call i32 @free(i32* %14)
ret i32 0
90: ; preds = %0, %90
%91 = phi i64 [ %96, %90 ], [ 0, %0 ]
%92 = trunc i64 %91 to i32
%93 = mul nsw i32 %92, 600
%94 = or i32 %93, 4
%95 = getelementptr inbounds i32, i32* %12, i64 %91
store i32 %94, i32* %95
%96 = add nuw nsw i64 %91, 1
%97 = load i32, i32* %2
%98 = sext i32 %97 to i64
%99 = icmp slt i64 %96, %98
br i1 %99, label %90, label %53
}