#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;
int /*<<< orphan*/ errno;
float ldexpf(float, int);
float expf(const float x) {
  int n;
  float xn, g, r, z, y;
  int sign;
  if (x >= 0.0) {
    y = x;
    sign = 0;
  } else {
    y = -x;
    sign = 1;
  }
  if (y < 1.0E-7)
    return 1.0;
  if (y > 88.72283911) {
    if (sign) {
      errno = ERANGE;
      return 3.402823466 + 38;
    } else {
      return 0.0;
    }
  }
  z = y * 1.4426950409;
  n = z;
  if (n < 0)
    --n;
  if (z - n >= 0.5)
    ++n;
  xn = n;
  g = ((y - xn * 0.693359375)) - xn * -2.1219444005469058277e-4;
  z = g * g;
  r = ((0.4160288626E-2 * z) + 0.2499999995E+0) * g;
  r = 0.5 + (r / (((0.4998717877E-1 * z) + 0.5000000000E+0) - r));
  n++;
  z = ldexpf(r, n);
  if (sign)
    return 1.0 / z;
  else
    return z;
}


x86 assembly (clang, -O0):
<expf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1149 <expf+0x39>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
jmp    1167 <expf+0x57>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe88(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1194 <expf+0x84>
movss  0xeca(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13b4 <expf+0x2a4>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe63(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ea <expf+0xda>
cmpl   $0x0,-0x24(%rbp)
je     11dd <expf+0xcd>
mov    0x2e28(%rip),%rax
mov    (%rax),%ecx
mov    0x2e0f(%rip),%rax
mov    %ecx,(%rax)
movss  0xe7d(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13b4 <expf+0x2a4>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13b4 <expf+0x2a4>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe15(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvttss2si -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1223 <expf+0x113>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xddb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1250 <expf+0x140>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xdb5(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd7d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd3c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd38(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcf4(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xce0(%rip),%xmm2
addsd  %xmm2,%xmm0
movss  -0x18(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
subsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xcc3(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1030 <ldexpf@plt>
movss  %xmm0,-0x1c(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     13aa <expf+0x29a>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xcb0(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13b4 <expf+0x2a4>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expf>:
sub    $0x18,%rsp
movaps %xmm0,%xmm2
movaps 0xee2(%rip),%xmm0
xorps  %xmm2,%xmm0
xorps  %xmm1,%xmm1
cmpnless %xmm2,%xmm1
andps  %xmm1,%xmm0
andnps %xmm2,%xmm1
orps   %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  0xedf(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1154 <expf+0x44>
movss  0xec1(%rip),%xmm0
add    $0x18,%rsp
ret
ucomisd 0xecc(%rip),%xmm0
jbe    1189 <expf+0x79>
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jae    1267 <expf+0x157>
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    0x2e5e(%rip),%rcx
mov    %eax,(%rcx)
movss  0xe94(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0xe9f(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
cvttss2si %xmm1,%eax
mov    %eax,%edi
sar    $0x1f,%edi
add    %eax,%edi
movaps %xmm2,(%rsp)
xorps  %xmm2,%xmm2
cvtsi2ss %edi,%xmm2
subss  %xmm2,%xmm1
ucomiss 0xe5a(%rip),%xmm1
sbb    $0xffffffff,%edi
xorps  %xmm1,%xmm1
cvtsi2ss %edi,%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe68(%rip),%xmm2
mulsd  %xmm1,%xmm2
mulsd  0xe64(%rip),%xmm1
addsd  %xmm0,%xmm2
addsd  %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mulss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe46(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe42(%rip),%xmm2
mulsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  0xe33(%rip),%xmm0
movsd  0xe33(%rip),%xmm2
addsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
add    $0x1,%edi
call   1030 <ldexpf@plt>
xorps  %xmm1,%xmm1
movaps (%rsp),%xmm2
ucomiss %xmm1,%xmm2
jae    1267 <expf+0x157>
movss  0xdb0(%rip),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@ERANGE = global i32 0
@errno = global i32 0
define float @expf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
store float %0, float* %3
%11 = load float, float* %3
%12 = fpext float %11 to double
%13 = fcmp oge double %12, 0.000000e+00
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = load float, float* %3
store float %15, float* %9
store i32 0, i32* %10
br label %19
16: ; preds = %1
%17 = load float, float* %3
%18 = fneg float %17
store float %18, float* %9
store i32 1, i32* %10
br label %19
19: ; preds = %16, %14
%20 = load float, float* %9
%21 = fpext float %20 to double
%22 = fcmp olt double %21, 0x3E7AD7F29ABCAF48
br i1 %22, label %23, label %24
23: ; preds = %19
store float 1.000000e+00, float* %2
br label %105
24: ; preds = %19
%25 = load float, float* %9
%26 = fpext float %25 to double
%27 = fcmp ogt double %26, 0x40562E42FEF86E10
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load i32, i32* %10
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = load i32, i32* @ERANGE
store i32 %32, i32* @errno
store float 0x4044B38FC0000000, float* %2
br label %105
33: ; preds = %28
store float 0.000000e+00, float* %2
br label %105
34: ; preds = %24
%35 = load float, float* %9
%36 = fpext float %35 to double
%37 = fmul double %36, 0x3FF71547652C4526
%38 = fptrunc double %37 to float
store float %38, float* %8
%39 = load float, float* %8
%40 = fptosi float %39 to i32
store i32 %40, i32* %4
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %34
%44 = load i32, i32* %4
%45 = add nsw i32 %44, -1
store i32 %45, i32* %4
br label %46
46: ; preds = %43, %34
%47 = load float, float* %8
%48 = load i32, i32* %4
%49 = sitofp i32 %48 to float
%50 = fsub float %47, %49
%51 = fpext float %50 to double
%52 = fcmp oge double %51, 5.000000e-01
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %56
56: ; preds = %53, %46
%57 = load i32, i32* %4
%58 = sitofp i32 %57 to float
store float %58, float* %5
%59 = load float, float* %9
%60 = fpext float %59 to double
%61 = load float, float* %5
%62 = fpext float %61 to double
%63 = fneg double %62
%64 = call double @llvm.fmuladd.f64(double %63, double 0x3FE6300000000000, double %60)
%65 = load float, float* %5
%66 = fpext float %65 to double
%67 = fneg double %66
%68 = call double @llvm.fmuladd.f64(double %67, double 0xBF2BD0105C610CA8, double %64)
%69 = fptrunc double %68 to float
store float %69, float* %6
%70 = load float, float* %6
%71 = load float, float* %6
%72 = fmul float %70, %71
store float %72, float* %8
%73 = load float, float* %8
%74 = fpext float %73 to double
%75 = call double @llvm.fmuladd.f64(double 0x3F710A60F9730F50, double %74, double 0x3FCFFFFFFEED1F41)
%76 = load float, float* %6
%77 = fpext float %76 to double
%78 = fmul double %75, %77
%79 = fptrunc double %78 to float
store float %79, float* %7
%80 = load float, float* %7
%81 = fpext float %80 to double
%82 = load float, float* %8
%83 = fpext float %82 to double
%84 = call double @llvm.fmuladd.f64(double 0x3FA997EB6412AA4C, double %83, double 5.000000e-01)
%85 = load float, float* %7
%86 = fpext float %85 to double
%87 = fsub double %84, %86
%88 = fdiv double %81, %87
%89 = fadd double 5.000000e-01, %88
%90 = fptrunc double %89 to float
store float %90, float* %7
%91 = load i32, i32* %4
%92 = add nsw i32 %91, 1
store i32 %92, i32* %4
%93 = load float, float* %7
%94 = load i32, i32* %4
%95 = call float @ldexpf(float %93, i32 %94)
store float %95, float* %8
%96 = load i32, i32* %10
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %103
98: ; preds = %56
%99 = load float, float* %8
%100 = fpext float %99 to double
%101 = fdiv double 1.000000e+00, %100
%102 = fptrunc double %101 to float
store float %102, float* %2
br label %105
103: ; preds = %56
%104 = load float, float* %8
store float %104, float* %2
br label %105
105: ; preds = %103, %98, %33, %31, %23
%106 = load float, float* %2
ret float %106
}

LLVM IR (-O2):
@ERANGE = global i32 0
@errno = global i32 0
define float @expf(float %0) {
%2 = fcmp ult float %0, 0.000000e+00
%3 = fneg float %0
%4 = select i1 %2, float %3, float %0
%5 = fpext float %4 to double
%6 = fcmp olt double %5, 0x3E7AD7F29ABCAF48
br i1 %6, label %45, label %7
7: ; preds = %1
%8 = fcmp ogt double %5, 0x40562E42FEF86E10
br i1 %8, label %9, label %12
9: ; preds = %7
br i1 %2, label %10, label %45
10: ; preds = %9
%11 = load i32, i32* @ERANGE
store i32 %11, i32* @errno
br label %45
12: ; preds = %7
%13 = fmul double %5, 0x3FF71547652C4526
%14 = fptrunc double %13 to float
%15 = fptosi float %14 to i32
%16 = ashr i32 %15, 31
%17 = add nsw i32 %16, %15
%18 = sitofp i32 %17 to float
%19 = fsub float %14, %18
%20 = fcmp oge float %19, 5.000000e-01
%21 = zext i1 %20 to i32
%22 = add nuw nsw i32 %17, %21
%23 = sitofp i32 %22 to float
%24 = fpext float %23 to double
%25 = fneg double %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double 0x3FE6300000000000, double %5)
%27 = tail call double @llvm.fmuladd.f64(double %25, double 0xBF2BD0105C610CA8, double %26)
%28 = fptrunc double %27 to float
%29 = fmul float %28, %28
%30 = fpext float %29 to double
%31 = tail call double @llvm.fmuladd.f64(double %30, double 0x3F710A60F9730F50, double 0x3FCFFFFFFEED1F41)
%32 = fpext float %28 to double
%33 = fmul double %31, %32
%34 = fptrunc double %33 to float
%35 = fpext float %34 to double
%36 = tail call double @llvm.fmuladd.f64(double %30, double 0x3FA997EB6412AA4C, double 5.000000e-01)
%37 = fsub double %36, %35
%38 = fdiv double %35, %37
%39 = fadd double %38, 5.000000e-01
%40 = fptrunc double %39 to float
%41 = add nsw i32 %22, 1
%42 = tail call float @ldexpf(float %40, i32 %41)
br i1 %2, label %43, label %45
43: ; preds = %12
%44 = fdiv float 1.000000e+00, %42
br label %45
45: ; preds = %12, %9, %1, %43, %10
%46 = phi float [ 0x4044B38FC0000000, %10 ], [ %44, %43 ], [ 1.000000e+00, %1 ], [ 0.000000e+00, %9 ], [ %42, %12 ]
ret float %46
}