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


x86 assembly (clang, -O0):
<fir_lowpass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xec6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11e0 <fir_lowpass+0xd0>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sinc@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1153 <fir_lowpass+0x43>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fir_lowpass>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm1
mulsd  0xed0(%rip),%xmm1
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     11a7 <fir_lowpass+0x97>
mov    %rsi,%r15
mov    %rdi,%r12
cltq
lea    (%rdi,%rax,8),%r13
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,(%rsp)
nopw   0x0(%rax,%rax,1)
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
call   1030 <sinc@plt>
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
mulsd  (%r15,%rbx,8),%xmm1
movsd  %xmm1,(%r12,%rbx,8)
add    $0x1,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm1,0x0(%r13)
movsd  0x8(%rsp),%xmm1
add    $0xfffffffffffffff8,%r13
ucomisd %xmm0,%xmm1
jae    1160 <fir_lowpass+0x50>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @fir_lowpass(double* %0, double* %1, i32 %2, double %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double %3, double* %8
%12 = load i32, i32* %7
%13 = sub nsw i32 %12, 1
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 2.000000e+00
store double %15, double* %11
store i32 0, i32* %9
%16 = load i32, i32* %7
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %10
br label %18
18: ; preds = %52, %4
%19 = load i32, i32* %9
%20 = sitofp i32 %19 to double
%21 = load double, double* %11
%22 = fcmp ole double %20, %21
br i1 %22, label %23, label %57
23: ; preds = %18
%24 = load double, double* %8
%25 = load double, double* %8
%26 = load i32, i32* %9
%27 = sitofp i32 %26 to double
%28 = load double, double* %11
%29 = fsub double %27, %28
%30 = fmul double %25, %29
%31 = call double @sinc(double %30)
%32 = fmul double %24, %31
%33 = load double*, double** %6
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = fmul double %32, %37
%39 = load double*, double** %5
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double %38, double* %42
%43 = load double*, double** %5
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = load double*, double** %5
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %47, double* %51
br label %52
52: ; preds = %23
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
%55 = load i32, i32* %10
%56 = add nsw i32 %55, -1
store i32 %56, i32* %10
br label %18
57: ; preds = %18
%58 = load i32, i32* %7
ret i32 %58
}

LLVM IR (-O2):
define i32 @fir_lowpass(double* nocapture writeonly %0, double* nocapture %1, i32 returned %2, double %3) {
%5 = add i32 %2, -1
%6 = sitofp i32 %5 to double
%7 = fmul double %6, 5.000000e-01
%8 = fcmp ult double %7, 0.000000e+00
br i1 %8, label %29, label %9
9: ; preds = %4
%10 = sext i32 %5 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ %10, %9 ], [ %25, %11 ]
%13 = phi i64 [ 0, %9 ], [ %24, %11 ]
%14 = phi double [ 0.000000e+00, %9 ], [ %27, %11 ]
%15 = fsub double %14, %7
%16 = fmul double %15, %3
%17 = tail call double @sinc(double %16)
%18 = fmul double %17, %3
%19 = getelementptr inbounds double, double* %1, i64 %13
%20 = load double, double* %19
%21 = fmul double %18, %20
%22 = getelementptr inbounds double, double* %0, i64 %13
store double %21, double* %22
%23 = getelementptr inbounds double, double* %0, i64 %12
store double %21, double* %23
%24 = add nuw i64 %13, 1
%25 = add i64 %12, -1
%26 = trunc i64 %24 to i32
%27 = sitofp i32 %26 to double
%28 = fcmp ult double %7, %27
br i1 %28, label %29, label %11
29: ; preds = %11, %4
ret i32 %2
}