#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 __factd(unsigned int);
double pow(double, unsigned int);
double sin(double x) {
  double sinv = x;
  unsigned int ex = 3;
  for (int i = 1; i < (9) + 1; i++) {
    if (i % 2 == 1) {
      sinv -= pow(x, ex) / __factd(ex);
    } else {
      sinv += pow(x, ex) / __factd(ex);
    }
    ex += 2;
  }
  return sinv;
}


x86 assembly (clang, -O0):
<sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    11e0 <sin+0xc0>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1199 <sin+0x79>
movsd  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <__factd@plt>
movsd  -0x20(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11c9 <sin+0xa9>
movsd  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <__factd@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <sin+0x25>
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin>:
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    $0x3,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3,%edi
call   1030 <__factd@plt>
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,(%rsp)
mov    $0x5,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x5,%edi
call   1030 <__factd@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x7,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x7,%edi
call   1030 <__factd@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x9,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x9,%edi
call   1030 <__factd@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0xb,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xb,%edi
call   1030 <__factd@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0xd,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xd,%edi
call   1030 <__factd@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0xf,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0xf,%edi
call   1030 <__factd@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x11,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x11,%edi
call   1030 <__factd@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x13,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x13,%edi
call   1030 <__factd@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @sin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store double %0, double* %2
%6 = load double, double* %2
store double %6, double* %3
store i32 3, i32* %4
store i32 1, i32* %5
br label %7
7: ; preds = %35, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %38
10: ; preds = %7
%11 = load i32, i32* %5
%12 = srem i32 %11, 2
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load double, double* %2
%16 = load i32, i32* %4
%17 = call double @pow(double %15, i32 %16)
%18 = load i32, i32* %4
%19 = call double @__factd(i32 %18)
%20 = fdiv double %17, %19
%21 = load double, double* %3
%22 = fsub double %21, %20
store double %22, double* %3
br label %32
23: ; preds = %10
%24 = load double, double* %2
%25 = load i32, i32* %4
%26 = call double @pow(double %24, i32 %25)
%27 = load i32, i32* %4
%28 = call double @__factd(i32 %27)
%29 = fdiv double %26, %28
%30 = load double, double* %3
%31 = fadd double %30, %29
store double %31, double* %3
br label %32
32: ; preds = %23, %14
%33 = load i32, i32* %4
%34 = add i32 %33, 2
store i32 %34, i32* %4
br label %35
35: ; preds = %32
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %7
38: ; preds = %7
%39 = load double, double* %3
ret double %39
}

LLVM IR (-O2):
define double @sin(double %0) {
%2 = tail call double @pow(double %0, i32 3)
%3 = tail call double @__factd(i32 3)
%4 = fdiv double %2, %3
%5 = fsub double %0, %4
%6 = tail call double @pow(double %0, i32 5)
%7 = tail call double @__factd(i32 5)
%8 = fdiv double %6, %7
%9 = fadd double %5, %8
%10 = tail call double @pow(double %0, i32 7)
%11 = tail call double @__factd(i32 7)
%12 = fdiv double %10, %11
%13 = fsub double %9, %12
%14 = tail call double @pow(double %0, i32 9)
%15 = tail call double @__factd(i32 9)
%16 = fdiv double %14, %15
%17 = fadd double %13, %16
%18 = tail call double @pow(double %0, i32 11)
%19 = tail call double @__factd(i32 11)
%20 = fdiv double %18, %19
%21 = fsub double %17, %20
%22 = tail call double @pow(double %0, i32 13)
%23 = tail call double @__factd(i32 13)
%24 = fdiv double %22, %23
%25 = fadd double %21, %24
%26 = tail call double @pow(double %0, i32 15)
%27 = tail call double @__factd(i32 15)
%28 = fdiv double %26, %27
%29 = fsub double %25, %28
%30 = tail call double @pow(double %0, i32 17)
%31 = tail call double @__factd(i32 17)
%32 = fdiv double %30, %31
%33 = fadd double %29, %32
%34 = tail call double @pow(double %0, i32 19)
%35 = tail call double @__factd(i32 19)
%36 = fdiv double %34, %35
%37 = fsub double %33, %36
ret double %37
}