#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ cf_accum(int, int, int, int, double *, double *,
                            double const *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
int wiginit(int, int, int, double const *, double *);
int /*<<< orphan*/ wigrec(int, int, int, int, double const *, double *,
                          double *);
void wignerd_cf_from_cl(int s1, int s2, int nfunc, int ntheta, int lmax,
                        const double *cos_theta, double *out_cf,
                        const double *in_cl) {
  int l;
  double *wigd_lo, *wigd_hi;
  wigd_lo = (double *)calloc(ntheta, sizeof(double));
  wigd_hi = (double *)calloc(ntheta, sizeof(double));
  memset(out_cf, 0, nfunc * ntheta * sizeof(double));
  l = wiginit(s1, s2, ntheta, cos_theta, &wigd_hi[0]);
  if (l <= lmax)
    cf_accum(l, nfunc, ntheta, lmax, &wigd_hi[0], out_cf, in_cl);
  while (l < lmax) {
    wigrec(l, s1, s2, ntheta, cos_theta, &wigd_hi[0], &wigd_lo[0]);
    l++;
    cf_accum(l, nfunc, ntheta, lmax, &wigd_hi[0], out_cf, in_cl);
  }
  free(wigd_lo);
  free(wigd_hi);
}


x86 assembly (clang, -O0):
<wignerd_cf_from_cl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
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    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    0x10(%rbp),%rdi
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1050 <wiginit@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1206 <wignerd_cf_from_cl+0xa6>
mov    -0x24(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x38(%rbp),%r8
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%rax
mov    %rax,(%rsp)
call   1080 <cf_accum@plt>
jmp    120b <wignerd_cf_from_cl+0xab>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1267 <wignerd_cf_from_cl+0x107>
mov    -0x24(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <wigrec@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x38(%rbp),%r8
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%rax
mov    %rax,(%rsp)
call   1080 <cf_accum@plt>
jmp    120b <wignerd_cf_from_cl+0xab>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wignerd_cf_from_cl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,0x40(%rsp)
mov    %r8d,%ebp
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %esi,0x18(%rsp)
mov    %edi,%r15d
mov    0x88(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0x80(%rsp),%r12
mov    %ecx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,0x38(%rsp)
mov    %r13d,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
mov    %r14d,0x14(%rsp)
imul   %r13d,%r14d
shl    $0x3,%r14d
mov    %r12,0x20(%rsp)
mov    %r12,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1060 <memset@plt>
mov    %r15d,0x1c(%rsp)
mov    %r15d,%edi
mov    0x18(%rsp),%esi
mov    %r13d,%edx
mov    0x40(%rsp),%rcx
mov    %rcx,%r12
mov    %rbx,%r8
call   1050 <wiginit@plt>
mov    %eax,%r15d
cmp    %ebp,%eax
jg     1220 <wignerd_cf_from_cl+0xc0>
mov    0x28(%rsp),%rax
mov    %rax,(%rsp)
mov    %r15d,%edi
mov    0x14(%rsp),%esi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    %rbx,%r8
mov    0x20(%rsp),%r9
call   1080 <cf_accum@plt>
cmp    %ebp,%r15d
mov    %rbx,%rdx
mov    0x20(%rsp),%rbx
mov    0x38(%rsp),%rdi
mov    %rdx,0x30(%rsp)
jge    12a2 <wignerd_cf_from_cl+0x142>
mov    %ebp,%eax
mov    %r13d,%ecx
mov    0x30(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdi,(%rsp)
mov    %r15d,%edi
mov    0x1c(%rsp),%esi
mov    0x18(%rsp),%edx
mov    %eax,%r13d
mov    %ecx,%ebp
mov    %r12,%r8
mov    %r14,%r9
call   1040 <wigrec@plt>
add    $0x1,%r15d
mov    0x28(%rsp),%rax
mov    %rax,(%rsp)
mov    %r15d,%edi
mov    0x14(%rsp),%esi
mov    %ebp,%edx
mov    %r13d,%ecx
mov    %r14,%r8
mov    %rbx,%r9
call   1080 <cf_accum@plt>
mov    %ebp,%ecx
mov    %r13d,%eax
mov    0x38(%rsp),%rdi
cmp    %r15d,%r13d
jne    1250 <wignerd_cf_from_cl+0xf0>
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @wignerd_cf_from_cl(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, double* %5, double* %6, double* %7) {
%9 = tail call i64 @calloc(i32 %3, i32 8)
%10 = inttoptr i64 %9 to double*
%11 = tail call i64 @calloc(i32 %3, i32 8)
%12 = inttoptr i64 %11 to double*
%13 = shl i32 %2, 3
%14 = mul i32 %13, %3
%15 = tail call i32 @memset(double* %6, i32 0, i32 %14)
%16 = tail call i32 @wiginit(i32 %0, i32 %1, i32 %3, double* %5, double* %12)
%17 = icmp sgt i32 %16, %4
br i1 %17, label %20, label %18
18: ; preds = %8
%19 = tail call i32 @cf_accum(i32 %16, i32 %2, i32 %3, i32 %4, double* %12, double* %6, double* %7)
br label %20
20: ; preds = %18, %8
%21 = icmp slt i32 %16, %4
br i1 %21, label %22, label %28
22: ; preds = %20, %22
%23 = phi i32 [ %25, %22 ], [ %16, %20 ]
%24 = tail call i32 @wigrec(i32 %23, i32 %0, i32 %1, i32 %3, double* %5, double* %12, double* %10)
%25 = add i32 %23, 1
%26 = tail call i32 @cf_accum(i32 %25, i32 %2, i32 %3, i32 %4, double* %12, double* %6, double* %7)
%27 = icmp eq i32 %25, %4
br i1 %27, label %28, label %22
28: ; preds = %22, %20
%29 = tail call i32 @free(double* %10)
%30 = tail call i32 @free(double* %12)
ret void
}