#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 fact(int);
double mypow(double, int);
double mysin(double x) {
  double e = 0.0;
  int i;
  for (i = 0; i < 10; i++) {
    e += mypow(-1, i) * mypow(x, 2 * i + 1) / fact(2 * i + 1);
  }
  return e;
}


x86 assembly (clang, -O0):
<mysin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11b1 <mysin+0x91>
mov    -0x14(%rbp),%edi
movsd  0xeaf(%rip),%xmm0
call   1030 <mypow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1030 <mypow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1040 <fact@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <mysin+0x1c>
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysin>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x10(%rsp)
movsd  0xeb2(%rip),%xmm0
mov    %ebx,%edi
call   1030 <mypow@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %ebp,%edi
call   1030 <mypow@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
call   1040 <fact@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%ebx
add    $0x2,%ebp
cmp    $0x15,%ebp
jne    1140 <mysin+0x20>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @mysin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = load i32, i32* %4
%10 = call double @mypow(double -1.000000e+00, i32 %9)
%11 = load double, double* %2
%12 = load i32, i32* %4
%13 = mul nsw i32 2, %12
%14 = add nsw i32 %13, 1
%15 = call double @mypow(double %11, i32 %14)
%16 = fmul double %10, %15
%17 = load i32, i32* %4
%18 = mul nsw i32 2, %17
%19 = add nsw i32 %18, 1
%20 = call double @fact(i32 %19)
%21 = fdiv double %16, %20
%22 = load double, double* %3
%23 = fadd double %22, %21
store double %23, double* %3
br label %24
24: ; preds = %8
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
define double @mysin(double %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %13, %2 ]
%4 = phi double [ 0.000000e+00, %1 ], [ %12, %2 ]
%5 = tail call double @mypow(double -1.000000e+00, i32 %3)
%6 = shl nuw nsw i32 %3, 1
%7 = or i32 %6, 1
%8 = tail call double @mypow(double %0, i32 %7)
%9 = fmul double %5, %8
%10 = tail call double @fact(i32 %7)
%11 = fdiv double %9, %10
%12 = fadd double %4, %11
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %2
15: ; preds = %2
ret double %12
}