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


x86 assembly (clang, -O0):
<fir_highpass>:
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),%edi
and    $0x1,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     1200 <fir_highpass+0xe0>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%eax
sub    -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <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    1164 <fir_highpass+0x44>
movsd  0xdf8(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @fir_highpass(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 i32
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 = and i32 %12, 1
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %7
%16 = sub nsw i32 %15, 1
%17 = sdiv i32 %16, 2
store i32 %17, i32* %11
store i32 0, i32* %9
%18 = load i32, i32* %7
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %10
br label %20
20: ; preds = %54, %4
%21 = load i32, i32* %9
%22 = load i32, i32* %11
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %59
24: ; preds = %20
%25 = load double, double* %8
%26 = fneg double %25
%27 = load double, double* %8
%28 = load i32, i32* %9
%29 = load i32, i32* %11
%30 = sub nsw i32 %28, %29
%31 = sitofp i32 %30 to double
%32 = fmul double %27, %31
%33 = call double @sinc(double %32)
%34 = fmul double %26, %33
%35 = load double*, double** %6
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fmul double %34, %39
%41 = load double*, double** %5
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
store double %40, double* %44
%45 = load double*, double** %5
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = load double*, double** %5
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
store double %49, double* %53
br label %54
54: ; preds = %24
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
%57 = load i32, i32* %10
%58 = add nsw i32 %57, -1
store i32 %58, i32* %10
br label %20
59: ; preds = %20
%60 = load double, double* %8
%61 = fsub double 1.000000e+00, %60
%62 = load double*, double** %5
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
store double %61, double* %65
%66 = load i32, i32* %7
ret i32 %66
}

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