#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 sin(long double);
long double fun(long double x) {
  int k, n = 5;
  long double t1, d1 = 1.0L;
  t1 = x;
  for (k = 1; k <= n; k++) {
    d1 = 2.0 * d1;
    t1 = t1 + sin(d1 * x) / d1;
  }
  return t1;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
movl   $0x5,-0x18(%rbp)
fld1
fstpt  -0x40(%rbp)
fldt   -0x10(%rbp)
fstpt  -0x30(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     117e <fun+0x6e>
fldt   -0x40(%rbp)
fadd   %st,%st(0)
fstpt  -0x40(%rbp)
fldt   -0x30(%rbp)
fstpt  -0x4c(%rbp)
fldt   -0x40(%rbp)
fldt   -0x10(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <sin@plt>
fldt   -0x4c(%rbp)
fldt   -0x40(%rbp)
fdivrp %st,%st(2)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <fun+0x27>
fldt   -0x30(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
sub    $0x28,%rsp
fldt   0x30(%rsp)
fld    %st(0)
fstpt  0x1c(%rsp)
fadd   %st,%st(0)
fstpt  (%rsp)
call   1030 <sin@plt>
fmuls  0xed2(%rip)
fldt   0x1c(%rsp)
fadd   %st,%st(1)
fxch   %st(1)
fstpt  0x10(%rsp)
fmuls  0xec4(%rip)
fstpt  (%rsp)
call   1030 <sin@plt>
fmuls  0xeba(%rip)
fldt   0x10(%rsp)
faddp  %st,%st(1)
fstpt  0x10(%rsp)
fldt   0x1c(%rsp)
fmuls  0xeaa(%rip)
fstpt  (%rsp)
call   1030 <sin@plt>
fmuls  0xea0(%rip)
fldt   0x10(%rsp)
faddp  %st,%st(1)
fstpt  0x10(%rsp)
fldt   0x1c(%rsp)
fmuls  0xe90(%rip)
fstpt  (%rsp)
call   1030 <sin@plt>
fmuls  0xe86(%rip)
fldt   0x10(%rsp)
faddp  %st,%st(1)
fstpt  0x10(%rsp)
fldt   0x1c(%rsp)
fmuls  0xe76(%rip)
fstpt  (%rsp)
call   1030 <sin@plt>
fmuls  0xe6c(%rip)
fldt   0x10(%rsp)
faddp  %st,%st(1)
add    $0x28,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @fun(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca i32
%4 = alloca i32
%5 = alloca x86_fp80
%6 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %2
store i32 5, i32* %4
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %6
%7 = load x86_fp80, x86_fp80* %2
store x86_fp80 %7, x86_fp80* %5
store i32 1, i32* %3
br label %8
8: ; preds = %23, %1
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load x86_fp80, x86_fp80* %6
%14 = fmul x86_fp80 0xK40008000000000000000, %13
store x86_fp80 %14, x86_fp80* %6
%15 = load x86_fp80, x86_fp80* %5
%16 = load x86_fp80, x86_fp80* %6
%17 = load x86_fp80, x86_fp80* %2
%18 = fmul x86_fp80 %16, %17
%19 = call x86_fp80 @sin(x86_fp80 %18)
%20 = load x86_fp80, x86_fp80* %6
%21 = fdiv x86_fp80 %19, %20
%22 = fadd x86_fp80 %15, %21
store x86_fp80 %22, x86_fp80* %5
br label %23
23: ; preds = %12
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %8
26: ; preds = %8
%27 = load x86_fp80, x86_fp80* %5
ret x86_fp80 %27
}

LLVM IR (-O2):
define x86_fp80 @fun(x86_fp80 %0) {
%2 = fmul x86_fp80 %0, 0xK40008000000000000000
%3 = tail call x86_fp80 @sin(x86_fp80 %2)
%4 = fmul x86_fp80 %3, 0xK3FFE8000000000000000
%5 = fadd x86_fp80 %4, %0
%6 = fmul x86_fp80 %0, 0xK40018000000000000000
%7 = tail call x86_fp80 @sin(x86_fp80 %6)
%8 = fmul x86_fp80 %7, 0xK3FFD8000000000000000
%9 = fadd x86_fp80 %5, %8
%10 = fmul x86_fp80 %0, 0xK40028000000000000000
%11 = tail call x86_fp80 @sin(x86_fp80 %10)
%12 = fmul x86_fp80 %11, 0xK3FFC8000000000000000
%13 = fadd x86_fp80 %9, %12
%14 = fmul x86_fp80 %0, 0xK40038000000000000000
%15 = tail call x86_fp80 @sin(x86_fp80 %14)
%16 = fmul x86_fp80 %15, 0xK3FFB8000000000000000
%17 = fadd x86_fp80 %13, %16
%18 = fmul x86_fp80 %0, 0xK40048000000000000000
%19 = tail call x86_fp80 @sin(x86_fp80 %18)
%20 = fmul x86_fp80 %19, 0xK3FFA8000000000000000
%21 = fadd x86_fp80 %17, %20
ret x86_fp80 %21
}