#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 */
double M_PI;
double *binomial_mult(int, double *);
scalar_t__ calloc(int, int);
double cos(double);
int /*<<< orphan*/ free(double *);
double sin(double);
double *dcof_bwlp(int n, double fcf) {
  int k;
  double theta;
  double st;
  double ct;
  double parg;
  double sparg;
  double cparg;
  double a;
  double *rcof;
  double *dcof;
  rcof = (double *)calloc(2 * n, sizeof(double));
  if (rcof == NULL)
    return (NULL);
  theta = M_PI * fcf;
  st = sin(theta);
  ct = cos(theta);
  for (k = 0; k < n; ++k) {
    parg = M_PI * (double)(2 * k + 1) / (double)(2 * n);
    sparg = sin(parg);
    cparg = cos(parg);
    a = 1.0 + st * sparg;
    rcof[2 * k] = -ct / a;
    rcof[2 * k + 1] = -st * cparg / a;
  }
  dcof = binomial_mult(n, rcof);
  free(rcof);
  dcof[1] = dcof[0];
  dcof[0] = 1.0;
  for (k = 3; k <= n; ++k)
    dcof[k] = dcof[2 * k - 2];
  return (dcof);
}


x86 assembly (clang, -O0):
<dcof_bwlp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
shl    $0x1,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    118c <dcof_bwlp+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    133f <dcof_bwlp+0x1ef>
mov    0x2e55(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12ba <dcof_bwlp+0x16a>
mov    0x2e0f(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdcb(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x58(%rbp),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x50(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <dcof_bwlp+0x76>
mov    -0xc(%rbp),%edi
mov    -0x60(%rbp),%rsi
call   1070 <binomial_mult@plt>
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x68(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x68(%rbp),%rax
movsd  0xd10(%rip),%xmm0
movsd  %xmm0,(%rax)
movl   $0x3,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1337 <dcof_bwlp+0x1e7>
mov    -0x68(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12fb <dcof_bwlp+0x1ab>
mov    -0x68(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcof_bwlp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movsd  %xmm0,(%rsp)
mov    %edi,%r14d
lea    (%r14,%r14,1),%ebp
mov    %ebp,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1345 <dcof_bwlp+0x1f5>
mov    %rax,%r15
mov    0x2e5f(%rip),%r13
movsd  (%rsp),%xmm0
mulsd  0x0(%r13),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <sin@plt>
movapd %xmm0,0x30(%rsp)
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
movapd %xmm0,0x10(%rsp)
mov    %r14d,%r12d
test   %r14d,%r14d
jle    126b <dcof_bwlp+0x11b>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x20(%rsp)
movapd 0xe2b(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
xorpd  0x30(%rsp),%xmm1
movapd %xmm1,0x40(%rsp)
lea    (%r12,%r12,1),%rbp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x0(%r13),%xmm0
divsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
call   1050 <sin@plt>
movapd %xmm0,(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <cos@plt>
movapd (%rsp),%xmm2
mulsd  0x30(%rsp),%xmm2
addsd  0xdcc(%rip),%xmm2
mulsd  0x40(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
unpcklpd %xmm2,%xmm2
divpd  %xmm2,%xmm1
movupd %xmm1,(%r15,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%rbp
jne    1200 <dcof_bwlp+0xb0>
mov    %r14d,%edi
mov    %r15,%rsi
call   1070 <binomial_mult@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
movsd  (%rbx),%xmm0
movsd  %xmm0,0x8(%rbx)
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rbx)
cmp    $0x3,%r14d
jl     1347 <dcof_bwlp+0x1f7>
lea    -0x2(%r12),%rcx
add    $0xfffffffffffffffd,%r12
mov    %ecx,%eax
and    $0x3,%eax
mov    $0x3,%edx
cmp    $0x3,%r12
jb     1310 <dcof_bwlp+0x1c0>
lea    0x50(%rbx),%rsi
and    $0xfffffffffffffffc,%rcx
neg    %rcx
mov    $0x3,%edx
nopw   0x0(%rax,%rax,1)
movsd  -0x30(%rsi),%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
movsd  -0x20(%rsi),%xmm0
movsd  %xmm0,0x8(%rbx,%rdx,8)
movsd  -0x10(%rsi),%xmm0
movsd  %xmm0,0x10(%rbx,%rdx,8)
movsd  (%rsi),%xmm0
movsd  %xmm0,0x18(%rbx,%rdx,8)
add    $0x40,%rsi
lea    (%rcx,%rdx,1),%rdi
add    $0x4,%rdi
add    $0x4,%rdx
cmp    $0x3,%rdi
jne    12d0 <dcof_bwlp+0x180>
test   %rax,%rax
je     1347 <dcof_bwlp+0x1f7>
lea    (%rbx,%rdx,8),%rcx
shl    $0x4,%rdx
add    %rbx,%rdx
add    $0xfffffffffffffff0,%rdx
shl    $0x3,%rax
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movsd  (%rdx,%rsi,2),%xmm0
movsd  %xmm0,(%rcx,%rsi,1)
add    $0x8,%rsi
cmp    %rsi,%rax
jne    1330 <dcof_bwlp+0x1e0>
jmp    1347 <dcof_bwlp+0x1f7>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double* @dcof_bwlp(i32 %0, double %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double*
%15 = alloca double*
store i32 %0, i32* %4
store double %1, double* %5
%16 = load i32, i32* %4
%17 = mul nsw i32 2, %16
%18 = call i64 @calloc(i32 %17, i32 8)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %14
%20 = load double*, double** %14
%21 = icmp eq double* %20, null
br i1 %21, label %22, label %23
22: ; preds = %2
store double* null, double** %3
br label %111
23: ; preds = %2
%24 = load double, double* @M_PI
%25 = load double, double* %5
%26 = fmul double %24, %25
store double %26, double* %7
%27 = load double, double* %7
%28 = call double @sin(double %27)
store double %28, double* %8
%29 = load double, double* %7
%30 = call double @cos(double %29)
store double %30, double* %9
store i32 0, i32* %6
br label %31
31: ; preds = %74, %23
%32 = load i32, i32* %6
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %77
35: ; preds = %31
%36 = load double, double* @M_PI
%37 = load i32, i32* %6
%38 = mul nsw i32 2, %37
%39 = add nsw i32 %38, 1
%40 = sitofp i32 %39 to double
%41 = fmul double %36, %40
%42 = load i32, i32* %4
%43 = mul nsw i32 2, %42
%44 = sitofp i32 %43 to double
%45 = fdiv double %41, %44
store double %45, double* %10
%46 = load double, double* %10
%47 = call double @sin(double %46)
store double %47, double* %11
%48 = load double, double* %10
%49 = call double @cos(double %48)
store double %49, double* %12
%50 = load double, double* %8
%51 = load double, double* %11
%52 = call double @llvm.fmuladd.f64(double %50, double %51, double 1.000000e+00)
store double %52, double* %13
%53 = load double, double* %9
%54 = fneg double %53
%55 = load double, double* %13
%56 = fdiv double %54, %55
%57 = load double*, double** %14
%58 = load i32, i32* %6
%59 = mul nsw i32 2, %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %57, i64 %60
store double %56, double* %61
%62 = load double, double* %8
%63 = fneg double %62
%64 = load double, double* %12
%65 = fmul double %63, %64
%66 = load double, double* %13
%67 = fdiv double %65, %66
%68 = load double*, double** %14
%69 = load i32, i32* %6
%70 = mul nsw i32 2, %69
%71 = add nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %68, i64 %72
store double %67, double* %73
br label %74
74: ; preds = %35
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %31
77: ; preds = %31
%78 = load i32, i32* %4
%79 = load double*, double** %14
%80 = call double* @binomial_mult(i32 %78, double* %79)
store double* %80, double** %15
%81 = load double*, double** %14
%82 = call i32 @free(double* %81)
%83 = load double*, double** %15
%84 = getelementptr inbounds double, double* %83, i64 0
%85 = load double, double* %84
%86 = load double*, double** %15
%87 = getelementptr inbounds double, double* %86, i64 1
store double %85, double* %87
%88 = load double*, double** %15
%89 = getelementptr inbounds double, double* %88, i64 0
store double 1.000000e+00, double* %89
store i32 3, i32* %6
br label %90
90: ; preds = %106, %77
%91 = load i32, i32* %6
%92 = load i32, i32* %4
%93 = icmp sle i32 %91, %92
br i1 %93, label %94, label %109
94: ; preds = %90
%95 = load double*, double** %15
%96 = load i32, i32* %6
%97 = mul nsw i32 2, %96
%98 = sub nsw i32 %97, 2
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %95, i64 %99
%101 = load double, double* %100
%102 = load double*, double** %15
%103 = load i32, i32* %6
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double, double* %102, i64 %104
store double %101, double* %105
br label %106
106: ; preds = %94
%107 = load i32, i32* %6
%108 = add nsw i32 %107, 1
store i32 %108, i32* %6
br label %90
109: ; preds = %90
%110 = load double*, double** %15
store double* %110, double** %3
br label %111
111: ; preds = %109, %22
%112 = load double*, double** %3
ret double* %112
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double* @dcof_bwlp(i32 %0, double %1) {
%3 = shl nsw i32 %0, 1
%4 = tail call i64 @calloc(i32 %3, i32 8)
%5 = inttoptr i64 %4 to double*
%6 = icmp eq i64 %4, 0
br i1 %6, label %98, label %7
7: ; preds = %2
%8 = load double, double* @M_PI
%9 = fmul double %8, %1
%10 = tail call double @sin(double %9)
%11 = tail call double @cos(double %9)
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %40
13: ; preds = %7
%14 = sitofp i32 %3 to double
%15 = fneg double %11
%16 = fneg double %10
%17 = zext i32 %0 to i64
%18 = insertelement <2 x double> poison, double %15, i64 0
br label %19
19: ; preds = %13, %19
%20 = phi i64 [ 0, %13 ], [ %38, %19 ]
%21 = load double, double* @M_PI
%22 = shl nuw nsw i64 %20, 1
%23 = trunc i64 %22 to i32
%24 = or i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fmul double %21, %25
%27 = fdiv double %26, %14
%28 = tail call double @sin(double %27)
%29 = tail call double @cos(double %27)
%30 = tail call double @llvm.fmuladd.f64(double %10, double %28, double 1.000000e+00)
%31 = getelementptr inbounds double, double* %5, i64 %22
%32 = fmul double %29, %16
%33 = insertelement <2 x double> %18, double %32, i64 1
%34 = insertelement <2 x double> poison, double %30, i64 0
%35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> zeroinitializer
%36 = fdiv <2 x double> %33, %35
%37 = bitcast double* %31 to <2 x double>*
store <2 x double> %36, <2 x double>* %37
%38 = add nuw nsw i64 %20, 1
%39 = icmp eq i64 %38, %17
br i1 %39, label %40, label %19
40: ; preds = %19, %7
%41 = tail call double* @binomial_mult(i32 %0, double* %5)
%42 = tail call i32 @free(double* %5)
%43 = load double, double* %41
%44 = getelementptr inbounds double, double* %41, i64 1
store double %43, double* %44
store double 1.000000e+00, double* %41
%45 = icmp slt i32 %0, 3
br i1 %45, label %98, label %46
46: ; preds = %40
%47 = add nuw i32 %0, 1
%48 = zext i32 %47 to i64
%49 = add nsw i64 %48, -3
%50 = add nsw i64 %48, -4
%51 = and i64 %49, 3
%52 = icmp ult i64 %50, 3
br i1 %52, label %84, label %53
53: ; preds = %46
%54 = and i64 %49, -4
br label %55
55: ; preds = %55, %53
%56 = phi i64 [ 3, %53 ], [ %81, %55 ]
%57 = phi i64 [ 0, %53 ], [ %82, %55 ]
%58 = shl nuw nsw i64 %56, 1
%59 = add nsw i64 %58, -2
%60 = getelementptr inbounds double, double* %41, i64 %59
%61 = load double, double* %60
%62 = getelementptr inbounds double, double* %41, i64 %56
store double %61, double* %62
%63 = add nuw nsw i64 %56, 1
%64 = shl nuw nsw i64 %63, 1
%65 = add nsw i64 %64, -2
%66 = getelementptr inbounds double, double* %41, i64 %65
%67 = load double, double* %66
%68 = getelementptr inbounds double, double* %41, i64 %63
store double %67, double* %68
%69 = add nuw nsw i64 %56, 2
%70 = shl nuw nsw i64 %69, 1
%71 = add nsw i64 %70, -2
%72 = getelementptr inbounds double, double* %41, i64 %71
%73 = load double, double* %72
%74 = getelementptr inbounds double, double* %41, i64 %69
store double %73, double* %74
%75 = add nuw nsw i64 %56, 3
%76 = shl nuw nsw i64 %75, 1
%77 = add nsw i64 %76, -2
%78 = getelementptr inbounds double, double* %41, i64 %77
%79 = load double, double* %78
%80 = getelementptr inbounds double, double* %41, i64 %75
store double %79, double* %80
%81 = add nuw nsw i64 %56, 4
%82 = add i64 %57, 4
%83 = icmp eq i64 %82, %54
br i1 %83, label %84, label %55
84: ; preds = %55, %46
%85 = phi i64 [ 3, %46 ], [ %81, %55 ]
%86 = icmp eq i64 %51, 0
br i1 %86, label %98, label %87
87: ; preds = %84, %87
%88 = phi i64 [ %95, %87 ], [ %85, %84 ]
%89 = phi i64 [ %96, %87 ], [ 0, %84 ]
%90 = shl nuw nsw i64 %88, 1
%91 = add nsw i64 %90, -2
%92 = getelementptr inbounds double, double* %41, i64 %91
%93 = load double, double* %92
%94 = getelementptr inbounds double, double* %41, i64 %88
store double %93, double* %94
%95 = add nuw nsw i64 %88, 1
%96 = add i64 %89, 1
%97 = icmp eq i64 %96, %51
br i1 %97, label %98, label %87
98: ; preds = %84, %87, %40, %2
%99 = phi double* [ null, %2 ], [ %41, %40 ], [ %41, %87 ], [ %41, %84 ]
ret double* %99
}