#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);
double sinc(double);
int fir_bandstop(double *h, double *w, int N, double fc1, double fc2) {
  int i, j;
  int delay;
  assert(N & 1);
  delay = (N - 1) / 2;
  for (i = 0, j = N - 1; i <= delay; i++, j--) {
    h[i] = -((double)fc2 * sinc(fc2 * (i - delay)) -
             (double)fc1 * sinc(fc1 * (i - delay))) *
           w[i];
    h[j] = h[i];
  }
  h[delay] = 1 - (fc2 - fc1);
  return N;
}


x86 assembly (clang, -O0):
<fir_bandstop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    -0x14(%rbp),%edi
and    $0x1,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jg     1255 <fir_bandstop+0x135>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x2c(%rbp),%eax
sub    -0x34(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sinc@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x2c(%rbp),%eax
sub    -0x34(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sinc@plt>
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    1169 <fir_bandstop+0x49>
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xd99(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fir_bandstop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r13
mov    %edx,%edi
and    $0x1,%edi
call   1030 <assert@plt>
movsd  0x20(%rsp),%xmm1
lea    -0x1(%rbx),%eax
shr    $0x1f,%eax
add    %ebx,%eax
add    $0xffffffff,%eax
sar    %eax
mov    %eax,0xc(%rsp)
mov    %rbx,0x18(%rsp)
test   %ebx,%ebx
js     1212 <fir_bandstop+0xf2>
mov    0x18(%rsp),%eax
xor    %ebp,%ebp
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
mov    $0x0,%ebx
cmovg  %ecx,%ebx
add    $0x1,%ebx
lea    -0x8(,%rax,8),%r14
ff
add    %r13,%r14
mov    %ecx,%r12d
neg    %r12d
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbp,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x28(%rsp)
mulsd  %xmm1,%xmm0
call   1040 <sinc@plt>
movapd %xmm0,0x30(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1040 <sinc@plt>
movsd  0x20(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
movapd 0x30(%rsp),%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm0,%xmm2
xorpd  0xe0d(%rip),%xmm2
mulsd  (%r15,%rbp,8),%xmm2
movsd  %xmm2,0x0(%r13,%rbp,8)
movsd  %xmm2,(%r14)
add    $0x1,%rbp
add    $0xfffffffffffffff8,%r14
cmp    %rbp,%rbx
jne    11a0 <fir_bandstop+0x80>
movsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
addsd  0xdec(%rip),%xmm0
movslq 0xc(%rsp),%rax
movsd  %xmm0,0x0(%r13,%rax,8)
mov    0x18(%rsp),%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fir_bandstop(double* %0, double* %1, i32 %2, double %3, double %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store double %3, double* %9
store double %4, double* %10
%14 = load i32, i32* %8
%15 = and i32 %14, 1
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %8
%18 = sub nsw i32 %17, 1
%19 = sdiv i32 %18, 2
store i32 %19, i32* %13
store i32 0, i32* %11
%20 = load i32, i32* %8
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %12
br label %22
22: ; preds = %66, %5
%23 = load i32, i32* %11
%24 = load i32, i32* %13
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %71
26: ; preds = %22
%27 = load double, double* %10
%28 = load double, double* %10
%29 = load i32, i32* %11
%30 = load i32, i32* %13
%31 = sub nsw i32 %29, %30
%32 = sitofp i32 %31 to double
%33 = fmul double %28, %32
%34 = call double @sinc(double %33)
%35 = load double, double* %9
%36 = load double, double* %9
%37 = load i32, i32* %11
%38 = load i32, i32* %13
%39 = sub nsw i32 %37, %38
%40 = sitofp i32 %39 to double
%41 = fmul double %36, %40
%42 = call double @sinc(double %41)
%43 = fmul double %35, %42
%44 = fneg double %43
%45 = call double @llvm.fmuladd.f64(double %27, double %34, double %44)
%46 = fneg double %45
%47 = load double*, double** %7
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = fmul double %46, %51
%53 = load double*, double** %6
%54 = load i32, i32* %11
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
store double %52, double* %56
%57 = load double*, double** %6
%58 = load i32, i32* %11
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = load double*, double** %6
%63 = load i32, i32* %12
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
store double %61, double* %65
br label %66
66: ; preds = %26
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
%69 = load i32, i32* %12
%70 = add nsw i32 %69, -1
store i32 %70, i32* %12
br label %22
71: ; preds = %22
%72 = load double, double* %10
%73 = load double, double* %9
%74 = fsub double %72, %73
%75 = fsub double 1.000000e+00, %74
%76 = load double*, double** %6
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
store double %75, double* %79
%80 = load i32, i32* %8
ret i32 %80
}

LLVM IR (-O2):
define i32 @fir_bandstop(double* nocapture writeonly %0, double* nocapture %1, i32 returned %2, double %3, double %4) {
%6 = and i32 %2, 1
%7 = tail call i32 @assert(i32 %6)
%8 = add nsw i32 %2, -1
%9 = sdiv i32 %8, 2
%10 = icmp slt i32 %2, 0
br i1 %10, label %38, label %11
11: ; preds = %5
%12 = zext i32 %2 to i64
%13 = call i32 @llvm.smax.i32(i32 %9, i32 0)
%14 = add nuw nsw i32 %13, 1
%15 = zext i32 %14 to i64
br label %16
16: ; preds = %11, %16
%17 = phi i64 [ %12, %11 ], [ %19, %16 ]
%18 = phi i64 [ 0, %11 ], [ %36, %16 ]
%19 = add nsw i64 %17, -1
%20 = trunc i64 %18 to i32
%21 = sub nsw i32 %20, %9
%22 = sitofp i32 %21 to double
%23 = fmul double %22, %4
%24 = tail call double @sinc(double %23)
%25 = fmul double %22, %3
%26 = tail call double @sinc(double %25)
%27 = fneg double %26
%28 = fmul double %27, %3
%29 = tail call double @llvm.fmuladd.f64(double %4, double %24, double %28)
%30 = fneg double %29
%31 = getelementptr inbounds double, double* %1, i64 %18
%32 = load double, double* %31
%33 = fmul double %32, %30
%34 = getelementptr inbounds double, double* %0, i64 %18
store double %33, double* %34
%35 = getelementptr inbounds double, double* %0, i64 %19
store double %33, double* %35
%36 = add nuw nsw i64 %18, 1
%37 = icmp eq i64 %36, %15
br i1 %37, label %38, label %16
38: ; preds = %16, %5
%39 = fsub double %3, %4
%40 = fadd double %39, 1.000000e+00
%41 = sext i32 %9 to i64
%42 = getelementptr inbounds double, double* %0, i64 %41
store double %40, double* %42
ret i32 %2
}