#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 alam) {
  int j;
  double a2, fac = 2.0, sum = 0.0, term, termbf = 0.0;
  a2 = -2.0 * alam * alam;
  for (j = 1; j <= 100; j++) {
    term = fac * exp(a2 * j * j);
    sum += term;
    if (fabs(term) <= 0.001 * termbf || fabs(term) <= 1.0e-8 * 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     1249 <probks+0x139>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm1
movaps 0xe7c(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe58(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jae    11f6 <probks+0xe6>
movsd  -0x38(%rbp),%xmm1
movaps 0xe55(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe39(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1205 <probks+0xf5>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1256 <probks+0x146>
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 0xdfe(%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  0xdbf(%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)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movapd 0x20(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm0,%xmm2
andpd  0xea8(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe7a(%rip),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm2,%xmm1
mulsd  0xe72(%rip),%xmm1
jae    11c6 <probks+0xb6>
ucomisd %xmm0,%xmm1
jae    11c6 <probks+0xb6>
xorpd  0xe8a(%rip),%xmm3
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1140 <probks+0x30>
movsd  0xe5a(%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
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
%10 = load double, double* %3
%11 = fmul double -2.000000e+00, %10
%12 = load double, double* %3
%13 = fmul double %11, %12
store double %13, double* %5
store i32 1, i32* %4
br label %14
14: ; preds = %49, %1
%15 = load i32, i32* %4
%16 = icmp sle i32 %15, 100
br i1 %16, label %17, label %52
17: ; preds = %14
%18 = load double, double* %6
%19 = load double, double* %5
%20 = load i32, i32* %4
%21 = sitofp i32 %20 to double
%22 = fmul double %19, %21
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to double
%25 = fmul double %22, %24
%26 = call double @exp(double %25)
%27 = fmul double %18, %26
store double %27, double* %8
%28 = load double, double* %8
%29 = load double, double* %7
%30 = fadd double %29, %28
store double %30, double* %7
%31 = load double, double* %8
%32 = call double @llvm.fabs.f64(double %31)
%33 = load double, double* %9
%34 = fmul double 1.000000e-03, %33
%35 = fcmp ole double %32, %34
br i1 %35, label %42, label %36
36: ; preds = %17
%37 = load double, double* %8
%38 = call double @llvm.fabs.f64(double %37)
%39 = load double, double* %7
%40 = fmul double 1.000000e-08, %39
%41 = fcmp ole double %38, %40
br i1 %41, label %42, label %44
42: ; preds = %36, %17
%43 = load double, double* %7
store double %43, double* %2
br label %53
44: ; preds = %36
%45 = load double, double* %6
%46 = fneg double %45
store double %46, double* %6
%47 = load double, double* %8
%48 = call double @llvm.fabs.f64(double %47)
store double %48, double* %9
br label %49
49: ; preds = %44
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %14
52: ; preds = %14
store double 1.000000e+00, double* %2
br label %53
53: ; preds = %52, %42
%54 = load double, double* %2
ret double %54
}

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 = sitofp i32 %8 to double
%10 = fmul double %3, %9
%11 = fmul double %10, %9
%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, 1.000000e-08
%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
}