#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 cos(double);
int /*<<< orphan*/ fir_low_pass(double *, size_t, double, double, double,
                                double);
double sin(double);
void fir_complex_band_pass(double *taps, size_t ntaps, double sample_rate,
                           double low_cutoff, double high_cutoff, double width,
                           double gain) {
  double *lptaps;
  double freq = M_PI * (high_cutoff + low_cutoff) / sample_rate;
  double phase;
  int i;
  lptaps = &taps[ntaps];
  fir_low_pass(lptaps, ntaps, sample_rate, (high_cutoff - low_cutoff) / 2,
               width, gain);
  if (ntaps & 1) {
    phase = -freq * (ntaps >> 1);
  } else {
    phase = -freq / 2.0 * ((1 + 2 * ntaps) >> 1);
  }
  for (i = 0; i < ntaps; i++, phase += freq) {
    taps[i * 2 + 0] = lptaps[i] * cos(phase);
    taps[i * 2 + 1] = lptaps[i] * sin(phase);
  }
}


x86 assembly (clang, -O0):
<fir_complex_band_pass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
mov    0x2e88(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x28(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xe52(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
call   1030 <fir_low_pass@plt>
mov    -0x10(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11fd <fir_complex_band_pass+0xcd>
movaps 0xe36(%rip),%xmm1
movsd  -0x48(%rbp),%xmm0
pxor   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
shr    %rax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    122d <fir_complex_band_pass+0xfd>
movsd  -0x48(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movabs $0x7fffffffffffffff,%rcx
ff ff 7f
and    %rcx,%rax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    12d9 <fir_complex_band_pass+0x1a9>
mov    -0x40(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x54(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x54(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1234 <fir_complex_band_pass+0x104>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fir_complex_band_pass>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2ea0(%rip),%rax
movapd %xmm1,%xmm5
addsd  %xmm2,%xmm5
mulsd  (%rax),%xmm5
divsd  %xmm0,%xmm5
movapd %xmm5,0x10(%rsp)
lea    (%rdi,%rsi,8),%r15
subsd  %xmm1,%xmm2
mulsd  0xe92(%rip),%xmm2
mov    %r15,%rdi
movapd %xmm2,%xmm1
movapd %xmm3,%xmm2
movaps %xmm4,%xmm3
call   1030 <fir_low_pass@plt>
test   $0x1,%r14b
jne    11b1 <fir_complex_band_pass+0x81>
test   %r14,%r14
movapd 0x10(%rsp),%xmm1
je     1244 <fir_complex_band_pass+0x114>
movsd  0xe6a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movabs $0x7fffffffffffffff,%rax
ff ff 7f
and    %r14,%rax
jmp    11c9 <fir_complex_band_pass+0x99>
movapd 0xe57(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
xorpd  %xmm1,%xmm0
mov    %r14,%rax
shr    %rax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
mulsd  %xmm0,%xmm2
add    $0x8,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm2,0x8(%rsp)
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
call   1050 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,-0x8(%r12)
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x8(%rsp),%xmm2
movapd 0x10(%rsp),%xmm1
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r12)
add    $0x1,%rbx
addsd  %xmm1,%xmm2
add    $0x10,%r12
cmp    %rbx,%r14
jne    11e0 <fir_complex_band_pass+0xb0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @fir_complex_band_pass(double* %0, i64 %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca double*
%9 = alloca i64
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double
%17 = alloca double
%18 = alloca i32
store double* %0, double** %8
store i64 %1, i64* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%19 = load double, double* @M_PI
%20 = load double, double* %12
%21 = load double, double* %11
%22 = fadd double %20, %21
%23 = fmul double %19, %22
%24 = load double, double* %10
%25 = fdiv double %23, %24
store double %25, double* %16
%26 = load double*, double** %8
%27 = load i64, i64* %9
%28 = getelementptr inbounds double, double* %26, i64 %27
store double* %28, double** %15
%29 = load double*, double** %15
%30 = load i64, i64* %9
%31 = load double, double* %10
%32 = load double, double* %12
%33 = load double, double* %11
%34 = fsub double %32, %33
%35 = fdiv double %34, 2.000000e+00
%36 = load double, double* %13
%37 = load double, double* %14
%38 = call i32 @fir_low_pass(double* %29, i64 %30, double %31, double %35, double %36, double %37)
%39 = load i64, i64* %9
%40 = and i64 %39, 1
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %7
%43 = load double, double* %16
%44 = fneg double %43
%45 = load i64, i64* %9
%46 = lshr i64 %45, 1
%47 = uitofp i64 %46 to double
%48 = fmul double %44, %47
store double %48, double* %17
br label %59
49: ; preds = %7
%50 = load double, double* %16
%51 = fneg double %50
%52 = fdiv double %51, 2.000000e+00
%53 = load i64, i64* %9
%54 = mul i64 2, %53
%55 = add i64 1, %54
%56 = lshr i64 %55, 1
%57 = uitofp i64 %56 to double
%58 = fmul double %52, %57
store double %58, double* %17
br label %59
59: ; preds = %49, %42
store i32 0, i32* %18
br label %60
60: ; preds = %94, %59
%61 = load i32, i32* %18
%62 = sext i32 %61 to i64
%63 = load i64, i64* %9
%64 = icmp ult i64 %62, %63
br i1 %64, label %65, label %100
65: ; preds = %60
%66 = load double*, double** %15
%67 = load i32, i32* %18
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = load double, double* %17
%72 = call double @cos(double %71)
%73 = fmul double %70, %72
%74 = load double*, double** %8
%75 = load i32, i32* %18
%76 = mul nsw i32 %75, 2
%77 = add nsw i32 %76, 0
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %74, i64 %78
store double %73, double* %79
%80 = load double*, double** %15
%81 = load i32, i32* %18
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = load double, double* %17
%86 = call double @sin(double %85)
%87 = fmul double %84, %86
%88 = load double*, double** %8
%89 = load i32, i32* %18
%90 = mul nsw i32 %89, 2
%91 = add nsw i32 %90, 1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double, double* %88, i64 %92
store double %87, double* %93
br label %94
94: ; preds = %65
%95 = load i32, i32* %18
%96 = add nsw i32 %95, 1
store i32 %96, i32* %18
%97 = load double, double* %16
%98 = load double, double* %17
%99 = fadd double %98, %97
store double %99, double* %17
br label %60
100: ; preds = %60
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @fir_complex_band_pass(double* %0, i64 %1, double %2, double %3, double %4, double %5, double %6) {
%8 = load double, double* @M_PI
%9 = fadd double %3, %4
%10 = fmul double %9, %8
%11 = fdiv double %10, %2
%12 = getelementptr inbounds double, double* %0, i64 %1
%13 = fsub double %4, %3
%14 = fmul double %13, 5.000000e-01
%15 = tail call i32 @fir_low_pass(double* %12, i64 %1, double %2, double %14, double %5, double %6)
%16 = and i64 %1, 1
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %7
%19 = fneg double %11
%20 = lshr i64 %1, 1
%21 = uitofp i64 %20 to double
%22 = fmul double %21, %19
br label %29
23: ; preds = %7
%24 = fmul double %11, -5.000000e-01
%25 = and i64 %1, 9223372036854775807
%26 = uitofp i64 %25 to double
%27 = fmul double %24, %26
%28 = icmp eq i64 %1, 0
br i1 %28, label %48, label %29
29: ; preds = %18, %23
%30 = phi double [ %27, %23 ], [ %22, %18 ]
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ %45, %31 ], [ 0, %29 ]
%33 = phi double [ %46, %31 ], [ %30, %29 ]
%34 = getelementptr inbounds double, double* %12, i64 %32
%35 = load double, double* %34
%36 = tail call double @cos(double %33)
%37 = fmul double %35, %36
%38 = shl nuw nsw i64 %32, 1
%39 = getelementptr inbounds double, double* %0, i64 %38
store double %37, double* %39
%40 = load double, double* %34
%41 = tail call double @sin(double %33)
%42 = fmul double %40, %41
%43 = or i64 %38, 1
%44 = getelementptr inbounds double, double* %0, i64 %43
store double %42, double* %44
%45 = add nuw nsw i64 %32, 1
%46 = fadd double %11, %33
%47 = icmp eq i64 %45, %1
br i1 %47, label %48, label %31
48: ; preds = %31, %23
ret void
}