#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 B_eff_mu(double, double, double, int /*<<< orphan*/, double);
int /*<<< orphan*/ exp(double);
double B_eff(double B_far, double B_near, double tau) {
  const int Nmu = 20;
  const double dmu = 1. / Nmu;
  double Beff = 0;
  for (int imu = 0; imu < Nmu; ++imu) {
    double mu = .5 * dmu + imu * dmu;
    Beff += B_eff_mu(B_far, B_near, tau, exp(-tau / mu), mu) * mu * dmu;
  }
  return Beff * 2;
}


x86 assembly (clang, -O0):
<B_eff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movl   $0x14,-0x1c(%rbp)
movsd  0xeba(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x14,-0x34(%rbp)
jge    1212 <B_eff+0xf2>
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  0xe8f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe93(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x40(%rbp),%xmm0
call   1030 <exp@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
mov    %eax,%edi
movsd  -0x40(%rbp),%xmm3
call   1040 <B_eff_mu@plt>
mulsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xe09(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115a <B_eff+0x3a>
movsd  0xdee(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<B_eff>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
movapd 0xec7(%rip),%xmm0
movapd %xmm2,0x40(%rsp)
xorpd  %xmm2,%xmm0
movapd %xmm0,0x30(%rsp)
xorpd  %xmm0,%xmm0
mov    $0x14,%ebx
xorpd  %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0xe9c(%rip),%xmm0
mulsd  %xmm0,%xmm1
addsd  0xe98(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movapd 0x30(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movapd 0x40(%rsp),%xmm2
mov    %eax,%edi
movsd  0x10(%rsp),%xmm3
call   1040 <B_eff_mu@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  0xe4e(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x28(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
addsd  0xe3a(%rip),%xmm1
add    $0xffffffff,%ebx
jne    1160 <B_eff+0x40>
addsd  %xmm0,%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @B_eff(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store i32 20, i32* %7
store double 5.000000e-02, double* %8
store double 0.000000e+00, double* %9
store i32 0, i32* %10
br label %12
12: ; preds = %33, %3
%13 = load i32, i32* %10
%14 = icmp slt i32 %13, 20
br i1 %14, label %15, label %36
15: ; preds = %12
%16 = load i32, i32* %10
%17 = sitofp i32 %16 to double
%18 = call double @llvm.fmuladd.f64(double %17, double 5.000000e-02, double 2.500000e-02)
store double %18, double* %11
%19 = load double, double* %4
%20 = load double, double* %5
%21 = load double, double* %6
%22 = load double, double* %6
%23 = fneg double %22
%24 = load double, double* %11
%25 = fdiv double %23, %24
%26 = call i32 @exp(double %25)
%27 = load double, double* %11
%28 = call double @B_eff_mu(double %19, double %20, double %21, i32 %26, double %27)
%29 = load double, double* %11
%30 = fmul double %28, %29
%31 = load double, double* %9
%32 = call double @llvm.fmuladd.f64(double %30, double 5.000000e-02, double %31)
store double %32, double* %9
br label %33
33: ; preds = %15
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %12
36: ; preds = %12
%37 = load double, double* %9
%38 = fmul double %37, 2.000000e+00
ret double %38
}

LLVM IR (-O2):
define double @B_eff(double %0, double %1, double %2) {
%4 = fneg double %2
br label %7
5: ; preds = %7
%6 = fmul double %16, 2.000000e+00
ret double %6
7: ; preds = %3, %7
%8 = phi double [ 0.000000e+00, %3 ], [ %16, %7 ]
%9 = phi i32 [ 0, %3 ], [ %17, %7 ]
%10 = sitofp i32 %9 to double
%11 = tail call double @llvm.fmuladd.f64(double %10, double 5.000000e-02, double 2.500000e-02)
%12 = fdiv double %4, %11
%13 = tail call i32 @exp(double %12)
%14 = tail call double @B_eff_mu(double %0, double %1, double %2, i32 %13, double %11)
%15 = fmul double %11, %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double 5.000000e-02, double %8)
%17 = add nuw nsw i32 %9, 1
%18 = icmp eq i32 %17, 20
br i1 %18, label %5, label %7
}