#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 Izero(double);
double sin(double);
double sqrt(double);
void LpFilter(double c[], int N, double frq, double Beta, int Num) {
  double IBeta, temp, inm1;
  int i;
  c[0] = 2.0 * frq;
  for (i = 1; i < N; i++) {
    temp = (3.14159265358979232846) * (double)i / (double)Num;
    c[i] = sin(2.0 * temp * frq) / temp;
  }
  IBeta = 1.0 / Izero(Beta);
  inm1 = 1.0 / ((double)(N - 1));
  for (i = 1; i < N; i++) {
    temp = (double)i * inm1;
    c[i] *= Izero(Beta * sqrt(1.0 - temp * temp)) * IBeta;
  }
}


x86 assembly (clang, -O0):
<LpFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movsd  0xeac(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ca <LpFilter+0x9a>
cvtsi2sdl -0x44(%rbp),%xmm1
movsd  0xe8f(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe65(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
divsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1168 <LpFilter+0x38>
movsd  -0x20(%rbp),%xmm0
call   1030 <Izero@plt>
movaps %xmm0,%xmm1
movsd  0xe29(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe0e(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    129b <LpFilter+0x16b>
cvtsi2sdl -0x44(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdac(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <Izero@plt>
mulsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    120a <LpFilter+0xda>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LpFilter>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm1,0x18(%rsp)
movapd %xmm0,%xmm1
mov    %esi,%r14d
mov    %rdi,%rbx
addsd  %xmm0,%xmm0
movsd  %xmm0,(%rdi)
mov    %esi,%r15d
cmp    $0x2,%esi
jl     11c2 <LpFilter+0x92>
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    $0x1,%ebp
movsd  %xmm1,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe71(%rip),%xmm0
divsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  0x8(%rsp),%xmm1
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1180 <LpFilter+0x50>
movsd  0x18(%rsp),%xmm0
call   1030 <Izero@plt>
cmp    $0x2,%r14d
jl     1266 <LpFilter+0x136>
add    $0xffffffff,%r14d
movsd  0xe25(%rip),%xmm2
movapd %xmm2,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
divsd  %xmm0,%xmm3
movsd  %xmm3,0x10(%rsp)
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    $0x1,%ebp
jmp    1239 <LpFilter+0x109>
nopw   0x0(%rax,%rax,1)
call   1050 <sqrt@plt>
mulsd  0x18(%rsp),%xmm0
call   1030 <Izero@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
je     1266 <LpFilter+0x136>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xdb6(%rip),%xmm0
subsd  %xmm1,%xmm0
ucomisd 0xdb2(%rip),%xmm0
jb     1210 <LpFilter+0xe0>
sqrtsd %xmm0,%xmm0
jmp    1215 <LpFilter+0xe5>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @LpFilter(double* %0, i32 %1, double %2, double %3, i32 %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
%15 = load double, double* %8
%16 = fmul double 2.000000e+00, %15
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 0
store double %16, double* %18
store i32 1, i32* %14
br label %19
19: ; preds = %41, %5
%20 = load i32, i32* %14
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %44
23: ; preds = %19
%24 = load i32, i32* %14
%25 = sitofp i32 %24 to double
%26 = fmul double 0x400921FB54442D16, %25
%27 = load i32, i32* %10
%28 = sitofp i32 %27 to double
%29 = fdiv double %26, %28
store double %29, double* %12
%30 = load double, double* %12
%31 = fmul double 2.000000e+00, %30
%32 = load double, double* %8
%33 = fmul double %31, %32
%34 = call double @sin(double %33)
%35 = load double, double* %12
%36 = fdiv double %34, %35
%37 = load double*, double** %6
%38 = load i32, i32* %14
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %36, double* %40
br label %41
41: ; preds = %23
%42 = load i32, i32* %14
%43 = add nsw i32 %42, 1
store i32 %43, i32* %14
br label %19
44: ; preds = %19
%45 = load double, double* %9
%46 = call double @Izero(double %45)
%47 = fdiv double 1.000000e+00, %46
store double %47, double* %11
%48 = load i32, i32* %7
%49 = sub nsw i32 %48, 1
%50 = sitofp i32 %49 to double
%51 = fdiv double 1.000000e+00, %50
store double %51, double* %13
store i32 1, i32* %14
br label %52
52: ; preds = %77, %44
%53 = load i32, i32* %14
%54 = load i32, i32* %7
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %80
56: ; preds = %52
%57 = load i32, i32* %14
%58 = sitofp i32 %57 to double
%59 = load double, double* %13
%60 = fmul double %58, %59
store double %60, double* %12
%61 = load double, double* %9
%62 = load double, double* %12
%63 = load double, double* %12
%64 = fneg double %62
%65 = call double @llvm.fmuladd.f64(double %64, double %63, double 1.000000e+00)
%66 = call double @sqrt(double %65)
%67 = fmul double %61, %66
%68 = call double @Izero(double %67)
%69 = load double, double* %11
%70 = fmul double %68, %69
%71 = load double*, double** %6
%72 = load i32, i32* %14
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
%76 = fmul double %75, %70
store double %76, double* %74
br label %77
77: ; preds = %56
%78 = load i32, i32* %14
%79 = add nsw i32 %78, 1
store i32 %79, i32* %14
br label %52
80: ; preds = %52
ret void
}

LLVM IR (-O2):
define void @LpFilter(double* nocapture %0, i32 %1, double %2, double %3, i32 %4) {
%6 = fmul double %2, 2.000000e+00
store double %6, double* %0
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = sitofp i32 %4 to double
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 1, %8 ], [ %22, %11 ]
%13 = trunc i64 %12 to i32
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 0x400921FB54442D16
%16 = fdiv double %15, %9
%17 = fmul double %16, 2.000000e+00
%18 = fmul double %17, %2
%19 = tail call double @sin(double %18)
%20 = fdiv double %19, %16
%21 = getelementptr inbounds double, double* %0, i64 %12
store double %20, double* %21
%22 = add nuw nsw i64 %12, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %24, label %11
24: ; preds = %11, %5
%25 = tail call double @Izero(double %3)
%26 = fdiv double 1.000000e+00, %25
%27 = add nsw i32 %1, -1
%28 = sitofp i32 %27 to double
%29 = fdiv double 1.000000e+00, %28
br i1 %7, label %30, label %48
30: ; preds = %24
%31 = zext i32 %1 to i64
br label %32
32: ; preds = %30, %32
%33 = phi i64 [ 1, %30 ], [ %46, %32 ]
%34 = trunc i64 %33 to i32
%35 = sitofp i32 %34 to double
%36 = fmul double %29, %35
%37 = fneg double %36
%38 = tail call double @llvm.fmuladd.f64(double %37, double %36, double 1.000000e+00)
%39 = tail call double @sqrt(double %38)
%40 = fmul double %39, %3
%41 = tail call double @Izero(double %40)
%42 = fmul double %26, %41
%43 = getelementptr inbounds double, double* %0, i64 %33
%44 = load double, double* %43
%45 = fmul double %44, %42
store double %45, double* %43
%46 = add nuw nsw i64 %33, 1
%47 = icmp eq i64 %46, %31
br i1 %47, label %48, label %32
48: ; preds = %32, %24
ret void
}