#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 fasterlog(float);
float fasterpow2(float);
float fmaxf(float, float const);
float fasterlambertwexpx(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 = fasterlog(logarg);
  float powterm = fasterpow2(powarg);
  float w = powterm * (logarg - logterm + logterm / logarg);
  float logw = fasterlog(w);
  return w * (1.0f + x - logw) / (1.0f + w);
}


x86 assembly (clang, -O0):
<fasterlambertwexpx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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 <fasterlambertwexpx+0x5c>
movss  -0x4(%rbp),%xmm1
movss  0xe9e(%rip),%xmm0
subss  %xmm0,%xmm1
movss  0xe96(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1189 <fasterlambertwexpx+0x69>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1189 <fasterlambertwexpx+0x69>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fasterlog@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <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   1030 <fasterlog@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xe15(%rip),%xmm1
addss  -0x4(%rbp),%xmm1
subss  -0x1c(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xdff(%rip),%xmm1
addss  -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fasterlambertwexpx>:
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   1030 <fasterlog@plt>
movss  %xmm0,0x4(%rsp)
movaps 0x10(%rsp),%xmm0
call   1040 <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   1030 <fasterlog@plt>
movss  0xe5f(%rip),%xmm1
movss  0xc(%rsp),%xmm2
addss  %xmm1,%xmm2
subss  %xmm0,%xmm2
movss  0x4(%rsp),%xmm0
mulss  %xmm0,%xmm2
addss  %xmm1,%xmm0
divss  %xmm0,%xmm2
movaps %xmm2,%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
define float @fasterlambertwexpx(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 @fasterlog(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 @fasterlog(float %12)
%14 = fadd float %0, 1.000000e+00
%15 = fsub float %14, %13
%16 = fmul float %12, %15
%17 = fadd float %12, 1.000000e+00
%18 = fdiv float %16, %17
ret float %18
}