#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 */
double _pow(double, unsigned int);
double fac(unsigned int);
double exp(double x) {
  double y = 0;
  for (unsigned int i = 0; i != 8; i++)
    y += _pow(x, i) / fac(i);
  return y;
}


x86 assembly (clang, -O0):
<exp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
je     1184 <exp+0x64>
movsd  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <_pow@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <fac@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <exp+0x1c>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exp>:
sub    $0x58,%rsp
movsd  %xmm0,(%rsp)
xor    %edi,%edi
call   1030 <_pow@plt>
movaps %xmm0,0x30(%rsp)
xor    %edi,%edi
call   1040 <fac@plt>
movaps %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
mov    $0x1,%edi
call   1030 <_pow@plt>
movapd %xmm0,0x10(%rsp)
mov    $0x1,%edi
call   1040 <fac@plt>
movapd 0x30(%rsp),%xmm1
unpcklpd 0x10(%rsp),%xmm1
movapd 0x20(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x30(%rsp)
movsd  (%rsp),%xmm0
mov    $0x2,%edi
call   1030 <_pow@plt>
movaps %xmm0,0x20(%rsp)
mov    $0x2,%edi
call   1040 <fac@plt>
movaps %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mov    $0x3,%edi
call   1030 <_pow@plt>
movapd %xmm0,0x40(%rsp)
mov    $0x3,%edi
call   1040 <fac@plt>
movapd 0x20(%rsp),%xmm1
unpcklpd 0x40(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd 0x30(%rsp),%xmm0
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  (%rsp),%xmm0
mov    $0x4,%edi
call   1030 <_pow@plt>
movaps %xmm0,0x30(%rsp)
mov    $0x4,%edi
call   1040 <fac@plt>
movaps %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mov    $0x5,%edi
call   1030 <_pow@plt>
movapd %xmm0,0x40(%rsp)
mov    $0x5,%edi
call   1040 <fac@plt>
movapd 0x30(%rsp),%xmm1
unpcklpd 0x40(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd 0x20(%rsp),%xmm0
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x30(%rsp)
movsd  (%rsp),%xmm0
mov    $0x6,%edi
call   1030 <_pow@plt>
movaps %xmm0,0x20(%rsp)
mov    $0x6,%edi
call   1040 <fac@plt>
movaps %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mov    $0x7,%edi
call   1030 <_pow@plt>
movapd %xmm0,(%rsp)
mov    $0x7,%edi
call   1040 <fac@plt>
movapd 0x20(%rsp),%xmm1
unpcklpd (%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd 0x30(%rsp),%xmm0
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @exp(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %3
store i32 0, i32* %4
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 8
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load double, double* %2
%10 = load i32, i32* %4
%11 = call double @_pow(double %9, i32 %10)
%12 = load i32, i32* %4
%13 = call double @fac(i32 %12)
%14 = fdiv double %11, %13
%15 = load double, double* %3
%16 = fadd double %15, %14
store double %16, double* %3
br label %17
17: ; preds = %8
%18 = load i32, i32* %4
%19 = add i32 %18, 1
store i32 %19, i32* %4
br label %5
20: ; preds = %5
%21 = load double, double* %3
ret double %21
}

LLVM IR (-O2):
define double @exp(double %0) {
%2 = tail call double @_pow(double %0, i32 0)
%3 = tail call double @fac(i32 0)
%4 = tail call double @_pow(double %0, i32 1)
%5 = tail call double @fac(i32 1)
%6 = insertelement <2 x double> poison, double %2, i64 0
%7 = insertelement <2 x double> %6, double %4, i64 1
%8 = insertelement <2 x double> poison, double %3, i64 0
%9 = insertelement <2 x double> %8, double %5, i64 1
%10 = fdiv <2 x double> %7, %9
%11 = extractelement <2 x double> %10, i64 0
%12 = fadd double %11, 0.000000e+00
%13 = extractelement <2 x double> %10, i64 1
%14 = fadd double %12, %13
%15 = tail call double @_pow(double %0, i32 2)
%16 = tail call double @fac(i32 2)
%17 = tail call double @_pow(double %0, i32 3)
%18 = tail call double @fac(i32 3)
%19 = insertelement <2 x double> poison, double %15, i64 0
%20 = insertelement <2 x double> %19, double %17, i64 1
%21 = insertelement <2 x double> poison, double %16, i64 0
%22 = insertelement <2 x double> %21, double %18, i64 1
%23 = fdiv <2 x double> %20, %22
%24 = extractelement <2 x double> %23, i64 0
%25 = fadd double %14, %24
%26 = extractelement <2 x double> %23, i64 1
%27 = fadd double %25, %26
%28 = tail call double @_pow(double %0, i32 4)
%29 = tail call double @fac(i32 4)
%30 = tail call double @_pow(double %0, i32 5)
%31 = tail call double @fac(i32 5)
%32 = insertelement <2 x double> poison, double %28, i64 0
%33 = insertelement <2 x double> %32, double %30, i64 1
%34 = insertelement <2 x double> poison, double %29, i64 0
%35 = insertelement <2 x double> %34, double %31, i64 1
%36 = fdiv <2 x double> %33, %35
%37 = extractelement <2 x double> %36, i64 0
%38 = fadd double %27, %37
%39 = extractelement <2 x double> %36, i64 1
%40 = fadd double %38, %39
%41 = tail call double @_pow(double %0, i32 6)
%42 = tail call double @fac(i32 6)
%43 = tail call double @_pow(double %0, i32 7)
%44 = tail call double @fac(i32 7)
%45 = insertelement <2 x double> poison, double %41, i64 0
%46 = insertelement <2 x double> %45, double %43, i64 1
%47 = insertelement <2 x double> poison, double %42, i64 0
%48 = insertelement <2 x double> %47, double %44, i64 1
%49 = fdiv <2 x double> %46, %48
%50 = extractelement <2 x double> %49, i64 0
%51 = fadd double %40, %50
%52 = extractelement <2 x double> %49, i64 1
%53 = fadd double %51, %52
ret double %53
}