#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 */
int /*<<< orphan*/ L2_3term_so3(int, int, int, double *, double *, double *);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
int /*<<< orphan*/ vec_add_scalar_so3(double, double *, double *, int);
int /*<<< orphan*/ vec_add_so3(double *, double *, double *, int);
int /*<<< orphan*/ vec_mul_inplace_so3(double, double *, int);
int /*<<< orphan*/ vec_mul_so3(double, double *, double *, int);
int /*<<< orphan*/ vec_pt_mul_so3(double *, double *, double *, int);
int /*<<< orphan*/ wigSpec_L2(int, int, double *, double *, int, double *);
void genWig_L2_U(int m1, int m2, int bw, int n, double *sinEval,
                 double *cosEval, double *sinEval2, double *cosEval2,
                 double *result, double *workspace) {
  int i, lCtr, m;
  int tmpM1, tmpM2;
  double *prevprev, *prev;
  double *tmp0, *tmp1, *tmp2, *tmp3;
  double an, bn, cn;
  lCtr = 0;
  tmpM1 = ((m1) > 0 ? (m1) : (-m1));
  tmpM2 = ((m2) > 0 ? (m2) : (-m2));
  m = ((tmpM1) > (tmpM2) ? (tmpM1) : (tmpM2));
  prevprev = workspace;
  prev = prevprev + n;
  tmp0 = prev + n;
  tmp1 = tmp0 + n;
  tmp2 = tmp1 + n;
  tmp3 = tmp2 + n;
  memset(prevprev, 0, sizeof(double) * n);
  wigSpec_L2(m1, m2, sinEval2, cosEval2, n, prev);
  memcpy(result, prev, sizeof(double) * n);
  for (i = 0; i < bw - m - 1; i++) {
    L2_3term_so3(m + i, m1, m2, &an, &bn, &cn);
    vec_mul_so3(an, prevprev, tmp0, n);
    vec_add_scalar_so3(cn, cosEval, tmp1, n);
    vec_mul_inplace_so3(bn, tmp1, n);
    vec_pt_mul_so3(prev, tmp1, tmp2, n);
    vec_add_so3(tmp0, tmp2, tmp3, n);
    memcpy(result + (i + 1) * n, tmp3, sizeof(double) * n);
    memcpy(prevprev, prev, sizeof(double) * n);
    memcpy(prev, tmp3, sizeof(double) * n);
  }
}


