#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 */
double fabs(double);
double sqrt(double);
void kstwo(double data1[], unsigned long n1, double data2[], unsigned long n2,
           double *d, double *prob) {
  double probks(double alam);
  void sort(unsigned long n, double arr[]);
  unsigned long j1 = 1, j2 = 1;
  double d1, d2, dt, en1, en2, en, fn1 = 0.0, fn2 = 0.0;
  sort(n1, data1);
  sort(n2, data2);
  en1 = n1;
  en2 = n2;
  *d = 0.0;
  while (j1 <= n1 && j2 <= n2) {
    if ((d1 = data1[j1]) <= (d2 = data2[j2]))
      fn1 = j1++ / en1;
    if (d2 <= d1)
      fn2 = j2++ / en2;
    if ((dt = fabs(fn2 - fn1)) > *d)
      *d = dt;
  }
  en = sqrt(en1 * en2 / (en1 + en2));
  *prob = probks((en + 0.12 + 0.11 / en) * (*d));
}


x86 assembly (clang, -O0):
<kstwo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x1,-0x38(%rbp)
movq   $0x1,-0x40(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <sort@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <sort@plt>
movq   -0x10(%rbp),%xmm0
movaps 0xe67(%rip),%xmm2
punpckldq %xmm2,%xmm0
movapd 0xe6b(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm3
unpckhpd %xmm0,%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,-0x60(%rbp)
movq   -0x20(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x81(%rbp)
ja     1208 <kstwo+0xd8>
mov    -0x40(%rbp),%rax
cmp    -0x20(%rbp),%rax
setbe  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    121b <kstwo+0xeb>
jmp    1317 <kstwo+0x1e7>
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  %xmm1,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
ucomisd %xmm1,%xmm0
jb     1289 <kstwo+0x159>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movq   %rax,%xmm0
movaps 0xd9c(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xda0(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12dd <kstwo+0x1ad>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movq   %rax,%xmm0
movaps 0xd48(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xd4c(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
movaps 0xd32(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x28(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1312 <kstwo+0x1e2>
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11e1 <kstwo+0xb1>
movsd  -0x60(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
addsd  -0x68(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  0xcf7(%rip),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  0xce2(%rip),%xmm1
divsd  -0x70(%rbp),%xmm1
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mulsd  (%rax),%xmm0
call   1040 <probks@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kstwo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsi,%rdi
mov    %rbp,%rsi
call   1030 <sort@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <sort@plt>
movq   %rbx,%xmm0
movdqa 0xe8f(%rip),%xmm8
punpckldq %xmm8,%xmm0
movapd 0xe92(%rip),%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movq   %r13,%xmm0
punpckldq %xmm8,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movq   $0x0,(%r15)
test   %rbx,%rbx
je     1278 <kstwo+0x148>
test   %r13,%r13
je     1278 <kstwo+0x148>
mov    $0x1,%eax
xorpd  %xmm5,%xmm5
movapd 0xe4d(%rip),%xmm9
movapd 0xe34(%rip),%xmm10
xorpd  %xmm6,%xmm6
xorpd  %xmm4,%xmm4
mov    $0x1,%ecx
nopl   0x0(%rax)
movsd  0x0(%rbp,%rax,8),%xmm0
movsd  (%r12,%rcx,8),%xmm3
ucomisd %xmm0,%xmm3
jb     1225 <kstwo+0xf5>
movq   %rax,%xmm7
add    $0x1,%rax
punpckldq %xmm8,%xmm7
subpd  %xmm10,%xmm7
movapd %xmm7,%xmm4
unpckhpd %xmm7,%xmm4
addsd  %xmm7,%xmm4
divsd  %xmm1,%xmm4
ucomisd %xmm3,%xmm0
jb     124e <kstwo+0x11e>
movq   %rcx,%xmm0
add    $0x1,%rcx
punpckldq %xmm8,%xmm0
subpd  %xmm10,%xmm0
movapd %xmm0,%xmm6
unpckhpd %xmm0,%xmm6
addsd  %xmm0,%xmm6
divsd  %xmm2,%xmm6
movapd %xmm6,%xmm0
subsd  %xmm4,%xmm0
andpd  %xmm9,%xmm0
ucomisd %xmm5,%xmm0
jbe    126a <kstwo+0x13a>
movsd  %xmm0,(%r15)
movapd %xmm0,%xmm5
cmp    %rbx,%rax
ja     1278 <kstwo+0x148>
cmp    %r13,%rcx
jbe    11f0 <kstwo+0xc0>
movapd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1298 <kstwo+0x168>
sqrtsd %xmm0,%xmm0
jmp    129d <kstwo+0x16d>
call   1050 <sqrt@plt>
movsd  0xd8b(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0xd87(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
mulsd  (%r15),%xmm1
movapd %xmm1,%xmm0
call   1040 <probks@plt>
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @kstwo(double* %0, i64 %1, double* %2, i64 %3, double* %4, double* %5) {
%7 = alloca double*
%8 = alloca i64
%9 = alloca double*
%10 = alloca i64
%11 = alloca double*
%12 = alloca double*
%13 = alloca i64
%14 = alloca i64
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
store double* %0, double** %7
store i64 %1, i64* %8
store double* %2, double** %9
store i64 %3, i64* %10
store double* %4, double** %11
store double* %5, double** %12
store i64 1, i64* %13
store i64 1, i64* %14
store double 0.000000e+00, double* %21
store double 0.000000e+00, double* %22
%23 = load i64, i64* %8
%24 = load double*, double** %7
%25 = load i64, i64* %10
%26 = load double*, double** %9
%27 = load i64, i64* %8
%28 = uitofp i64 %27 to double
store double %28, double* %18
%29 = load i64, i64* %10
%30 = uitofp i64 %29 to double
store double %30, double* %19
%31 = load double*, double** %11
store double 0.000000e+00, double* %31
br label %32
32: ; preds = %79, %6
%33 = load i64, i64* %13
%34 = load i64, i64* %8
%35 = icmp ule i64 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i64, i64* %14
%38 = load i64, i64* %10
%39 = icmp ule i64 %37, %38
br label %40
40: ; preds = %36, %32
%41 = phi i1 [ false, %32 ], [ %39, %36 ]
br i1 %41, label %42, label %80
42: ; preds = %40
%43 = load double*, double** %7
%44 = load i64, i64* %13
%45 = getelementptr inbounds double, double* %43, i64 %44
%46 = load double, double* %45
store double %46, double* %15
%47 = load double*, double** %9
%48 = load i64, i64* %14
%49 = getelementptr inbounds double, double* %47, i64 %48
%50 = load double, double* %49
store double %50, double* %16
%51 = fcmp ole double %46, %50
br i1 %51, label %52, label %58
52: ; preds = %42
%53 = load i64, i64* %13
%54 = add i64 %53, 1
store i64 %54, i64* %13
%55 = uitofp i64 %53 to double
%56 = load double, double* %18
%57 = fdiv double %55, %56
store double %57, double* %21
br label %58
58: ; preds = %52, %42
%59 = load double, double* %16
%60 = load double, double* %15
%61 = fcmp ole double %59, %60
br i1 %61, label %62, label %68
62: ; preds = %58
%63 = load i64, i64* %14
%64 = add i64 %63, 1
store i64 %64, i64* %14
%65 = uitofp i64 %63 to double
%66 = load double, double* %19
%67 = fdiv double %65, %66
store double %67, double* %22
br label %68
68: ; preds = %62, %58
%69 = load double, double* %22
%70 = load double, double* %21
%71 = fsub double %69, %70
%72 = call double @llvm.fabs.f64(double %71)
store double %72, double* %17
%73 = load double*, double** %11
%74 = load double, double* %73
%75 = fcmp ogt double %72, %74
br i1 %75, label %76, label %79
76: ; preds = %68
%77 = load double, double* %17
%78 = load double*, double** %11
store double %77, double* %78
br label %79
79: ; preds = %76, %68
br label %32
80: ; preds = %40
%81 = load double, double* %18
%82 = load double, double* %19
%83 = fmul double %81, %82
%84 = load double, double* %18
%85 = load double, double* %19
%86 = fadd double %84, %85
%87 = fdiv double %83, %86
%88 = call double @sqrt(double %87)
store double %88, double* %20
%89 = load double, double* %20
%90 = fadd double %89, 1.200000e-01
%91 = load double, double* %20
%92 = fdiv double 1.100000e-01, %91
%93 = fadd double %90, %92
%94 = load double*, double** %11
%95 = load double, double* %94
%96 = fmul double %93, %95
%97 = call double @probks(double %96)
%98 = load double*, double** %12
store double %97, double* %98
ret void
}

LLVM IR (-O2):
define void @kstwo(double* %0, i64 %1, double* %2, i64 %3, double* nocapture %4, double* nocapture writeonly %5) {
tail call void @sort(i64 %1, double* %0)
tail call void @sort(i64 %3, double* %2)
%7 = uitofp i64 %1 to double
%8 = uitofp i64 %3 to double
store double 0.000000e+00, double* %4
%9 = icmp ne i64 %1, 0
%10 = icmp ne i64 %3, 0
%11 = and i1 %9, %10
br i1 %11, label %12, label %47
12: ; preds = %6, %42
%13 = phi double [ %43, %42 ], [ 0.000000e+00, %6 ]
%14 = phi double [ %37, %42 ], [ 0.000000e+00, %6 ]
%15 = phi double [ %29, %42 ], [ 0.000000e+00, %6 ]
%16 = phi i64 [ %28, %42 ], [ 1, %6 ]
%17 = phi i64 [ %36, %42 ], [ 1, %6 ]
%18 = getelementptr inbounds double, double* %0, i64 %16
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %2, i64 %17
%21 = load double, double* %20
%22 = fcmp ugt double %19, %21
br i1 %22, label %27, label %23
23: ; preds = %12
%24 = add i64 %16, 1
%25 = uitofp i64 %16 to double
%26 = fdiv double %25, %7
br label %27
27: ; preds = %23, %12
%28 = phi i64 [ %24, %23 ], [ %16, %12 ]
%29 = phi double [ %26, %23 ], [ %15, %12 ]
%30 = fcmp ugt double %21, %19
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = add i64 %17, 1
%33 = uitofp i64 %17 to double
%34 = fdiv double %33, %8
br label %35
35: ; preds = %31, %27
%36 = phi i64 [ %32, %31 ], [ %17, %27 ]
%37 = phi double [ %34, %31 ], [ %14, %27 ]
%38 = fsub double %37, %29
%39 = tail call double @llvm.fabs.f64(double %38)
%40 = fcmp ogt double %39, %13
br i1 %40, label %41, label %42
41: ; preds = %35
store double %39, double* %4
br label %42
42: ; preds = %41, %35
%43 = phi double [ %39, %41 ], [ %13, %35 ]
%44 = icmp ule i64 %28, %1
%45 = icmp ule i64 %36, %3
%46 = select i1 %44, i1 %45, i1 false
br i1 %46, label %12, label %47
47: ; preds = %42, %6
%48 = fmul double %7, %8
%49 = fadd double %7, %8
%50 = fdiv double %48, %49
%51 = tail call double @sqrt(double %50)
%52 = fadd double %51, 1.200000e-01
%53 = fdiv double 1.100000e-01, %51
%54 = fadd double %52, %53
%55 = load double, double* %4
%56 = fmul double %55, %54
%57 = tail call double @probks(double %56)
store double %57, double* %5
ret void
}