#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 */
float __fact(unsigned int);
float powf(float, unsigned int);
float sinf(float x) {
  float sinv = x;
  unsigned int ex = 3;
  for (int i = 1; i < (8) + 1; i++) {
    if (i % 2 == 1) {
      sinv -= powf(x, ex) / __fact(ex);
    } else {
      sinv += powf(x, ex) / __fact(ex);
    }
    ex += 2;
  }
  return sinv;
}


x86 assembly (clang, -O0):
<sinf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x9,-0x10(%rbp)
jge    11e0 <sinf+0xc0>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1199 <sinf+0x79>
movss  -0x4(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1040 <powf@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <__fact@plt>
movss  -0x14(%rbp),%xmm1
divss  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11c9 <sinf+0xa9>
movss  -0x4(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1040 <powf@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <__fact@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <sinf+0x25>
movss  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinf>:
sub    $0x18,%rsp
movss  %xmm0,0x14(%rsp)
mov    $0x3,%edi
call   1040 <powf@plt>
movss  %xmm0,0xc(%rsp)
mov    $0x3,%edi
call   1030 <__fact@plt>
movss  0xc(%rsp),%xmm2
divss  %xmm0,%xmm2
movss  0x14(%rsp),%xmm0
movaps %xmm0,%xmm1
subss  %xmm2,%xmm1
movss  %xmm1,0x10(%rsp)
mov    $0x5,%edi
call   1040 <powf@plt>
movss  %xmm0,0xc(%rsp)
mov    $0x5,%edi
call   1030 <__fact@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
addss  0x10(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x14(%rsp),%xmm0
mov    $0x7,%edi
call   1040 <powf@plt>
movss  %xmm0,0x10(%rsp)
mov    $0x7,%edi
call   1030 <__fact@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
mov    $0x9,%edi
call   1040 <powf@plt>
movss  %xmm0,0x10(%rsp)
mov    $0x9,%edi
call   1030 <__fact@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
addss  0xc(%rsp),%xmm1
movss  %xmm1,0x10(%rsp)
movss  0x14(%rsp),%xmm0
mov    $0xb,%edi
call   1040 <powf@plt>
movss  %xmm0,0xc(%rsp)
mov    $0xb,%edi
call   1030 <__fact@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0x10(%rsp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x14(%rsp),%xmm0
mov    $0xd,%edi
call   1040 <powf@plt>
movss  %xmm0,0xc(%rsp)
mov    $0xd,%edi
call   1030 <__fact@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
addss  0x10(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x14(%rsp),%xmm0
mov    $0xf,%edi
call   1040 <powf@plt>
movss  %xmm0,0x10(%rsp)
mov    $0xf,%edi
call   1030 <__fact@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
mov    $0x11,%edi
call   1040 <powf@plt>
movss  %xmm0,0x14(%rsp)
mov    $0x11,%edi
call   1030 <__fact@plt>
movss  0x14(%rsp),%xmm1
divss  %xmm0,%xmm1
addss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @sinf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store float %0, float* %2
%6 = load float, float* %2
store float %6, float* %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, 9
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 float, float* %2
%16 = load i32, i32* %4
%17 = call float @powf(float %15, i32 %16)
%18 = load i32, i32* %4
%19 = call float @__fact(i32 %18)
%20 = fdiv float %17, %19
%21 = load float, float* %3
%22 = fsub float %21, %20
store float %22, float* %3
br label %32
23: ; preds = %10
%24 = load float, float* %2
%25 = load i32, i32* %4
%26 = call float @powf(float %24, i32 %25)
%27 = load i32, i32* %4
%28 = call float @__fact(i32 %27)
%29 = fdiv float %26, %28
%30 = load float, float* %3
%31 = fadd float %30, %29
store float %31, float* %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 float, float* %3
ret float %39
}

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