#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 exp(double);
double fabs(double);
double FindExpCoeff(double b) {
  double a, bg;
  int Try;
  if (fabs(b - 1) <= 0.001)
    return 0;
  if (b < 2)
    a = (b - 1) / 2;
  else
    a = b;
  bg = a / (1 - exp(-a));
  for (Try = 0; fabs(bg - b) > 0.001 || Try < 100; Try++) {
    a = a + (b - bg);
    bg = a / (1 - exp(-a));
  }
  return a;
}


x86 assembly (clang, -O0):
<FindExpCoeff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xede(%rip),%xmm0
subsd  %xmm0,%xmm1
movaps 0xeeb(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xebf(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1158 <FindExpCoeff+0x48>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a5 <FindExpCoeff+0x195>
movsd  0xeb0(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1192 <FindExpCoeff+0x82>
movsd  -0x10(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119c <FindExpCoeff+0x8c>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movsd  -0x30(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe26(%rip),%xmm1
pand   %xmm1,%xmm0
mov    $0x1,%al
movsd  0xdf8(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x31(%rbp)
ja     121f <FindExpCoeff+0x10f>
cmpl   $0x64,-0x24(%rbp)
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    122f <FindExpCoeff+0x11f>
jmp    129b <FindExpCoeff+0x18b>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movsd  -0x40(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e9 <FindExpCoeff+0xd9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindExpCoeff>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm0,%xmm2
movsd  0xedf(%rip),%xmm4
addsd  %xmm0,%xmm4
movapd 0xef3(%rip),%xmm1
andpd  %xmm4,%xmm1
xorpd  %xmm0,%xmm0
movsd  0xecb(%rip),%xmm3
ucomisd %xmm1,%xmm3
jae    1213 <FindExpCoeff+0x103>
mulsd  0xec1(%rip),%xmm4
movapd %xmm2,%xmm1
cmpltsd 0xebc(%rip),%xmm1
andpd  %xmm1,%xmm4
andnpd %xmm2,%xmm1
orpd   %xmm4,%xmm1
movapd %xmm1,(%rsp)
movapd 0xebb(%rip),%xmm0
xorpd  %xmm1,%xmm0
movapd %xmm2,0x10(%rsp)
call   1030 <exp@plt>
movapd (%rsp),%xmm0
movapd 0x10(%rsp),%xmm2
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
movapd %xmm0,%xmm3
divsd  %xmm1,%xmm3
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
mov    %eax,%ebx
movapd %xmm2,%xmm1
subsd  %xmm3,%xmm1
addsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
xorpd  0xe65(%rip),%xmm0
call   1030 <exp@plt>
movapd (%rsp),%xmm0
movapd 0x10(%rsp),%xmm2
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
movapd %xmm0,%xmm3
divsd  %xmm1,%xmm3
lea    0x1(%rbx),%eax
movapd %xmm3,%xmm1
subsd  %xmm2,%xmm1
andpd  0xe1c(%rip),%xmm1
ucomisd 0xdfc(%rip),%xmm1
ja     11b0 <FindExpCoeff+0xa0>
cmp    $0x63,%ebx
jb     11b0 <FindExpCoeff+0xa0>
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define double @FindExpCoeff(double %0) {
%2 = fadd double %0, -1.000000e+00
%3 = tail call double @llvm.fabs.f64(double %2)
%4 = fcmp ugt double %3, 1.000000e-03
br i1 %4, label %5, label %31
5: ; preds = %1
%6 = fcmp olt double %0, 2.000000e+00
%7 = fmul double %2, 5.000000e-01
%8 = select i1 %6, double %7, double %0
%9 = fneg double %8
%10 = tail call i32 @exp(double %9)
%11 = sub nsw i32 1, %10
%12 = sitofp i32 %11 to double
%13 = fdiv double %8, %12
br label %14
14: ; preds = %5, %14
%15 = phi i32 [ 0, %5 ], [ %25, %14 ]
%16 = phi double [ %13, %5 ], [ %24, %14 ]
%17 = phi double [ %8, %5 ], [ %19, %14 ]
%18 = fsub double %0, %16
%19 = fadd double %17, %18
%20 = fneg double %19
%21 = tail call i32 @exp(double %20)
%22 = sub nsw i32 1, %21
%23 = sitofp i32 %22 to double
%24 = fdiv double %19, %23
%25 = add nuw nsw i32 %15, 1
%26 = fsub double %24, %0
%27 = tail call double @llvm.fabs.f64(double %26)
%28 = fcmp ogt double %27, 1.000000e-03
%29 = icmp ult i32 %15, 99
%30 = select i1 %28, i1 true, i1 %29
br i1 %30, label %14, label %31
31: ; preds = %14, %1
%32 = phi double [ 0.000000e+00, %1 ], [ %19, %14 ]
ret double %32
}