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


x86 assembly (clang, -O0):
<marginal_j_mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cc <marginal_j_mean+0xac>
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11b9 <marginal_j_mean+0x99>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%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    11be <marginal_j_mean+0x9e>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114d <marginal_j_mean+0x2d>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
call   1040 <atan@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<marginal_j_mean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r14
mov    %rdx,0x18(%rsp)
mov    %esi,%r15d
test   %edi,%edi
jle    1172 <marginal_j_mean+0x52>
mov    %r9,%rbp
mov    %r15d,%eax
imul   %edi,%eax
cltq
mov    %r15d,%r12d
mov    %edi,%r13d
cmp    $0x1,%edi
mov    %r8,0x40(%rsp)
mov    %rax,0x38(%rsp)
jne    117b <marginal_j_mean+0x5b>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
test   $0x1,%r13b
jne    1264 <marginal_j_mean+0x144>
jmp    12b8 <marginal_j_mean+0x198>
xorpd  %xmm0,%xmm0
jmp    12b8 <marginal_j_mean+0x198>
mov    %r15d,0x24(%rsp)
mov    %r14,0x30(%rsp)
mov    %r13,0x28(%rsp)
and    $0xfffffffe,%r13d
lea    (%r8,%rax,8),%r15
add    $0x8,%r15
xorpd  %xmm0,%xmm0
xor    %r14d,%r14d
jmp    11ad <marginal_j_mean+0x8d>
nop
add    $0x1,%r14
cmp    %r13,%r14
je     124b <marginal_j_mean+0x12b>
mov    %r14,%rbx
cmp    %r14,%r12
je     11f9 <marginal_j_mean+0xd9>
movsd  -0x8(%r15,%rbx,8),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0x0(%rbp,%rbx,8),%xmm0
mov    0x18(%rsp),%rax
subsd  (%rax,%rbx,8),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
lea    0x1(%rbx),%r14
cmp    %r12,%r14
je     11a0 <marginal_j_mean+0x80>
movsd  (%r15,%rbx,8),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbp,%rbx,8),%xmm0
mov    0x18(%rsp),%rax
subsd  0x8(%rax,%rbx,8),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
jmp    11a0 <marginal_j_mean+0x80>
add    $0x2,%rbx
mov    0x30(%rsp),%r14
mov    0x24(%rsp),%r15d
mov    0x28(%rsp),%r13
test   $0x1,%r13b
je     12b8 <marginal_j_mean+0x198>
cmp    %r12,%rbx
je     12b8 <marginal_j_mean+0x198>
mov    0x38(%rsp),%rcx
add    %rbx,%rcx
mov    0x40(%rsp),%rax
movsd  (%rax,%rcx,8),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0x0(%rbp,%rbx,8),%xmm0
mov    0x18(%rsp),%rax
subsd  (%rax,%rbx,8),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movslq %r15d,%rax
mov    0x18(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm1
movsd  %xmm1,0x8(%rsp)
divsd  (%r14,%rax,8),%xmm0
call   1040 <atan@plt>
addsd  0x8(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @marginal_j_mean(i32 %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
store double 0.000000e+00, double* %14
store i32 0, i32* %13
br label %15
15: ; preds = %48, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %51
19: ; preds = %15
%20 = load i32, i32* %13
%21 = load i32, i32* %8
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %47
23: ; preds = %19
%24 = load double*, double** %11
%25 = load i32, i32* %8
%26 = load i32, i32* %7
%27 = mul nsw i32 %25, %26
%28 = load i32, i32* %13
%29 = add nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %24, i64 %30
%32 = load double, double* %31
%33 = load double*, double** %12
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %9
%39 = load i32, i32* %13
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = fsub double %37, %42
%44 = call double @sin(double %43)
%45 = load double, double* %14
%46 = call double @llvm.fmuladd.f64(double %32, double %44, double %45)
store double %46, double* %14
br label %47
47: ; preds = %23, %19
br label %48
48: ; preds = %47
%49 = load i32, i32* %13
%50 = add nsw i32 %49, 1
store i32 %50, i32* %13
br label %15
51: ; preds = %15
%52 = load double*, double** %9
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = load double, double* %14
%58 = load double*, double** %10
%59 = load i32, i32* %8
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = fdiv double %57, %62
%64 = call double @atan(double %63)
%65 = fadd double %56, %64
ret double %65
}

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