#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*/ exit(int /*<<< orphan*/);
double exp(double);
int /*<<< orphan*/ printf(char *);
double sqrt(double);
void ks_prob(int n, double kp, double km, double *pp, double *pm) {
  double xn;
  if (n <= 0) {
    printf("Error in ks_prob: argument out of range\n");
    printf("Program aborted\n\n");
    exit(0);
  }
  xn = (double)n;
  if (kp < 1e-8)
    *pp = 0.0;
  else if (kp > 3.5)
    *pp = 1.0;
  else
    *pp = 1.0 - exp(-2.0 * kp * kp) * (1.0 - 2.0 * kp / (3.0 * sqrt(xn)));
  if (km < 1e-8)
    *pm = 0.0;
  else if (km > 3.5)
    *pm = 1.0;
  else
    *pm = 1.0 - exp(-2.0 * km * km) * (1.0 - 2.0 * km / (3.0 * sqrt(xn)));
}


x86 assembly (clang, -O0):
<ks_prob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1186 <ks_prob+0x46>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe68(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b3 <ks_prob+0x73>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1274 <ks_prob+0x134>
movsd  -0x10(%rbp),%xmm0
movsd  0xe48(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11df <ks_prob+0x9f>
mov    -0x20(%rbp),%rax
movsd  0xe3a(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    126f <ks_prob+0x12f>
movsd  0xe41(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe1d(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x38(%rbp),%xmm0
movsd  0xdec(%rip),%xmm1
mulsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movsd  0xdd4(%rip),%xmm1
subsd  %xmm2,%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdad(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1274 <ks_prob+0x134>
movsd  0xd84(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1297 <ks_prob+0x157>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1358 <ks_prob+0x218>
movsd  -0x18(%rbp),%xmm0
movsd  0xd64(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12c3 <ks_prob+0x183>
mov    -0x28(%rbp),%rax
movsd  0xd56(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1353 <ks_prob+0x213>
movsd  0xd5d(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xd39(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x48(%rbp),%xmm0
movsd  0xd08(%rip),%xmm1
mulsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movsd  0xcf0(%rip),%xmm1
subsd  %xmm2,%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xcc9(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1358 <ks_prob+0x218>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ks_prob>:
push   %r14
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    12f0 <ks_prob+0x1b0>
mov    %rdx,%r14
mov    %rsi,%rbx
movapd %xmm0,%xmm5
cvtsi2sd %edi,%xmm2
xorpd  %xmm3,%xmm3
movsd  0xe97(%rip),%xmm4
ucomisd %xmm0,%xmm4
xorpd  %xmm0,%xmm0
ja     1235 <ks_prob+0xf5>
ucomisd 0xe91(%rip),%xmm5
jbe    118e <ks_prob+0x4e>
movsd  0xe7f(%rip),%xmm0
jmp    1235 <ks_prob+0xf5>
movsd  %xmm1,0x10(%rsp)
movsd  0xe7c(%rip),%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm2,0x8(%rsp)
movsd  %xmm5,0x18(%rsp)
call   1040 <exp@plt>
movsd  0x18(%rsp),%xmm5
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm6
addsd  %xmm5,%xmm5
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     11dc <ks_prob+0x9c>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    1203 <ks_prob+0xc3>
movapd %xmm2,%xmm0
movsd  %xmm5,0x18(%rsp)
movsd  %xmm6,0x20(%rsp)
call   1050 <sqrt@plt>
movsd  0x20(%rsp),%xmm6
movsd  0x18(%rsp),%xmm5
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
xorpd  %xmm3,%xmm3
movsd  0xdeb(%rip),%xmm4
mulsd  0xe03(%rip),%xmm0
divsd  %xmm0,%xmm5
movsd  0xddf(%rip),%xmm0
addsd  %xmm0,%xmm5
mulsd  %xmm5,%xmm6
subsd  %xmm6,%xmm0
movsd  %xmm0,(%rbx)
ucomisd %xmm1,%xmm4
ja     12e3 <ks_prob+0x1a3>
ucomisd 0xdc5(%rip),%xmm1
jbe    125a <ks_prob+0x11a>
movsd  0xdb3(%rip),%xmm3
jmp    12e3 <ks_prob+0x1a3>
movsd  0xdb6(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1040 <exp@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
movapd %xmm0,%xmm4
addsd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     12a2 <ks_prob+0x162>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    12c3 <ks_prob+0x183>
movapd %xmm2,%xmm0
movsd  %xmm1,0x10(%rsp)
movsd  %xmm4,0x8(%rsp)
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm1
mulsd  0xd55(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xd31(%rip),%xmm3
addsd  %xmm3,%xmm1
mulsd  %xmm1,%xmm4
subsd  %xmm4,%xmm3
movsd  %xmm3,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd31(%rip),%rdi
call   1030 <puts@plt>
lea    0xd4d(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"Error in ks_prob: argument out of range\0A\00"
@.str.1 = [18 x i8] c"Program aborted\0A\0A\00"
define void @ks_prob(i32 %0, double %1, double %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double* %3, double** %9
store double* %4, double** %10
%12 = load i32, i32* %6
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %5
%19 = load i32, i32* %6
%20 = sitofp i32 %19 to double
store double %20, double* %11
%21 = load double, double* %7
%22 = fcmp olt double %21, 1.000000e-08
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load double*, double** %9
store double 0.000000e+00, double* %24
br label %47
25: ; preds = %18
%26 = load double, double* %7
%27 = fcmp ogt double %26, 3.500000e+00
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = load double*, double** %9
store double 1.000000e+00, double* %29
br label %46
30: ; preds = %25
%31 = load double, double* %7
%32 = fmul double -2.000000e+00, %31
%33 = load double, double* %7
%34 = fmul double %32, %33
%35 = call double @exp(double %34)
%36 = load double, double* %7
%37 = fmul double 2.000000e+00, %36
%38 = load double, double* %11
%39 = call double @sqrt(double %38)
%40 = fmul double 3.000000e+00, %39
%41 = fdiv double %37, %40
%42 = fsub double 1.000000e+00, %41
%43 = fneg double %35
%44 = call double @llvm.fmuladd.f64(double %43, double %42, double 1.000000e+00)
%45 = load double*, double** %9
store double %44, double* %45
br label %46
46: ; preds = %30, %28
br label %47
47: ; preds = %46, %23
%48 = load double, double* %8
%49 = fcmp olt double %48, 1.000000e-08
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = load double*, double** %10
store double 0.000000e+00, double* %51
br label %74
52: ; preds = %47
%53 = load double, double* %8
%54 = fcmp ogt double %53, 3.500000e+00
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = load double*, double** %10
store double 1.000000e+00, double* %56
br label %73
57: ; preds = %52
%58 = load double, double* %8
%59 = fmul double -2.000000e+00, %58
%60 = load double, double* %8
%61 = fmul double %59, %60
%62 = call double @exp(double %61)
%63 = load double, double* %8
%64 = fmul double 2.000000e+00, %63
%65 = load double, double* %11
%66 = call double @sqrt(double %65)
%67 = fmul double 3.000000e+00, %66
%68 = fdiv double %64, %67
%69 = fsub double 1.000000e+00, %68
%70 = fneg double %62
%71 = call double @llvm.fmuladd.f64(double %70, double %69, double 1.000000e+00)
%72 = load double*, double** %10
store double %71, double* %72
br label %73
73: ; preds = %57, %55
br label %74
74: ; preds = %73, %50
ret void
}

LLVM IR (-O2):
@str = [40 x i8] c"Error in ks_prob: argument out of range\00"
@str.2 = [17 x i8] c"Program aborted\0A\00"
define void @ks_prob(i32 %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = icmp slt i32 %0, 1
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.2, i64 0, i64 0))
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %5
%12 = sitofp i32 %0 to double
%13 = fcmp olt double %1, 1.000000e-08
br i1 %13, label %27, label %14
14: ; preds = %11
%15 = fcmp ogt double %1, 3.500000e+00
br i1 %15, label %27, label %16
16: ; preds = %14
%17 = fmul double %1, -2.000000e+00
%18 = fmul double %17, %1
%19 = tail call double @exp(double %18)
%20 = fmul double %1, 2.000000e+00
%21 = tail call double @sqrt(double %12)
%22 = fmul double %21, 3.000000e+00
%23 = fdiv double %20, %22
%24 = fsub double 1.000000e+00, %23
%25 = fneg double %19
%26 = tail call double @llvm.fmuladd.f64(double %25, double %24, double 1.000000e+00)
br label %27
27: ; preds = %14, %11, %16
%28 = phi double [ %26, %16 ], [ 0.000000e+00, %11 ], [ 1.000000e+00, %14 ]
store double %28, double* %3
%29 = fcmp olt double %2, 1.000000e-08
br i1 %29, label %43, label %30
30: ; preds = %27
%31 = fcmp ogt double %2, 3.500000e+00
br i1 %31, label %43, label %32
32: ; preds = %30
%33 = fmul double %2, -2.000000e+00
%34 = fmul double %33, %2
%35 = tail call double @exp(double %34)
%36 = fmul double %2, 2.000000e+00
%37 = tail call double @sqrt(double %12)
%38 = fmul double %37, 3.000000e+00
%39 = fdiv double %36, %38
%40 = fsub double 1.000000e+00, %39
%41 = fneg double %35
%42 = tail call double @llvm.fmuladd.f64(double %41, double %40, double 1.000000e+00)
br label %43
43: ; preds = %30, %27, %32
%44 = phi double [ %42, %32 ], [ 0.000000e+00, %27 ], [ 1.000000e+00, %30 ]
store double %44, double* %4
ret void
}