#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 log10(double);
double pow(int, double);
double reduce_factorial(int, int);
int p_value_test(int branch_genome_size, int window_size, int num_branch_snps,
                 int block_snp_count, int min_snps) {
  double threshold = 0.0;
  int cutoff = 0;
  double pvalue = 0.0;
  double part1, part2, part3 = 0.0;
  if (block_snp_count < min_snps) {
    return 0;
  }
  threshold = 0.05 / branch_genome_size;
  while (cutoff < block_snp_count) {
    part1 = reduce_factorial(window_size, cutoff) -
            reduce_factorial(cutoff, cutoff);
    part2 = log10((num_branch_snps * 1.0) / branch_genome_size) * cutoff;
    part3 = log10(1.0 - ((num_branch_snps * 1.0) / branch_genome_size)) *
            (window_size - cutoff);
    pvalue = pvalue + pow(10, (part1 + part2 + part3));
    cutoff++;
  }
  pvalue = 1.0 - pvalue;
  if (pvalue < threshold) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<p_value_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    117f <p_value_test+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    12b1 <p_value_test+0x181>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe74(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1278 <p_value_test+0x148>
mov    -0xc(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1030 <reduce_factorial@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1030 <reduce_factorial@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log10@plt>
imul   -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe02(%rip),%xmm0
mulsd  %xmm0,%xmm1
cvtsi2sdl -0x8(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xded(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1050 <log10@plt>
mov    -0xc(%rbp),%ecx
sub    -0x24(%rbp),%ecx
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1195 <p_value_test+0x65>
movsd  0xd88(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12aa <p_value_test+0x17a>
movl   $0x1,-0x4(%rbp)
jmp    12b1 <p_value_test+0x181>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p_value_test>:
xor    %eax,%eax
cmp    %r8d,%ecx
jl     1253 <p_value_test+0x123>
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r15d
cvtsi2sd %edi,%xmm0
movsd  0xeac(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
test   %ecx,%ecx
jle    122a <p_value_test+0xfa>
mov    %esi,%r14d
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
divsd  %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
movsd  %xmm1,0x18(%rsp)
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
mov    %esi,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm1,0x20(%rsp)
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <reduce_factorial@plt>
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
mov    %ebp,%esi
call   1030 <reduce_factorial@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <log10@plt>
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <log10@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
add    $0x1,%ebp
add    $0xffffffff,%ebx
cmp    %ebp,%r15d
jne    11a0 <p_value_test+0x70>
jmp    122e <p_value_test+0xfe>
xorpd  %xmm1,%xmm1
movsd  0xdd2(%rip),%xmm0
subsd  %xmm1,%xmm0
xor    %eax,%eax
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @p_value_test(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double 0.000000e+00, double* %12
store i32 0, i32* %13
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %17
%18 = load i32, i32* %10
%19 = load i32, i32* %11
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %5
store i32 0, i32* %6
br label %79
22: ; preds = %5
%23 = load i32, i32* %7
%24 = sitofp i32 %23 to double
%25 = fdiv double 5.000000e-02, %24
store double %25, double* %12
br label %26
26: ; preds = %30, %22
%27 = load i32, i32* %13
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %71
30: ; preds = %26
%31 = load i32, i32* %8
%32 = load i32, i32* %13
%33 = call double @reduce_factorial(i32 %31, i32 %32)
%34 = load i32, i32* %13
%35 = load i32, i32* %13
%36 = call double @reduce_factorial(i32 %34, i32 %35)
%37 = fsub double %33, %36
store double %37, double* %15
%38 = load i32, i32* %9
%39 = sitofp i32 %38 to double
%40 = fmul double %39, 1.000000e+00
%41 = load i32, i32* %7
%42 = sitofp i32 %41 to double
%43 = fdiv double %40, %42
%44 = call i32 @log10(double %43)
%45 = load i32, i32* %13
%46 = mul nsw i32 %44, %45
%47 = sitofp i32 %46 to double
store double %47, double* %16
%48 = load i32, i32* %9
%49 = sitofp i32 %48 to double
%50 = fmul double %49, 1.000000e+00
%51 = load i32, i32* %7
%52 = sitofp i32 %51 to double
%53 = fdiv double %50, %52
%54 = fsub double 1.000000e+00, %53
%55 = call i32 @log10(double %54)
%56 = load i32, i32* %8
%57 = load i32, i32* %13
%58 = sub nsw i32 %56, %57
%59 = mul nsw i32 %55, %58
%60 = sitofp i32 %59 to double
store double %60, double* %17
%61 = load double, double* %14
%62 = load double, double* %15
%63 = load double, double* %16
%64 = fadd double %62, %63
%65 = load double, double* %17
%66 = fadd double %64, %65
%67 = call double @pow(i32 10, double %66)
%68 = fadd double %61, %67
store double %68, double* %14
%69 = load i32, i32* %13
%70 = add nsw i32 %69, 1
store i32 %70, i32* %13
br label %26
71: ; preds = %26
%72 = load double, double* %14
%73 = fsub double 1.000000e+00, %72
store double %73, double* %14
%74 = load double, double* %14
%75 = load double, double* %12
%76 = fcmp olt double %74, %75
br i1 %76, label %77, label %78
77: ; preds = %71
store i32 1, i32* %6
br label %79
78: ; preds = %71
store i32 0, i32* %6
br label %79
79: ; preds = %78, %77, %21
%80 = load i32, i32* %6
ret i32 %80
}

LLVM IR (-O2):
define i32 @p_value_test(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %3, %4
br i1 %6, label %39, label %7
7: ; preds = %5
%8 = sitofp i32 %0 to double
%9 = fdiv double 5.000000e-02, %8
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %34
11: ; preds = %7
%12 = sitofp i32 %2 to double
%13 = fdiv double %12, %8
%14 = fsub double 1.000000e+00, %13
br label %15
15: ; preds = %11, %15
%16 = phi double [ 0.000000e+00, %11 ], [ %31, %15 ]
%17 = phi i32 [ 0, %11 ], [ %32, %15 ]
%18 = tail call double @reduce_factorial(i32 %1, i32 %17)
%19 = tail call double @reduce_factorial(i32 %17, i32 %17)
%20 = fsub double %18, %19
%21 = tail call i32 @log10(double %13)
%22 = mul nsw i32 %21, %17
%23 = sitofp i32 %22 to double
%24 = tail call i32 @log10(double %14)
%25 = sub nsw i32 %1, %17
%26 = mul nsw i32 %24, %25
%27 = sitofp i32 %26 to double
%28 = fadd double %20, %23
%29 = fadd double %28, %27
%30 = tail call double @pow(i32 10, double %29)
%31 = fadd double %16, %30
%32 = add nuw nsw i32 %17, 1
%33 = icmp eq i32 %32, %3
br i1 %33, label %34, label %15
34: ; preds = %15, %7
%35 = phi double [ 0.000000e+00, %7 ], [ %31, %15 ]
%36 = fsub double 1.000000e+00, %35
%37 = fcmp olt double %36, %9
%38 = zext i1 %37 to i32
br label %39
39: ; preds = %34, %5
%40 = phi i32 [ 0, %5 ], [ %38, %34 ]
ret i32 %40
}