#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 marginal_j_concentration(int, int, double *, double *, double *,
                                double *);
double sin(double);
double vm_marginalKapa_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[R * p + l] * sin(theta_i[l] - mu[l]);
      }
    }
    return acum * sin(theta_i[S] - mu[S]) /
           marginal_j_concentration(p, R, mu, kappa, lambda, theta_i);
  }
}


x86 assembly (clang, -O0):
<vm_marginalKapa_lambda_partial_naive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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     1165 <vm_marginalKapa_lambda_partial_naive+0x45>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <vm_marginalKapa_lambda_partial_naive+0x131>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11eb <vm_marginalKapa_lambda_partial_naive+0xcb>
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     11d8 <vm_marginalKapa_lambda_partial_naive+0xb8>
mov    0x10(%rbp),%rax
mov    -0x14(%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   1040 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11dd <vm_marginalKapa_lambda_partial_naive+0xbd>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116c <vm_marginalKapa_lambda_partial_naive+0x4c>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%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   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    0x10(%rbp),%r8
mov    0x18(%rbp),%r9
call   1030 <marginal_j_concentration@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vm_marginalKapa_lambda_partial_naive>:
xorpd  %xmm0,%xmm0
cmp    %edx,%esi
jne    1315 <vm_marginalKapa_lambda_partial_naive+0x1f5>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r15
mov    %r8,%rbx
mov    %esi,%r12d
mov    %edi,%r13d
mov    0x70(%rsp),%rdx
test   %edi,%edi
mov    %ecx,0x1c(%rsp)
jle    118d <vm_marginalKapa_lambda_partial_naive+0x6d>
mov    %r12d,%eax
imul   %r13d,%eax
cltq
mov    %r12d,%r14d
mov    %r13d,%esi
cmp    $0x1,%r13d
mov    %rax,0x28(%rsp)
mov    %rsi,0x30(%rsp)
jne    119b <vm_marginalKapa_lambda_partial_naive+0x7b>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %ebp,%ebp
testb  $0x1,0x30(%rsp)
jne    1278 <vm_marginalKapa_lambda_partial_naive+0x158>
jmp    12bd <vm_marginalKapa_lambda_partial_naive+0x19d>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
jmp    12bd <vm_marginalKapa_lambda_partial_naive+0x19d>
mov    %r13d,0x14(%rsp)
mov    %r12d,0x18(%rsp)
mov    %r15,0x20(%rsp)
mov    %esi,%r15d
and    $0xfffffffe,%r15d
lea    (%rdx,%rax,8),%r12
add    $0x8,%r12
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %r13d,%r13d
jmp    11dd <vm_marginalKapa_lambda_partial_naive+0xbd>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r15,%r13
je     125e <vm_marginalKapa_lambda_partial_naive+0x13e>
mov    %r13,%rbp
cmp    %r13,%r14
je     121a <vm_marginalKapa_lambda_partial_naive+0xfa>
movsd  -0x8(%r12,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x78(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
subsd  (%rbx,%rbp,8),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
lea    0x1(%rbp),%r13
cmp    %r14,%r13
je     11d0 <vm_marginalKapa_lambda_partial_naive+0xb0>
movsd  (%r12,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x78(%rsp),%rax
movsd  0x8(%rax,%rbp,8),%xmm0
subsd  0x8(%rbx,%rbp,8),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
jmp    11d0 <vm_marginalKapa_lambda_partial_naive+0xb0>
add    $0x2,%rbp
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%r12d
mov    0x14(%rsp),%r13d
testb  $0x1,0x30(%rsp)
je     12bd <vm_marginalKapa_lambda_partial_naive+0x19d>
cmp    %r14,%rbp
je     12bd <vm_marginalKapa_lambda_partial_naive+0x19d>
mov    0x28(%rsp),%rcx
add    %rbp,%rcx
mov    0x70(%rsp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x78(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
subsd  (%rbx,%rbp,8),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movslq 0x1c(%rsp),%rax
mov    0x78(%rsp),%rbp
movsd  0x0(%rbp,%rax,8),%xmm0
subsd  (%rbx,%rax,8),%xmm0
call   1040 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r13d,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    0x70(%rsp),%r8
mov    %rbp,%r9
call   1030 <marginal_j_concentration@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @vm_marginalKapa_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 %84
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* %12
%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* %19
%63 = load double*, double** %17
%64 = load i32, i32* %13
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = load double*, double** %14
%69 = load i32, i32* %13
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = fsub double %67, %72
%74 = call double @sin(double %73)
%75 = fmul double %62, %74
%76 = load i32, i32* %10
%77 = load i32, i32* %12
%78 = load double*, double** %14
%79 = load double*, double** %15
%80 = load double*, double** %16
%81 = load double*, double** %17
%82 = call double @marginal_j_concentration(i32 %76, i32 %77, double* %78, double* %79, double* %80, double* %81)
%83 = fdiv double %75, %82
store double %83, double* %9
br label %84
84: ; preds = %61, %23
%85 = load double, double* %9
ret double %85
}

LLVM IR (-O2):
define double @vm_marginalKapa_lambda_partial_naive(i32 %0, i32 %1, i32 %2, i32 %3, double* %4, double* %5, double* %6, double* %7) {
%9 = icmp eq i32 %1, %2
br i1 %9, label %10, label %87
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 %3 to i64
%78 = getelementptr inbounds double, double* %7, i64 %77
%79 = load double, double* %78
%80 = getelementptr inbounds double, double* %4, i64 %77
%81 = load double, double* %80
%82 = fsub double %79, %81
%83 = tail call double @sin(double %82)
%84 = fmul double %76, %83
%85 = tail call double @marginal_j_concentration(i32 %0, i32 %1, double* %4, double* %5, double* %6, double* %7)
%86 = fdiv double %84, %85
br label %87
87: ; preds = %8, %75
%88 = phi double [ %86, %75 ], [ 0.000000e+00, %8 ]
ret double %88
}