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


x86 assembly (clang, -O0):
<accelerationmain>:
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    11b4 <accelerationmain+0xa4>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%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 <sin@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1138 <accelerationmain+0x28>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accelerationmain>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    11b7 <accelerationmain+0xa7>
movapd %xmm0,%xmm3
mov    %rsi,%r14
mov    %edi,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
mov    0x2eae(%rip),%r12
movsd  %xmm1,0x18(%rsp)
movsd  %xmm3,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x20(%rsp)
add    $0x1,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  (%r12),%xmm2
divsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
cmp    %rbx,%r15
jne    1150 <accelerationmain+0x40>
jmp    11bb <accelerationmain+0xab>
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 @accelerationmain(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 = %34, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %37
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 @sin(i32 %31)
%33 = call double @llvm.fmuladd.f64(double %21, double %32, double %16)
store double %33, double* %9
br label %34
34: ; preds = %15
%35 = load i32, i32* %10
%36 = add nsw i32 %35, 1
store i32 %36, i32* %10
br label %11
37: ; preds = %11
%38 = load double, double* %9
ret double %38
}

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