#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 */
long double expl(double);
long double powl(double, double);
double igf(double S, double Z) {
  if (Z < 0.0) {
    return 0.0;
  }
  long double Sc = (1.0 / S);
  Sc *= powl(Z, S);
  Sc *= expl(-Z);
  long double Sum = 1.0;
  long double Nom = 1.0;
  long double Denom = 1.0;
  for (int I = 0; I < 200; I++) {
    Nom *= Z;
    S++;
    Denom *= S;
    Sum += (Nom / Denom);
  }
  return Sum * Sc;
}


x86 assembly (clang, -O0):
<igf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1150 <igf+0x30>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1222 <igf+0x102>
movsd  -0x10(%rbp),%xmm1
movsd  0xea3(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
fldl   -0x70(%rbp)
fstpt  -0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <powl@plt>
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
movaps 0xe86(%rip),%xmm1
movsd  -0x18(%rbp),%xmm0
pxor   %xmm1,%xmm0
call   1040 <expl@plt>
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
fld1
fld    %st(0)
fstpt  -0x40(%rbp)
fld    %st(0)
fstpt  -0x50(%rbp)
fstpt  -0x60(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0xc8,-0x64(%rbp)
jge    120d <igf+0xed>
fldl   -0x18(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
fstpt  -0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe25(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
fldl   -0x10(%rbp)
fldt   -0x60(%rbp)
fmulp  %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
fldt   -0x60(%rbp)
fdivrp %st,%st(1)
fldt   -0x40(%rbp)
faddp  %st,%st(1)
fstpt  -0x40(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b6 <igf+0x96>
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
fmulp  %st,%st(1)
fstpl  -0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<igf>:
movapd %xmm1,%xmm2
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
ja     1215 <igf+0xf5>
sub    $0x68,%rsp
movsd  0xebe(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm1
movapd %xmm2,0x50(%rsp)
call   1030 <powl@plt>
fstpt  0x44(%rsp)
movaps 0xe9e(%rip),%xmm0
xorps  0x50(%rsp),%xmm0
call   1040 <expl@plt>
movsd  0xe7c(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
movapd 0x50(%rsp),%xmm2
movsd  %xmm2,0x38(%rsp)
fld1
mov    $0xc8,%eax
fldl   0x38(%rsp)
fld    %st(1)
fld    %st(2)
cs nopw 0x0(%rax,%rax,1)
nop
fxch   %st(1)
fmul   %st(2),%st
addsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
fxch   %st(3)
fmull  0x30(%rsp)
fld    %st(3)
fdiv   %st(1),%st
faddp  %st,%st(2)
addsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
fmull  0x28(%rsp)
fxch   %st(3)
fmul   %st(2),%st
fld    %st(0)
fdiv   %st(4),%st
faddp  %st,%st(2)
add    $0xfffffffe,%eax
fxch   %st(1)
jne    11b0 <igf+0x90>
fstp   %st(2)
fstp   %st(2)
fstp   %st(1)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
fldt   0x44(%rsp)
fmull  0x20(%rsp)
fmulp  %st,%st(2)
fmulp  %st,%st(1)
fstpl  0x18(%rsp)
movsd  0x18(%rsp),%xmm0
add    $0x68,%rsp
ret

LLVM IR (-O0):
define double @igf(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca x86_fp80
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca x86_fp80
%10 = alloca i32
store double %0, double* %4
store double %1, double* %5
%11 = load double, double* %5
%12 = fcmp olt double %11, 0.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %2
store double 0.000000e+00, double* %3
br label %55
14: ; preds = %2
%15 = load double, double* %4
%16 = fdiv double 1.000000e+00, %15
%17 = fpext double %16 to x86_fp80
store x86_fp80 %17, x86_fp80* %6
%18 = load double, double* %5
%19 = load double, double* %4
%20 = call x86_fp80 @powl(double %18, double %19)
%21 = load x86_fp80, x86_fp80* %6
%22 = fmul x86_fp80 %21, %20
store x86_fp80 %22, x86_fp80* %6
%23 = load double, double* %5
%24 = fneg double %23
%25 = call x86_fp80 @expl(double %24)
%26 = load x86_fp80, x86_fp80* %6
%27 = fmul x86_fp80 %26, %25
store x86_fp80 %27, x86_fp80* %6
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %7
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %8
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %9
store i32 0, i32* %10
br label %28
28: ; preds = %47, %14
%29 = load i32, i32* %10
%30 = icmp slt i32 %29, 200
br i1 %30, label %31, label %50
31: ; preds = %28
%32 = load double, double* %5
%33 = fpext double %32 to x86_fp80
%34 = load x86_fp80, x86_fp80* %8
%35 = fmul x86_fp80 %34, %33
store x86_fp80 %35, x86_fp80* %8
%36 = load double, double* %4
%37 = fadd double %36, 1.000000e+00
store double %37, double* %4
%38 = load double, double* %4
%39 = fpext double %38 to x86_fp80
%40 = load x86_fp80, x86_fp80* %9
%41 = fmul x86_fp80 %40, %39
store x86_fp80 %41, x86_fp80* %9
%42 = load x86_fp80, x86_fp80* %8
%43 = load x86_fp80, x86_fp80* %9
%44 = fdiv x86_fp80 %42, %43
%45 = load x86_fp80, x86_fp80* %7
%46 = fadd x86_fp80 %45, %44
store x86_fp80 %46, x86_fp80* %7
br label %47
47: ; preds = %31
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
br label %28
50: ; preds = %28
%51 = load x86_fp80, x86_fp80* %7
%52 = load x86_fp80, x86_fp80* %6
%53 = fmul x86_fp80 %51, %52
%54 = fptrunc x86_fp80 %53 to double
store double %54, double* %3
br label %55
55: ; preds = %50, %13
%56 = load double, double* %3
ret double %56
}

LLVM IR (-O2):
define double @igf(double %0, double %1) {
%3 = fcmp olt double %1, 0.000000e+00
br i1 %3, label %36, label %4
4: ; preds = %2
%5 = fdiv double 1.000000e+00, %0
%6 = tail call x86_fp80 @powl(double %1, double %0)
%7 = fneg double %1
%8 = tail call x86_fp80 @expl(double %7)
%9 = fpext double %1 to x86_fp80
br label %16
10: ; preds = %16
%11 = fpext double %5 to x86_fp80
%12 = fmul x86_fp80 %6, %11
%13 = fmul x86_fp80 %12, %8
%14 = fmul x86_fp80 %13, %33
%15 = fptrunc x86_fp80 %14 to double
br label %36
16: ; preds = %16, %4
%17 = phi i32 [ 0, %4 ], [ %34, %16 ]
%18 = phi x86_fp80 [ 0xK3FFF8000000000000000, %4 ], [ %31, %16 ]
%19 = phi x86_fp80 [ 0xK3FFF8000000000000000, %4 ], [ %28, %16 ]
%20 = phi double [ %0, %4 ], [ %29, %16 ]
%21 = phi x86_fp80 [ 0xK3FFF8000000000000000, %4 ], [ %33, %16 ]
%22 = fmul x86_fp80 %19, %9
%23 = fadd double %20, 1.000000e+00
%24 = fpext double %23 to x86_fp80
%25 = fmul x86_fp80 %18, %24
%26 = fdiv x86_fp80 %22, %25
%27 = fadd x86_fp80 %21, %26
%28 = fmul x86_fp80 %22, %9
%29 = fadd double %23, 1.000000e+00
%30 = fpext double %29 to x86_fp80
%31 = fmul x86_fp80 %25, %30
%32 = fdiv x86_fp80 %28, %31
%33 = fadd x86_fp80 %27, %32
%34 = add nuw nsw i32 %17, 2
%35 = icmp eq i32 %34, 200
br i1 %35, label %10, label %16
36: ; preds = %2, %10
%37 = phi double [ %15, %10 ], [ 0.000000e+00, %2 ]
ret double %37
}