#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 */
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
double *calloc(size_t, int);
int /*<<< orphan*/ fir_complex_band_pass(double *, size_t, double, double,
                                         double, double, double);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ lround(double);
void fir_int16_complex_band_pass(int16_t *taps, size_t ntaps,
                                 double sample_rate, double low_cutoff,
                                 double high_cutoff, double width,
                                 double gain) {
  double *dtaps;
  int i;
  dtaps = calloc(ntaps, sizeof(double) * 2);
  fir_complex_band_pass(dtaps, ntaps, sample_rate, low_cutoff, high_cutoff,
                        width, gain);
  for (i = 0; i < ntaps * 2; i++) {
    taps[i] = lround(dtaps[i] * 32767.0);
  }
  free(dtaps);
}


x86 assembly (clang, -O0):
<fir_int16_complex_band_pass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1050 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
call   1060 <fir_complex_band_pass@plt>
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x1,%rcx
cmp    %rcx,%rax
jae    11f2 <fir_int16_complex_band_pass+0xb2>
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0xe33(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1040 <lround@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11a8 <fir_int16_complex_band_pass+0x68>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fir_int16_complex_band_pass>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm4,0x20(%rsp)
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0x10,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r15,%rsi
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  0x20(%rsp),%xmm4
call   1060 <fir_complex_band_pass@plt>
add    %r15,%r15
je     11d0 <fir_int16_complex_band_pass+0x90>
xor    %ebx,%ebx
nopl   (%rax)
movsd  (%r12,%rbx,8),%xmm0
mulsd  0xe42(%rip),%xmm0
call   1040 <lround@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11b0 <fir_int16_complex_band_pass+0x70>
mov    %r12,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @fir_int16_complex_band_pass(i32* %0, i64 %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca i32*
%9 = alloca i64
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca i32
store i32* %0, i32** %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
%17 = load i64, i64* %9
%18 = call double* @calloc(i64 %17, i32 16)
store double* %18, double** %15
%19 = load double*, double** %15
%20 = load i64, i64* %9
%21 = load double, double* %10
%22 = load double, double* %11
%23 = load double, double* %12
%24 = load double, double* %13
%25 = load double, double* %14
%26 = call i32 @fir_complex_band_pass(double* %19, i64 %20, double %21, double %22, double %23, double %24, double %25)
store i32 0, i32* %16
br label %27
27: ; preds = %45, %7
%28 = load i32, i32* %16
%29 = sext i32 %28 to i64
%30 = load i64, i64* %9
%31 = mul i64 %30, 2
%32 = icmp ult i64 %29, %31
br i1 %32, label %33, label %48
33: ; preds = %27
%34 = load double*, double** %15
%35 = load i32, i32* %16
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fmul double %38, 3.276700e+04
%40 = call i32 @lround(double %39)
%41 = load i32*, i32** %8
%42 = load i32, i32* %16
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %40, i32* %44
br label %45
45: ; preds = %33
%46 = load i32, i32* %16
%47 = add nsw i32 %46, 1
store i32 %47, i32* %16
br label %27
48: ; preds = %27
%49 = load double*, double** %15
%50 = call i32 @free(double* %49)
ret void
}

LLVM IR (-O2):
define void @fir_int16_complex_band_pass(i32* nocapture writeonly %0, i64 %1, double %2, double %3, double %4, double %5, double %6) {
%8 = tail call double* @calloc(i64 %1, i32 16)
%9 = tail call i32 @fir_complex_band_pass(double* %8, i64 %1, double %2, double %3, double %4, double %5, double %6)
%10 = shl i64 %1, 1
%11 = icmp eq i64 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %7, %12
%13 = phi i64 [ %19, %12 ], [ 0, %7 ]
%14 = getelementptr inbounds double, double* %8, i64 %13
%15 = load double, double* %14
%16 = fmul double %15, 3.276700e+04
%17 = tail call i32 @lround(double %16)
%18 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %17, i32* %18
%19 = add nuw i64 %13, 1
%20 = icmp eq i64 %19, %10
br i1 %20, label %21, label %12
21: ; preds = %12, %7
%22 = tail call i32 @free(double* %8)
ret void
}