#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(int m1, int m2, int bw, double *sinEval, double *cosEval,
               double *sinEval2, double *cosEval2, double *result,
               double *workspace) {
  int i, lCtr, m, n;
  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));
  n = 2 * bw;
  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>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
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    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11db <genWig_L2+0x4b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8c(%rbp)
jmp    11e6 <genWig_L2+0x56>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1207 <genWig_L2+0x77>
mov    -0x8(%rbp),%eax
mov    %eax,-0x90(%rbp)
jmp    1212 <genWig_L2+0x82>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0x90(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jle    1235 <genWig_L2+0xa5>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x94(%rbp)
jmp    123e <genWig_L2+0xae>
mov    -0x40(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
movslq -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x48(%rbp),%rdi
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    0x10(%rbp),%rcx
mov    -0x38(%rbp),%r8d
mov    -0x50(%rbp),%r9
call   10a0 <wigSpec_L2@plt>
mov    0x18(%rbp),%rdi
mov    -0x50(%rbp),%rsi
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x34(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1405 <genWig_L2+0x275>
mov    -0x34(%rbp),%edi
add    -0x2c(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    -0x78(%rbp),%rcx
lea    -0x80(%rbp),%r8
lea    -0x88(%rbp),%r9
call   1030 <L2_3term_so3@plt>
movsd  -0x78(%rbp),%xmm0
mov    -0x48(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   10b0 <vec_mul_so3@plt>
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1090 <vec_add_scalar_so3@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1070 <vec_mul_inplace_so3@plt>
mov    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x38(%rbp),%ecx
call   1060 <vec_pt_mul_so3@plt>
mov    -0x58(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x70(%rbp),%rdx
mov    -0x38(%rbp),%ecx
call   1080 <vec_add_so3@plt>
mov    0x18(%rbp),%rdi
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
imul   -0x38(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x70(%rbp),%rsi
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x50(%rbp),%rdi
mov    -0x70(%rbp),%rsi
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1305 <genWig_L2+0x175>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genWig_L2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,(%rsp)
mov    %r8,0x40(%rsp)
mov    %esi,%ebp
mov    %edi,%r14d
mov    0xb0(%rsp),%rdi
mov    %r14d,%eax
neg    %eax
cmovs  %r14d,%eax
mov    %esi,%r12d
neg    %r12d
cmovs  %esi,%r12d
cmp    %r12d,%eax
cmova  %eax,%r12d
mov    %rdx,0x18(%rsp)
lea    (%rdx,%rdx,1),%r13d
movslq %r13d,%r15
lea    (%rdi,%r15,8),%rax
mov    %rax,0x10(%rsp)
mov    %edx,%ebx
shl    $0x4,%ebx
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <memset@plt>
mov    %r14d,0x20(%rsp)
mov    %r14d,%edi
mov    0xa8(%rsp),%r14
mov    %ebp,0x24(%rsp)
mov    %ebp,%esi
mov    (%rsp),%rdx
mov    0xa0(%rsp),%rcx
mov    %r15,0x8(%rsp)
mov    %r15d,%r8d
mov    0x10(%rsp),%rbp
mov    %rbp,%r9
call   10a0 <wigSpec_L2@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %ebx,%r15d
mov    %ebx,%edx
call   1050 <memcpy@plt>
mov    %r12d,%eax
not    %eax
add    0x18(%rsp),%eax
test   %eax,%eax
jle    1387 <genWig_L2+0x1f7>
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdx
mov    %rdx,(%rsp)
lea    (%rdx,%rcx,8),%rdx
mov    %rdx,0x38(%rsp)
lea    (%rdx,%rcx,8),%rdx
mov    %rdx,0x30(%rsp)
lea    (%rdx,%rcx,8),%rdx
mov    %rdx,0x28(%rsp)
mov    %eax,%eax
neg    %rax
mov    0xa8(%rsp),%rdx
lea    (%rdx,%rcx,8),%rbp
shl    $0x3,%rcx
mov    %rcx,0x8(%rsp)
mov    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,0x48(%rsp)
mov    %r12d,0x18(%rsp)
mov    %r12d,%edi
mov    0x20(%rsp),%esi
mov    0x24(%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    0xb0(%rsp),%rdi
mov    (%rsp),%rsi
mov    %r13d,%edx
call   10b0 <vec_mul_so3@plt>
movsd  0x50(%rsp),%xmm0
mov    0x40(%rsp),%rdi
mov    0x38(%rsp),%r12
mov    %r12,%rsi
mov    %r13d,%edx
call   1090 <vec_add_scalar_so3@plt>
movsd  0x58(%rsp),%xmm0
mov    %r12,%rdi
mov    %r13d,%esi
call   1070 <vec_mul_inplace_so3@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    0x30(%rsp),%rbx
mov    %rbx,%rdx
mov    %r13d,%ecx
call   1060 <vec_pt_mul_so3@plt>
mov    (%rsp),%rdi
mov    0x18(%rsp),%r12d
mov    %rbx,%rsi
mov    0x28(%rsp),%rbx
mov    %rbx,%rdx
mov    %r13d,%ecx
call   1080 <vec_add_so3@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
mov    0xb0(%rsp),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
mov    0x48(%rsp),%rax
add    $0x1,%r12d
add    0x8(%rsp),%rbp
inc    %rax
jne    12a0 <genWig_L2+0x110>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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