#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
double fatorial(int);
double *malloc(int);
int /*<<< orphan*/ printf(char *, double, double, ...);
int main(int argc, char *argv[]) {
  int i, j, impar;
  double valor_calc;
  double extra;
  double valor = 0;
  int global_potencia = 8;
  double *x;
  double resultado_final;
  x = malloc(sizeof(double) * global_potencia);
  for (j = 0; j < 10; j++) {
    valor += 0.2;
    x[0] = valor;
    for (i = 1; i < global_potencia; i++) {
      x[i] = x[i - 1] * valor * valor;
    }
    for (i = 0; i < global_potencia; i++) {
      impar = 2 * i + 1;
      valor_calc = fatorial(impar);
      if (i % 2 == 0) {
        extra = x[i] / valor_calc;
      } else {
        extra = x[i] / valor_calc * -1;
      }
      printf("Extra: %.8f -- X[i]: %.2f -- Fatorial: %.2f\n", extra, x[i],
             valor_calc);
      resultado_final += extra;
    }
    printf("Resultado Final:\nSeno(%.0f) = %.4f\n", valor, resultado_final);
    resultado_final = 0;
  }
  for (i = 0; i < 50000; i++)
    ;
  exit(0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x8,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    12e1 <main+0x1a1>
movsd  0xe6f(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    11f2 <main+0xb2>
mov    -0x48(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11af <main+0x6f>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    12b3 <main+0x173>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <fatorial@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    124e <main+0x10e>
mov    -0x48(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1271 <main+0x131>
mov    -0x48(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xda0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xd81(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f9 <main+0xb9>
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
lea    0xd79(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117f <main+0x3f>
movl   $0x0,-0x14(%rbp)
cmpl   $0xc350,-0x14(%rbp)
jge    1308 <main+0x1c8>
jmp    12fa <main+0x1ba>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12e8 <main+0x1a8>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
xorpd  %xmm1,%xmm1
xor    %r12d,%r12d
lea    0xeb7(%rip),%r14
lea    0xedd(%rip),%r15
jmp    11a2 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
movsd  (%rsp),%xmm0
mov    $0x2,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm1
add    $0x1,%r12d
cmp    $0xa,%r12d
je     1290 <main+0x150>
addsd  0xe56(%rip),%xmm1
movsd  %xmm1,0x0(%r13)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r13)
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%r13)
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%r13)
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%r13)
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%r13)
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%r13)
mulsd  %xmm1,%xmm0
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x38(%r13)
mov    $0x1,%ebp
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1261 <main+0x121>
nopl   0x0(%rax,%rax,1)
divsd  %xmm2,%xmm0
mov    %r14,%rdi
movapd %xmm0,0x10(%rsp)
mov    $0x3,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
add    $0x1,%rbx
add    $0x2,%ebp
cmp    $0x8,%rbx
je     1180 <main+0x40>
movsd  %xmm1,0x8(%rsp)
mov    %ebp,%edi
call   1050 <fatorial@plt>
movapd %xmm0,%xmm2
movsd  0x0(%r13,%rbx,8),%xmm1
movapd %xmm1,%xmm0
test   $0x1,%bl
je     1230 <main+0xf0>
movapd %xmm1,%xmm0
xorpd  0xd82(%rip),%xmm0
jmp    1230 <main+0xf0>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"Extra: %.8f -- X[i]: %.2f -- Fatorial: %.2f\0A\00"
@.str.1 = [36 x i8] c"Resultado Final:\0ASeno(%.0f) = %.4f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca double*
%14 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %11
store i32 8, i32* %12
%15 = load i32, i32* %12
%16 = sext i32 %15 to i64
%17 = mul i64 8, %16
%18 = trunc i64 %17 to i32
%19 = call double* @malloc(i32 %18)
store double* %19, double** %13
store i32 0, i32* %7
br label %20
20: ; preds = %101, %2
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %104
23: ; preds = %20
%24 = load double, double* %11
%25 = fadd double %24, 2.000000e-01
store double %25, double* %11
%26 = load double, double* %11
%27 = load double*, double** %13
%28 = getelementptr inbounds double, double* %27, i64 0
store double %26, double* %28
store i32 1, i32* %6
br label %29
29: ; preds = %48, %23
%30 = load i32, i32* %6
%31 = load i32, i32* %12
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %51
33: ; preds = %29
%34 = load double*, double** %13
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %34, i64 %37
%39 = load double, double* %38
%40 = load double, double* %11
%41 = fmul double %39, %40
%42 = load double, double* %11
%43 = fmul double %41, %42
%44 = load double*, double** %13
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %48
48: ; preds = %33
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %29
51: ; preds = %29
store i32 0, i32* %6
br label %52
52: ; preds = %94, %51
%53 = load i32, i32* %6
%54 = load i32, i32* %12
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %97
56: ; preds = %52
%57 = load i32, i32* %6
%58 = mul nsw i32 2, %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %8
%60 = load i32, i32* %8
%61 = call double @fatorial(i32 %60)
store double %61, double* %9
%62 = load i32, i32* %6
%63 = srem i32 %62, 2
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %73
65: ; preds = %56
%66 = load double*, double** %13
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = load double, double* %9
%72 = fdiv double %70, %71
store double %72, double* %10
br label %82
73: ; preds = %56
%74 = load double*, double** %13
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
%78 = load double, double* %77
%79 = load double, double* %9
%80 = fdiv double %78, %79
%81 = fmul double %80, -1.000000e+00
store double %81, double* %10
br label %82
82: ; preds = %73, %65
%83 = load double, double* %10
%84 = load double*, double** %13
%85 = load i32, i32* %6
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = load double, double* %9
%90 = call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), double %83, double %88, double %89)
%91 = load double, double* %10
%92 = load double, double* %14
%93 = fadd double %92, %91
store double %93, double* %14
br label %94
94: ; preds = %82
%95 = load i32, i32* %6
%96 = add nsw i32 %95, 1
store i32 %96, i32* %6
br label %52
97: ; preds = %52
%98 = load double, double* %11
%99 = load double, double* %14
%100 = call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), double %98, double %99)
store double 0.000000e+00, double* %14
br label %101
101: ; preds = %97
%102 = load i32, i32* %7
%103 = add nsw i32 %102, 1
store i32 %103, i32* %7
br label %20
104: ; preds = %20
store i32 0, i32* %6
br label %105
105: ; preds = %109, %104
%106 = load i32, i32* %6
%107 = icmp slt i32 %106, 50000
br i1 %107, label %108, label %112
108: ; preds = %105
br label %109
109: ; preds = %108
%110 = load i32, i32* %6
%111 = add nsw i32 %110, 1
store i32 %111, i32* %6
br label %105
112: ; preds = %105
%113 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [45 x i8] c"Extra: %.8f -- X[i]: %.2f -- Fatorial: %.2f\0A\00"
@.str.1 = [36 x i8] c"Resultado Final:\0ASeno(%.0f) = %.4f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call double* @malloc(i32 64)
%4 = getelementptr inbounds double, double* %3, i64 1
%5 = getelementptr inbounds double, double* %3, i64 2
%6 = getelementptr inbounds double, double* %3, i64 3
%7 = getelementptr inbounds double, double* %3, i64 4
%8 = getelementptr inbounds double, double* %3, i64 5
%9 = getelementptr inbounds double, double* %3, i64 6
%10 = getelementptr inbounds double, double* %3, i64 7
br label %11
11: ; preds = %2, %47
%12 = phi i32 [ 0, %2 ], [ %49, %47 ]
%13 = phi double [ 0.000000e+00, %2 ], [ %14, %47 ]
%14 = fadd double %13, 2.000000e-01
store double %14, double* %3
%15 = fmul double %14, %14
%16 = fmul double %14, %15
store double %16, double* %4
%17 = fmul double %14, %16
%18 = fmul double %14, %17
store double %18, double* %5
%19 = fmul double %14, %18
%20 = fmul double %14, %19
store double %20, double* %6
%21 = fmul double %14, %20
%22 = fmul double %14, %21
store double %22, double* %7
%23 = fmul double %14, %22
%24 = fmul double %14, %23
store double %24, double* %8
%25 = fmul double %14, %24
%26 = fmul double %14, %25
store double %26, double* %9
%27 = fmul double %14, %26
%28 = fmul double %14, %27
store double %28, double* %10
br label %29
29: ; preds = %11, %29
%30 = phi i64 [ 0, %11 ], [ %45, %29 ]
%31 = phi double [ 0.000000e+00, %11 ], [ %44, %29 ]
%32 = trunc i64 %30 to i32
%33 = shl i32 %32, 1
%34 = or i32 %33, 1
%35 = tail call double @fatorial(i32 %34)
%36 = and i64 %30, 1
%37 = icmp eq i64 %36, 0
%38 = getelementptr inbounds double, double* %3, i64 %30
%39 = load double, double* %38
%40 = fneg double %39
%41 = select i1 %37, double %39, double %40
%42 = fdiv double %41, %35
%43 = tail call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), double %42, double %39, double %35)
%44 = fadd double %31, %42
%45 = add nuw nsw i64 %30, 1
%46 = icmp eq i64 %45, 8
br i1 %46, label %47, label %29
47: ; preds = %29
%48 = tail call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), double %14, double %44)
%49 = add nuw nsw i32 %12, 1
%50 = icmp eq i32 %49, 10
br i1 %50, label %51, label %11
51: ; preds = %47
%52 = tail call i32 @exit(i32 0)
unreachable
}