#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 */
int DBL_EPSILON;
double M_PI;
double acos(double);
double cos(double);
double cosh(double const);
int fabs(double);
int square(double const);
double CalculateSum12Exp(const double d12, const double d34, const double eta) {
  const double coshe = cosh(eta);
  const double cos12 = cos(6.283185307179586476925 * d12);
  const double cos34 = cos(6.283185307179586476925 * d34);
  const double b = 1 + square(coshe) + cos12 * cos34;
  const double c = coshe * (cos12 + cos34);
  double x = 0;
  double f = c;
  do {
    x = x - f / (3 * x * x - b);
    f = x * x * x - b * x + c;
  } while (fabs(f) > 4 * DBL_EPSILON);
  return acos(x) / M_PI;
}


x86 assembly (clang, -O0):
<CalculateSum12Exp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <cosh@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe82(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe6b(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <square@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xe00(%rip),%xmm2
mulsd  -0x48(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1060 <fabs@plt>
mov    0x2d4a(%rip),%rcx
mov    (%rcx),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jg     11f6 <CalculateSum12Exp+0xa6>
movsd  -0x48(%rbp),%xmm0
call   1050 <acos@plt>
mov    0x2d34(%rip),%rax
divsd  (%rax),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateSum12Exp>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movaps %xmm2,%xmm0
call   1030 <cosh@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe83(%rip),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe6a(%rip),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <square@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm2,%xmm3
xorpd  0xe36(%rip),%xmm1
movapd %xmm1,0x20(%rsp)
mulsd  0x18(%rsp),%xmm3
xorpd  %xmm0,%xmm0
mov    0x2def(%rip),%rbx
movsd  %xmm3,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movapd %xmm0,%xmm2
mulsd  0xdfc(%rip),%xmm2
mulsd  %xmm0,%xmm2
movapd 0x20(%rsp),%xmm1
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm3
subsd  %xmm3,%xmm0
movsd  %xmm0,0x18(%rsp)
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
addsd  0x8(%rsp),%xmm3
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm0
call   1060 <fabs@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm0
mov    (%rbx),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jg     1200 <CalculateSum12Exp+0xb0>
call   1050 <acos@plt>
mov    0x2d72(%rip),%rax
divsd  (%rax),%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@DBL_EPSILON = global i32 0
@M_PI = global double 0.000000e+00
define double @CalculateSum12Exp(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%14 = load double, double* %6
%15 = call double @cosh(double %14)
store double %15, double* %7
%16 = load double, double* %4
%17 = fmul double 0x401921FB54442D18, %16
%18 = call double @cos(double %17)
store double %18, double* %8
%19 = load double, double* %5
%20 = fmul double 0x401921FB54442D18, %19
%21 = call double @cos(double %20)
store double %21, double* %9
%22 = load double, double* %7
%23 = call i32 @square(double %22)
%24 = add nsw i32 1, %23
%25 = sitofp i32 %24 to double
%26 = load double, double* %8
%27 = load double, double* %9
%28 = call double @llvm.fmuladd.f64(double %26, double %27, double %25)
store double %28, double* %10
%29 = load double, double* %7
%30 = load double, double* %8
%31 = load double, double* %9
%32 = fadd double %30, %31
%33 = fmul double %29, %32
store double %33, double* %11
store double 0.000000e+00, double* %12
%34 = load double, double* %11
store double %34, double* %13
br label %35
35: ; preds = %57, %3
%36 = load double, double* %12
%37 = load double, double* %13
%38 = load double, double* %12
%39 = fmul double 3.000000e+00, %38
%40 = load double, double* %12
%41 = load double, double* %10
%42 = fneg double %41
%43 = call double @llvm.fmuladd.f64(double %39, double %40, double %42)
%44 = fdiv double %37, %43
%45 = fsub double %36, %44
store double %45, double* %12
%46 = load double, double* %12
%47 = load double, double* %12
%48 = fmul double %46, %47
%49 = load double, double* %12
%50 = load double, double* %10
%51 = load double, double* %12
%52 = fmul double %50, %51
%53 = fneg double %52
%54 = call double @llvm.fmuladd.f64(double %48, double %49, double %53)
%55 = load double, double* %11
%56 = fadd double %54, %55
store double %56, double* %13
br label %57
57: ; preds = %35
%58 = load double, double* %13
%59 = call i32 @fabs(double %58)
%60 = load i32, i32* @DBL_EPSILON
%61 = mul nsw i32 4, %60
%62 = icmp sgt i32 %59, %61
br i1 %62, label %35, label %63
63: ; preds = %57
%64 = load double, double* %12
%65 = call double @acos(double %64)
%66 = load double, double* @M_PI
%67 = fdiv double %65, %66
ret double %67
}

LLVM IR (-O2):
@DBL_EPSILON = global i32 0
@M_PI = global double 0.000000e+00
define double @CalculateSum12Exp(double %0, double %1, double %2) {
%4 = tail call double @cosh(double %2)
%5 = fmul double %0, 0x401921FB54442D18
%6 = tail call double @cos(double %5)
%7 = fmul double %1, 0x401921FB54442D18
%8 = tail call double @cos(double %7)
%9 = tail call i32 @square(double %4)
%10 = add nsw i32 %9, 1
%11 = sitofp i32 %10 to double
%12 = tail call double @llvm.fmuladd.f64(double %6, double %8, double %11)
%13 = fadd double %6, %8
%14 = fmul double %4, %13
%15 = fneg double %12
br label %16
16: ; preds = %16, %3
%17 = phi double [ 0.000000e+00, %3 ], [ %22, %16 ]
%18 = phi double [ %14, %3 ], [ %26, %16 ]
%19 = fmul double %17, 3.000000e+00
%20 = tail call double @llvm.fmuladd.f64(double %19, double %17, double %15)
%21 = fdiv double %18, %20
%22 = fsub double %17, %21
%23 = fmul double %22, %22
%24 = fmul double %22, %15
%25 = tail call double @llvm.fmuladd.f64(double %23, double %22, double %24)
%26 = fadd double %14, %25
%27 = tail call i32 @fabs(double %26)
%28 = load i32, i32* @DBL_EPSILON
%29 = shl nsw i32 %28, 2
%30 = icmp sgt i32 %27, %29
br i1 %30, label %16, label %31
31: ; preds = %16
%32 = tail call double @acos(double %22)
%33 = load double, double* @M_PI
%34 = fdiv double %32, %33
ret double %34
}