#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 exp(double);
double fabs(double);
double probks(double lam) {
  int j;
  double a2, fac = 2.0, sum = 0.0, term, termbf = 0.0;
  double t;
  a2 = -2.0 * lam * lam;
  for (j = 1; j <= 100; j++) {
    t = a2 * (double)(j * j);
    term = fac * exp(t);
    sum += term;
    t = fabs(term);
    if ((t <= .001 * termbf) || (t <= 1.0e-12 * sum))
      return sum;
    fac = -fac;
    termbf = fabs(term);
  }
  return 1.0;
}


x86 assembly (clang, -O0):
<probks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xee3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xebe(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jg     124f <probks+0x13f>
movsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movaps 0xe75(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  0xe47(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jae    11fc <probks+0xec>
movsd  -0x48(%rbp),%xmm1
movsd  0xe33(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     120b <probks+0xfb>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125c <probks+0x14c>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
movaps 0xdf8(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1158 <probks+0x48>
movsd  0xdb9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<probks>:
push   %rbx
sub    $0x30,%rsp
movsd  0xee3(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x1,%ebx
movsd  0xed0(%rip),%xmm3
xorpd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
movsd  %xmm0,0x10(%rsp)
movapd %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
mov    %ebx,%eax
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
movapd 0x20(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm0,%xmm2
andpd  0xeab(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe7d(%rip),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm2,%xmm1
mulsd  0xe75(%rip),%xmm1
jae    11c3 <probks+0xb3>
ucomisd %xmm0,%xmm1
jae    11c3 <probks+0xb3>
xorpd  0xe8d(%rip),%xmm3
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1140 <probks+0x30>
movsd  0xe5d(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @probks(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %3
store double 2.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %9
%11 = load double, double* %3
%12 = fmul double -2.000000e+00, %11
%13 = load double, double* %3
%14 = fmul double %12, %13
store double %14, double* %5
store i32 1, i32* %4
br label %15
15: ; preds = %50, %1
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 100
br i1 %17, label %18, label %53
18: ; preds = %15
%19 = load double, double* %5
%20 = load i32, i32* %4
%21 = load i32, i32* %4
%22 = mul nsw i32 %20, %21
%23 = sitofp i32 %22 to double
%24 = fmul double %19, %23
store double %24, double* %10
%25 = load double, double* %6
%26 = load double, double* %10
%27 = call double @exp(double %26)
%28 = fmul double %25, %27
store double %28, double* %8
%29 = load double, double* %8
%30 = load double, double* %7
%31 = fadd double %30, %29
store double %31, double* %7
%32 = load double, double* %8
%33 = call double @llvm.fabs.f64(double %32)
store double %33, double* %10
%34 = load double, double* %10
%35 = load double, double* %9
%36 = fmul double 1.000000e-03, %35
%37 = fcmp ole double %34, %36
br i1 %37, label %43, label %38
38: ; preds = %18
%39 = load double, double* %10
%40 = load double, double* %7
%41 = fmul double 0x3D719799812DEA11, %40
%42 = fcmp ole double %39, %41
br i1 %42, label %43, label %45
43: ; preds = %38, %18
%44 = load double, double* %7
store double %44, double* %2
br label %54
45: ; preds = %38
%46 = load double, double* %6
%47 = fneg double %46
store double %47, double* %6
%48 = load double, double* %8
%49 = call double @llvm.fabs.f64(double %48)
store double %49, double* %9
br label %50
50: ; preds = %45
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %15
53: ; preds = %15
store double 1.000000e+00, double* %2
br label %54
54: ; preds = %53, %43
%55 = load double, double* %2
ret double %55
}

LLVM IR (-O2):
define double @probks(double %0) {
%2 = fmul double %0, -2.000000e+00
%3 = fmul double %2, %0
br label %4
4: ; preds = %1, %21
%5 = phi double [ 0.000000e+00, %1 ], [ %15, %21 ]
%6 = phi double [ 0.000000e+00, %1 ], [ %14, %21 ]
%7 = phi double [ 2.000000e+00, %1 ], [ %22, %21 ]
%8 = phi i32 [ 1, %1 ], [ %23, %21 ]
%9 = mul nuw nsw i32 %8, %8
%10 = sitofp i32 %9 to double
%11 = fmul double %3, %10
%12 = tail call double @exp(double %11)
%13 = fmul double %7, %12
%14 = fadd double %6, %13
%15 = tail call double @llvm.fabs.f64(double %13)
%16 = fmul double %5, 1.000000e-03
%17 = fcmp ugt double %15, %16
%18 = fmul double %14, 0x3D719799812DEA11
%19 = fcmp ugt double %15, %18
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %21, label %25
21: ; preds = %4
%22 = fneg double %7
%23 = add nuw nsw i32 %8, 1
%24 = icmp eq i32 %23, 101
br i1 %24, label %25, label %4
25: ; preds = %21, %4
%26 = phi double [ %14, %4 ], [ 1.000000e+00, %21 ]
ret double %26
}