#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 pow(double, double);
double _acceleration(double *thetai, int n, double theta_hat) {
  double a = 0;
  double sq = 0;
  double cb = 0;
  for (int i = 0; i < n; i++) {
    double diff = theta_hat - thetai[i];
    sq += diff * diff;
    cb += diff * diff * diff;
  }
  a = cb / (6.0 * pow(sq, 1.5));
  return a;
}


x86 assembly (clang, -O0):
<_acceleration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b1 <_acceleration+0xa1>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1143 <_acceleration+0x33>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe40(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_acceleration>:
sub    $0x18,%rsp
test   %esi,%esi
jle    1132 <_acceleration+0x22>
mov    %esi,%eax
cmp    $0x1,%esi
jne    113b <_acceleration+0x2b>
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
test   $0x1,%al
jne    11b0 <_acceleration+0xa0>
jmp    11d5 <_acceleration+0xc5>
xorpd  %xmm4,%xmm4
jmp    11d5 <_acceleration+0xc5>
mov    %eax,%edx
and    $0xfffffffe,%edx
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movapd %xmm0,%xmm2
subsd  (%rdi,%rcx,8),%xmm2
movapd %xmm2,%xmm3
mulsd  %xmm2,%xmm3
movapd %xmm2,%xmm4
unpcklpd %xmm3,%xmm4
unpcklpd %xmm2,%xmm2
mulpd  %xmm4,%xmm2
movapd %xmm0,%xmm4
subsd  0x8(%rdi,%rcx,8),%xmm4
addpd  %xmm1,%xmm2
movapd %xmm4,%xmm1
mulsd  %xmm4,%xmm1
movapd %xmm4,%xmm3
unpcklpd %xmm1,%xmm3
unpcklpd %xmm4,%xmm4
mulpd  %xmm3,%xmm4
movapd %xmm4,%xmm1
addpd  %xmm2,%xmm1
add    $0x2,%rcx
cmp    %rcx,%rdx
jne    1150 <_acceleration+0x40>
addpd  %xmm2,%xmm4
test   $0x1,%al
je     11d5 <_acceleration+0xc5>
subsd  (%rdi,%rcx,8),%xmm0
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm2,%xmm3
unpcklpd %xmm0,%xmm0
mulpd  %xmm3,%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm4
movapd %xmm4,(%rsp)
movsd  0xe1e(%rip),%xmm1
movapd %xmm4,%xmm0
call   1030 <pow@plt>
mulsd  0xe15(%rip),%xmm0
movapd (%rsp),%xmm1
unpckhpd %xmm1,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @_acceleration(double* nocapture %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %27
5: ; preds = %3
%6 = zext i32 %1 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %1, 1
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %34
11: ; preds = %34
%12 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %53, <2 x double> %45)
br label %13
13: ; preds = %11, %5
%14 = phi <2 x double> [ undef, %5 ], [ %12, %11 ]
%15 = phi i64 [ 0, %5 ], [ %55, %11 ]
%16 = phi <2 x double> [ zeroinitializer, %5 ], [ %54, %11 ]
%17 = icmp eq i64 %7, 0
br i1 %17, label %27, label %18
18: ; preds = %13
%19 = getelementptr inbounds double, double* %0, i64 %15
%20 = load double, double* %19
%21 = fsub double %2, %20
%22 = fmul double %21, %21
%23 = insertelement <2 x double> poison, double %21, i64 0
%24 = insertelement <2 x double> %23, double %22, i64 1
%25 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
%26 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %24, <2 x double> %25, <2 x double> %16)
br label %27
27: ; preds = %18, %13, %3
%28 = phi <2 x double> [ zeroinitializer, %3 ], [ %14, %13 ], [ %26, %18 ]
%29 = extractelement <2 x double> %28, i64 0
%30 = tail call double @pow(double %29, double 1.500000e+00)
%31 = fmul double %30, 6.000000e+00
%32 = extractelement <2 x double> %28, i64 1
%33 = fdiv double %32, %31
ret double %33
34: ; preds = %34, %9
%35 = phi i64 [ 0, %9 ], [ %55, %34 ]
%36 = phi <2 x double> [ zeroinitializer, %9 ], [ %54, %34 ]
%37 = phi i64 [ 0, %9 ], [ %56, %34 ]
%38 = getelementptr inbounds double, double* %0, i64 %35
%39 = load double, double* %38
%40 = fsub double %2, %39
%41 = fmul double %40, %40
%42 = insertelement <2 x double> poison, double %40, i64 0
%43 = insertelement <2 x double> %42, double %41, i64 1
%44 = shufflevector <2 x double> %42, <2 x double> poison, <2 x i32> zeroinitializer
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %43, <2 x double> %44, <2 x double> %36)
%46 = or i64 %35, 1
%47 = getelementptr inbounds double, double* %0, i64 %46
%48 = load double, double* %47
%49 = fsub double %2, %48
%50 = fmul double %49, %49
%51 = insertelement <2 x double> poison, double %49, i64 0
%52 = insertelement <2 x double> %51, double %50, i64 1
%53 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> zeroinitializer
%54 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %53, <2 x double> %45)
%55 = add nuw nsw i64 %35, 2
%56 = add i64 %37, 2
%57 = icmp eq i64 %56, %10
br i1 %57, label %11, label %34
}