#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 fatorial(int);
float pot(float, int);
int /*<<< orphan*/ printf(char *, float);
float radi(float);
float coss(float teta) {
  float x = 0;
  int negativo = 0;
  if (teta < 0) {
    negativo = 1;
  }
  teta = radi(teta);
  int i = 0;
  for (i = 0; i < 12; i++) {
    x += (pot(-1, i) * pot(teta, 2 * i)) / fatorial(2 * i);
  }
  if (negativo == 1) {
    x = x * -1;
  }
  printf("%f valor do coseno com precisão de 5 casas\n", x);
}


x86 assembly (clang, -O0):
<coss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1170 <coss+0x30>
movl   $0x1,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <radi@plt>
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    11fc <coss+0xbc>
mov    -0x14(%rbp),%edi
movss  0xe5e(%rip),%xmm0
call   1050 <pot@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
call   1050 <pot@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
call   1060 <fatorial@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <coss+0x4d>
cmpl   $0x1,-0x10(%rbp)
jne    1218 <coss+0xd8>
movss  0xdf2(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
lea    0xde0(%rip),%rdi
call   1040 <printf@plt>
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coss>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
movaps %xmm0,0x10(%rsp)
call   1030 <radi@plt>
movss  %xmm0,0xc(%rsp)
xorps  %xmm3,%xmm3
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   (%rax)
movaps %xmm3,0x20(%rsp)
movss  0xe93(%rip),%xmm0
mov    %ebp,%edi
call   1050 <pot@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
mov    %ebx,%edi
call   1050 <pot@plt>
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1060 <fatorial@plt>
movaps 0x20(%rsp),%xmm3
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
addss  %xmm1,%xmm3
add    $0x1,%ebp
add    $0x2,%ebx
cmp    $0xc,%ebp
jne    1160 <coss+0x20>
movaps 0xe51(%rip),%xmm2
xorps  %xmm3,%xmm2
xorps  %xmm1,%xmm1
movaps 0x10(%rsp),%xmm0
cmpltss %xmm1,%xmm0
andps  %xmm0,%xmm2
andnps %xmm3,%xmm0
orps   %xmm2,%xmm0
lea    0xe41(%rip),%rdi
add    $0x38,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"%f valor do coseno com precis\C3\A3o de 5 casas\0A\00"
define float @coss(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store float %0, float* %3
store float 0.000000e+00, float* %4
store i32 0, i32* %5
%7 = load float, float* %3
%8 = fcmp olt float %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %5
br label %10
10: ; preds = %9, %1
%11 = load float, float* %3
%12 = call float @radi(float %11)
store float %12, float* %3
store i32 0, i32* %6
store i32 0, i32* %6
br label %13
13: ; preds = %30, %10
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 12
br i1 %15, label %16, label %33
16: ; preds = %13
%17 = load i32, i32* %6
%18 = call float @pot(float -1.000000e+00, i32 %17)
%19 = load float, float* %3
%20 = load i32, i32* %6
%21 = mul nsw i32 2, %20
%22 = call float @pot(float %19, i32 %21)
%23 = fmul float %18, %22
%24 = load i32, i32* %6
%25 = mul nsw i32 2, %24
%26 = call float @fatorial(i32 %25)
%27 = fdiv float %23, %26
%28 = load float, float* %4
%29 = fadd float %28, %27
store float %29, float* %4
br label %30
30: ; preds = %16
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %13
33: ; preds = %13
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load float, float* %4
%38 = fmul float %37, -1.000000e+00
store float %38, float* %4
br label %39
39: ; preds = %36, %33
%40 = load float, float* %4
%41 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), float %40)
%42 = load float, float* %2
ret float %42
}

LLVM IR (-O2):
@.str = [45 x i8] c"%f valor do coseno com precis\C3\A3o de 5 casas\0A\00"
define float @coss(float %0) {
%2 = tail call float @radi(float %0)
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %13, %3 ]
%5 = phi float [ 0.000000e+00, %1 ], [ %12, %3 ]
%6 = tail call float @pot(float -1.000000e+00, i32 %4)
%7 = shl nuw nsw i32 %4, 1
%8 = tail call float @pot(float %2, i32 %7)
%9 = fmul float %6, %8
%10 = tail call float @fatorial(i32 %7)
%11 = fdiv float %9, %10
%12 = fadd float %5, %11
%13 = add nuw nsw i32 %4, 1
%14 = icmp eq i32 %13, 12
br i1 %14, label %15, label %3
15: ; preds = %3
%16 = fcmp olt float %0, 0.000000e+00
%17 = fneg float %12
%18 = select i1 %16, float %17, float %12
%19 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), float %18)
ret float undef
}