#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 sin(double);
double vm_marginalMu_lambda_partial_naive(int p, int j, int R, int S,
                                          double *mu, double *kappa,
                                          double *lambda, double *theta_i) {
  int l;
  double acum = 0.;
  if (j != R)
    return 0;
  else {
    for (l = 0; l < p; l++) {
      if (l != j) {
        acum += lambda[j * p + l] * sin(theta_i[l] - mu[l]);
      }
    }
    acum /= kappa[j];
    acum = (1 + acum * acum) * kappa[j];
    return sin(theta_i[S] - mu[S]) / acum;
  }
}


x86 assembly (clang, -O0):
<vm_marginalMu_lambda_partial_naive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1155 <vm_marginalMu_lambda_partial_naive+0x45>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124b <vm_marginalMu_lambda_partial_naive+0x13b>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11db <vm_marginalMu_lambda_partial_naive+0xcb>
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     11c8 <vm_marginalMu_lambda_partial_naive+0xb8>
mov    0x10(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11cd <vm_marginalMu_lambda_partial_naive+0xbd>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115c <vm_marginalMu_lambda_partial_naive+0x4c>
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf4(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x18(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
call   1030 <sin@plt>
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vm_marginalMu_lambda_partial_naive>:
xorpd  %xmm0,%xmm0
cmp    %edx,%esi
jne    12f1 <vm_marginalMu_lambda_partial_naive+0x1e1>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r15
mov    %r8,%rbx
mov    %ecx,%r14d
mov    %esi,%r12d
test   %edi,%edi
jle    1171 <vm_marginalMu_lambda_partial_naive+0x61>
mov    0x70(%rsp),%rcx
mov    %r12d,%eax
imul   %edi,%eax
cltq
mov    %r12d,%r13d
mov    %edi,%edx
cmp    $0x1,%edi
mov    %rax,0x28(%rsp)
mov    %rdx,0x30(%rsp)
jne    117a <vm_marginalMu_lambda_partial_naive+0x6a>
xorpd  %xmm1,%xmm1
xor    %ebp,%ebp
testb  $0x1,0x30(%rsp)
jne    125c <vm_marginalMu_lambda_partial_naive+0x14c>
jmp    12a3 <vm_marginalMu_lambda_partial_naive+0x193>
xorpd  %xmm1,%xmm1
jmp    12a3 <vm_marginalMu_lambda_partial_naive+0x193>
mov    %r12d,0x18(%rsp)
mov    %r15,0x20(%rsp)
mov    %r14d,0x1c(%rsp)
mov    %edx,%r15d
and    $0xfffffffe,%r15d
lea    (%rcx,%rax,8),%r12
add    $0x8,%r12
xorpd  %xmm1,%xmm1
xor    %r14d,%r14d
jmp    11bd <vm_marginalMu_lambda_partial_naive+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r15,%r14
je     1242 <vm_marginalMu_lambda_partial_naive+0x132>
mov    %r14,%rbp
cmp    %r14,%r13
je     11fc <vm_marginalMu_lambda_partial_naive+0xec>
movsd  -0x8(%r12,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x78(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
subsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm1
lea    0x1(%rbp),%r14
cmp    %r13,%r14
je     11b0 <vm_marginalMu_lambda_partial_naive+0xa0>
movsd  (%r12,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x78(%rsp),%rax
movsd  0x8(%rax,%rbp,8),%xmm0
subsd  0x8(%rbx,%rbp,8),%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm1
jmp    11b0 <vm_marginalMu_lambda_partial_naive+0xa0>
add    $0x2,%rbp
mov    0x1c(%rsp),%r14d
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%r12d
testb  $0x1,0x30(%rsp)
je     12a3 <vm_marginalMu_lambda_partial_naive+0x193>
cmp    %r13,%rbp
je     12a3 <vm_marginalMu_lambda_partial_naive+0x193>
mov    0x28(%rsp),%rcx
add    %rbp,%rcx
mov    0x70(%rsp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x78(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
subsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm1
movslq %r12d,%rax
movsd  (%r15,%rax,8),%xmm0
divsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
addsd  0xd44(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movslq %r14d,%rax
mov    0x78(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm0
subsd  (%rbx,%rax,8),%xmm0
call   1030 <sin@plt>
divsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @vm_marginalMu_lambda_partial_naive(i32 %0, i32 %1, i32 %2, i32 %3, double* %4, double* %5, double* %6, double* %7) {
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca i32
%19 = alloca double
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store double* %4, double** %14
store double* %5, double** %15
store double* %6, double** %16
store double* %7, double** %17
store double 0.000000e+00, double* %19
%20 = load i32, i32* %11
%21 = load i32, i32* %12
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %8
store double 0.000000e+00, double* %9
br label %92
24: ; preds = %8
store i32 0, i32* %18
br label %25
25: ; preds = %58, %24
%26 = load i32, i32* %18
%27 = load i32, i32* %10
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %61
29: ; preds = %25
%30 = load i32, i32* %18
%31 = load i32, i32* %11
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %57
33: ; preds = %29
%34 = load double*, double** %16
%35 = load i32, i32* %11
%36 = load i32, i32* %10
%37 = mul nsw i32 %35, %36
%38 = load i32, i32* %18
%39 = add nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %34, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %17
%44 = load i32, i32* %18
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = load double*, double** %14
%49 = load i32, i32* %18
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = fsub double %47, %52
%54 = call double @sin(double %53)
%55 = load double, double* %19
%56 = call double @llvm.fmuladd.f64(double %42, double %54, double %55)
store double %56, double* %19
br label %57
57: ; preds = %33, %29
br label %58
58: ; preds = %57
%59 = load i32, i32* %18
%60 = add nsw i32 %59, 1
store i32 %60, i32* %18
br label %25
61: ; preds = %25
%62 = load double*, double** %15
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = load double, double* %19
%68 = fdiv double %67, %66
store double %68, double* %19
%69 = load double, double* %19
%70 = load double, double* %19
%71 = call double @llvm.fmuladd.f64(double %69, double %70, double 1.000000e+00)
%72 = load double*, double** %15
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
%76 = load double, double* %75
%77 = fmul double %71, %76
store double %77, double* %19
%78 = load double*, double** %17
%79 = load i32, i32* %13
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
%82 = load double, double* %81
%83 = load double*, double** %14
%84 = load i32, i32* %13
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
%87 = load double, double* %86
%88 = fsub double %82, %87
%89 = call double @sin(double %88)
%90 = load double, double* %19
%91 = fdiv double %89, %90
store double %91, double* %9
br label %92
92: ; preds = %61, %23
%93 = load double, double* %9
ret double %93
}

LLVM IR (-O2):
define double @vm_marginalMu_lambda_partial_naive(i32 %0, i32 %1, i32 %2, i32 %3, double* nocapture %4, double* nocapture %5, double* nocapture %6, double* nocapture %7) {
%9 = icmp eq i32 %1, %2
br i1 %9, label %10, label %91
10: ; preds = %8
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %75
12: ; preds = %10
%13 = mul nsw i32 %1, %0
%14 = sext i32 %13 to i64
%15 = zext i32 %1 to i64
%16 = zext i32 %0 to i64
%17 = and i64 %16, 1
%18 = icmp eq i32 %0, 1
br i1 %18, label %57, label %19
19: ; preds = %12
%20 = and i64 %16, 4294967294
br label %21
21: ; preds = %52, %19
%22 = phi i64 [ 0, %19 ], [ %54, %52 ]
%23 = phi double [ 0.000000e+00, %19 ], [ %53, %52 ]
%24 = phi i64 [ 0, %19 ], [ %55, %52 ]
%25 = icmp eq i64 %22, %15
br i1 %25, label %37, label %26
26: ; preds = %21
%27 = add nsw i64 %22, %14
%28 = getelementptr inbounds double, double* %6, i64 %27
%29 = load double, double* %28
%30 = getelementptr inbounds double, double* %7, i64 %22
%31 = load double, double* %30
%32 = getelementptr inbounds double, double* %4, i64 %22
%33 = load double, double* %32
%34 = fsub double %31, %33
%35 = tail call double @sin(double %34)
%36 = tail call double @llvm.fmuladd.f64(double %29, double %35, double %23)
br label %37
37: ; preds = %21, %26
%38 = phi double [ %36, %26 ], [ %23, %21 ]
%39 = or i64 %22, 1
%40 = icmp eq i64 %39, %15
br i1 %40, label %52, label %41
41: ; preds = %37
%42 = add nsw i64 %39, %14
%43 = getelementptr inbounds double, double* %6, i64 %42
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %7, i64 %39
%46 = load double, double* %45
%47 = getelementptr inbounds double, double* %4, i64 %39
%48 = load double, double* %47
%49 = fsub double %46, %48
%50 = tail call double @sin(double %49)
%51 = tail call double @llvm.fmuladd.f64(double %44, double %50, double %38)
br label %52
52: ; preds = %41, %37
%53 = phi double [ %51, %41 ], [ %38, %37 ]
%54 = add nuw nsw i64 %22, 2
%55 = add i64 %24, 2
%56 = icmp eq i64 %55, %20
br i1 %56, label %57, label %21
57: ; preds = %52, %12
%58 = phi double [ undef, %12 ], [ %53, %52 ]
%59 = phi i64 [ 0, %12 ], [ %54, %52 ]
%60 = phi double [ 0.000000e+00, %12 ], [ %53, %52 ]
%61 = icmp eq i64 %17, 0
br i1 %61, label %75, label %62
62: ; preds = %57
%63 = icmp eq i64 %59, %15
br i1 %63, label %75, label %64
64: ; preds = %62
%65 = add nsw i64 %59, %14
%66 = getelementptr inbounds double, double* %6, i64 %65
%67 = load double, double* %66
%68 = getelementptr inbounds double, double* %7, i64 %59
%69 = load double, double* %68
%70 = getelementptr inbounds double, double* %4, i64 %59
%71 = load double, double* %70
%72 = fsub double %69, %71
%73 = tail call double @sin(double %72)
%74 = tail call double @llvm.fmuladd.f64(double %67, double %73, double %60)
br label %75
75: ; preds = %57, %64, %62, %10
%76 = phi double [ 0.000000e+00, %10 ], [ %58, %57 ], [ %74, %64 ], [ %60, %62 ]
%77 = sext i32 %1 to i64
%78 = getelementptr inbounds double, double* %5, i64 %77
%79 = load double, double* %78
%80 = fdiv double %76, %79
%81 = tail call double @llvm.fmuladd.f64(double %80, double %80, double 1.000000e+00)
%82 = fmul double %79, %81
%83 = sext i32 %3 to i64
%84 = getelementptr inbounds double, double* %7, i64 %83
%85 = load double, double* %84
%86 = getelementptr inbounds double, double* %4, i64 %83
%87 = load double, double* %86
%88 = fsub double %85, %87
%89 = tail call double @sin(double %88)
%90 = fdiv double %89, %82
br label %91
91: ; preds = %8, %75
%92 = phi double [ %90, %75 ], [ 0.000000e+00, %8 ]
ret double %92
}