#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 ldexp2kf(float, int);
double mlaf(float, double, double);
scalar_t__ rintfk(float);
__attribute__((always_)) const float expm1kf(float d) {
  int q = (int)rintfk(
      d *
      1.442695040888963407359924681001892137426645954152985934135449406931f);
  float s, u;
  s = mlaf(q, -0.693145751953125f, d);
  s = mlaf(q, -1.428606765330187045e-06f, s);
  float s2 = s * s, s4 = s2 * s2;
  u = mlaf(
      s4,
      mlaf(s, (0.000198527617612853646278381), (0.00139304355252534151077271)),
      mlaf(s2,
           mlaf(s, (0.00833336077630519866943359),
                (0.0416664853692054748535156)),
           mlaf(s, (0.166666671633720397949219), (0.5))));
  u = s * s * u + s;
  if (q != 0)
    u = ldexp2kf(u + 1, q) - 1;
  return u;
}


x86 assembly (clang, -O0):
<expm1kf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xefb(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
call   1050 <rintfk@plt>
mov    %eax,-0x8(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xed0(%rip),%xmm1
call   1040 <mlaf@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xea4(%rip),%xmm1
call   1040 <mlaf@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movsd  0xe51(%rip),%xmm1
movsd  0xe51(%rip),%xmm2
call   1040 <mlaf@plt>
movsd  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
movsd  0xe18(%rip),%xmm1
movsd  0xe18(%rip),%xmm2
call   1040 <mlaf@plt>
movsd  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
movsd  0xde9(%rip),%xmm1
movsd  0xde9(%rip),%xmm2
call   1040 <mlaf@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x2c(%rbp),%xmm0
call   1040 <mlaf@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x1c(%rbp),%xmm0
call   1040 <mlaf@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     129d <expm1kf+0x16d>
movss  0xdc0(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%edi
call   1030 <ldexp2kf@plt>
sub    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expm1kf>:
push   %rbx
sub    $0x20,%rsp
movaps %xmm0,%xmm1
movss  %xmm0,0x8(%rsp)
movss  0xeba(%rip),%xmm0
mulss  %xmm1,%xmm0
call   1050 <rintfk@plt>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe97(%rip),%xmm1
call   1040 <mlaf@plt>
cvtsd2ss %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  0xe87(%rip),%xmm1
movss  0x4(%rsp),%xmm0
call   1040 <mlaf@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
mulss  %xmm1,%xmm1
movss  %xmm1,0xc(%rsp)
movsd  0xe5b(%rip),%xmm1
movsd  0xe5b(%rip),%xmm2
call   1040 <mlaf@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xe50(%rip),%xmm1
movsd  0xe50(%rip),%xmm2
movss  0x4(%rsp),%xmm0
call   1040 <mlaf@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe3f(%rip),%xmm1
movsd  0xe3f(%rip),%xmm2
movss  0x4(%rsp),%xmm0
call   1040 <mlaf@plt>
movaps %xmm0,%xmm2
movss  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <mlaf@plt>
movaps %xmm0,%xmm2
movss  0xc(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1040 <mlaf@plt>
cvtsd2ss %xmm0,%xmm0
mulss  0x8(%rsp),%xmm0
addss  0x4(%rsp),%xmm0
test   %ebx,%ebx
je     1261 <expm1kf+0x131>
addss  0xdb4(%rip),%xmm0
mov    %ebx,%edi
call   1030 <ldexp2kf@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @expm1kf(float %0) {
%2 = alloca float
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %2
%8 = load float, float* %2
%9 = fmul float %8, 0x3FF7154760000000
%10 = call i64 @rintfk(float %9)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = sitofp i32 %12 to float
%14 = load float, float* %2
%15 = fpext float %14 to double
%16 = call double @mlaf(float %13, double 0xBFE62E4000000000, double %15)
%17 = fptrunc double %16 to float
store float %17, float* %4
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to float
%20 = load float, float* %4
%21 = fpext float %20 to double
%22 = call double @mlaf(float %19, double 0xBEB7F7D1C0000000, double %21)
%23 = fptrunc double %22 to float
store float %23, float* %4
%24 = load float, float* %4
%25 = load float, float* %4
%26 = fmul float %24, %25
store float %26, float* %6
%27 = load float, float* %6
%28 = load float, float* %6
%29 = fmul float %27, %28
store float %29, float* %7
%30 = load float, float* %7
%31 = load float, float* %4
%32 = call double @mlaf(float %31, double 0x3F2A057B40000000, double 0x3F56D2D920000000)
%33 = load float, float* %6
%34 = load float, float* %4
%35 = call double @mlaf(float %34, double 0x3F811114C0000000, double 0x3FA5554F40000000)
%36 = load float, float* %4
%37 = call double @mlaf(float %36, double 0x3FC5555560000000, double 5.000000e-01)
%38 = call double @mlaf(float %33, double %35, double %37)
%39 = call double @mlaf(float %30, double %32, double %38)
%40 = fptrunc double %39 to float
store float %40, float* %5
%41 = load float, float* %4
%42 = load float, float* %4
%43 = fmul float %41, %42
%44 = load float, float* %5
%45 = load float, float* %4
%46 = call float @llvm.fmuladd.f32(float %43, float %44, float %45)
store float %46, float* %5
%47 = load i32, i32* %3
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %1
%50 = load float, float* %5
%51 = fadd float %50, 1.000000e+00
%52 = load i32, i32* %3
%53 = call i32 @ldexp2kf(float %51, i32 %52)
%54 = sub nsw i32 %53, 1
%55 = sitofp i32 %54 to float
store float %55, float* %5
br label %56
56: ; preds = %49, %1
%57 = load float, float* %5
ret float %57
}

LLVM IR (-O2):
define float @expm1kf(float %0) {
%2 = fmul float %0, 0x3FF7154760000000
%3 = tail call i64 @rintfk(float %2)
%4 = trunc i64 %3 to i32
%5 = sitofp i32 %4 to float
%6 = fpext float %0 to double
%7 = tail call double @mlaf(float %5, double 0xBFE62E4000000000, double %6)
%8 = fptrunc double %7 to float
%9 = fpext float %8 to double
%10 = tail call double @mlaf(float %5, double 0xBEB7F7D1C0000000, double %9)
%11 = fptrunc double %10 to float
%12 = fmul float %11, %11
%13 = fmul float %12, %12
%14 = tail call double @mlaf(float %11, double 0x3F2A057B40000000, double 0x3F56D2D920000000)
%15 = tail call double @mlaf(float %11, double 0x3F811114C0000000, double 0x3FA5554F40000000)
%16 = tail call double @mlaf(float %11, double 0x3FC5555560000000, double 5.000000e-01)
%17 = tail call double @mlaf(float %12, double %15, double %16)
%18 = tail call double @mlaf(float %13, double %14, double %17)
%19 = fptrunc double %18 to float
%20 = tail call float @llvm.fmuladd.f32(float %12, float %19, float %11)
%21 = icmp eq i32 %4, 0
br i1 %21, label %27, label %22
22: ; preds = %1
%23 = fadd float %20, 1.000000e+00
%24 = tail call i32 @ldexp2kf(float %23, i32 %4)
%25 = add nsw i32 %24, -1
%26 = sitofp i32 %25 to float
br label %27
27: ; preds = %22, %1
%28 = phi float [ %26, %22 ], [ %20, %1 ]
ret float %28
}