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


x86 assembly (clang, -O0):
<taylor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeaa(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11b5 <taylor+0x85>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <myexp@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    0xe9c(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xe62(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    114e <taylor+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<taylor>:
push   %rbx
sub    $0x10,%rsp
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
call   1040 <myexp@plt>
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
call   1060 <exp@plt>
lea    0xeb2(%rip),%rbx
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe75(%rip),%xmm0
call   1040 <myexp@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe62(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xe52(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe43(%rip),%xmm0
call   1040 <myexp@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe30(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xe20(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe11(%rip),%xmm0
call   1040 <myexp@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xdfe(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xdee(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xddf(%rip),%xmm0
call   1040 <myexp@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xdcc(%rip),%xmm0
call   1060 <exp@plt>
mov    %rbx,%rdi
movsd  0xdbc(%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() {
%1 = alloca double
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, 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(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() {
%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(double 0.000000e+00)
%3 = tail call i32 @exp(double 0.000000e+00)
%4 = 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 %2, i32 %3)
%5 = tail call double @myexp(double 1.000000e+01)
%6 = tail call i32 @exp(double 1.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 1.000000e+01, double %5, i32 %6)
%8 = tail call double @myexp(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(double 3.000000e+01)
%12 = tail call i32 @exp(double 3.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 3.000000e+01, double %11, i32 %12)
%14 = tail call double @myexp(double 4.000000e+01)
%15 = tail call i32 @exp(double 4.000000e+01)
%16 = 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 %14, i32 %15)
ret void
}