#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 */
scalar_t__ Poisson(int /*<<< orphan*/, double);
scalar_t__ Poisson1(int /*<<< orphan*/, double);
double SumPoisson20(long, double);
double SumPoisson(long k, double ny) {
  double sum;
  long j;
  if (k >= 20)
    sum = SumPoisson20(k, ny);
  else {
    sum = 0.0;
    j = 0;
    while (j <= k)
      if (j < 12)
        sum += Poisson(j++, ny);
      else
        sum += Poisson1(j++, ny);
    if (sum > 1.0)
      sum = 1.0;
  }
  return (sum);
}


x86 assembly (clang, -O0):
<SumPoisson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cmpq   $0x14,-0x8(%rbp)
jl     1164 <SumPoisson+0x34>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
call   1050 <SumPoisson20@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1214 <SumPoisson+0xe4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jg     11eb <SumPoisson+0xbb>
cmpq   $0xc,-0x20(%rbp)
jge    11bc <SumPoisson+0x8c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    %eax,%edi
movsd  -0x10(%rbp),%xmm0
call   1030 <Poisson@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11e6 <SumPoisson+0xb6>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    %eax,%edi
movsd  -0x10(%rbp),%xmm0
call   1040 <Poisson1@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1174 <SumPoisson+0x44>
movsd  -0x18(%rbp),%xmm0
movsd  0xe08(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    120f <SumPoisson+0xdf>
movsd  0xdf6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1214 <SumPoisson+0xe4>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SumPoisson>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
cmp    $0x13,%rdi
jle    114f <SumPoisson+0x1f>
mov    %r14,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1050 <SumPoisson20@plt>
test   %r14,%r14
js     11bf <SumPoisson+0x8f>
add    $0x1,%r14
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
jmp    1196 <SumPoisson+0x66>
cs nopw 0x0(%rax,%rax,1)
call   1040 <Poisson1@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbx
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm2
cmp    %rbx,%r14
je     11ab <SumPoisson+0x7b>
cmp    $0xb,%rbx
movsd  %xmm2,0x10(%rsp)
mov    %ebx,%edi
ja     1170 <SumPoisson+0x40>
call   1030 <Poisson@plt>
jmp    1175 <SumPoisson+0x45>
ucomisd 0xe4d(%rip),%xmm2
jbe    11c3 <SumPoisson+0x93>
movsd  0xe43(%rip),%xmm2
jmp    11c3 <SumPoisson+0x93>
xorpd  %xmm2,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @SumPoisson(i64 %0, double %1) {
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca i64
store i64 %0, i64* %3
store double %1, double* %4
%7 = load i64, i64* %3
%8 = icmp sge i64 %7, 20
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i64, i64* %3
%11 = load double, double* %4
%12 = call double @SumPoisson20(i64 %10, double %11)
store double %12, double* %5
br label %45
13: ; preds = %2
store double 0.000000e+00, double* %5
store i64 0, i64* %6
br label %14
14: ; preds = %39, %13
%15 = load i64, i64* %6
%16 = load i64, i64* %3
%17 = icmp sle i64 %15, %16
br i1 %17, label %18, label %40
18: ; preds = %14
%19 = load i64, i64* %6
%20 = icmp slt i64 %19, 12
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i64, i64* %6
%23 = add nsw i64 %22, 1
store i64 %23, i64* %6
%24 = trunc i64 %22 to i32
%25 = load double, double* %4
%26 = call i64 @Poisson(i32 %24, double %25)
%27 = sitofp i64 %26 to double
%28 = load double, double* %5
%29 = fadd double %28, %27
store double %29, double* %5
br label %39
30: ; preds = %18
%31 = load i64, i64* %6
%32 = add nsw i64 %31, 1
store i64 %32, i64* %6
%33 = trunc i64 %31 to i32
%34 = load double, double* %4
%35 = call i64 @Poisson1(i32 %33, double %34)
%36 = sitofp i64 %35 to double
%37 = load double, double* %5
%38 = fadd double %37, %36
store double %38, double* %5
br label %39
39: ; preds = %30, %21
br label %14
40: ; preds = %14
%41 = load double, double* %5
%42 = fcmp ogt double %41, 1.000000e+00
br i1 %42, label %43, label %44
43: ; preds = %40
store double 1.000000e+00, double* %5
br label %44
44: ; preds = %43, %40
br label %45
45: ; preds = %44, %9
%46 = load double, double* %5
ret double %46
}

LLVM IR (-O2):
define double @SumPoisson(i64 %0, double %1) {
%3 = icmp sgt i64 %0, 19
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = icmp slt i64 %0, 0
br i1 %5, label %26, label %8
6: ; preds = %2
%7 = tail call double @SumPoisson20(i64 %0, double %1)
br label %26
8: ; preds = %4, %17
%9 = phi i64 [ %19, %17 ], [ 0, %4 ]
%10 = phi double [ %21, %17 ], [ 0.000000e+00, %4 ]
%11 = icmp ult i64 %9, 12
%12 = trunc i64 %9 to i32
br i1 %11, label %13, label %15
13: ; preds = %8
%14 = tail call i64 @Poisson(i32 %12, double %1)
br label %17
15: ; preds = %8
%16 = tail call i64 @Poisson1(i32 %12, double %1)
br label %17
17: ; preds = %15, %13
%18 = phi i64 [ %14, %13 ], [ %16, %15 ]
%19 = add nuw i64 %9, 1
%20 = sitofp i64 %18 to double
%21 = fadd double %10, %20
%22 = icmp eq i64 %9, %0
br i1 %22, label %23, label %8
23: ; preds = %17
%24 = fcmp ogt double %21, 1.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %23
br label %26
26: ; preds = %4, %23, %25, %6
%27 = phi double [ %7, %6 ], [ 1.000000e+00, %25 ], [ %21, %23 ], [ 0.000000e+00, %4 ]
ret double %27
}