#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);
int fabs(double);
double log(double);
double _calcPhi_1(double theta) {
  double phi_1, a_n, step1, step2, n, riemann_zeta_2, I_m;
  step1 = 1.0;
  step2 = 0.0;
  n = 1.0;
  a_n = 0.0;
  while (fabs(step1 - step2) > 1E-6) {
    step1 = step2;
    step2 = 1.0 / (exp(n / theta) * n * n);
    a_n += step2;
    n = n + 1.0;
  }
  riemann_zeta_2 = 3.14159265358979323846 * 3.14159265358979323846 / 6.0;
  I_m = theta * log(1.0 - exp(-1.0 / theta)) +
        theta * theta * (riemann_zeta_2 - a_n);
  phi_1 = 0.5 + 2.0 * I_m;
  return phi_1;
}


x86 assembly (clang, -O0):
<_calcPhi_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xebb(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xea6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe86(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e9 <_calcPhi_1+0xb9>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
movsd  0xe46(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe26(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1167 <_calcPhi_1+0x37>
movsd  0xe2f(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe10(%rip),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xde3(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm3
subsd  -0x18(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xdac(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_calcPhi_1>:
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
movsd  0xebe(%rip),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
test   %eax,%eax
jle    11de <_calcPhi_1+0xae>
movsd  %xmm0,(%rsp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
call   1040 <exp@plt>
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe63(%rip),%xmm1
movapd %xmm1,%xmm3
divsd  %xmm0,%xmm3
movsd  %xmm3,0x18(%rsp)
movsd  (%rsp),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,(%rsp)
addsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
subsd  %xmm3,%xmm0
call   1030 <fabs@plt>
movsd  0x18(%rsp),%xmm0
test   %eax,%eax
jg     1170 <_calcPhi_1+0x40>
jmp    11e3 <_calcPhi_1+0xb3>
movsd  %xmm0,(%rsp)
movsd  0xe1d(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1040 <exp@plt>
movsd  0xe02(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1050 <log@plt>
movsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movsd  0xdef(%rip),%xmm2
subsd  (%rsp),%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm0,%xmm0
addsd  0xdda(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @_calcPhi_1(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %2
store double 1.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 1.000000e+00, double* %7
store double 0.000000e+00, double* %4
br label %10
10: ; preds = %17, %1
%11 = load double, double* %5
%12 = load double, double* %6
%13 = fsub double %11, %12
%14 = call i32 @fabs(double %13)
%15 = sitofp i32 %14 to double
%16 = fcmp ogt double %15, 0x3EB0C6F7A0B5ED8D
br i1 %16, label %17, label %33
17: ; preds = %10
%18 = load double, double* %6
store double %18, double* %5
%19 = load double, double* %7
%20 = load double, double* %2
%21 = fdiv double %19, %20
%22 = call double @exp(double %21)
%23 = load double, double* %7
%24 = fmul double %22, %23
%25 = load double, double* %7
%26 = fmul double %24, %25
%27 = fdiv double 1.000000e+00, %26
store double %27, double* %6
%28 = load double, double* %6
%29 = load double, double* %4
%30 = fadd double %29, %28
store double %30, double* %4
%31 = load double, double* %7
%32 = fadd double %31, 1.000000e+00
store double %32, double* %7
br label %10
33: ; preds = %10
store double 0x3FFA51A6625307D3, double* %8
%34 = load double, double* %2
%35 = load double, double* %2
%36 = fdiv double -1.000000e+00, %35
%37 = call double @exp(double %36)
%38 = fsub double 1.000000e+00, %37
%39 = call double @log(double %38)
%40 = load double, double* %2
%41 = load double, double* %2
%42 = fmul double %40, %41
%43 = load double, double* %8
%44 = load double, double* %4
%45 = fsub double %43, %44
%46 = fmul double %42, %45
%47 = call double @llvm.fmuladd.f64(double %34, double %39, double %46)
store double %47, double* %9
%48 = load double, double* %9
%49 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %48, double 5.000000e-01)
store double %49, double* %3
%50 = load double, double* %3
ret double %50
}

LLVM IR (-O2):
define double @_calcPhi_1(double %0) {
%2 = tail call i32 @fabs(double 1.000000e+00)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1, %4
%5 = phi double [ %13, %4 ], [ 0.000000e+00, %1 ]
%6 = phi double [ %14, %4 ], [ 1.000000e+00, %1 ]
%7 = phi double [ %12, %4 ], [ 0.000000e+00, %1 ]
%8 = fdiv double %6, %0
%9 = tail call double @exp(double %8)
%10 = fmul double %6, %9
%11 = fmul double %6, %10
%12 = fdiv double 1.000000e+00, %11
%13 = fadd double %5, %12
%14 = fadd double %6, 1.000000e+00
%15 = fsub double %7, %12
%16 = tail call i32 @fabs(double %15)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %4, label %18
18: ; preds = %4, %1
%19 = phi double [ 0.000000e+00, %1 ], [ %13, %4 ]
%20 = fdiv double -1.000000e+00, %0
%21 = tail call double @exp(double %20)
%22 = fsub double 1.000000e+00, %21
%23 = tail call double @log(double %22)
%24 = fmul double %0, %0
%25 = fsub double 0x3FFA51A6625307D3, %19
%26 = fmul double %24, %25
%27 = tail call double @llvm.fmuladd.f64(double %0, double %23, double %26)
%28 = tail call double @llvm.fmuladd.f64(double %27, double 2.000000e+00, double 5.000000e-01)
ret double %28
}