#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 */
scalar_t__ umath_double_factorial(int);
double umath_double_pow(double, int);
double umath_double_exp(double x) {
  int i;
  double result = 0.0;
  int neg;
  if (x >= 0) {
    neg = 1;
    x = ((x) > 0 ? (x) : (-(x)));
  } else {
    neg = 0;
  }
  i = 10;
  while (i != 0) {
    result += umath_double_pow(x, i) / (double)(umath_double_factorial(i));
    i -= 1;
  }
  result += 1.0;
  return neg != 0 ? result : 1.0 / result;
}


x86 assembly (clang, -O0):
<umath_double_exp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119f <umath_double_exp+0x7f>
movl   $0x1,-0x1c(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    116f <umath_double_exp+0x4f>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1190 <umath_double_exp+0x70>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a6 <umath_double_exp+0x86>
movl   $0x0,-0x1c(%rbp)
movl   $0xa,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11f7 <umath_double_exp+0xd7>
movsd  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <umath_double_factorial@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ad <umath_double_exp+0x8d>
movsd  0xe01(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1222 <umath_double_exp+0x102>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1234 <umath_double_exp+0x114>
movsd  0xdd6(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<umath_double_exp>:
sub    $0x38,%rsp
movapd %xmm0,0x20(%rsp)
movapd 0xece(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm3
cmpneqsd %xmm1,%xmm3
movapd %xmm3,%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm3,0x10(%rsp)
movapd %xmm3,%xmm0
mov    $0xa,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0xe89(%rip),%xmm1
movsd  %xmm1,(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x9,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x9,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x8,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x8,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x7,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x7,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x6,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x6,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x5,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x5,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x4,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x4,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x3,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x2,%edi
call   1040 <umath_double_factorial@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%rsp)
movaps 0x10(%rsp),%xmm0
mov    $0x1,%edi
call   1030 <umath_double_pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%edi
call   1040 <umath_double_factorial@plt>
movsd  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movapd 0x20(%rsp),%xmm0
ucomisd 0xc68(%rip),%xmm0
addsd  0xc58(%rip),%xmm1
jae    13ca <umath_double_exp+0x2aa>
movsd  0xc4e(%rip),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @umath_double_exp(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %4
%6 = load double, double* %2
%7 = fcmp oge double %6, 0.000000e+00
br i1 %7, label %8, label %18
8: ; preds = %1
store i32 1, i32* %5
%9 = load double, double* %2
%10 = fcmp ogt double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load double, double* %2
br label %16
13: ; preds = %8
%14 = load double, double* %2
%15 = fneg double %14
br label %16
16: ; preds = %13, %11
%17 = phi double [ %12, %11 ], [ %15, %13 ]
store double %17, double* %2
br label %19
18: ; preds = %1
store i32 0, i32* %5
br label %19
19: ; preds = %18, %16
store i32 10, i32* %3
br label %20
20: ; preds = %23, %19
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load double, double* %2
%25 = load i32, i32* %3
%26 = call double @umath_double_pow(double %24, i32 %25)
%27 = load i32, i32* %3
%28 = call i64 @umath_double_factorial(i32 %27)
%29 = sitofp i64 %28 to double
%30 = fdiv double %26, %29
%31 = load double, double* %4
%32 = fadd double %31, %30
store double %32, double* %4
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 1
store i32 %34, i32* %3
br label %20
35: ; preds = %20
%36 = load double, double* %4
%37 = fadd double %36, 1.000000e+00
store double %37, double* %4
%38 = load i32, i32* %5
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = load double, double* %4
br label %45
42: ; preds = %35
%43 = load double, double* %4
%44 = fdiv double 1.000000e+00, %43
br label %45
45: ; preds = %42, %40
%46 = phi double [ %41, %40 ], [ %44, %42 ]
ret double %46
}

LLVM IR (-O2):
define double @umath_double_exp(double %0) {
%2 = fneg double %0
%3 = fcmp une double %0, 0.000000e+00
%4 = select i1 %3, double %0, double %2
%5 = tail call double @umath_double_pow(double %4, i32 10)
%6 = tail call i64 @umath_double_factorial(i32 10)
%7 = sitofp i64 %6 to double
%8 = fdiv double %5, %7
%9 = fadd double %8, 0.000000e+00
%10 = tail call double @umath_double_pow(double %4, i32 9)
%11 = tail call i64 @umath_double_factorial(i32 9)
%12 = sitofp i64 %11 to double
%13 = fdiv double %10, %12
%14 = fadd double %9, %13
%15 = tail call double @umath_double_pow(double %4, i32 8)
%16 = tail call i64 @umath_double_factorial(i32 8)
%17 = sitofp i64 %16 to double
%18 = fdiv double %15, %17
%19 = fadd double %14, %18
%20 = tail call double @umath_double_pow(double %4, i32 7)
%21 = tail call i64 @umath_double_factorial(i32 7)
%22 = sitofp i64 %21 to double
%23 = fdiv double %20, %22
%24 = fadd double %19, %23
%25 = tail call double @umath_double_pow(double %4, i32 6)
%26 = tail call i64 @umath_double_factorial(i32 6)
%27 = sitofp i64 %26 to double
%28 = fdiv double %25, %27
%29 = fadd double %24, %28
%30 = tail call double @umath_double_pow(double %4, i32 5)
%31 = tail call i64 @umath_double_factorial(i32 5)
%32 = sitofp i64 %31 to double
%33 = fdiv double %30, %32
%34 = fadd double %29, %33
%35 = tail call double @umath_double_pow(double %4, i32 4)
%36 = tail call i64 @umath_double_factorial(i32 4)
%37 = sitofp i64 %36 to double
%38 = fdiv double %35, %37
%39 = fadd double %34, %38
%40 = tail call double @umath_double_pow(double %4, i32 3)
%41 = tail call i64 @umath_double_factorial(i32 3)
%42 = sitofp i64 %41 to double
%43 = fdiv double %40, %42
%44 = fadd double %39, %43
%45 = tail call double @umath_double_pow(double %4, i32 2)
%46 = tail call i64 @umath_double_factorial(i32 2)
%47 = sitofp i64 %46 to double
%48 = fdiv double %45, %47
%49 = fadd double %44, %48
%50 = tail call double @umath_double_pow(double %4, i32 1)
%51 = tail call i64 @umath_double_factorial(i32 1)
%52 = sitofp i64 %51 to double
%53 = fdiv double %50, %52
%54 = fadd double %49, %53
%55 = fcmp ult double %0, 0.000000e+00
%56 = fadd double %54, 1.000000e+00
%57 = fdiv double 1.000000e+00, %56
%58 = select i1 %55, double %57, double %56
ret double %58
}