#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 */
long double M_LN2;
long double expl(long double);
long double fabsl(long double);
long double ldexpl(int, int);
int /*<<< orphan*/ printf(char *, long double, long double, long double,
                          long double);
int roundf(long double);
void myexp(long double num) {
  long double u, w, approxValue, actualValue, z, rerr;
  int m;
  z = num / M_LN2;
  m = roundf(z);
  w = z - m;
  u = w * M_LN2;
  approxValue = ldexpl(
      (1 +
       u * (1 + u * (1 / 2.0 +
                     u * (1 / 6.0 + u * (1 / 24.0 + u * (1 / 120.0 +
                                                         u * (1 / 720.0 +
                                                              u / 5040.0))))))),
      m);
  actualValue = expl(num);
  rerr = fabsl((actualValue - approxValue) / approxValue);
  printf("%+0.9Le %0.15Le %0.15Le %0.15Le\n", num, approxValue, actualValue,
         rerr);
  return;
}


x86 assembly (clang, -O0):
<myexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
mov    0x2e85(%rip),%rax
mov    %rax,-0x88(%rbp)
fldt   (%rax)
fdivrp %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x60(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <roundf@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,-0x74(%rbp)
fldt   -0x60(%rbp)
mov    -0x74(%rbp),%ecx
mov    %ecx,-0x7c(%rbp)
fildl  -0x7c(%rbp)
fsubrp %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldt   (%rax)
fmulp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
flds   0xe5a(%rip)
fdivr  %st(1),%st
fldl   0xe5a(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
fldl   0xe58(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
fldl   0xe56(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
fldl   0xe54(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
flds   0xe2e(%rip)
faddp  %st,%st(1)
fmul   %st(1),%st
fld1
fadd   %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fnstcw -0x7e(%rbp)
movzwl -0x7e(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x80(%rbp)
fldcw  -0x80(%rbp)
fistpl -0x78(%rbp)
fldcw  -0x7e(%rbp)
mov    -0x78(%rbp),%edi
mov    -0x74(%rbp),%esi
call   1050 <ldexpl@plt>
fstpt  -0x40(%rbp)
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <expl@plt>
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   -0x40(%rbp)
fsubr  %st,%st(1)
fdivrp %st,%st(1)
fabs
fstpt  -0x70(%rbp)
fldt   -0x10(%rbp)
fldt   -0x40(%rbp)
fldt   -0x50(%rbp)
fldt   -0x70(%rbp)
mov    %rsp,%rax
fstpt  0x30(%rax)
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0xddd(%rip),%rdi
call   1030 <printf@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myexp>:
push   %rbx
sub    $0x70,%rsp
fldt   0x80(%rsp)
fld    %st(0)
fstpt  0x64(%rsp)
mov    0x2e87(%rip),%rbx
fldt   (%rbx)
fdivrp %st,%st(1)
fld    %st(0)
fstpt  0x58(%rsp)
fstpt  (%rsp)
call   1060 <roundf@plt>
mov    %eax,0x50(%rsp)
fldt   0x58(%rsp)
fisubl 0x50(%rsp)
fldt   (%rbx)
fmulp  %st,%st(1)
fld    %st(0)
fdivs  0xe7d(%rip)
faddl  0xe7f(%rip)
fmul   %st(1),%st
faddl  0xe7f(%rip)
fmul   %st(1),%st
faddl  0xe7f(%rip)
fmul   %st(1),%st
faddl  0xe7f(%rip)
fmul   %st(1),%st
fadds  0xe5b(%rip)
fmul   %st(1),%st
fld1
fadd   %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fnstcw 0x4c(%rsp)
movzwl 0x4c(%rsp),%ecx
or     $0xc00,%ecx
mov    %cx,0x4e(%rsp)
fldcw  0x4e(%rsp)
fistpl 0x54(%rsp)
fldcw  0x4c(%rsp)
mov    0x54(%rsp),%edi
mov    %eax,%esi
call   1050 <ldexpl@plt>
fstpt  0x58(%rsp)
fldt   0x64(%rsp)
fstpt  (%rsp)
call   1040 <expl@plt>
fldt   0x58(%rsp)
fld    %st(1)
fsub   %st(1),%st
fdiv   %st(1),%st
fabs
fxch   %st(2)
fstpt  0x20(%rsp)
fstpt  0x10(%rsp)
fldt   0x64(%rsp)
fstpt  (%rsp)
fstpt  0x30(%rsp)
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_LN2 = global x86_fp80 0xK00000000000000000000
@.str = [33 x i8] c"%+0.9Le %0.15Le %0.15Le %0.15Le\0A\00"
define void @myexp(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca i32
store x86_fp80 %0, x86_fp80* %2
%10 = load x86_fp80, x86_fp80* %2
%11 = load x86_fp80, x86_fp80* @M_LN2
%12 = fdiv x86_fp80 %10, %11
store x86_fp80 %12, x86_fp80* %7
%13 = load x86_fp80, x86_fp80* %7
%14 = call i32 @roundf(x86_fp80 %13)
store i32 %14, i32* %9
%15 = load x86_fp80, x86_fp80* %7
%16 = load i32, i32* %9
%17 = sitofp i32 %16 to x86_fp80
%18 = fsub x86_fp80 %15, %17
store x86_fp80 %18, x86_fp80* %4
%19 = load x86_fp80, x86_fp80* %4
%20 = load x86_fp80, x86_fp80* @M_LN2
%21 = fmul x86_fp80 %19, %20
store x86_fp80 %21, x86_fp80* %3
%22 = load x86_fp80, x86_fp80* %3
%23 = load x86_fp80, x86_fp80* %3
%24 = load x86_fp80, x86_fp80* %3
%25 = load x86_fp80, x86_fp80* %3
%26 = load x86_fp80, x86_fp80* %3
%27 = load x86_fp80, x86_fp80* %3
%28 = load x86_fp80, x86_fp80* %3
%29 = fdiv x86_fp80 %28, 0xK400B9D80000000000000
%30 = fadd x86_fp80 0xK3FF5B60B60B60B60B800, %29
%31 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %27, x86_fp80 %30, x86_fp80 0xK3FF88888888888888800)
%32 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %26, x86_fp80 %31, x86_fp80 0xK3FFAAAAAAAAAAAAAA800)
%33 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %25, x86_fp80 %32, x86_fp80 0xK3FFCAAAAAAAAAAAAA800)
%34 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %24, x86_fp80 %33, x86_fp80 0xK3FFE8000000000000000)
%35 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %23, x86_fp80 %34, x86_fp80 0xK3FFF8000000000000000)
%36 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %22, x86_fp80 %35, x86_fp80 0xK3FFF8000000000000000)
%37 = fptosi x86_fp80 %36 to i32
%38 = load i32, i32* %9
%39 = call x86_fp80 @ldexpl(i32 %37, i32 %38)
store x86_fp80 %39, x86_fp80* %5
%40 = load x86_fp80, x86_fp80* %2
%41 = call x86_fp80 @expl(x86_fp80 %40)
store x86_fp80 %41, x86_fp80* %6
%42 = load x86_fp80, x86_fp80* %6
%43 = load x86_fp80, x86_fp80* %5
%44 = fsub x86_fp80 %42, %43
%45 = load x86_fp80, x86_fp80* %5
%46 = fdiv x86_fp80 %44, %45
%47 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %46)
store x86_fp80 %47, x86_fp80* %8
%48 = load x86_fp80, x86_fp80* %2
%49 = load x86_fp80, x86_fp80* %5
%50 = load x86_fp80, x86_fp80* %6
%51 = load x86_fp80, x86_fp80* %8
%52 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), x86_fp80 %48, x86_fp80 %49, x86_fp80 %50, x86_fp80 %51)
ret void
}

