#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 */
float fasterpow2(float);
float fastlog(float);
float fmaxf(float, float const);
float fastlambertwexpx(float x) {
  static const float k = 1.1765631309f;
  static const float a = 0.94537622168f;
  float logarg = fmaxf(x, k);
  float powarg = (x < k) ? a * (x - k) : 0;
  float logterm = fastlog(logarg);
  float powterm = fasterpow2(powarg);
  float w = powterm * (logarg - logterm + logterm / logarg);
  float logw = fastlog(w);
  float p = x - logw;
  return w * (2.0f + p + w * (3.0f + 2.0f * p)) /
         (2.0f - p + w * (5.0f + 2.0f * w));
}


x86 assembly (clang, -O0):
<fastlambertwexpx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xec6(%rip),%xmm1
maxss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xeb5(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    117c <fastlambertwexpx+0x5c>
movss  -0x4(%rbp),%xmm1
movss  0xe9e(%rip),%xmm0
subss  %xmm0,%xmm1
movss  0xe96(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1189 <fastlambertwexpx+0x69>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1189 <fastlambertwexpx+0x69>
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <fastlog@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fasterpow2@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
divss  -0x8(%rbp),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <fastlog@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xe0a(%rip),%xmm2
addss  -0x20(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
movss  -0x20(%rbp),%xmm3
addss  %xmm3,%xmm3
movss  0xdf3(%rip),%xmm4
addss  %xmm4,%xmm3
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xdd7(%rip),%xmm2
subss  -0x20(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
movss  -0x18(%rbp),%xmm3
addss  %xmm3,%xmm3
movss  0xdb8(%rip),%xmm4
addss  %xmm4,%xmm3
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fastlambertwexpx>:
sub    $0x28,%rsp
movss  %xmm0,0xc(%rsp)
movss  0xece(%rip),%xmm2
movaps %xmm0,%xmm3
maxss  %xmm2,%xmm3
movss  %xmm3,0x8(%rsp)
movss  0xebd(%rip),%xmm1
addss  %xmm0,%xmm1
mulss  0xeb5(%rip),%xmm1
cmpltss %xmm2,%xmm0
andps  %xmm1,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm3,%xmm0
call   1040 <fastlog@plt>
movss  %xmm0,0x4(%rsp)
movaps 0x10(%rsp),%xmm0
call   1030 <fasterpow2@plt>
movss  0x8(%rsp),%xmm3
movaps %xmm3,%xmm1
movss  0x4(%rsp),%xmm2
subss  %xmm2,%xmm1
divss  %xmm3,%xmm2
addss  %xmm1,%xmm2
mulss  %xmm0,%xmm2
movss  %xmm2,0x4(%rsp)
movaps %xmm2,%xmm0
call   1040 <fastlog@plt>
movss  0xc(%rsp),%xmm2
subss  %xmm0,%xmm2
movss  0xe55(%rip),%xmm0
movaps %xmm2,%xmm1
addss  %xmm0,%xmm1
subss  %xmm2,%xmm0
addss  %xmm2,%xmm2
addss  0xe42(%rip),%xmm2
movss  0x4(%rsp),%xmm3
mulss  %xmm3,%xmm2
addss  %xmm1,%xmm2
movaps %xmm3,%xmm1
addss  %xmm3,%xmm1
addss  0xe29(%rip),%xmm1
mulss  %xmm3,%xmm2
mulss  %xmm3,%xmm1
addss  %xmm0,%xmm1
divss  %xmm1,%xmm2
movaps %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@fastlambertwexpx.k = internal constant float 0x3FF2D333E0000000
@fastlambertwexpx.a = internal constant float 0x3FEE4085A0000000
define float @fastlambertwexpx(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %2
%10 = load float, float* %2
%11 = call float @llvm.maxnum.f32(float %10, float 0x3FF2D333E0000000)
store float %11, float* %3
%12 = load float, float* %2
%13 = fcmp olt float %12, 0x3FF2D333E0000000
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load float, float* %2
%16 = fsub float %15, 0x3FF2D333E0000000
%17 = fmul float 0x3FEE4085A0000000, %16
br label %19
18: ; preds = %1
br label %19
19: ; preds = %18, %14
%20 = phi float [ %17, %14 ], [ 0.000000e+00, %18 ]
store float %20, float* %4
%21 = load float, float* %3
%22 = call float @fastlog(float %21)
store float %22, float* %5
%23 = load float, float* %4
%24 = call float @fasterpow2(float %23)
store float %24, float* %6
%25 = load float, float* %6
%26 = load float, float* %3
%27 = load float, float* %5
%28 = fsub float %26, %27
%29 = load float, float* %5
%30 = load float, float* %3
%31 = fdiv float %29, %30
%32 = fadd float %28, %31
%33 = fmul float %25, %32
store float %33, float* %7
%34 = load float, float* %7
%35 = call float @fastlog(float %34)
store float %35, float* %8
%36 = load float, float* %2
%37 = load float, float* %8
%38 = fsub float %36, %37
store float %38, float* %9
%39 = load float, float* %7
%40 = load float, float* %9
%41 = fadd float 2.000000e+00, %40
%42 = load float, float* %7
%43 = load float, float* %9
%44 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %43, float 3.000000e+00)
%45 = call float @llvm.fmuladd.f32(float %42, float %44, float %41)
%46 = fmul float %39, %45
%47 = load float, float* %9
%48 = fsub float 2.000000e+00, %47
%49 = load float, float* %7
%50 = load float, float* %7
%51 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %50, float 5.000000e+00)
%52 = call float @llvm.fmuladd.f32(float %49, float %51, float %48)
%53 = fdiv float %46, %52
ret float %53
}

LLVM IR (-O2):
define float @fastlambertwexpx(float %0) {
%2 = tail call float @llvm.maxnum.f32(float %0, float 0x3FF2D333E0000000)
%3 = fcmp olt float %0, 0x3FF2D333E0000000
%4 = fadd float %0, 0xBFF2D333E0000000
%5 = fmul float %4, 0x3FEE4085A0000000
%6 = select i1 %3, float %5, float 0.000000e+00
%7 = tail call float @fastlog(float %2)
%8 = tail call float @fasterpow2(float %6)
%9 = fsub float %2, %7
%10 = fdiv float %7, %2
%11 = fadd float %9, %10
%12 = fmul float %8, %11
%13 = tail call float @fastlog(float %12)
%14 = fsub float %0, %13
%15 = fadd float %14, 2.000000e+00
%16 = tail call float @llvm.fmuladd.f32(float %14, float 2.000000e+00, float 3.000000e+00)
%17 = tail call float @llvm.fmuladd.f32(float %12, float %16, float %15)
%18 = fmul float %12, %17
%19 = fsub float 2.000000e+00, %14
%20 = tail call float @llvm.fmuladd.f32(float %12, float 2.000000e+00, float 5.000000e+00)
%21 = tail call float @llvm.fmuladd.f32(float %12, float %20, float %19)
%22 = fdiv float %18, %21
ret float %22
}