#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 fastexp(float);
float fastlog(float);
float fastlambertw(float x) {
  static const float threshold = 2.26445f;
  float c = (x < threshold) ? 1.546865557f : 1.0f;
  float d = (x < threshold) ? 2.250366841f : 0.0f;
  float a = (x < threshold) ? -0.737769969f : 0.0f;
  float logterm = fastlog(c * x + d);
  float loglogterm = fastlog(logterm);
  float minusw = -a - logterm + loglogterm - loglogterm / logterm;
  float expminusw = fastexp(minusw);
  float xexpminusw = x * expminusw;
  float pexpminusw = xexpminusw - minusw;
  return (2.0f * xexpminusw -
          minusw * (4.0f * xexpminusw - minusw * pexpminusw)) /
         (2.0f + pexpminusw * (2.0f - minusw));
}


x86 assembly (clang, -O0):
<fastlambertw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xeda(%rip),%xmm3
movss  0xed6(%rip),%xmm2
movss  0xec2(%rip),%xmm1
cmpltss %xmm1,%xmm0
movaps %xmm0,%xmm1
andps  %xmm3,%xmm1
andnps %xmm2,%xmm0
orps   %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xea3(%rip),%xmm3
xorps  %xmm2,%xmm2
movss  0xe94(%rip),%xmm1
cmpltss %xmm1,%xmm0
movaps %xmm0,%xmm1
andps  %xmm3,%xmm1
andnps %xmm2,%xmm0
orps   %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe6d(%rip),%xmm3
xorps  %xmm2,%xmm2
movss  0xe66(%rip),%xmm1
cmpltss %xmm1,%xmm0
movaps %xmm0,%xmm1
andps  %xmm3,%xmm1
andnps %xmm2,%xmm0
orps   %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <fastlog@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <fastlog@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
subss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
divss  -0x14(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <fastexp@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm3
mulss  -0x28(%rbp),%xmm3
movd   %xmm3,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm3
movss  0xd8e(%rip),%xmm4
mulss  %xmm4,%xmm2
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
movss  0xd5c(%rip),%xmm2
subss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xd4b(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fastlambertw>:
sub    $0x28,%rsp
movaps %xmm0,%xmm2
movss  0xed1(%rip),%xmm0
xor    %eax,%eax
ucomiss %xmm2,%xmm0
seta   %cl
ja     1148 <fastlambertw+0x28>
xorps  %xmm1,%xmm1
jbe    1152 <fastlambertw+0x32>
movss  0xec2(%rip),%xmm0
jmp    1155 <fastlambertw+0x35>
movss  0xeb4(%rip),%xmm1
ja     113e <fastlambertw+0x1e>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    %cl,%al
lea    0xeb1(%rip),%rcx
movss  (%rcx,%rax,4),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm2,0xc(%rsp)
call   1030 <fastlog@plt>
movss  %xmm0,0x8(%rsp)
call   1030 <fastlog@plt>
movaps 0x10(%rsp),%xmm1
xorps  0xe8e(%rip),%xmm1
movss  0x8(%rsp),%xmm2
subss  %xmm2,%xmm1
addss  %xmm0,%xmm1
divss  %xmm2,%xmm0
subss  %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movaps %xmm1,%xmm0
call   1040 <fastexp@plt>
mulss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
movaps 0x10(%rsp),%xmm4
subss  %xmm4,%xmm1
movss  0xe41(%rip),%xmm2
movaps %xmm2,%xmm3
subss  %xmm4,%xmm3
mulss  %xmm1,%xmm3
mulss  %xmm4,%xmm1
movaps %xmm4,%xmm5
movss  0xe23(%rip),%xmm4
mulss  %xmm0,%xmm4
subss  %xmm1,%xmm4
mulss  %xmm5,%xmm4
addss  %xmm0,%xmm0
subss  %xmm4,%xmm0
addss  %xmm2,%xmm3
divss  %xmm3,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@fastlambertw.threshold = internal constant float 0x40021D9800000000
define float @fastlambertw(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
%10 = alloca float
%11 = alloca float
store float %0, float* %2
%12 = load float, float* %2
%13 = fcmp olt float %12, 0x40021D9800000000
%14 = zext i1 %13 to i64
%15 = select i1 %13, float 0x3FF8BFF620000000, float 1.000000e+00
store float %15, float* %3
%16 = load float, float* %2
%17 = fcmp olt float %16, 0x40021D9800000000
%18 = zext i1 %17 to i64
%19 = select i1 %17, float 0x400200C060000000, float 0.000000e+00
store float %19, float* %4
%20 = load float, float* %2
%21 = fcmp olt float %20, 0x40021D9800000000
%22 = zext i1 %21 to i64
%23 = select i1 %21, float 0xBFE79BCFC0000000, float 0.000000e+00
store float %23, float* %5
%24 = load float, float* %3
%25 = load float, float* %2
%26 = load float, float* %4
%27 = call float @llvm.fmuladd.f32(float %24, float %25, float %26)
%28 = call float @fastlog(float %27)
store float %28, float* %6
%29 = load float, float* %6
%30 = call float @fastlog(float %29)
store float %30, float* %7
%31 = load float, float* %5
%32 = fneg float %31
%33 = load float, float* %6
%34 = fsub float %32, %33
%35 = load float, float* %7
%36 = fadd float %34, %35
%37 = load float, float* %7
%38 = load float, float* %6
%39 = fdiv float %37, %38
%40 = fsub float %36, %39
store float %40, float* %8
%41 = load float, float* %8
%42 = call float @fastexp(float %41)
store float %42, float* %9
%43 = load float, float* %2
%44 = load float, float* %9
%45 = fmul float %43, %44
store float %45, float* %10
%46 = load float, float* %10
%47 = load float, float* %8
%48 = fsub float %46, %47
store float %48, float* %11
%49 = load float, float* %10
%50 = load float, float* %8
%51 = load float, float* %10
%52 = load float, float* %8
%53 = load float, float* %11
%54 = fmul float %52, %53
%55 = fneg float %54
%56 = call float @llvm.fmuladd.f32(float 4.000000e+00, float %51, float %55)
%57 = fmul float %50, %56
%58 = fneg float %57
%59 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %49, float %58)
%60 = load float, float* %11
%61 = load float, float* %8
%62 = fsub float 2.000000e+00, %61
%63 = call float @llvm.fmuladd.f32(float %60, float %62, float 2.000000e+00)
%64 = fdiv float %59, %63
ret float %64
}

LLVM IR (-O2):
define float @fastlambertw(float %0) {
%2 = fcmp olt float %0, 0x40021D9800000000
%3 = select i1 %2, float 0x3FF8BFF620000000, float 1.000000e+00
%4 = select i1 %2, float 0x400200C060000000, float 0.000000e+00
%5 = select i1 %2, float 0xBFE79BCFC0000000, float 0.000000e+00
%6 = tail call float @llvm.fmuladd.f32(float %3, float %0, float %4)
%7 = tail call float @fastlog(float %6)
%8 = tail call float @fastlog(float %7)
%9 = fneg float %5
%10 = fsub float %9, %7
%11 = fadd float %10, %8
%12 = fdiv float %8, %7
%13 = fsub float %11, %12
%14 = tail call float @fastexp(float %13)
%15 = fmul float %14, %0
%16 = fsub float %15, %13
%17 = fneg float %13
%18 = fmul float %16, %17
%19 = tail call float @llvm.fmuladd.f32(float %15, float 4.000000e+00, float %18)
%20 = fmul float %19, %17
%21 = tail call float @llvm.fmuladd.f32(float %15, float 2.000000e+00, float %20)
%22 = fsub float 2.000000e+00, %13
%23 = tail call float @llvm.fmuladd.f32(float %16, float %22, float 2.000000e+00)
%24 = fdiv float %21, %23
ret float %24
}