#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 IntPoisson(double, double);
double Poisson(long, double);
long ceil(double);
double fabs(double);
long floor(double);
double sqrt(double);
long InvSumPoisson(double y, double ny) {
  const int imax = 200;
  const double diffeps = 1e-14;
  const double amin = 1e-16;
  double k, kold;
  double yn;
  double a, b;
  double eps;
  int i = 0;
  if (ny < 1e-6)
    return (0.0);
  if (ny > 1)
    eps = sqrt(ny) / 10.0;
  else
    eps = ny / 10.0;
  k = ny;
  for (i = 1; i < imax; i++) {
    yn = IntPoisson(k, ny);
    if (ny < 100)
      a = Poisson(ceil(k), ny);
    else
      a = Poisson(floor(k), ny);
    if (fabs(a) < amin)
      break;
    if ((a > 0) && (1.0 - yn < diffeps))
      break;
    if ((a < 0) && (yn < diffeps))
      break;
    b = yn - a * k;
    kold = k;
    k = (y - b) / a;
    if (k < 0)
      k = 0;
    if (fabs(k - kold) < eps)
      break;
  }
  return (ceil(k));
}


x86 assembly (clang, -O0):
<InvSumPoisson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movl   $0xc8,-0x1c(%rbp)
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x64(%rbp)
movsd  0xe6e(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11aa <InvSumPoisson+0x5a>
movq   $0x0,-0x8(%rbp)
jmp    13ad <InvSumPoisson+0x25d>
movsd  -0x18(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e1 <InvSumPoisson+0x91>
movsd  -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  0xe4d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    11f7 <InvSumPoisson+0xa7>
movsd  -0x18(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x64(%rbp)
cmpl   $0xc8,-0x64(%rbp)
jge    139f <InvSumPoisson+0x24f>
movsd  -0x38(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <IntPoisson@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xdf7(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    125d <InvSumPoisson+0x10d>
movsd  -0x38(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
call   1040 <Poisson@plt>
movsd  %xmm0,-0x50(%rbp)
jmp    1279 <InvSumPoisson+0x129>
movsd  -0x38(%rbp),%xmm0
call   1070 <floor@plt>
mov    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
call   1040 <Poisson@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movaps 0xdab(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd77(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12a0 <InvSumPoisson+0x150>
jmp    139f <InvSumPoisson+0x24f>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12d6 <InvSumPoisson+0x186>
movsd  0xd5e(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
movsd  0xd49(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12d6 <InvSumPoisson+0x186>
jmp    139f <InvSumPoisson+0x24f>
xorps  %xmm0,%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    12fc <InvSumPoisson+0x1ac>
movsd  0xd24(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    12fc <InvSumPoisson+0x1ac>
jmp    139f <InvSumPoisson+0x24f>
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1363 <InvSumPoisson+0x213>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movaps 0xcbc(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    138c <InvSumPoisson+0x23c>
jmp    139f <InvSumPoisson+0x24f>
jmp    1391 <InvSumPoisson+0x241>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1208 <InvSumPoisson+0xb8>
movsd  -0x38(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InvSumPoisson>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm0,0x20(%rsp)
movsd  0xe9d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1171 <InvSumPoisson+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret
ucomisd 0xe8f(%rip),%xmm1
movapd %xmm1,%xmm2
movsd  %xmm1,0x8(%rsp)
jbe    11b9 <InvSumPoisson+0x69>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm1
jb     11a4 <InvSumPoisson+0x54>
xorps  %xmm2,%xmm2
sqrtsd %xmm1,%xmm2
jmp    11b9 <InvSumPoisson+0x69>
movsd  0x8(%rsp),%xmm0
call   1060 <sqrt@plt>
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
divsd  0xe4f(%rip),%xmm2
mov    $0xc6,%ebx
movsd  %xmm2,0x18(%rsp)
nopl   0x0(%rax)
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
call   1050 <IntPoisson@plt>
movsd  0xe2b(%rip),%xmm1
ucomisd 0x8(%rsp),%xmm1
movsd  %xmm0,0x28(%rsp)
jbe    1210 <InvSumPoisson+0xc0>
movsd  0x10(%rsp),%xmm0
call   1030 <ceil@plt>
jmp    121b <InvSumPoisson+0xcb>
nopl   0x0(%rax,%rax,1)
movsd  0x10(%rsp),%xmm0
call   1070 <floor@plt>
movsd  0x8(%rsp),%xmm0
mov    %rax,%rdi
call   1040 <Poisson@plt>
movapd %xmm0,%xmm1
movapd 0xdfb(%rip),%xmm2
andpd  %xmm2,%xmm1
movsd  0xddf(%rip),%xmm3
ucomisd %xmm1,%xmm3
ja     12dd <InvSumPoisson+0x18d>
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
movsd  0x28(%rsp),%xmm5
jbe    1275 <InvSumPoisson+0x125>
movsd  0xda5(%rip),%xmm1
subsd  %xmm5,%xmm1
movsd  0xdb9(%rip),%xmm4
ucomisd %xmm1,%xmm4
ja     12dd <InvSumPoisson+0x18d>
ucomisd %xmm0,%xmm3
jbe    1289 <InvSumPoisson+0x139>
movsd  0xda5(%rip),%xmm1
ucomisd %xmm5,%xmm1
ja     12dd <InvSumPoisson+0x18d>
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm1
subsd  %xmm1,%xmm5
movsd  0x20(%rsp),%xmm1
subsd  %xmm5,%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
maxsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
subsd  %xmm3,%xmm1
andpd  %xmm2,%xmm1
sub    $0x1,%ebx
setb   %al
movsd  0x18(%rsp),%xmm2
ucomisd %xmm1,%xmm2
ja     12e3 <InvSumPoisson+0x193>
movapd %xmm0,%xmm1
test   %al,%al
je     11d0 <InvSumPoisson+0x80>
jmp    12e3 <InvSumPoisson+0x193>
movsd  0x10(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
jmp    1030 <ceil@plt>

LLVM IR (-O0):
define i64 @InvSumPoisson(double %0, double %1) {
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
store double %0, double* %4
store double %1, double* %5
store i32 200, i32* %6
store double 0x3D06849B86A12B9B, double* %7
store double 0x3C9CD2B297D889BC, double* %8
store i32 0, i32* %15
%16 = load double, double* %5
%17 = fcmp olt double %16, 0x3EB0C6F7A0B5ED8D
br i1 %17, label %18, label %19
18: ; preds = %2
store i64 0, i64* %3
br label %100
19: ; preds = %2
%20 = load double, double* %5
%21 = fcmp ogt double %20, 1.000000e+00
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load double, double* %5
%24 = call double @sqrt(double %23)
%25 = fdiv double %24, 1.000000e+01
store double %25, double* %14
br label %29
26: ; preds = %19
%27 = load double, double* %5
%28 = fdiv double %27, 1.000000e+01
store double %28, double* %14
br label %29
29: ; preds = %26, %22
%30 = load double, double* %5
store double %30, double* %9
store i32 1, i32* %15
br label %31
31: ; preds = %94, %29
%32 = load i32, i32* %15
%33 = icmp slt i32 %32, 200
br i1 %33, label %34, label %97
34: ; preds = %31
%35 = load double, double* %9
%36 = load double, double* %5
%37 = call double @IntPoisson(double %35, double %36)
store double %37, double* %11
%38 = load double, double* %5
%39 = fcmp olt double %38, 1.000000e+02
br i1 %39, label %40, label %45
40: ; preds = %34
%41 = load double, double* %9
%42 = call i64 @ceil(double %41)
%43 = load double, double* %5
%44 = call double @Poisson(i64 %42, double %43)
store double %44, double* %12
br label %50
45: ; preds = %34
%46 = load double, double* %9
%47 = call i64 @floor(double %46)
%48 = load double, double* %5
%49 = call double @Poisson(i64 %47, double %48)
store double %49, double* %12
br label %50
50: ; preds = %45, %40
%51 = load double, double* %12
%52 = call double @llvm.fabs.f64(double %51)
%53 = fcmp olt double %52, 0x3C9CD2B297D889BC
br i1 %53, label %54, label %55
54: ; preds = %50
br label %97
55: ; preds = %50
%56 = load double, double* %12
%57 = fcmp ogt double %56, 0.000000e+00
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = load double, double* %11
%60 = fsub double 1.000000e+00, %59
%61 = fcmp olt double %60, 0x3D06849B86A12B9B
br i1 %61, label %62, label %63
62: ; preds = %58
br label %97
63: ; preds = %58, %55
%64 = load double, double* %12
%65 = fcmp olt double %64, 0.000000e+00
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = load double, double* %11
%68 = fcmp olt double %67, 0x3D06849B86A12B9B
br i1 %68, label %69, label %70
69: ; preds = %66
br label %97
70: ; preds = %66, %63
%71 = load double, double* %11
%72 = load double, double* %12
%73 = load double, double* %9
%74 = fneg double %72
%75 = call double @llvm.fmuladd.f64(double %74, double %73, double %71)
store double %75, double* %13
%76 = load double, double* %9
store double %76, double* %10
%77 = load double, double* %4
%78 = load double, double* %13
%79 = fsub double %77, %78
%80 = load double, double* %12
%81 = fdiv double %79, %80
store double %81, double* %9
%82 = load double, double* %9
%83 = fcmp olt double %82, 0.000000e+00
br i1 %83, label %84, label %85
84: ; preds = %70
store double 0.000000e+00, double* %9
br label %85
85: ; preds = %84, %70
%86 = load double, double* %9
%87 = load double, double* %10
%88 = fsub double %86, %87
%89 = call double @llvm.fabs.f64(double %88)
%90 = load double, double* %14
%91 = fcmp olt double %89, %90
br i1 %91, label %92, label %93
92: ; preds = %85
br label %97
93: ; preds = %85
br label %94
94: ; preds = %93
%95 = load i32, i32* %15
%96 = add nsw i32 %95, 1
store i32 %96, i32* %15
br label %31
97: ; preds = %92, %69, %62, %54, %31
%98 = load double, double* %9
%99 = call i64 @ceil(double %98)
store i64 %99, i64* %3
br label %100
100: ; preds = %97, %18
%101 = load i64, i64* %3
ret i64 %101
}

LLVM IR (-O2):
define i64 @InvSumPoisson(double %0, double %1) {
%3 = fcmp olt double %1, 0x3EB0C6F7A0B5ED8D
br i1 %3, label %50, label %4
4: ; preds = %2
%5 = fcmp ogt double %1, 1.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call double @sqrt(double %1)
br label %8
8: ; preds = %4, %6
%9 = phi double [ %7, %6 ], [ %1, %4 ]
%10 = fdiv double %9, 1.000000e+01
%11 = fcmp olt double %1, 1.000000e+02
br label %12
12: ; preds = %34, %8
%13 = phi i32 [ 1, %8 ], [ %44, %34 ]
%14 = phi double [ %1, %8 ], [ %40, %34 ]
%15 = tail call double @IntPoisson(double %14, double %1)
br i1 %11, label %16, label %18
16: ; preds = %12
%17 = tail call i64 @ceil(double %14)
br label %20
18: ; preds = %12
%19 = tail call i64 @floor(double %14)
br label %20
20: ; preds = %18, %16
%21 = phi i64 [ %19, %18 ], [ %17, %16 ]
%22 = tail call double @Poisson(i64 %21, double %1)
%23 = tail call double @llvm.fabs.f64(double %22)
%24 = fcmp olt double %23, 0x3C9CD2B297D889BC
br i1 %24, label %47, label %25
25: ; preds = %20
%26 = fcmp ogt double %22, 0.000000e+00
%27 = fsub double 1.000000e+00, %15
%28 = fcmp olt double %27, 0x3D06849B86A12B9B
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %47, label %30
30: ; preds = %25
%31 = fcmp olt double %22, 0.000000e+00
%32 = fcmp olt double %15, 0x3D06849B86A12B9B
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %47, label %34
34: ; preds = %30
%35 = fneg double %22
%36 = tail call double @llvm.fmuladd.f64(double %35, double %14, double %15)
%37 = fsub double %0, %36
%38 = fdiv double %37, %22
%39 = fcmp olt double %38, 0.000000e+00
%40 = select i1 %39, double 0.000000e+00, double %38
%41 = fsub double %40, %14
%42 = tail call double @llvm.fabs.f64(double %41)
%43 = fcmp olt double %42, %10
%44 = add nuw nsw i32 %13, 1
%45 = icmp eq i32 %44, 200
%46 = select i1 %43, i1 true, i1 %45
br i1 %46, label %47, label %12
47: ; preds = %25, %34, %30, %20
%48 = phi double [ %14, %20 ], [ %14, %30 ], [ %40, %34 ], [ %14, %25 ]
%49 = tail call i64 @ceil(double %48)
br label %50
50: ; preds = %2, %47
%51 = phi i64 [ %49, %47 ], [ 0, %2 ]
ret i64 %51
}