#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 /*<<< orphan*/ exp(double);
double myexp_ex(double);
int /*<<< orphan*/ printf(char *, ...);
void taylor_ex() {
  double x;
  printf("    x      myexp(x)        exp(x)\n");
  for (x = -40; x <= 40; x = x + 10) {
    printf("%5.1f%14.6g%14.6g\n", x, myexp_ex(x), exp(x));
  }
}


x86 assembly (clang, -O0):
<taylor_ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xead(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11ba <taylor_ex+0x8a>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <exp@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    %eax,%esi
lea    0xe9f(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xe65(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1153 <taylor_ex+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<taylor_ex>:
push   %rbx
sub    $0x10,%rsp
lea    0xf07(%rip),%rdi
call   1040 <puts@plt>
movsd  0xea7(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe94(%rip),%xmm0
call   1060 <exp@plt>
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
movsd  0xe7d(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe6e(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe5b(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xe4b(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe3c(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe29(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xe19(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe0a(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xdf7(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xde7(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
call   1060 <exp@plt>
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xdad(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd9a(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xd8a(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xd7b(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd68(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xd58(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xd49(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd36(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xd26(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xd17(%rip),%xmm0
call   1030 <myexp_ex@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd04(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xcf4(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
add    $0x10,%rsp
pop    %rbx
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [35 x i8] c" x myexp(x) exp(x)\0A\00"
@.str.1 = [19 x i8] c"%5.1f%14.6g%14.6g\0A\00"
define void @taylor_ex() {
%1 = alloca double
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store double -4.000000e+01, double* %1
br label %3
3: ; preds = %13, %0
%4 = load double, double* %1
%5 = fcmp ole double %4, 4.000000e+01
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load double, double* %1
%8 = load double, double* %1
%9 = call double @myexp_ex(double %8)
%10 = load double, double* %1
%11 = call i32 @exp(double %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %7, double %9, i32 %11)
br label %13
13: ; preds = %6
%14 = load double, double* %1
%15 = fadd double %14, 1.000000e+01
store double %15, double* %1
br label %3
16: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"%5.1f%14.6g%14.6g\0A\00"
@str = [34 x i8] c" x myexp(x) exp(x)\00"
define void @taylor_ex() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%2 = tail call double @myexp_ex(double -4.000000e+01)
%3 = tail call i32 @exp(double -4.000000e+01)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double -4.000000e+01, double %2, i32 %3)
%5 = tail call double @myexp_ex(double -3.000000e+01)
%6 = tail call i32 @exp(double -3.000000e+01)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double -3.000000e+01, double %5, i32 %6)
%8 = tail call double @myexp_ex(double -2.000000e+01)
%9 = tail call i32 @exp(double -2.000000e+01)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double -2.000000e+01, double %8, i32 %9)
%11 = tail call double @myexp_ex(double -1.000000e+01)
%12 = tail call i32 @exp(double -1.000000e+01)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double -1.000000e+01, double %11, i32 %12)
%14 = tail call double @myexp_ex(double 0.000000e+00)
%15 = tail call i32 @exp(double 0.000000e+00)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double 0.000000e+00, double %14, i32 %15)
%17 = tail call double @myexp_ex(double 1.000000e+01)
%18 = tail call i32 @exp(double 1.000000e+01)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+01, double %17, i32 %18)
%20 = tail call double @myexp_ex(double 2.000000e+01)
%21 = tail call i32 @exp(double 2.000000e+01)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double 2.000000e+01, double %20, i32 %21)
%23 = tail call double @myexp_ex(double 3.000000e+01)
%24 = tail call i32 @exp(double 3.000000e+01)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double 3.000000e+01, double %23, i32 %24)
%26 = tail call double @myexp_ex(double 4.000000e+01)
%27 = tail call i32 @exp(double 4.000000e+01)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double 4.000000e+01, double %26, i32 %27)
ret void
}