#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);
float sinc(float);
int fir_highpass(float *h, float *w, int N, float 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] = -(float)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    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movss  %xmm0,-0x18(%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,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11f6 <fir_highpass+0xd6>
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
sub    -0x24(%rbp),%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
call   1040 <sinc@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1164 <fir_highpass+0x44>
movss  0xe02(%rip),%xmm0
subss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x30,%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
movaps %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>
movaps 0xe9a(%rip),%xmm0
xorps  0x10(%rsp),%xmm0
movaps %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    -0x4(,%rax,4),%r14
ff
add    %r13,%r14
mov    %ecx,%r12d
neg    %r12d
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbp,1),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x10(%rsp),%xmm0
call   1040 <sinc@plt>
mulss  0x20(%rsp),%xmm0
mulss  (%r15,%rbp,4),%xmm0
movss  %xmm0,0x0(%r13,%rbp,4)
movss  %xmm0,(%r14)
add    $0x1,%rbp
add    $0xfffffffffffffffc,%r14
cmp    %rbp,%rbx
jne    11a0 <fir_highpass+0x80>
movss  0xe2d(%rip),%xmm0
subss  0x10(%rsp),%xmm0
movslq 0x4(%rsp),%rax
movss  %xmm0,0x0(%r13,%rax,4)
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(float* %0, float* %1, i32 %2, float %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca float
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store i32 %2, i32* %7
store float %3, float* %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 float, float* %8
%26 = fneg float %25
%27 = load float, float* %8
%28 = load i32, i32* %9
%29 = load i32, i32* %11
%30 = sub nsw i32 %28, %29
%31 = sitofp i32 %30 to float
%32 = fmul float %27, %31
%33 = call float @sinc(float %32)
%34 = fmul float %26, %33
%35 = load float*, float** %6
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float, float* %35, i64 %37
%39 = load float, float* %38
%40 = fmul float %34, %39
%41 = load float*, float** %5
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds float, float* %41, i64 %43
store float %40, float* %44
%45 = load float*, float** %5
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds float, float* %45, i64 %47
%49 = load float, float* %48
%50 = load float*, float** %5
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %50, i64 %52
store float %49, float* %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 float, float* %8
%61 = fsub float 1.000000e+00, %60
%62 = load float*, float** %5
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds float, float* %62, i64 %64
store float %61, float* %65
%66 = load i32, i32* %7
ret i32 %66
}

LLVM IR (-O2):
define i32 @fir_highpass(float* nocapture writeonly %0, float* nocapture %1, i32 returned %2, float %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 float %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 float
%23 = fmul float %22, %3
%24 = tail call float @sinc(float %23)
%25 = fmul float %24, %11
%26 = getelementptr inbounds float, float* %1, i64 %18
%27 = load float, float* %26
%28 = fmul float %25, %27
%29 = getelementptr inbounds float, float* %0, i64 %18
store float %28, float* %29
%30 = getelementptr inbounds float, float* %0, i64 %19
store float %28, float* %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 float 1.000000e+00, %3
%35 = sext i32 %8 to i64
%36 = getelementptr inbounds float, float* %0, i64 %35
store float %34, float* %36
ret i32 %2
}