#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*/ memset(double *, int /*<<< orphan*/, int);
void specFilter(double *freqBuff, int sampleRate, int lowpassFreq,
                int specLen) {
  int lowpass, xlowpass;
  lowpass = (lowpassFreq * specLen) / (sampleRate >> 1) + 1;
  xlowpass = (lowpass < specLen) ? lowpass : specLen;
  memset(freqBuff + xlowpass, 0, (specLen - xlowpass) * sizeof(double));
}


x86 assembly (clang, -O0):
<specFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    $0x1,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1152 <specFilter+0x42>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1158 <specFilter+0x48>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x14(%rbp),%eax
sub    -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<specFilter>:
mov    %edx,%eax
imul   %ecx,%eax
sar    %esi
cltd
idiv   %esi
add    $0x1,%eax
cmp    %ecx,%eax
cmovge %ecx,%eax
cltq
lea    (%rdi,%rax,8),%rdi
sub    %eax,%ecx
lea    0x0(,%rcx,8),%edx
xor    %esi,%esi
jmp    1030 <memset@plt>

LLVM IR (-O0):
define void @specFilter(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %7
%12 = load i32, i32* %8
%13 = mul nsw i32 %11, %12
%14 = load i32, i32* %6
%15 = ashr i32 %14, 1
%16 = sdiv i32 %13, %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %4
%22 = load i32, i32* %9
br label %25
23: ; preds = %4
%24 = load i32, i32* %8
br label %25
25: ; preds = %23, %21
%26 = phi i32 [ %22, %21 ], [ %24, %23 ]
store i32 %26, i32* %10
%27 = load double*, double** %5
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load i32, i32* %8
%32 = load i32, i32* %10
%33 = sub nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 8
%36 = trunc i64 %35 to i32
%37 = call i32 @memset(double* %30, i32 0, i32 %36)
ret void
}

LLVM IR (-O2):
define void @specFilter(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = mul nsw i32 %3, %2
%6 = ashr i32 %1, 1
%7 = sdiv i32 %5, %6
%8 = add nsw i32 %7, 1
%9 = icmp slt i32 %8, %3
%10 = select i1 %9, i32 %8, i32 %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = sub nsw i32 %3, %10
%14 = shl i32 %13, 3
%15 = tail call i32 @memset(double* %12, i32 0, i32 %14)
ret void
}