x86 assembly (clang, -O0):
<genWig_L2_U>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11de <genWig_L2_U+0x4e>
mov    -0x4(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    11e9 <genWig_L2_U+0x59>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    120a <genWig_L2_U+0x7a>
mov    -0x8(%rbp),%eax
mov    %eax,-0x88(%rbp)
jmp    1215 <genWig_L2_U+0x85>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    1238 <genWig_L2_U+0xa8>
mov    -0x30(%rbp),%eax
mov    %eax,-0x8c(%rbp)
jmp    1241 <genWig_L2_U+0xb1>
mov    -0x34(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%rdx
mov    0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8d
mov    -0x48(%rbp),%r9
call   10a0 <wigSpec_L2@plt>
mov    0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    13f9 <genWig_L2_U+0x269>
mov    -0x2c(%rbp),%edi
add    -0x24(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    -0x70(%rbp),%rcx
lea    -0x78(%rbp),%r8
lea    -0x80(%rbp),%r9
call   1030 <L2_3term_so3@plt>
movsd  -0x70(%rbp),%xmm0
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   10b0 <vec_mul_so3@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x20(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1090 <vec_add_scalar_so3@plt>
movsd  -0x78(%rbp),%xmm0
mov    -0x58(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1070 <vec_mul_inplace_so3@plt>
mov    -0x48(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1060 <vec_pt_mul_so3@plt>
mov    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1080 <vec_add_so3@plt>
mov    0x20(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x68(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x68(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ff <genWig_L2_U+0x16f>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genWig_L2_U>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x40(%rsp)
mov    %ecx,%r13d
mov    %edx,(%rsp)
mov    %esi,%ebx
mov    %edi,%ebp
mov    0xb8(%rsp),%rdi
mov    %ebp,%eax
neg    %eax
cmovs  %ebp,%eax
mov    %esi,%r15d
neg    %r15d
cmovs  %esi,%r15d
cmp    %r15d,%eax
cmova  %eax,%r15d
movslq %ecx,%r12
lea    (%rdi,%r12,8),%r14
lea    0x0(,%r12,8),%edx
mov    %edx,0x8(%rsp)
xor    %esi,%esi
call   1040 <memset@plt>
mov    %ebp,0xc(%rsp)
mov    %ebp,%edi
mov    0xb0(%rsp),%rbp
mov    %ebx,0x10(%rsp)
mov    %ebx,%esi
mov    0xa0(%rsp),%rdx
mov    0xa8(%rsp),%rcx
mov    %r12,%rbx
mov    %r12d,%r8d
mov    %r14,%r9
call   10a0 <wigSpec_L2@plt>
mov    %rbp,%rdi
mov    %r14,0x18(%rsp)
mov    %r14,%rsi
mov    0x8(%rsp),%r12d
mov    %r12d,%edx
call   1050 <memcpy@plt>
mov    %r15d,%eax
not    %eax
add    (%rsp),%eax
test   %eax,%eax
jle    1377 <genWig_L2_U+0x1e7>
mov    %rbx,%rcx
mov    0x18(%rsp),%rdx
lea    (%rdx,%rbx,8),%rdx
mov    %rdx,(%rsp)
lea    (%rdx,%rbx,8),%rdx
mov    %rdx,0x30(%rsp)
lea    (%rdx,%rbx,8),%rdx
mov    %rdx,0x28(%rsp)
lea    (%rdx,%rbx,8),%rdx
mov    %rdx,0x20(%rsp)
mov    %eax,%eax
neg    %rax
lea    0x0(,%rbx,8),%rbx
add    %rbp,%rbx
shl    $0x3,%rcx
mov    %rcx,0x38(%rsp)
mov    0x18(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %rax,0x48(%rsp)
mov    %r15d,0x14(%rsp)
mov    %r15d,%edi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
lea    0x60(%rsp),%rcx
lea    0x58(%rsp),%r8
lea    0x50(%rsp),%r9
call   1030 <L2_3term_so3@plt>
movsd  0x60(%rsp),%xmm0
mov    0xb8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %r13d,%edx
call   10b0 <vec_mul_so3@plt>
movsd  0x50(%rsp),%xmm0
mov    0x40(%rsp),%rdi
mov    0x30(%rsp),%r15
mov    %r15,%rsi
mov    %r13d,%edx
call   1090 <vec_add_scalar_so3@plt>
movsd  0x58(%rsp),%xmm0
mov    %r15,%rdi
mov    %r13d,%esi
call   1070 <vec_mul_inplace_so3@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    0x28(%rsp),%rbp
mov    %rbp,%rdx
mov    %r13d,%ecx
call   1060 <vec_pt_mul_so3@plt>
mov    (%rsp),%rdi
mov    0x14(%rsp),%r15d
mov    %rbp,%rsi
mov    0x20(%rsp),%rbp
mov    %rbp,%rdx
mov    %r13d,%ecx
call   1080 <vec_add_so3@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <memcpy@plt>
mov    0xb8(%rsp),%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <memcpy@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <memcpy@plt>
mov    0x48(%rsp),%rax
add    $0x1,%r15d
add    0x38(%rsp),%rbx
inc    %rax
jne    1290 <genWig_L2_U+0x100>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @genWig_L2_U(i32 %0, i32 %1, i32 %2, i32 %3, double* %4, double* %5, double* %6, double* %7, double* %8, double* %9) {
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca double*
%27 = alloca double*
%28 = alloca double*
%29 = alloca double*
%30 = alloca double*
%31 = alloca double*
%32 = alloca double
%33 = alloca double
%34 = alloca double
store i32 %0, i32* %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store double* %4, double** %15
store double* %5, double** %16
store double* %6, double** %17
store double* %7, double** %18
store double* %8, double** %19
store double* %9, double** %20
store i32 0, i32* %22
%35 = load i32, i32* %11
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %10
%38 = load i32, i32* %11
br label %42
39: ; preds = %10
%40 = load i32, i32* %11
%41 = sub nsw i32 0, %40
br label %42
42: ; preds = %39, %37
%43 = phi i32 [ %38, %37 ], [ %41, %39 ]
store i32 %43, i32* %24
%44 = load i32, i32* %12
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = load i32, i32* %12
br label %51
48: ; preds = %42
%49 = load i32, i32* %12
%50 = sub nsw i32 0, %49
br label %51
51: ; preds = %48, %46
%52 = phi i32 [ %47, %46 ], [ %50, %48 ]
store i32 %52, i32* %25
%53 = load i32, i32* %24
%54 = load i32, i32* %25
%55 = icmp sgt i32 %53, %54
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = load i32, i32* %24
br label %60
58: ; preds = %51
%59 = load i32, i32* %25
br label %60
60: ; preds = %58, %56
%61 = phi i32 [ %57, %56 ], [ %59, %58 ]
store i32 %61, i32* %23
%62 = load double*, double** %20
store double* %62, double** %26
%63 = load double*, double** %26
%64 = load i32, i32* %14
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
store double* %66, double** %27
%67 = load double*, double** %27
%68 = load i32, i32* %14
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
store double* %70, double** %28
%71 = load double*, double** %28
%72 = load i32, i32* %14
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
store double* %74, double** %29
%75 = load double*, double** %29
%76 = load i32, i32* %14
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %75, i64 %77
store double* %78, double** %30
%79 = load double*, double** %30
%80 = load i32, i32* %14
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
store double* %82, double** %31
%83 = load double*, double** %26
%84 = load i32, i32* %14
%85 = sext i32 %84 to i64
%86 = mul i64 8, %85
%87 = trunc i64 %86 to i32
%88 = call i32 @memset(double* %83, i32 0, i32 %87)
%89 = load i32, i32* %11
%90 = load i32, i32* %12
%91 = load double*, double** %17
%92 = load double*, double** %18
%93 = load i32, i32* %14
%94 = load double*, double** %27
%95 = call i32 @wigSpec_L2(i32 %89, i32 %90, double* %91, double* %92, i32 %93, double* %94)
%96 = load double*, double** %19
%97 = load double*, double** %27
%98 = load i32, i32* %14
%99 = sext i32 %98 to i64
%100 = mul i64 8, %99
%101 = trunc i64 %100 to i32
%102 = call i32 @memcpy(double* %96, double* %97, i32 %101)
store i32 0, i32* %21
br label %103
103: ; preds = %168, %60
%104 = load i32, i32* %21
%105 = load i32, i32* %13
%106 = load i32, i32* %23
%107 = sub nsw i32 %105, %106
%108 = sub nsw i32 %107, 1
%109 = icmp slt i32 %104, %108
br i1 %109, label %110, label %171
110: ; preds = %103
%111 = load i32, i32* %23
%112 = load i32, i32* %21
%113 = add nsw i32 %111, %112
%114 = load i32, i32* %11
%115 = load i32, i32* %12
%116 = call i32 @L2_3term_so3(i32 %113, i32 %114, i32 %115, double* %32, double* %33, double* %34)
%117 = load double, double* %32
%118 = load double*, double** %26
%119 = load double*, double** %28
%120 = load i32, i32* %14
%121 = call i32 @vec_mul_so3(double %117, double* %118, double* %119, i32 %120)
%122 = load double, double* %34
%123 = load double*, double** %16
%124 = load double*, double** %29
%125 = load i32, i32* %14
%126 = call i32 @vec_add_scalar_so3(double %122, double* %123, double* %124, i32 %125)
%127 = load double, double* %33
%128 = load double*, double** %29
%129 = load i32, i32* %14
%130 = call i32 @vec_mul_inplace_so3(double %127, double* %128, i32 %129)
%131 = load double*, double** %27
%132 = load double*, double** %29
%133 = load double*, double** %30
%134 = load i32, i32* %14
%135 = call i32 @vec_pt_mul_so3(double* %131, double* %132, double* %133, i32 %134)
%136 = load double*, double** %28
%137 = load double*, double** %30
%138 = load double*, double** %31
%139 = load i32, i32* %14
%140 = call i32 @vec_add_so3(double* %136, double* %137, double* %138, i32 %139)
%141 = load double*, double** %19
%142 = load i32, i32* %21
%143 = add nsw i32 %142, 1
%144 = load i32, i32* %14
%145 = mul nsw i32 %143, %144
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds double, double* %141, i64 %146
%148 = load double*, double** %31
%149 = load i32, i32* %14
%150 = sext i32 %149 to i64
%151 = mul i64 8, %150
%152 = trunc i64 %151 to i32
%153 = call i32 @memcpy(double* %147, double* %148, i32 %152)
%154 = load double*, double** %26
%155 = load double*, double** %27
%156 = load i32, i32* %14
%157 = sext i32 %156 to i64
%158 = mul i64 8, %157
%159 = trunc i64 %158 to i32
%160 = call i32 @memcpy(double* %154, double* %155, i32 %159)
%161 = load double*, double** %27
%162 = load double*, double** %31
%163 = load i32, i32* %14
%164 = sext i32 %163 to i64
%165 = mul i64 8, %164
%166 = trunc i64 %165 to i32
%167 = call i32 @memcpy(double* %161, double* %162, i32 %166)
br label %168
168: ; preds = %110
%169 = load i32, i32* %21
%170 = add nsw i32 %169, 1
store i32 %170, i32* %21
br label %103
171: ; preds = %103
ret void
}

LLVM IR (-O2):
define void @genWig_L2_U(i32 %0, i32 %1, i32 %2, i32 %3, double* nocapture readnone %4, double* %5, double* %6, double* %7, double* %8, double* %9) {
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = bitcast double* %11 to i8*
%15 = bitcast double* %12 to i8*
%16 = bitcast double* %13 to i8*
%17 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%18 = tail call i32 @llvm.abs.i32(i32 %1, i1 true)
%19 = icmp ugt i32 %17, %18
%20 = select i1 %19, i32 %17, i32 %18
%21 = sext i32 %3 to i64
%22 = getelementptr inbounds double, double* %9, i64 %21
%23 = getelementptr inbounds double, double* %22, i64 %21
%24 = getelementptr inbounds double, double* %23, i64 %21
%25 = getelementptr inbounds double, double* %24, i64 %21
%26 = getelementptr inbounds double, double* %25, i64 %21
%27 = shl i32 %3, 3
%28 = tail call i32 @memset(double* %9, i32 0, i32 %27)
%29 = tail call i32 @wigSpec_L2(i32 %0, i32 %1, double* %6, double* %7, i32 %3, double* %22)
%30 = tail call i32 @memcpy(double* %8, double* %22, i32 %27)
%31 = xor i32 %20, -1
%32 = add i32 %31, %2
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %56
34: ; preds = %10
%35 = zext i32 %32 to i64
br label %36
36: ; preds = %34, %36
%37 = phi i64 [ 0, %34 ], [ %49, %36 ]
%38 = trunc i64 %37 to i32
%39 = add i32 %20, %38
%40 = call i32 @L2_3term_so3(i32 %39, i32 %0, i32 %1, double* %11, double* %12, double* %13)
%41 = load double, double* %11
%42 = call i32 @vec_mul_so3(double %41, double* %9, double* %23, i32 %3)
%43 = load double, double* %13
%44 = call i32 @vec_add_scalar_so3(double %43, double* %5, double* %24, i32 %3)
%45 = load double, double* %12
%46 = call i32 @vec_mul_inplace_so3(double %45, double* %24, i32 %3)
%47 = call i32 @vec_pt_mul_so3(double* %22, double* %24, double* %25, i32 %3)
%48 = call i32 @vec_add_so3(double* %23, double* %25, double* %26, i32 %3)
%49 = add nuw nsw i64 %37, 1
%50 = mul nsw i64 %49, %21
%51 = getelementptr inbounds double, double* %8, i64 %50
%52 = call i32 @memcpy(double* %51, double* %26, i32 %27)
%53 = call i32 @memcpy(double* %9, double* %22, i32 %27)
%54 = call i32 @memcpy(double* %22, double* %26, i32 %27)
%55 = icmp eq i64 %49, %35
br i1 %55, label %56, label %36
56: ; preds = %36, %10
ret void
}