LLVM IR (-O2):
@M_LN2 = global x86_fp80 0xK00000000000000000000
@.str = [33 x i8] c"%+0.9Le %0.15Le %0.15Le %0.15Le\0A\00"
define void @myexp(x86_fp80 %0) {
%2 = load x86_fp80, x86_fp80* @M_LN2
%3 = fdiv x86_fp80 %0, %2
%4 = tail call i32 @roundf(x86_fp80 %3)
%5 = sitofp i32 %4 to x86_fp80
%6 = fsub x86_fp80 %3, %5
%7 = load x86_fp80, x86_fp80* @M_LN2
%8 = fmul x86_fp80 %7, %6
%9 = fdiv x86_fp80 %8, 0xK400B9D80000000000000
%10 = fadd x86_fp80 %9, 0xK3FF5B60B60B60B60B800
%11 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %8, x86_fp80 %10, x86_fp80 0xK3FF88888888888888800)
%12 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %8, x86_fp80 %11, x86_fp80 0xK3FFAAAAAAAAAAAAAA800)
%13 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %8, x86_fp80 %12, x86_fp80 0xK3FFCAAAAAAAAAAAAA800)
%14 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %8, x86_fp80 %13, x86_fp80 0xK3FFE8000000000000000)
%15 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %8, x86_fp80 %14, x86_fp80 0xK3FFF8000000000000000)
%16 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %8, x86_fp80 %15, x86_fp80 0xK3FFF8000000000000000)
%17 = fptosi x86_fp80 %16 to i32
%18 = tail call x86_fp80 @ldexpl(i32 %17, i32 %4)
%19 = tail call x86_fp80 @expl(x86_fp80 %0)
%20 = fsub x86_fp80 %19, %18
%21 = fdiv x86_fp80 %20, %18
%22 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %21)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), x86_fp80 %0, x86_fp80 %18, x86_fp80 %19, x86_fp80 %22)
ret void
}