#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 */
long double cosl(double);
long double sinl(double);
void mv_theta_cos_sinTransform(int n, int p, double *theta, double *mu,
                               long double *S, long double *C) {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < p; j++) {
      S[i * p + j] = sinl(theta[i * p + j] - mu[j]);
      C[i * p + j] = cosl(theta[i * p + j] - mu[j]);
    }
  }
}


x86 assembly (clang, -O0):
<mv_theta_cos_sinTransform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121b <mv_theta_cos_sinTransform+0xfb>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1208 <mv_theta_cos_sinTransform+0xe8>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%edx
mov    -0x8(%rbp),%ecx
imul   %ecx,%edx
movslq -0x30(%rbp),%rcx
mov    %ecx,%esi
add    %esi,%edx
movslq %edx,%rdx
movsd  (%rax,%rdx,8),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm1
subsd  %xmm1,%xmm0
call   1030 <sinl@plt>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    -0x8(%rbp),%edx
imul   %edx,%ecx
mov    -0x30(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
shl    $0x4,%rcx
fstpt  (%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%edx
mov    -0x8(%rbp),%ecx
imul   %ecx,%edx
movslq -0x30(%rbp),%rcx
mov    %ecx,%esi
add    %esi,%edx
movslq %edx,%rdx
movsd  (%rax,%rdx,8),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm1
subsd  %xmm1,%xmm0
call   1040 <cosl@plt>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    -0x8(%rbp),%edx
imul   %edx,%ecx
mov    -0x30(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
shl    $0x4,%rcx
fstpt  (%rax,%rcx,1)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1158 <mv_theta_cos_sinTransform+0x38>
jmp    120d <mv_theta_cos_sinTransform+0xed>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1145 <mv_theta_cos_sinTransform+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mv_theta_cos_sinTransform>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    11e3 <mv_theta_cos_sinTransform+0xc3>
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
movslq 0x4(%rsp),%rax
mov    %edi,%ecx
mov    %rcx,0x10(%rsp)
mov    %eax,%r13d
lea    0x0(,%rax,8),%rcx
mov    %rcx,0x8(%rsp)
shl    $0x4,%rax
mov    %rax,0x18(%rsp)
shl    $0x3,%r13
xor    %ecx,%ecx
jmp    11a0 <mv_theta_cos_sinTransform+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x20(%rsp),%rcx
add    $0x1,%rcx
add    0x8(%rsp),%rbx
mov    0x18(%rsp),%rax
add    %rax,%r15
add    %rax,%r14
cmp    0x10(%rsp),%rcx
je     11e3 <mv_theta_cos_sinTransform+0xc3>
mov    %rcx,0x20(%rsp)
cmpl   $0x0,0x4(%rsp)
jle    1180 <mv_theta_cos_sinTransform+0x60>
xor    %ebp,%ebp
xchg   %ax,%ax
movsd  (%rbx,%rbp,1),%xmm0
subsd  (%r12,%rbp,1),%xmm0
call   1030 <sinl@plt>
fstpt  (%r15,%rbp,2)
movsd  (%rbx,%rbp,1),%xmm0
subsd  (%r12,%rbp,1),%xmm0
call   1040 <cosl@plt>
fstpt  (%r14,%rbp,2)
add    $0x8,%rbp
cmp    %rbp,%r13
jne    11b0 <mv_theta_cos_sinTransform+0x90>
jmp    1180 <mv_theta_cos_sinTransform+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mv_theta_cos_sinTransform(i32 %0, i32 %1, double* %2, double* %3, x86_fp80* %4, x86_fp80* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca x86_fp80*
%12 = alloca x86_fp80*
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store double* %2, double** %9
store double* %3, double** %10
store x86_fp80* %4, x86_fp80** %11
store x86_fp80* %5, x86_fp80** %12
store i32 0, i32* %13
br label %15
15: ; preds = %77, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %80
19: ; preds = %15
store i32 0, i32* %14
br label %20
20: ; preds = %73, %19
%21 = load i32, i32* %14
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %76
24: ; preds = %20
%25 = load double*, double** %9
%26 = load i32, i32* %13
%27 = load i32, i32* %8
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %14
%30 = add nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %25, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %10
%35 = load i32, i32* %14
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fsub double %33, %38
%40 = call x86_fp80 @sinl(double %39)
%41 = load x86_fp80*, x86_fp80** %11
%42 = load i32, i32* %13
%43 = load i32, i32* %8
%44 = mul nsw i32 %42, %43
%45 = load i32, i32* %14
%46 = add nsw i32 %44, %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds x86_fp80, x86_fp80* %41, i64 %47
store x86_fp80 %40, x86_fp80* %48
%49 = load double*, double** %9
%50 = load i32, i32* %13
%51 = load i32, i32* %8
%52 = mul nsw i32 %50, %51
%53 = load i32, i32* %14
%54 = add nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %49, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %10
%59 = load i32, i32* %14
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = fsub double %57, %62
%64 = call x86_fp80 @cosl(double %63)
%65 = load x86_fp80*, x86_fp80** %12
%66 = load i32, i32* %13
%67 = load i32, i32* %8
%68 = mul nsw i32 %66, %67
%69 = load i32, i32* %14
%70 = add nsw i32 %68, %69
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds x86_fp80, x86_fp80* %65, i64 %71
store x86_fp80 %64, x86_fp80* %72
br label %73
73: ; preds = %24
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 1
store i32 %75, i32* %14
br label %20
76: ; preds = %20
br label %77
77: ; preds = %76
%78 = load i32, i32* %13
%79 = add nsw i32 %78, 1
store i32 %79, i32* %13
br label %15
80: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @mv_theta_cos_sinTransform(i32 %0, i32 %1, double* nocapture %2, double* nocapture %3, x86_fp80* nocapture writeonly %4, x86_fp80* nocapture writeonly %5) {
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %37
8: ; preds = %6
%9 = icmp sgt i32 %1, 0
%10 = sext i32 %1 to i64
%11 = zext i32 %0 to i64
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %8, %34
%14 = phi i64 [ 0, %8 ], [ %35, %34 ]
br i1 %9, label %15, label %34
15: ; preds = %13
%16 = mul nsw i64 %14, %10
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %32, %17 ]
%19 = add nsw i64 %18, %16
%20 = getelementptr inbounds double, double* %2, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %3, i64 %18
%23 = load double, double* %22
%24 = fsub double %21, %23
%25 = tail call x86_fp80 @sinl(double %24)
%26 = getelementptr inbounds x86_fp80, x86_fp80* %4, i64 %19
store x86_fp80 %25, x86_fp80* %26
%27 = load double, double* %20
%28 = load double, double* %22
%29 = fsub double %27, %28
%30 = tail call x86_fp80 @cosl(double %29)
%31 = getelementptr inbounds x86_fp80, x86_fp80* %5, i64 %19
store x86_fp80 %30, x86_fp80* %31
%32 = add nuw nsw i64 %18, 1
%33 = icmp eq i64 %32, %12
br i1 %33, label %34, label %17
34: ; preds = %17, %13
%35 = add nuw nsw i64 %14, 1
%36 = icmp eq i64 %35, %11
br i1 %36, label %37, label %13
37: ; preds = %34, %6
ret void
}