#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 fabs(double);
double myexp(double x) {
  double EPS = 1e-08;
  double s = 1.0, e = 1.0, d;
  int k;
  for (k = 1; k <= 200; k++) {
    d = s;
    e = e * x / k;
    s = s + e;
    if (fabs(s - d) < EPS * fabs(d)) {
      return s;
    }
  }
  return 0.0;
}


x86 assembly (clang, -O0):
<myexp>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  0xef7(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xee2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x34(%rbp)
cmpl   $0xc8,-0x34(%rbp)
jg     11cf <myexp+0xcf>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
movaps 0xe8a(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movaps 0xe75(%rip),%xmm3
pand   %xmm3,%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11bc <myexp+0xbc>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d7 <myexp+0xd7>
jmp    11c1 <myexp+0xc1>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1137 <myexp+0x37>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<myexp>:
movsd  0xef8(%rip),%xmm2
mov    $0x1,%eax
movapd 0xefb(%rip),%xmm3
movsd  0xeeb(%rip),%xmm4
movapd %xmm2,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movapd %xmm1,%xmm5
mulsd  %xmm0,%xmm2
xorps  %xmm6,%xmm6
cvtsi2sd %eax,%xmm6
divsd  %xmm6,%xmm2
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm6
subsd  %xmm5,%xmm6
andpd  %xmm3,%xmm6
andpd  %xmm3,%xmm5
mulsd  %xmm4,%xmm5
ucomisd %xmm6,%xmm5
ja     116f <myexp+0x6f>
add    $0x1,%eax
cmp    $0xc9,%eax
jne    1130 <myexp+0x30>
xorpd  %xmm1,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @myexp(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store double %0, double* %3
store double 1.000000e-08, double* %4
store double 1.000000e+00, double* %5
store double 1.000000e+00, double* %6
store i32 1, i32* %8
br label %9
9: ; preds = %35, %1
%10 = load i32, i32* %8
%11 = icmp sle i32 %10, 200
br i1 %11, label %12, label %38
12: ; preds = %9
%13 = load double, double* %5
store double %13, double* %7
%14 = load double, double* %6
%15 = load double, double* %3
%16 = fmul double %14, %15
%17 = load i32, i32* %8
%18 = sitofp i32 %17 to double
%19 = fdiv double %16, %18
store double %19, double* %6
%20 = load double, double* %5
%21 = load double, double* %6
%22 = fadd double %20, %21
store double %22, double* %5
%23 = load double, double* %5
%24 = load double, double* %7
%25 = fsub double %23, %24
%26 = call double @llvm.fabs.f64(double %25)
%27 = load double, double* %4
%28 = load double, double* %7
%29 = call double @llvm.fabs.f64(double %28)
%30 = fmul double %27, %29
%31 = fcmp olt double %26, %30
br i1 %31, label %32, label %34
32: ; preds = %12
%33 = load double, double* %5
store double %33, double* %2
br label %39
34: ; preds = %12
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %9
38: ; preds = %9
store double 0.000000e+00, double* %2
br label %39
39: ; preds = %38, %32
%40 = load double, double* %2
ret double %40
}

LLVM IR (-O2):
define double @myexp(double %0) {
br label %5
2: ; preds = %5
%3 = add nuw nsw i32 %6, 1
%4 = icmp eq i32 %3, 201
br i1 %4, label %18, label %5
5: ; preds = %1, %2
%6 = phi i32 [ 1, %1 ], [ %3, %2 ]
%7 = phi double [ 1.000000e+00, %1 ], [ %11, %2 ]
%8 = phi double [ 1.000000e+00, %1 ], [ %12, %2 ]
%9 = fmul double %7, %0
%10 = sitofp i32 %6 to double
%11 = fdiv double %9, %10
%12 = fadd double %8, %11
%13 = fsub double %12, %8
%14 = tail call double @llvm.fabs.f64(double %13)
%15 = tail call double @llvm.fabs.f64(double %8)
%16 = fmul double %15, 1.000000e-08
%17 = fcmp olt double %14, %16
br i1 %17, label %18, label %2
18: ; preds = %2, %5
%19 = phi double [ %12, %5 ], [ 0.000000e+00, %2 ]
ret double %19
}