#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 M_PI;
double cos(int);
double vitessemain(int n, double A[], double Cy, double time) {
  double resultat = 0;
  for (int i = 0; i < n; i++)
    resultat = resultat -
               A[i] * cos((i + 1) * (M_PI / Cy) * time) / ((i + 1) * M_PI / Cy);
  return resultat;
}


x86 assembly (clang, -O0):
<vitessemain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d2 <vitessemain+0xc2>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    0x2e77(%rip),%rax
movsd  (%rax),%xmm1
divsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm2
mov    0x2e3a(%rip),%rax
mulsd  (%rax),%xmm2
divsd  -0x18(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1138 <vitessemain+0x28>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vitessemain>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    11ca <vitessemain+0xba>
movapd %xmm0,%xmm3
mov    %rsi,%r14
mov    %edi,%r12d
mov    0x2eb4(%rip),%r15
movsd  (%r15),%xmm2
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
movsd  %xmm1,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x20(%rsp)
add    $0x1,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x18(%rsp)
divsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
call   1030 <cos@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm0
movsd  (%r15),%xmm2
movsd  0x18(%rsp),%xmm4
mulsd  %xmm2,%xmm4
divsd  %xmm3,%xmm4
divsd  %xmm4,%xmm0
movsd  (%rsp),%xmm4
subsd  %xmm0,%xmm4
movsd  %xmm4,(%rsp)
movsd  (%rsp),%xmm0
cmp    %rbx,%r12
jne    1150 <vitessemain+0x40>
jmp    11ce <vitessemain+0xbe>
xorpd  %xmm0,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @vitessemain(i32 %0, double* %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double %2, double* %7
store double %3, double* %8
store double 0.000000e+00, double* %9
store i32 0, i32* %10
br label %11
11: ; preds = %43, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %46
15: ; preds = %11
%16 = load double, double* %9
%17 = load double*, double** %6
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = load i32, i32* %10
%23 = add nsw i32 %22, 1
%24 = sitofp i32 %23 to double
%25 = load double, double* @M_PI
%26 = load double, double* %7
%27 = fdiv double %25, %26
%28 = fmul double %24, %27
%29 = load double, double* %8
%30 = fmul double %28, %29
%31 = fptosi double %30 to i32
%32 = call double @cos(i32 %31)
%33 = fmul double %21, %32
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
%36 = sitofp i32 %35 to double
%37 = load double, double* @M_PI
%38 = fmul double %36, %37
%39 = load double, double* %7
%40 = fdiv double %38, %39
%41 = fdiv double %33, %40
%42 = fsub double %16, %41
store double %42, double* %9
br label %43
43: ; preds = %15
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %11
46: ; preds = %11
%47 = load double, double* %9
ret double %47
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @vitessemain(i32 %0, double* nocapture %1, double %2, double %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = zext i32 %0 to i64
%8 = load double, double* @M_PI
br label %11
9: ; preds = %11, %4
%10 = phi double [ 0.000000e+00, %4 ], [ %30, %11 ]
ret double %10
11: ; preds = %6, %11
%12 = phi double [ %8, %6 ], [ %26, %11 ]
%13 = phi i64 [ 0, %6 ], [ %17, %11 ]
%14 = phi double [ 0.000000e+00, %6 ], [ %30, %11 ]
%15 = getelementptr inbounds double, double* %1, i64 %13
%16 = load double, double* %15
%17 = add nuw nsw i64 %13, 1
%18 = trunc i64 %17 to i32
%19 = sitofp i32 %18 to double
%20 = fdiv double %12, %2
%21 = fmul double %20, %19
%22 = fmul double %21, %3
%23 = fptosi double %22 to i32
%24 = tail call double @cos(i32 %23)
%25 = fmul double %16, %24
%26 = load double, double* @M_PI
%27 = fmul double %26, %19
%28 = fdiv double %27, %2
%29 = fdiv double %25, %28
%30 = fsub double %14, %29
%31 = icmp eq i64 %17, %7
br i1 %31, label %9, label %11
}