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


x86 assembly (clang, -O0):
<myexp_ex>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  0xf07(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xef2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xee5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xec4(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0xc8,-0x3c(%rbp)
jg     120d <myexp_ex+0x10d>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x3c(%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 0xe65(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movaps 0xe50(%rip),%xmm3
pand   %xmm3,%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11fa <myexp_ex+0xfa>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11e3 <myexp_ex+0xe3>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1215 <myexp_ex+0x115>
movsd  0xe25(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1215 <myexp_ex+0x115>
jmp    11ff <myexp_ex+0xff>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    114c <myexp_ex+0x4c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<myexp_ex>:
movapd %xmm0,%xmm1
movapd 0xef4(%rip),%xmm2
andpd  %xmm0,%xmm2
movsd  0xef8(%rip),%xmm0
mov    $0x1,%eax
movapd 0xedb(%rip),%xmm3
movsd  0xeeb(%rip),%xmm4
movapd %xmm0,%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movapd %xmm0,%xmm6
mulsd  %xmm2,%xmm5
xorps  %xmm7,%xmm7
cvtsi2sd %eax,%xmm7
divsd  %xmm7,%xmm5
addsd  %xmm5,%xmm0
movapd %xmm0,%xmm7
subsd  %xmm6,%xmm7
andpd  %xmm3,%xmm7
andpd  %xmm3,%xmm6
mulsd  %xmm4,%xmm6
ucomisd %xmm7,%xmm6
ja     1180 <myexp_ex+0x80>
add    $0x1,%eax
cmp    $0xc9,%eax
jne    1140 <myexp_ex+0x40>
xorpd  %xmm0,%xmm0
ret
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
ja     119a <myexp_ex+0x9a>
movsd  0xe7e(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

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

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