double KS(double *X, long n, double (*F)(double)) {
  double *a, *b, Y, rminus, rplus, value;
  long *c, m, k, j;
  m = n + 1;
  a = (double *)(_mymalloc(
      ((m + 1) * sizeof(double)), 70,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/master/"
      "genesis/src/sprng/TESTS/chisquare.c"));
  b = (double *)(_mymalloc(
      ((m + 1) * sizeof(double)), 71,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/master/"
      "genesis/src/sprng/TESTS/chisquare.c"));
  c = (long *)(_mymalloc(
      ((m + 1) * sizeof(long)), 72,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/master/"
      "genesis/src/sprng/TESTS/chisquare.c"));
  memset(c, 0, (m + 1) * sizeof(long));
  for (k = 0; k < m + 1; k++) {
    a[k] = 1.0;
    b[k] = 0.0;
  }
  for (j = 0; j < n; j++) {
    Y = F(X[j]);
    k = m * Y;
    a[k] = (a[k] > Y ? Y : a[k]);
    b[k] = (b[k] < Y ? Y : b[k]);
    c[k]++;
  }
  for (k = j = 0, rplus = rminus = 0.0; k < m; k++) {
    if (c[k] <= 0)
      continue;
    rminus = (rminus < a[k] - (double)j / n ? a[k] - (double)j / n : rminus);
    j += c[k];
    rplus = (rplus < (double)j / n - b[k] ? (double)j / n - b[k] : rplus);
  }
  value = sqrt((double)n) * (rplus < rminus ? rminus : rplus);
  free(a);
  free(b);
  free(c);
  return value;
}


