#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*/ assert(int);
void cf_accum(int l, int nfunc, int ntheta, int lmax, const double *wigd,
              double *out_cf, const double *in_cl) {
  int i, f;
  double cl;
  assert(l <= lmax);
  for (f = 0; f < nfunc; f++) {
    cl = in_cl[f * (lmax + 1) + l];
    for (i = 0; i < ntheta; i++)
      out_cf[f * ntheta + i] += cl * wigd[i];
  }
}


x86 assembly (clang, -O0):
<cf_accum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11df <cf_accum+0xcf>
mov    0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%edx
add    $0x1,%edx
imul   %edx,%ecx
add    -0x4(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cc <cf_accum+0xbc>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117d <cf_accum+0x6d>
jmp    11d1 <cf_accum+0xc1>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114a <cf_accum+0x3a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cf_accum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,(%rsp)
mov    %r8,%rbx
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r13d
xor    %edi,%edi
cmp    %ecx,%r13d
setle  %dil
call   1030 <assert@plt>
test   %r15d,%r15d
jle    13b1 <cf_accum+0x2a1>
mov    0x80(%rsp),%rsi
add    $0x1,%r12d
movslq %r12d,%rdi
movslq %r13d,%r10
movslq %r14d,%rbp
mov    %r15d,%r12d
mov    %ebp,%eax
lea    (%rbx,%rax,8),%rcx
mov    %rcx,0x38(%rsp)
mov    %eax,%ecx
and    $0xfffffffc,%ecx
mov    %rcx,0x20(%rsp)
add    $0xfffffffffffffffc,%rcx
mov    %rcx,0x18(%rsp)
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %rdx,%rcx
mov    %rdx,0x10(%rsp)
and    $0xfffffffffffffffe,%rdx
mov    %rdx,0x8(%rsp)
mov    %rax,%rcx
neg    %rcx
mov    %rcx,0x40(%rsp)
mov    (%rsp),%rcx
lea    0x30(%rcx),%r13
lea    0x0(,%rbp,8),%r11
lea    0x8(%rcx),%r8
xor    %r9d,%r9d
mov    %r12,0x30(%rsp)
mov    %rbp,0x28(%rsp)
jmp    11e3 <cf_accum+0xd3>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r9
add    %r11,%r13
add    %r11,%r8
cmp    %r12,%r9
je     13b1 <cf_accum+0x2a1>
test   %r14d,%r14d
jle    11d0 <cf_accum+0xc0>
mov    %r9,%r15
imul   %rbp,%r15
mov    %r9,%rcx
imul   %rdi,%rcx
add    %r10,%rcx
movsd  (%rsi,%rcx,8),%xmm0
cmp    $0x4,%r14d
jb     1224 <cf_accum+0x114>
mov    (%rsp),%rdx
lea    (%rdx,%r15,8),%rcx
cmp    0x38(%rsp),%rcx
jae    129b <cf_accum+0x18b>
lea    (%r15,%rax,1),%rcx
lea    (%rdx,%rcx,8),%rcx
cmp    %rbx,%rcx
jbe    129b <cf_accum+0x18b>
xor    %ecx,%ecx
mov    %rcx,%rdx
test   $0x1,%al
je     1250 <cf_accum+0x140>
add    %rcx,%r15
movsd  (%rbx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
mov    (%rsp),%rdx
addsd  (%rdx,%r15,8),%xmm1
movsd  %xmm1,(%rdx,%r15,8)
mov    %rcx,%rdx
or     $0x1,%rdx
not    %rcx
cmp    0x40(%rsp),%rcx
je     11d0 <cf_accum+0xc0>
xchg   %ax,%ax
movsd  (%rbx,%rdx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  -0x8(%r8,%rdx,8),%xmm1
movsd  %xmm1,-0x8(%r8,%rdx,8)
movsd  0x8(%rbx,%rdx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%r8,%rdx,8),%xmm1
movsd  %xmm1,(%r8,%rdx,8)
add    $0x2,%rdx
cmp    %rdx,%rax
jne    1260 <cf_accum+0x150>
jmp    11d0 <cf_accum+0xc0>
mov    %r10,%rbp
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x18(%rsp)
je     13a5 <cf_accum+0x295>
mov    0x8(%rsp),%r12
xor    %r10d,%r10d
nopw   0x0(%rax,%rax,1)
movupd (%rbx,%r10,8),%xmm2
movupd 0x10(%rbx,%r10,8),%xmm3
mulpd  %xmm1,%xmm2
movupd -0x30(%r13,%r10,8),%xmm4
addpd  %xmm2,%xmm4
movupd -0x20(%r13,%r10,8),%xmm2
movupd -0x10(%r13,%r10,8),%xmm5
movupd 0x0(%r13,%r10,8),%xmm6
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movupd %xmm4,-0x30(%r13,%r10,8)
movupd %xmm3,-0x20(%r13,%r10,8)
movupd 0x20(%rbx,%r10,8),%xmm2
movupd 0x30(%rbx,%r10,8),%xmm3
mulpd  %xmm1,%xmm2
addpd  %xmm5,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm6,%xmm3
movupd %xmm2,-0x10(%r13,%r10,8)
movupd %xmm3,0x0(%r13,%r10,8)
add    $0x8,%r10
add    $0xfffffffffffffffe,%r12
jne    12c0 <cf_accum+0x1b0>
testb  $0x1,0x10(%rsp)
je     1382 <cf_accum+0x272>
movupd (%rbx,%r10,8),%xmm2
movupd 0x10(%rbx,%r10,8),%xmm3
add    %r15,%r10
mov    (%rsp),%rcx
movupd (%rcx,%r10,8),%xmm4
movupd 0x10(%rcx,%r10,8),%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm2,(%rcx,%r10,8)
movupd %xmm3,0x10(%rcx,%r10,8)
mov    0x20(%rsp),%rdx
mov    %rdx,%rcx
cmp    %rax,%rdx
mov    %rbp,%r10
mov    0x28(%rsp),%rbp
mov    0x30(%rsp),%r12
je     11d0 <cf_accum+0xc0>
jmp    1226 <cf_accum+0x116>
xor    %r10d,%r10d
testb  $0x1,0x10(%rsp)
jne    1344 <cf_accum+0x234>
jmp    1382 <cf_accum+0x272>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @cf_accum(i32 %0, i32 %1, i32 %2, i32 %3, double* nocapture %4, double* nocapture %5, double* nocapture %6) {
%8 = icmp sle i32 %0, %3
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = icmp sgt i32 %1, 0
br i1 %11, label %12, label %152
12: ; preds = %7
%13 = add nsw i32 %3, 1
%14 = icmp sgt i32 %2, 0
%15 = sext i32 %13 to i64
%16 = sext i32 %0 to i64
%17 = sext i32 %2 to i64
%18 = zext i32 %1 to i64
%19 = zext i32 %2 to i64
%20 = getelementptr double, double* %4, i64 %19
%21 = and i64 %19, 4294967292
%22 = add nsw i64 %21, -4
%23 = lshr exact i64 %22, 2
%24 = add nuw nsw i64 %23, 1
%25 = icmp ult i32 %2, 4
%26 = and i64 %19, 4294967292
%27 = and i64 %24, 1
%28 = icmp eq i64 %22, 0
%29 = and i64 %24, 9223372036854775806
%30 = icmp eq i64 %27, 0
%31 = icmp eq i64 %26, %19
%32 = and i64 %19, 1
%33 = icmp eq i64 %32, 0
%34 = sub nsw i64 0, %19
br label %35
35: ; preds = %12, %149
%36 = phi i64 [ 0, %12 ], [ %150, %149 ]
%37 = mul i64 %36, %17
%38 = getelementptr double, double* %5, i64 %37
%39 = add i64 %37, %19
%40 = getelementptr double, double* %5, i64 %39
%41 = mul nsw i64 %36, %15
%42 = add nsw i64 %41, %16
%43 = getelementptr inbounds double, double* %6, i64 %42
%44 = load double, double* %43
br i1 %14, label %45, label %149
45: ; preds = %35
%46 = mul nsw i64 %36, %17
br i1 %25, label %118, label %47
47: ; preds = %45
%48 = icmp ult double* %38, %20
%49 = icmp ugt double* %40, %4
%50 = and i1 %48, %49
br i1 %50, label %118, label %51
51: ; preds = %47
%52 = insertelement <2 x double> poison, double %44, i64 0
%53 = shufflevector <2 x double> %52, <2 x double> poison, <2 x i32> zeroinitializer
%54 = insertelement <2 x double> poison, double %44, i64 0
%55 = shufflevector <2 x double> %54, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %28, label %97, label %56
56: ; preds = %51, %56
%57 = phi i64 [ %94, %56 ], [ 0, %51 ]
%58 = phi i64 [ %95, %56 ], [ 0, %51 ]
%59 = getelementptr inbounds double, double* %4, i64 %57
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = getelementptr inbounds double, double* %59, i64 2
%63 = bitcast double* %62 to <2 x double>*
%64 = load <2 x double>, <2 x double>* %63
%65 = add nsw i64 %57, %46
%66 = getelementptr inbounds double, double* %5, i64 %65
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = getelementptr inbounds double, double* %66, i64 2
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %53, <2 x double> %61, <2 x double> %68)
%73 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %64, <2 x double> %71)
%74 = bitcast double* %66 to <2 x double>*
store <2 x double> %72, <2 x double>* %74
%75 = bitcast double* %69 to <2 x double>*
store <2 x double> %73, <2 x double>* %75
%76 = or i64 %57, 4
%77 = getelementptr inbounds double, double* %4, i64 %76
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = getelementptr inbounds double, double* %77, i64 2
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = add nsw i64 %76, %46
%84 = getelementptr inbounds double, double* %5, i64 %83
%85 = bitcast double* %84 to <2 x double>*
%86 = load <2 x double>, <2 x double>* %85
%87 = getelementptr inbounds double, double* %84, i64 2
%88 = bitcast double* %87 to <2 x double>*
%89 = load <2 x double>, <2 x double>* %88
%90 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %53, <2 x double> %79, <2 x double> %86)
%91 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %82, <2 x double> %89)
%92 = bitcast double* %84 to <2 x double>*
store <2 x double> %90, <2 x double>* %92
%93 = bitcast double* %87 to <2 x double>*
store <2 x double> %91, <2 x double>* %93
%94 = add nuw i64 %57, 8
%95 = add i64 %58, 2
%96 = icmp eq i64 %95, %29
br i1 %96, label %97, label %56
97: ; preds = %56, %51
%98 = phi i64 [ 0, %51 ], [ %94, %56 ]
br i1 %30, label %117, label %99
99: ; preds = %97
%100 = getelementptr inbounds double, double* %4, i64 %98
%101 = bitcast double* %100 to <2 x double>*
%102 = load <2 x double>, <2 x double>* %101
%103 = getelementptr inbounds double, double* %100, i64 2
%104 = bitcast double* %103 to <2 x double>*
%105 = load <2 x double>, <2 x double>* %104
%106 = add nsw i64 %98, %46
%107 = getelementptr inbounds double, double* %5, i64 %106
%108 = bitcast double* %107 to <2 x double>*
%109 = load <2 x double>, <2 x double>* %108
%110 = getelementptr inbounds double, double* %107, i64 2
%111 = bitcast double* %110 to <2 x double>*
%112 = load <2 x double>, <2 x double>* %111
%113 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %53, <2 x double> %102, <2 x double> %109)
%114 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %105, <2 x double> %112)
%115 = bitcast double* %107 to <2 x double>*
store <2 x double> %113, <2 x double>* %115
%116 = bitcast double* %110 to <2 x double>*
store <2 x double> %114, <2 x double>* %116
br label %117
117: ; preds = %97, %99
br i1 %31, label %149, label %118
118: ; preds = %47, %45, %117
%119 = phi i64 [ 0, %47 ], [ 0, %45 ], [ %26, %117 ]
%120 = xor i64 %119, -1
br i1 %33, label %129, label %121
121: ; preds = %118
%122 = getelementptr inbounds double, double* %4, i64 %119
%123 = load double, double* %122
%124 = add nsw i64 %119, %46
%125 = getelementptr inbounds double, double* %5, i64 %124
%126 = load double, double* %125
%127 = tail call double @llvm.fmuladd.f64(double %44, double %123, double %126)
store double %127, double* %125
%128 = or i64 %119, 1
br label %129
129: ; preds = %121, %118
%130 = phi i64 [ %119, %118 ], [ %128, %121 ]
%131 = icmp eq i64 %120, %34
br i1 %131, label %149, label %132
132: ; preds = %129, %132
%133 = phi i64 [ %147, %132 ], [ %130, %129 ]
%134 = getelementptr inbounds double, double* %4, i64 %133
%135 = load double, double* %134
%136 = add nsw i64 %133, %46
%137 = getelementptr inbounds double, double* %5, i64 %136
%138 = load double, double* %137
%139 = tail call double @llvm.fmuladd.f64(double %44, double %135, double %138)
store double %139, double* %137
%140 = add nuw nsw i64 %133, 1
%141 = getelementptr inbounds double, double* %4, i64 %140
%142 = load double, double* %141
%143 = add nsw i64 %140, %46
%144 = getelementptr inbounds double, double* %5, i64 %143
%145 = load double, double* %144
%146 = tail call double @llvm.fmuladd.f64(double %44, double %142, double %145)
store double %146, double* %144
%147 = add nuw nsw i64 %133, 2
%148 = icmp eq i64 %147, %19
br i1 %148, label %149, label %132
149: ; preds = %129, %132, %117, %35
%150 = add nuw nsw i64 %36, 1
%151 = icmp eq i64 %150, %18
br i1 %151, label %152, label %35
152: ; preds = %149, %7
ret void
}