#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 */
int calcn(int);
int fatorial(int);
int pot(int, int);
double seno(int x) {
  int n;
  int numerador, denominador, term;
  double result = 0;
  for (n = 0; n < 10; n++) {
    numerador = pot(-1, n);
    denominador = fatorial(calcn(n));
    term = pot(x, calcn(n));
    result += ((double)numerador / (double)denominador) * (double)term;
  }
  return result;
}


x86 assembly (clang, -O0):
<seno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11c4 <seno+0x94>
mov    -0x8(%rbp),%esi
mov    $0xffffffff,%edi
call   1030 <pot@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <calcn@plt>
mov    %eax,%edi
call   1040 <fatorial@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <calcn@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1030 <pot@plt>
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114a <seno+0x1a>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seno>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    $0xffffffff,%edi
mov    %ebp,%esi
call   1030 <pot@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1050 <calcn@plt>
mov    %eax,%edi
call   1040 <fatorial@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1050 <calcn@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1030 <pot@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%ebp
cmp    $0xa,%ebp
jne    1140 <seno+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @seno(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 %0, i32* %2
store double 0.000000e+00, double* %7
store i32 0, i32* %3
br label %8
8: ; preds = %30, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %33
11: ; preds = %8
%12 = load i32, i32* %3
%13 = call i32 @pot(i32 -1, i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = call i32 @calcn(i32 %14)
%16 = call i32 @fatorial(i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i32 @calcn(i32 %18)
%20 = call i32 @pot(i32 %17, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to double
%23 = load i32, i32* %5
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = load double, double* %7
%29 = call double @llvm.fmuladd.f64(double %25, double %27, double %28)
store double %29, double* %7
br label %30
30: ; preds = %11
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %8
33: ; preds = %8
%34 = load double, double* %7
ret double %34
}

LLVM IR (-O2):
define double @seno(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi double [ 0.000000e+00, %1 ], [ %14, %2 ]
%4 = phi i32 [ 0, %1 ], [ %15, %2 ]
%5 = tail call i32 @pot(i32 -1, i32 %4)
%6 = tail call i32 @calcn(i32 %4)
%7 = tail call i32 @fatorial(i32 %6)
%8 = tail call i32 @calcn(i32 %4)
%9 = tail call i32 @pot(i32 %0, i32 %8)
%10 = sitofp i32 %5 to double
%11 = sitofp i32 %7 to double
%12 = fdiv double %10, %11
%13 = sitofp i32 %9 to double
%14 = tail call double @llvm.fmuladd.f64(double %12, double %13, double %3)
%15 = add nuw nsw i32 %4, 1
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %2
17: ; preds = %2
ret double %14
}