#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 ldexp2k(double, int);
double mla(double, double, double);
scalar_t__ rintk(double);
__attribute__((always_)) const double expm1k(double d) {
  int q = (int)rintk(
      d * 1.442695040888963407359924681001892137426645954152985934135449406931);
  double s, u;
  s = mla(q, -.69314718055966295651160180568695068359375, d);
  s = mla(q, -.28235290563031577122588448175013436025525412068e-12, s);
  double s2 = s * s, s4 = s2 * s2, s8 = s4 * s4;
  u = mla(
      s8,
      mla(s, (2.08860621107283687536341e-09), (2.51112930892876518610661e-08)),
      mla(s4,
          mla(s2,
              mla(s, (2.75573911234900471893338e-07),
                  (2.75572362911928827629423e-06)),
              mla(s, (2.4801587159235472998791e-05),
                  (0.000198412698960509205564975))),
          mla(s2,
              mla(s, (0.00138888888889774492207962),
                  (0.00833333333331652721664984)),
              mla(s, (0.0416666666666665047591422),
                  (0.166666666666666851703837)))));
  u = mla(s2, 0.5, s2 * s * u) + s;
  if (q != 0)
    u = ldexp2k(u + 1, q) - 1;
  return u;
}


x86 assembly (clang, -O0):
<expm1k>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xf20(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <rintk@plt>
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  0xef9(%rip),%xmm1
call   1050 <mla@plt>
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xed5(%rip),%xmm1
call   1050 <mla@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe77(%rip),%xmm1
movsd  0xe77(%rip),%xmm2
call   1050 <mla@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
movsd  0xe34(%rip),%xmm2
call   1050 <mla@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe05(%rip),%xmm1
movsd  0xe05(%rip),%xmm2
call   1050 <mla@plt>
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
call   1050 <mla@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdba(%rip),%xmm1
movsd  0xdba(%rip),%xmm2
call   1050 <mla@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xd8b(%rip),%xmm1
movsd  0xd8b(%rip),%xmm2
call   1050 <mla@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
call   1050 <mla@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
call   1050 <mla@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
call   1050 <mla@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  -0x20(%rbp),%xmm2
movsd  0xd1f(%rip),%xmm1
call   1050 <mla@plt>
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     131b <expm1k+0x1eb>
movsd  0xd6e(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1040 <ldexp2k@plt>
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expm1k>:
push   %rbx
sub    $0x40,%rsp
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  0xeb9(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <rintk@plt>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xea0(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
call   1050 <mla@plt>
movapd %xmm0,%xmm2
movsd  0xe91(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
call   1050 <mla@plt>
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm1,0x30(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm1,0x38(%rsp)
movsd  0xe5e(%rip),%xmm1
movsd  0xe5e(%rip),%xmm2
call   1050 <mla@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0xe53(%rip),%xmm1
movsd  0xe53(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
call   1050 <mla@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xe42(%rip),%xmm1
movsd  0xe42(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
call   1050 <mla@plt>
movaps %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1050 <mla@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xe1d(%rip),%xmm1
movsd  0xe1d(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
call   1050 <mla@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0xe0c(%rip),%xmm1
movsd  0xe0c(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
call   1050 <mla@plt>
movaps %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1050 <mla@plt>
movaps %xmm0,%xmm2
movsd  0x30(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1050 <mla@plt>
movaps %xmm0,%xmm2
movsd  0x38(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
call   1050 <mla@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
movsd  0xdb1(%rip),%xmm1
movapd %xmm3,%xmm0
call   1050 <mla@plt>
addsd  0x8(%rsp),%xmm0
test   %ebx,%ebx
je     12e3 <expm1k+0x1b3>
addsd  0xd9e(%rip),%xmm0
mov    %ebx,%edi
call   1040 <ldexp2k@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @expm1k(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %2
%9 = load double, double* %2
%10 = fmul double %9, 0x3FF71547652B82FE
%11 = call i64 @rintk(double %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = sitofp i32 %13 to double
%15 = load double, double* %2
%16 = call double @mla(double %14, double 0xBFE62E42FEFA3000, double %15)
store double %16, double* %4
%17 = load i32, i32* %3
%18 = sitofp i32 %17 to double
%19 = load double, double* %4
%20 = call double @mla(double %18, double 0xBD53DE6AF278ECE6, double %19)
store double %20, double* %4
%21 = load double, double* %4
%22 = load double, double* %4
%23 = fmul double %21, %22
store double %23, double* %6
%24 = load double, double* %6
%25 = load double, double* %6
%26 = fmul double %24, %25
store double %26, double* %7
%27 = load double, double* %7
%28 = load double, double* %7
%29 = fmul double %27, %28
store double %29, double* %8
%30 = load double, double* %8
%31 = load double, double* %4
%32 = call double @mla(double %31, double 0x3E21F0E4C4ECD775, double 0x3E5AF68A28CC800A)
%33 = load double, double* %7
%34 = load double, double* %6
%35 = load double, double* %4
%36 = call double @mla(double %35, double 0x3E927E52E0FCD573, double 0x3EC71DDF1629E6CE)
%37 = load double, double* %4
%38 = call double @mla(double %37, double 0x3EFA01A01780879E, double 0x3F2A01A01B3603F5)
%39 = call double @mla(double %34, double %36, double %38)
%40 = load double, double* %6
%41 = load double, double* %4
%42 = call double @mla(double %41, double 0x3F56C16C16C20BA0, double 0x3F8111111110EB39)
%43 = load double, double* %4
%44 = call double @mla(double %43, double 0x3FA555555555553E, double 0x3FC555555555555C)
%45 = call double @mla(double %40, double %42, double %44)
%46 = call double @mla(double %33, double %39, double %45)
%47 = call double @mla(double %30, double %32, double %46)
store double %47, double* %5
%48 = load double, double* %6
%49 = load double, double* %6
%50 = load double, double* %4
%51 = fmul double %49, %50
%52 = load double, double* %5
%53 = fmul double %51, %52
%54 = call double @mla(double %48, double 5.000000e-01, double %53)
%55 = load double, double* %4
%56 = fadd double %54, %55
store double %56, double* %5
%57 = load i32, i32* %3
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %66
59: ; preds = %1
%60 = load double, double* %5
%61 = fadd double %60, 1.000000e+00
%62 = load i32, i32* %3
%63 = call i32 @ldexp2k(double %61, i32 %62)
%64 = sub nsw i32 %63, 1
%65 = sitofp i32 %64 to double
store double %65, double* %5
br label %66
66: ; preds = %59, %1
%67 = load double, double* %5
ret double %67
}

LLVM IR (-O2):
define double @expm1k(double %0) {
%2 = fmul double %0, 0x3FF71547652B82FE
%3 = tail call i64 @rintk(double %2)
%4 = trunc i64 %3 to i32
%5 = sitofp i32 %4 to double
%6 = tail call double @mla(double %5, double 0xBFE62E42FEFA3000, double %0)
%7 = tail call double @mla(double %5, double 0xBD53DE6AF278ECE6, double %6)
%8 = fmul double %7, %7
%9 = fmul double %8, %8
%10 = fmul double %9, %9
%11 = tail call double @mla(double %7, double 0x3E21F0E4C4ECD775, double 0x3E5AF68A28CC800A)
%12 = tail call double @mla(double %7, double 0x3E927E52E0FCD573, double 0x3EC71DDF1629E6CE)
%13 = tail call double @mla(double %7, double 0x3EFA01A01780879E, double 0x3F2A01A01B3603F5)
%14 = tail call double @mla(double %8, double %12, double %13)
%15 = tail call double @mla(double %7, double 0x3F56C16C16C20BA0, double 0x3F8111111110EB39)
%16 = tail call double @mla(double %7, double 0x3FA555555555553E, double 0x3FC555555555555C)
%17 = tail call double @mla(double %8, double %15, double %16)
%18 = tail call double @mla(double %9, double %14, double %17)
%19 = tail call double @mla(double %10, double %11, double %18)
%20 = fmul double %7, %8
%21 = fmul double %20, %19
%22 = tail call double @mla(double %8, double 5.000000e-01, double %21)
%23 = fadd double %7, %22
%24 = icmp eq i32 %4, 0
br i1 %24, label %30, label %25
25: ; preds = %1
%26 = fadd double %23, 1.000000e+00
%27 = tail call i32 @ldexp2k(double %26, i32 %4)
%28 = add nsw i32 %27, -1
%29 = sitofp i32 %28 to double
br label %30
30: ; preds = %25, %1
%31 = phi double [ %29, %25 ], [ %23, %1 ]
ret double %31
}