x86 assembly (clang, -O0):
<KS>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
mov    $0x46,%esi
lea    0xe8d(%rip),%rdx
mov    $0x0,%al
call   1040 <_mymalloc@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x58(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
mov    $0x47,%esi
lea    0xe68(%rip),%rdx
mov    $0x0,%al
call   1040 <_mymalloc@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x58(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
mov    $0x48,%esi
lea    0xe43(%rip),%rdx
mov    $0x0,%al
call   1040 <_mymalloc@plt>
cltq
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
add    $0x1,%rdx
shl    $0x3,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jge    123c <KS+0xfc>
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  0xdea(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    11f1 <KS+0xb1>
movq   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    133d <KS+0x1fd>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x68(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
call   *%rax
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdq -0x58(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    12a5 <KS+0x165>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    12b7 <KS+0x177>
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12f4 <KS+0x1b4>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    1306 <KS+0x1c6>
mov    -0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x1,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1244 <KS+0x104>
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x60(%rbp),%rax
cmp    -0x58(%rbp),%rax
jge    1487 <KS+0x347>
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jg     1383 <KS+0x243>
jmp    1476 <KS+0x336>
movsd  -0x38(%rbp),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdq -0x68(%rbp),%xmm2
cvtsi2sdq -0x10(%rbp),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    13de <KS+0x29e>
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdq -0x68(%rbp),%xmm1
cvtsi2sdq -0x10(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    13e8 <KS+0x2a8>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    -0x68(%rbp),%rax
mov    %rax,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm1
cvtsi2sdq -0x68(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm2
divsd  %xmm2,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    145c <KS+0x31c>
cvtsi2sdq -0x68(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1469 <KS+0x329>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x40(%rbp)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    135d <KS+0x21d>
cvtsi2sdq -0x10(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    14c0 <KS+0x380>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    14cd <KS+0x38d>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm1
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x48(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,0x10(%rsp)
lea    0x10(,%rsi,8),%r13
lea    0xea6(%rip),%rbp
mov    %r13,%rdi
mov    $0x46,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <_mymalloc@plt>
movslq %eax,%rbx
mov    %r13,%rdi
mov    $0x47,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <_mymalloc@plt>
movslq %eax,%r12
mov    %r13,%rdi
mov    $0x48,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <_mymalloc@plt>
movslq %eax,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1050 <memset@plt>
cmp    $0xffffffffffffffff,%r15
jl     147e <KS+0x33e>
mov    0x8(%rsp),%r13
mov    0x10(%rsp),%r9
lea    0x2(%r15),%rax
cmp    $0x4,%rax
jb     11ee <KS+0xae>
lea    (%r12,%rax,8),%rcx
cmp    %rcx,%rbx
jae    1284 <KS+0x144>
lea    (%rbx,%rax,8),%rcx
cmp    %rcx,%r12
jae    1284 <KS+0x144>
xor    %ecx,%ecx
lea    0x2(%r15),%esi
mov    %r15,%rdx
sub    %rcx,%rdx
add    $0x1,%rdx
and    $0x3,%rsi
je     1226 <KS+0xe6>
movabs $0x3ff0000000000000,%rdi
xchg   %ax,%ax
mov    %rdi,(%rbx,%rcx,8)
movq   $0x0,(%r12,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1210 <KS+0xd0>
cmp    $0x3,%rdx
jb     1388 <KS+0x248>
movabs $0x3ff0000000000000,%rdx
nopw   0x0(%rax,%rax,1)
mov    %rdx,(%rbx,%rcx,8)
movq   $0x0,(%r12,%rcx,8)
mov    %rdx,0x8(%rbx,%rcx,8)
movq   $0x0,0x8(%r12,%rcx,8)
mov    %rdx,0x10(%rbx,%rcx,8)
movq   $0x0,0x10(%r12,%rcx,8)
mov    %rdx,0x18(%rbx,%rcx,8)
movq   $0x0,0x18(%r12,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%rax
jne    1240 <KS+0x100>
jmp    1388 <KS+0x248>
mov    %rax,%rcx
and    $0xfffffffffffffffc,%rcx
lea    -0x4(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0xc,%rdi
jae    12ac <KS+0x16c>
xor    %edi,%edi
jmp    1330 <KS+0x1f0>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
movapd 0xd46(%rip),%xmm0
xorpd  %xmm1,%xmm1
xchg   %ax,%ax
movupd %xmm0,(%rbx,%rdi,8)
movupd %xmm0,0x10(%rbx,%rdi,8)
movupd %xmm1,(%r12,%rdi,8)
movupd %xmm1,0x10(%r12,%rdi,8)
movupd %xmm0,0x20(%rbx,%rdi,8)
movupd %xmm0,0x30(%rbx,%rdi,8)
movupd %xmm1,0x20(%r12,%rdi,8)
movupd %xmm1,0x30(%r12,%rdi,8)
movupd %xmm0,0x40(%rbx,%rdi,8)
movupd %xmm0,0x50(%rbx,%rdi,8)
movupd %xmm1,0x40(%r12,%rdi,8)
movupd %xmm1,0x50(%r12,%rdi,8)
movupd %xmm0,0x60(%rbx,%rdi,8)
movupd %xmm0,0x70(%rbx,%rdi,8)
movupd %xmm1,0x60(%r12,%rdi,8)
movupd %xmm1,0x70(%r12,%rdi,8)
add    $0x10,%rdi
add    $0xfffffffffffffffc,%rsi
jne    12c0 <KS+0x180>
test   %rdx,%rdx
je     137f <KS+0x23f>
lea    (%r12,%rdi,8),%rsi
add    $0x10,%rsi
lea    (%rbx,%rdi,8),%rdi
add    $0x10,%rdi
shl    $0x5,%rdx
xor    %ebp,%ebp
movapd 0xcad(%rip),%xmm0
xorpd  %xmm1,%xmm1
nopw   0x0(%rax,%rax,1)
movupd %xmm0,-0x10(%rdi,%rbp,1)
movupd %xmm0,(%rdi,%rbp,1)
movupd %xmm1,-0x10(%rsi,%rbp,1)
movupd %xmm1,(%rsi,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%rdx
jne    1360 <KS+0x220>
cmp    %rcx,%rax
jne    11f0 <KS+0xb0>
lea    0x1(%r15),%rax
mov    %rax,0x18(%rsp)
test   %r15,%r15
jle    140d <KS+0x2cd>
xorps  %xmm0,%xmm0
cvtsi2sdq 0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebp,%ebp
mov    %rbx,0x20(%rsp)
nopl   (%rax)
movsd  (%r9,%rbp,8),%xmm0
mov    %r12,%rbx
mov    %r15,%r12
mov    %r14,%r15
mov    %r9,%r14
call   *%r13
mov    %r14,%r9
mov    %r15,%r14
mov    %r12,%r15
mov    %rbx,%r12
mov    0x20(%rsp),%rbx
movapd %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%rax
movapd %xmm0,%xmm1
minsd  (%rbx,%rax,8),%xmm1
movsd  %xmm1,(%rbx,%rax,8)
maxsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,(%r12,%rax,8)
addq   $0x1,(%r14,%rax,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    13b0 <KS+0x270>
test   %r15,%r15
js     147e <KS+0x33e>
xorps  %xmm0,%xmm0
cvtsi2sd %r15,%xmm0
xorpd  %xmm3,%xmm3
xor    %eax,%eax
xor    %ecx,%ecx
xorpd  %xmm4,%xmm4
mov    0x18(%rsp),%rsi
jmp    1439 <KS+0x2f9>
nopl   (%rax)
add    $0x1,%rcx
cmp    %rcx,%rsi
je     148e <KS+0x34e>
mov    (%r14,%rcx,8),%rdx
test   %rdx,%rdx
jle    1430 <KS+0x2f0>
movsd  (%rbx,%rcx,8),%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
divsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
maxsd  %xmm3,%xmm1
add    %rdx,%rax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
divsd  %xmm0,%xmm2
subsd  (%r12,%rcx,8),%xmm2
maxsd  %xmm4,%xmm2
movapd %xmm2,%xmm4
movapd %xmm1,%xmm3
jmp    1430 <KS+0x2f0>
xorps  %xmm0,%xmm0
cvtsi2sd %r15,%xmm0
xorpd  %xmm4,%xmm4
xorpd  %xmm3,%xmm3
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     149e <KS+0x35e>
sqrtsd %xmm0,%xmm0
jmp    14bb <KS+0x37b>
movsd  %xmm3,0x8(%rsp)
movsd  %xmm4,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
maxsd  %xmm4,%xmm3
mulsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/master/genesis/src/sprng/TESTS/chisquare.c\00"
define double @KS(double* %0, i64 %1, double (double)* %2) {
%4 = alloca double*
%5 = alloca i64
%6 = alloca double (double)*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i64*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
store double* %0, double** %4
store i64 %1, i64* %5
store double (double)* %2, double (double)** %6
%17 = load i64, i64* %5
%18 = add nsw i64 %17, 1
store i64 %18, i64* %14
%19 = load i64, i64* %14
%20 = add nsw i64 %19, 1
%21 = mul i64 %20, 8
%22 = call i32 (i64, i32, i8*, ...) bitcast (i32 (...)* @_mymalloc to i32 (i64, i32, i8*, ...)*)(i64 %21, i32 70, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0))
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to double*
store double* %24, double** %7
%25 = load i64, i64* %14
%26 = add nsw i64 %25, 1
%27 = mul i64 %26, 8
%28 = call i32 (i64, i32, i8*, ...) bitcast (i32 (...)* @_mymalloc to i32 (i64, i32, i8*, ...)*)(i64 %27, i32 71, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0))
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to double*
store double* %30, double** %8
%31 = load i64, i64* %14
%32 = add nsw i64 %31, 1
%33 = mul i64 %32, 8
%34 = call i32 (i64, i32, i8*, ...) bitcast (i32 (...)* @_mymalloc to i32 (i64, i32, i8*, ...)*)(i64 %33, i32 72, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0))
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i64*
store i64* %36, i64** %13
%37 = load i64*, i64** %13
%38 = bitcast i64* %37 to i8*
%39 = load i64, i64* %14
%40 = add nsw i64 %39, 1
%41 = mul i64 %40, 8
store i64 0, i64* %15
br label %42
42: ; preds = %54, %3
%43 = load i64, i64* %15
%44 = load i64, i64* %14
%45 = add nsw i64 %44, 1
%46 = icmp slt i64 %43, %45
br i1 %46, label %47, label %57
47: ; preds = %42
%48 = load double*, double** %7
%49 = load i64, i64* %15
%50 = getelementptr inbounds double, double* %48, i64 %49
store double 1.000000e+00, double* %50
%51 = load double*, double** %8
%52 = load i64, i64* %15
%53 = getelementptr inbounds double, double* %51, i64 %52
store double 0.000000e+00, double* %53
br label %54
54: ; preds = %47
%55 = load i64, i64* %15
%56 = add nsw i64 %55, 1
store i64 %56, i64* %15
br label %42
57: ; preds = %42
store i64 0, i64* %16
br label %58
58: ; preds = %115, %57
%59 = load i64, i64* %16
%60 = load i64, i64* %5
%61 = icmp slt i64 %59, %60
br i1 %61, label %62, label %118
62: ; preds = %58
%63 = load double (double)*, double (double)** %6
%64 = load double*, double** %4
%65 = load i64, i64* %16
%66 = getelementptr inbounds double, double* %64, i64 %65
%67 = load double, double* %66
%68 = call double %63(double %67)
store double %68, double* %9
%69 = load i64, i64* %14
%70 = sitofp i64 %69 to double
%71 = load double, double* %9
%72 = fmul double %70, %71
%73 = fptosi double %72 to i64
store i64 %73, i64* %15
%74 = load double*, double** %7
%75 = load i64, i64* %15
%76 = getelementptr inbounds double, double* %74, i64 %75
%77 = load double, double* %76
%78 = load double, double* %9
%79 = fcmp ogt double %77, %78
br i1 %79, label %80, label %82
80: ; preds = %62
%81 = load double, double* %9
br label %87
82: ; preds = %62
%83 = load double*, double** %7
%84 = load i64, i64* %15
%85 = getelementptr inbounds double, double* %83, i64 %84
%86 = load double, double* %85
br label %87
87: ; preds = %82, %80
%88 = phi double [ %81, %80 ], [ %86, %82 ]
%89 = load double*, double** %7
%90 = load i64, i64* %15
%91 = getelementptr inbounds double, double* %89, i64 %90
store double %88, double* %91
%92 = load double*, double** %8
%93 = load i64, i64* %15
%94 = getelementptr inbounds double, double* %92, i64 %93
%95 = load double, double* %94
%96 = load double, double* %9
%97 = fcmp olt double %95, %96
br i1 %97, label %98, label %100
98: ; preds = %87
%99 = load double, double* %9
br label %105
100: ; preds = %87
%101 = load double*, double** %8
%102 = load i64, i64* %15
%103 = getelementptr inbounds double, double* %101, i64 %102
%104 = load double, double* %103
br label %105
105: ; preds = %100, %98
%106 = phi double [ %99, %98 ], [ %104, %100 ]
%107 = load double*, double** %8
%108 = load i64, i64* %15
%109 = getelementptr inbounds double, double* %107, i64 %108
store double %106, double* %109
%110 = load i64*, i64** %13
%111 = load i64, i64* %15
%112 = getelementptr inbounds i64, i64* %110, i64 %111
%113 = load i64, i64* %112
%114 = add nsw i64 %113, 1
store i64 %114, i64* %112
br label %115
115: ; preds = %105
%116 = load i64, i64* %16
%117 = add nsw i64 %116, 1
store i64 %117, i64* %16
br label %58
118: ; preds = %58
store i64 0, i64* %16
store i64 0, i64* %15
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
br label %119
119: ; preds = %191, %118
%120 = load i64, i64* %15
%121 = load i64, i64* %14
%122 = icmp slt i64 %120, %121
br i1 %122, label %123, label %194
123: ; preds = %119
%124 = load i64*, i64** %13
%125 = load i64, i64* %15
%126 = getelementptr inbounds i64, i64* %124, i64 %125
%127 = load i64, i64* %126
%128 = icmp sle i64 %127, 0
br i1 %128, label %129, label %130
129: ; preds = %123
br label %191
130: ; preds = %123
%131 = load double, double* %10
%132 = load double*, double** %7
%133 = load i64, i64* %15
%134 = getelementptr inbounds double, double* %132, i64 %133
%135 = load double, double* %134
%136 = load i64, i64* %16
%137 = sitofp i64 %136 to double
%138 = load i64, i64* %5
%139 = sitofp i64 %138 to double
%140 = fdiv double %137, %139
%141 = fsub double %135, %140
%142 = fcmp olt double %131, %141
br i1 %142, label %143, label %154
143: ; preds = %130
%144 = load double*, double** %7
%145 = load i64, i64* %15
%146 = getelementptr inbounds double, double* %144, i64 %145
%147 = load double, double* %146
%148 = load i64, i64* %16
%149 = sitofp i64 %148 to double
%150 = load i64, i64* %5
%151 = sitofp i64 %150 to double
%152 = fdiv double %149, %151
%153 = fsub double %147, %152
br label %156
154: ; preds = %130
%155 = load double, double* %10
br label %156
156: ; preds = %154, %143
%157 = phi double [ %153, %143 ], [ %155, %154 ]
store double %157, double* %10
%158 = load i64*, i64** %13
%159 = load i64, i64* %15
%160 = getelementptr inbounds i64, i64* %158, i64 %159
%161 = load i64, i64* %160
%162 = load i64, i64* %16
%163 = add nsw i64 %162, %161
store i64 %163, i64* %16
%164 = load double, double* %11
%165 = load i64, i64* %16
%166 = sitofp i64 %165 to double
%167 = load i64, i64* %5
%168 = sitofp i64 %167 to double
%169 = fdiv double %166, %168
%170 = load double*, double** %8
%171 = load i64, i64* %15
%172 = getelementptr inbounds double, double* %170, i64 %171
%173 = load double, double* %172
%174 = fsub double %169, %173
%175 = fcmp olt double %164, %174
br i1 %175, label %176, label %187
176: ; preds = %156
%177 = load i64, i64* %16
%178 = sitofp i64 %177 to double
%179 = load i64, i64* %5
%180 = sitofp i64 %179 to double
%181 = fdiv double %178, %180
%182 = load double*, double** %8
%183 = load i64, i64* %15
%184 = getelementptr inbounds double, double* %182, i64 %183
%185 = load double, double* %184
%186 = fsub double %181, %185
br label %189
187: ; preds = %156
%188 = load double, double* %11
br label %189
189: ; preds = %187, %176
%190 = phi double [ %186, %176 ], [ %188, %187 ]
store double %190, double* %11
br label %191
191: ; preds = %189, %129
%192 = load i64, i64* %15
%193 = add nsw i64 %192, 1
store i64 %193, i64* %15
br label %119
194: ; preds = %119
%195 = load i64, i64* %5
%196 = sitofp i64 %195 to double
%197 = call double @sqrt(double %196)
%198 = load double, double* %11
%199 = load double, double* %10
%200 = fcmp olt double %198, %199
br i1 %200, label %201, label %203
201: ; preds = %194
%202 = load double, double* %10
br label %205
203: ; preds = %194
%204 = load double, double* %11
br label %205
205: ; preds = %203, %201
%206 = phi double [ %202, %201 ], [ %204, %203 ]
%207 = fmul double %197, %206
store double %207, double* %12
%208 = load double*, double** %7
%209 = bitcast double* %208 to i8*
%210 = load double*, double** %8
%211 = bitcast double* %210 to i8*
%212 = load i64*, i64** %13
%213 = bitcast i64* %212 to i8*
%214 = load double, double* %12
ret double %214
}

LLVM IR (-O2):
@.str = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/borismarin/genesis2.4gamma/refs/heads/master/genesis/src/sprng/TESTS/chisquare.c\00"
define double @KS(double* nocapture %0, i64 %1, double (double)* nocapture %2) {
%4 = add nsw i64 %1, 1
%5 = add nsw i64 %1, 2
%6 = shl i64 %5, 3
%7 = tail call i32 (i64, i32, i8*, ...) bitcast (i32 (...)* @_mymalloc to i32 (i64, i32, i8*, ...)*)(i64 %6, i32 70, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0))
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to double*
%10 = inttoptr i64 %8 to i8*
%11 = tail call i32 (i64, i32, i8*, ...) bitcast (i32 (...)* @_mymalloc to i32 (i64, i32, i8*, ...)*)(i64 %6, i32 71, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0))
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to double*
%14 = inttoptr i64 %12 to i8*
%15 = tail call i32 (i64, i32, i8*, ...) bitcast (i32 (...)* @_mymalloc to i32 (i64, i32, i8*, ...)*)(i64 %6, i32 72, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0))
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i64*
%18 = inttoptr i64 %16 to i8*
tail call void @llvm.memset.p0i8.i64(i8* align 8 %18, i8 0, i64 %6, i1 false)
%19 = icmp sgt i64 %1, -2
br i1 %19, label %20, label %138
20: ; preds = %3
%21 = icmp ult i64 %5, 4
br i1 %21, label %99, label %22
22: ; preds = %20
%23 = getelementptr double, double* %9, i64 %5
%24 = bitcast double* %23 to i8*
%25 = getelementptr double, double* %13, i64 %5
%26 = bitcast double* %25 to i8*
%27 = icmp ult i8* %10, %26
%28 = icmp ult i8* %14, %24
%29 = and i1 %27, %28
br i1 %29, label %99, label %30
30: ; preds = %22
%31 = and i64 %5, -4
%32 = add i64 %31, -4
%33 = lshr exact i64 %32, 2
%34 = add nuw nsw i64 %33, 1
%35 = and i64 %34, 3
%36 = icmp ult i64 %32, 12
br i1 %36, label %80, label %37
37: ; preds = %30
%38 = and i64 %34, 9223372036854775804
br label %39
39: ; preds = %39, %37
%40 = phi i64 [ 0, %37 ], [ %77, %39 ]
%41 = phi i64 [ 0, %37 ], [ %78, %39 ]
%42 = getelementptr inbounds double, double* %9, i64 %40
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %43
%44 = getelementptr inbounds double, double* %42, i64 2
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %45
%46 = getelementptr inbounds double, double* %13, i64 %40
%47 = bitcast double* %46 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %47
%48 = getelementptr inbounds double, double* %46, i64 2
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %49
%50 = or i64 %40, 4
%51 = getelementptr inbounds double, double* %9, i64 %50
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %52
%53 = getelementptr inbounds double, double* %51, i64 2
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %54
%55 = getelementptr inbounds double, double* %13, i64 %50
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %56
%57 = getelementptr inbounds double, double* %55, i64 2
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %58
%59 = or i64 %40, 8
%60 = getelementptr inbounds double, double* %9, i64 %59
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %61
%62 = getelementptr inbounds double, double* %60, i64 2
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %63
%64 = getelementptr inbounds double, double* %13, i64 %59
%65 = bitcast double* %64 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %65
%66 = getelementptr inbounds double, double* %64, i64 2
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %67
%68 = or i64 %40, 12
%69 = getelementptr inbounds double, double* %9, i64 %68
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %70
%71 = getelementptr inbounds double, double* %69, i64 2
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %72
%73 = getelementptr inbounds double, double* %13, i64 %68
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %74
%75 = getelementptr inbounds double, double* %73, i64 2
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %76
%77 = add nuw i64 %40, 16
%78 = add nuw i64 %41, 4
%79 = icmp eq i64 %78, %38
br i1 %79, label %80, label %39
80: ; preds = %39, %30
%81 = phi i64 [ 0, %30 ], [ %77, %39 ]
%82 = icmp eq i64 %35, 0
br i1 %82, label %97, label %83
83: ; preds = %80, %83
%84 = phi i64 [ %94, %83 ], [ %81, %80 ]
%85 = phi i64 [ %95, %83 ], [ 0, %80 ]
%86 = getelementptr inbounds double, double* %9, i64 %84
%87 = bitcast double* %86 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %87
%88 = getelementptr inbounds double, double* %86, i64 2
%89 = bitcast double* %88 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %89
%90 = getelementptr inbounds double, double* %13, i64 %84
%91 = bitcast double* %90 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %91
%92 = getelementptr inbounds double, double* %90, i64 2
%93 = bitcast double* %92 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %93
%94 = add nuw i64 %84, 4
%95 = add i64 %85, 1
%96 = icmp eq i64 %95, %35
br i1 %96, label %97, label %83
97: ; preds = %83, %80
%98 = icmp eq i64 %5, %31
br i1 %98, label %117, label %99
99: ; preds = %22, %20, %97
%100 = phi i64 [ 0, %22 ], [ 0, %20 ], [ %31, %97 ]
%101 = add i64 %1, 2
%102 = add i64 %1, 1
%103 = sub i64 %102, %100
%104 = and i64 %101, 3
%105 = icmp eq i64 %104, 0
br i1 %105, label %114, label %106
106: ; preds = %99, %106
%107 = phi i64 [ %111, %106 ], [ %100, %99 ]
%108 = phi i64 [ %112, %106 ], [ 0, %99 ]
%109 = getelementptr inbounds double, double* %9, i64 %107
store double 1.000000e+00, double* %109
%110 = getelementptr inbounds double, double* %13, i64 %107
store double 0.000000e+00, double* %110
%111 = add nuw nsw i64 %107, 1
%112 = add i64 %108, 1
%113 = icmp eq i64 %112, %104
br i1 %113, label %114, label %106
114: ; preds = %106, %99
%115 = phi i64 [ %100, %99 ], [ %111, %106 ]
%116 = icmp ult i64 %103, 3
br i1 %116, label %117, label %121
117: ; preds = %114, %121, %97
%118 = icmp sgt i64 %1, 0
br i1 %118, label %119, label %136
119: ; preds = %117
%120 = sitofp i64 %4 to double
br label %142
121: ; preds = %114, %121
%122 = phi i64 [ %134, %121 ], [ %115, %114 ]
%123 = getelementptr inbounds double, double* %9, i64 %122
store double 1.000000e+00, double* %123
%124 = getelementptr inbounds double, double* %13, i64 %122
store double 0.000000e+00, double* %124
%125 = add nuw nsw i64 %122, 1
%126 = getelementptr inbounds double, double* %9, i64 %125
store double 1.000000e+00, double* %126
%127 = getelementptr inbounds double, double* %13, i64 %125
store double 0.000000e+00, double* %127
%128 = add nuw nsw i64 %122, 2
%129 = getelementptr inbounds double, double* %9, i64 %128
store double 1.000000e+00, double* %129
%130 = getelementptr inbounds double, double* %13, i64 %128
store double 0.000000e+00, double* %130
%131 = add nuw nsw i64 %122, 3
%132 = getelementptr inbounds double, double* %9, i64 %131
store double 1.000000e+00, double* %132
%133 = getelementptr inbounds double, double* %13, i64 %131
store double 0.000000e+00, double* %133
%134 = add nuw nsw i64 %122, 4
%135 = icmp eq i64 %134, %5
br i1 %135, label %117, label %121
136: ; preds = %142, %117
%137 = icmp slt i64 %1, 0
br i1 %137, label %138, label %140
138: ; preds = %3, %136
%139 = sitofp i64 %1 to double
br label %192
140: ; preds = %136
%141 = sitofp i64 %1 to double
br label %162
142: ; preds = %119, %142
%143 = phi i64 [ 0, %119 ], [ %160, %142 ]
%144 = getelementptr inbounds double, double* %0, i64 %143
%145 = load double, double* %144
%146 = tail call double %2(double %145)
%147 = fmul double %146, %120
%148 = fptosi double %147 to i64
%149 = getelementptr inbounds double, double* %9, i64 %148
%150 = load double, double* %149
%151 = fcmp ogt double %150, %146
%152 = select i1 %151, double %146, double %150
store double %152, double* %149
%153 = getelementptr inbounds double, double* %13, i64 %148
%154 = load double, double* %153
%155 = fcmp olt double %154, %146
%156 = select i1 %155, double %146, double %154
store double %156, double* %153
%157 = getelementptr inbounds i64, i64* %17, i64 %148
%158 = load i64, i64* %157
%159 = add nsw i64 %158, 1
store i64 %159, i64* %157
%160 = add nuw nsw i64 %143, 1
%161 = icmp eq i64 %160, %1
br i1 %161, label %136, label %142
162: ; preds = %140, %186
%163 = phi i64 [ 0, %140 ], [ %189, %186 ]
%164 = phi i64 [ 0, %140 ], [ %190, %186 ]
%165 = phi double [ 0.000000e+00, %140 ], [ %188, %186 ]
%166 = phi double [ 0.000000e+00, %140 ], [ %187, %186 ]
%167 = getelementptr inbounds i64, i64* %17, i64 %164
%168 = load i64, i64* %167
%169 = icmp slt i64 %168, 1
br i1 %169, label %186, label %170
170: ; preds = %162
%171 = getelementptr inbounds double, double* %9, i64 %164
%172 = load double, double* %171
%173 = sitofp i64 %163 to double
%174 = fdiv double %173, %141
%175 = fsub double %172, %174
%176 = fcmp olt double %165, %175
%177 = select i1 %176, double %175, double %165
%178 = add nsw i64 %168, %163
%179 = sitofp i64 %178 to double
%180 = fdiv double %179, %141
%181 = getelementptr inbounds double, double* %13, i64 %164
%182 = load double, double* %181
%183 = fsub double %180, %182
%184 = fcmp olt double %166, %183
%185 = select i1 %184, double %183, double %166
br label %186
186: ; preds = %162, %170
%187 = phi double [ %166, %162 ], [ %185, %170 ]
%188 = phi double [ %165, %162 ], [ %177, %170 ]
%189 = phi i64 [ %163, %162 ], [ %178, %170 ]
%190 = add nuw i64 %164, 1
%191 = icmp eq i64 %164, %1
br i1 %191, label %192, label %162
192: ; preds = %186, %138
%193 = phi double [ %139, %138 ], [ %141, %186 ]
%194 = phi double [ 0.000000e+00, %138 ], [ %187, %186 ]
%195 = phi double [ 0.000000e+00, %138 ], [ %188, %186 ]
%196 = tail call double @sqrt(double %193)
%197 = fcmp olt double %194, %195
%198 = select i1 %197, double %195, double %194
%199 = fmul double %198, %196
%200 = inttoptr i64 %8 to i8*
tail call void @free(i8* %200)
%201 = inttoptr i64 %12 to i8*
tail call void @free(i8* %201)
tail call void @free(i8* %18)
ret double %199
}