#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 floor(float);
float ldexp(float, int);
float exp(float arg) {
  static float p0 = .2080384346694663001443843411e7;
  static float p1 = .3028697169744036299076048876e5;
  static float p2 = .6061485330061080841615584556e2;
  static float q0 = .6002720360238832528230907598e7;
  static float q1 = .3277251518082914423057964422e6;
  static float q2 = .1749287689093076403844945335e4;
  static float log2e = 1.4426950408889634073599247;
  static float sqrt2 = 1.4142135623730950488016887;
  static float maxf = 10000;
  float fract;
  float temp1, temp2, xsq;
  int ent;
  if (arg == 0.)
    return (1.);
  if (arg < -maxf)
    return (0.);
  if (arg > maxf) {
    return 1e42;
  }
  arg *= log2e;
  ent = floor(arg);
  fract = (arg - ent) - 0.5;
  xsq = fract * fract;
  temp1 = ((p2 * xsq + p1) * xsq + p0) * fract;
  temp2 = ((1.0 * xsq + q2) * xsq + q1) * xsq + q0;
  return (ldexp(sqrt2 * (temp2 + temp1) / (temp2 - temp1), ent));
}


x86 assembly (clang, -O0):
<exp>:
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 <exp+0x3b>
jp     115b <exp+0x3b>
movss  0xebb(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12cd <exp+0x1ad>
movss  -0x8(%rbp),%xmm1
movss  0x2ee8(%rip),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    118b <exp+0x6b>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12cd <exp+0x1ad>
movss  -0x8(%rbp),%xmm0
ucomiss 0x2eb9(%rip),%xmm0
jbe    11af <exp+0x8f>
movss  0xe63(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12cd <exp+0x1ad>
movss  0x2e91(%rip),%xmm0
mulss  -0x8(%rbp),%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  0xe18(%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  0x2e2c(%rip),%xmm0
movss  -0x18(%rbp),%xmm2
movss  0x2e1b(%rip),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm2
movss  0x2e02(%rip),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x2df3(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movss  0x2dd6(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movss  0x2db5(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0x2da8(%rip),%xmm0
movss  -0x14(%rbp),%xmm1
addss  -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
divss  %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):
<exp>:
push   %rax
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jne    1138 <exp+0x18>
jp     1138 <exp+0x18>
movss  0xeca(%rip),%xmm0
pop    %rax
ret
movss  0xec4(%rip),%xmm1
ucomiss %xmm2,%xmm1
ja     1156 <exp+0x36>
ucomiss 0xec0(%rip),%xmm2
jbe    1158 <exp+0x38>
movss  0xeb2(%rip),%xmm0
pop    %rax
ret
mulss  0xeb0(%rip),%xmm2
movss  %xmm2,0x4(%rsp)
movaps %xmm2,%xmm0
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
addss  0xe8d(%rip),%xmm1
movaps %xmm1,%xmm0
movaps %xmm1,%xmm3
mulss  %xmm1,%xmm0
movss  0xe7f(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe77(%rip),%xmm1
mulss  %xmm0,%xmm1
cvtss2sd %xmm0,%xmm0
movsd  0xe73(%rip),%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe6b(%rip),%xmm2
mulsd  %xmm0,%xmm2
addss  0xe4f(%rip),%xmm1
addsd  0xe5f(%rip),%xmm2
mulss  %xmm3,%xmm1
cvtsd2ss %xmm2,%xmm2
movaps %xmm1,%xmm0
addss  %xmm2,%xmm0
mulss  0xe34(%rip),%xmm0
subss  %xmm1,%xmm2
divss  %xmm2,%xmm0
mov    %eax,%edi
pop    %rax
jmp    1030 <ldexp@plt>

LLVM IR (-O0):
@exp.p0 = internal global float 0x413FBE8060000000
@exp.p1 = internal global float 0x40DD93BE40000000
@exp.p2 = internal global float 0x404E4EB380000000
@exp.q0 = internal global float 0x4156E60820000000
@exp.q1 = internal global float 0x411400B4A0000000
@exp.q2 = internal global float 0x409B5526A0000000
@exp.log2e = internal global float 0x3FF7154760000000
@exp.sqrt2 = internal global float 0x3FF6A09E60000000
@exp.maxf = internal global float 1.000000e+04
define float @exp(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 %76
13: ; preds = %1
%14 = load float, float* %3
%15 = load float, float* @exp.maxf
%16 = fneg float %15
%17 = fcmp olt float %14, %16
br i1 %17, label %18, label %19
18: ; preds = %13
store float 0.000000e+00, float* %2
br label %76
19: ; preds = %13
%20 = load float, float* %3
%21 = load float, float* @exp.maxf
%22 = fcmp ogt float %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store float 0x7FF0000000000000, float* %2
br label %76
24: ; preds = %19
%25 = load float, float* @exp.log2e
%26 = load float, float* %3
%27 = fmul float %26, %25
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* @exp.p2
%41 = load float, float* %7
%42 = load float, float* @exp.p1
%43 = call float @llvm.fmuladd.f32(float %40, float %41, float %42)
%44 = load float, float* %7
%45 = load float, float* @exp.p0
%46 = call float @llvm.fmuladd.f32(float %43, float %44, float %45)
%47 = load float, float* %4
%48 = fmul float %46, %47
store float %48, float* %5
%49 = load float, float* %7
%50 = fpext float %49 to double
%51 = load float, float* @exp.q2
%52 = fpext float %51 to double
%53 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %50, double %52)
%54 = load float, float* %7
%55 = fpext float %54 to double
%56 = load float, float* @exp.q1
%57 = fpext float %56 to double
%58 = call double @llvm.fmuladd.f64(double %53, double %55, double %57)
%59 = load float, float* %7
%60 = fpext float %59 to double
%61 = load float, float* @exp.q0
%62 = fpext float %61 to double
%63 = call double @llvm.fmuladd.f64(double %58, double %60, double %62)
%64 = fptrunc double %63 to float
store float %64, float* %6
%65 = load float, float* @exp.sqrt2
%66 = load float, float* %6
%67 = load float, float* %5
%68 = fadd float %66, %67
%69 = fmul float %65, %68
%70 = load float, float* %6
%71 = load float, float* %5
%72 = fsub float %70, %71
%73 = fdiv float %69, %72
%74 = load i32, i32* %8
%75 = call float @ldexp(float %73, i32 %74)
store float %75, float* %2
br label %76
76: ; preds = %24, %23, %18, %12
%77 = load float, float* %2
ret float %77
}

LLVM IR (-O2):
define float @exp(float %0) {
%2 = fcmp oeq float %0, 0.000000e+00
br i1 %2, label %27, label %3
3: ; preds = %1
%4 = fcmp olt float %0, -1.000000e+04
br i1 %4, label %27, label %5
5: ; preds = %3
%6 = fcmp ogt float %0, 1.000000e+04
br i1 %6, label %27, label %7
7: ; preds = %5
%8 = fmul float %0, 0x3FF7154760000000
%9 = tail call i32 @floor(float %8)
%10 = sitofp i32 %9 to float
%11 = fsub float %8, %10
%12 = fadd float %11, -5.000000e-01
%13 = fmul float %12, %12
%14 = tail call float @llvm.fmuladd.f32(float %13, float 0x404E4EB380000000, float 0x40DD93BE40000000)
%15 = tail call float @llvm.fmuladd.f32(float %14, float %13, float 0x413FBE8060000000)
%16 = fmul float %12, %15
%17 = fpext float %13 to double
%18 = fadd double %17, 0x409B5526A0000000
%19 = tail call double @llvm.fmuladd.f64(double %18, double %17, double 0x411400B4A0000000)
%20 = tail call double @llvm.fmuladd.f64(double %19, double %17, double 0x4156E60820000000)
%21 = fptrunc double %20 to float
%22 = fadd float %16, %21
%23 = fmul float %22, 0x3FF6A09E60000000
%24 = fsub float %21, %16
%25 = fdiv float %23, %24
%26 = tail call float @ldexp(float %25, i32 %9)
br label %27
27: ; preds = %5, %3, %1, %7
%28 = phi float [ %26, %7 ], [ 1.000000e+00, %1 ], [ 0.000000e+00, %3 ], [ 0x7FF0000000000000, %5 ]
ret float %28
}