#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 /*<<< orphan*/ ERANGE;
float HUGE_VALF;
int /*<<< orphan*/ errno;
int floor(float);
float ldexp(double, int);
float expf(float arg) {
  float fraction;
  float temp1, temp2, xsq;
  int ent;
  if (arg == 0.0) {
    return 1.0;
  }
  if (arg < -10000) {
    return 0.0;
  }
  if (arg > 10000) {
    errno = ERANGE;
    return HUGE_VALF;
  }
  arg *= 1.44269504088896;
  ent = floor(arg);
  fraction = arg - ent - 0.5;
  xsq = fraction * fraction;
  temp1 = ((0.60614853300611e2 * xsq + 0.30286971697440e5) * xsq +
           0.20803843466947e7) *
          fraction;
  temp2 = ((1.0 * xsq + 0.17492876890931e4) * xsq + 0.32772515180829e6) * xsq +
          0.60027203602388e7;
  return ldexp(1.41421356237310 * (temp2 + temp1) / (temp2 - temp1), ent);
}


x86 assembly (clang, -O0):
<expf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115b <expf+0x3b>
jp     115b <expf+0x3b>
movss  0xeb7(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12f1 <expf+0x1d1>
movss  0xe9d(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    117a <expf+0x5a>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12f1 <expf+0x1d1>
movss  -0x8(%rbp),%xmm0
movss  0xe7d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11b7 <expf+0x97>
mov    0x2e49(%rip),%rax
mov    (%rax),%ecx
mov    0x2e30(%rip),%rax
mov    %ecx,(%rax)
mov    0x2e47(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12f1 <expf+0x1d1>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe88(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4c(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe0b(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xde2(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdaf(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd8e(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd6d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd42(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
mov    -0x1c(%rbp),%edi
call   1030 <ldexp@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expf>:
push   %rax
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    1138 <expf+0x18>
jp     1138 <expf+0x18>
movss  0xeca(%rip),%xmm0
pop    %rax
ret
movss  0xec4(%rip),%xmm2
ucomiss %xmm1,%xmm2
ja     116b <expf+0x4b>
ucomiss 0xebc(%rip),%xmm1
jbe    116d <expf+0x4d>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    0x2e72(%rip),%rcx
mov    %eax,(%rcx)
mov    0x2e89(%rip),%rax
movss  (%rax),%xmm0
pop    %rax
ret
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe94(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
addss  0xe68(%rip),%xmm1
movaps %xmm1,%xmm0
movaps %xmm1,%xmm2
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5e(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe5a(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe56(%rip),%xmm1
cvtss2sd %xmm2,%xmm2
mulsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movsd  0xe47(%rip),%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe3f(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe3b(%rip),%xmm2
cvtsd2ss %xmm2,%xmm2
movaps %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe2c(%rip),%xmm0
subss  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    %eax,%edi
pop    %rax
jmp    1030 <ldexp@plt>

LLVM IR (-O0):
@ERANGE = global i32 0
@errno = global i32 0
@HUGE_VALF = global float 0.000000e+00
define float @expf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
store float %0, float* %3
%9 = load float, float* %3
%10 = fpext float %9 to double
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %1
store float 1.000000e+00, float* %2
br label %72
13: ; preds = %1
%14 = load float, float* %3
%15 = fcmp olt float %14, -1.000000e+04
br i1 %15, label %16, label %17
16: ; preds = %13
store float 0.000000e+00, float* %2
br label %72
17: ; preds = %13
%18 = load float, float* %3
%19 = fcmp ogt float %18, 1.000000e+04
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* @ERANGE
store i32 %21, i32* @errno
%22 = load float, float* @HUGE_VALF
store float %22, float* %2
br label %72
23: ; preds = %17
%24 = load float, float* %3
%25 = fpext float %24 to double
%26 = fmul double %25, 0x3FF71547652B82EF
%27 = fptrunc double %26 to float
store float %27, float* %3
%28 = load float, float* %3
%29 = call i32 @floor(float %28)
store i32 %29, i32* %8
%30 = load float, float* %3
%31 = load i32, i32* %8
%32 = sitofp i32 %31 to float
%33 = fsub float %30, %32
%34 = fpext float %33 to double
%35 = fsub double %34, 5.000000e-01
%36 = fptrunc double %35 to float
store float %36, float* %4
%37 = load float, float* %4
%38 = load float, float* %4
%39 = fmul float %37, %38
store float %39, float* %7
%40 = load float, float* %7
%41 = fpext float %40 to double
%42 = call double @llvm.fmuladd.f64(double 0x404E4EB38350FB20, double %41, double 0x40DD93BE304A759A)
%43 = load float, float* %7
%44 = fpext float %43 to double
%45 = call double @llvm.fmuladd.f64(double %42, double %44, double 0x413FBE8058C0FBDE)
%46 = load float, float* %4
%47 = fpext float %46 to double
%48 = fmul double %45, %47
%49 = fptrunc double %48 to float
store float %49, float* %5
%50 = load float, float* %7
%51 = fpext float %50 to double
%52 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %51, double 0x409B552697F8391F)
%53 = load float, float* %7
%54 = fpext float %53 to double
%55 = call double @llvm.fmuladd.f64(double %52, double %54, double 0x411400B49B73A1E3)
%56 = load float, float* %7
%57 = fpext float %56 to double
%58 = call double @llvm.fmuladd.f64(double %55, double %57, double 0x4156E608170E270A)
%59 = fptrunc double %58 to float
store float %59, float* %6
%60 = load float, float* %6
%61 = load float, float* %5
%62 = fadd float %60, %61
%63 = fpext float %62 to double
%64 = fmul double 0x3FF6A09E667F3BE3, %63
%65 = load float, float* %6
%66 = load float, float* %5
%67 = fsub float %65, %66
%68 = fpext float %67 to double
%69 = fdiv double %64, %68
%70 = load i32, i32* %8
%71 = call float @ldexp(double %69, i32 %70)
store float %71, float* %2
br label %72
72: ; preds = %23, %20, %16, %12
%73 = load float, float* %2
ret float %73
}

LLVM IR (-O2):
@ERANGE = global i32 0
@errno = global i32 0
@HUGE_VALF = global float 0.000000e+00
define float @expf(float %0) {
%2 = fpext float %0 to double
%3 = fcmp oeq float %0, 0.000000e+00
br i1 %3, label %36, label %4
4: ; preds = %1
%5 = fcmp olt float %0, -1.000000e+04
br i1 %5, label %36, label %6
6: ; preds = %4
%7 = fcmp ogt float %0, 1.000000e+04
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = load i32, i32* @ERANGE
store i32 %9, i32* @errno
%10 = load float, float* @HUGE_VALF
br label %36
11: ; preds = %6
%12 = fmul double %2, 0x3FF71547652B82EF
%13 = fptrunc double %12 to float
%14 = tail call i32 @floor(float %13)
%15 = sitofp i32 %14 to float
%16 = fsub float %13, %15
%17 = fadd float %16, -5.000000e-01
%18 = fmul float %17, %17
%19 = fpext float %18 to double
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0x404E4EB38350FB20, double 0x40DD93BE304A759A)
%21 = tail call double @llvm.fmuladd.f64(double %20, double %19, double 0x413FBE8058C0FBDE)
%22 = fpext float %17 to double
%23 = fmul double %21, %22
%24 = fptrunc double %23 to float
%25 = fadd double %19, 0x409B552697F8391F
%26 = tail call double @llvm.fmuladd.f64(double %25, double %19, double 0x411400B49B73A1E3)
%27 = tail call double @llvm.fmuladd.f64(double %26, double %19, double 0x4156E608170E270A)
%28 = fptrunc double %27 to float
%29 = fadd float %28, %24
%30 = fpext float %29 to double
%31 = fmul double %30, 0x3FF6A09E667F3BE3
%32 = fsub float %28, %24
%33 = fpext float %32 to double
%34 = fdiv double %31, %33
%35 = tail call float @ldexp(double %34, i32 %14)
br label %36
36: ; preds = %4, %1, %11, %8
%37 = phi float [ %10, %8 ], [ %35, %11 ], [ 1.000000e+00, %1 ], [ 0.000000e+00, %4 ]
ret float %37
}