#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 lsx_bessel_I_0(double);
int /*<<< orphan*/ lsx_debug(char *, int, double, double, double, double);
double *malloc(size_t);
double sin(double);
double sqrt(int);
double *lsx_make_lpf(int num_taps, double Fc, double beta, double rho,
                     double scale) {
  int i, m = num_taps - 1;
  double *h = malloc((size_t)num_taps * sizeof(*h));
  double mult = scale / lsx_bessel_I_0(beta), mult1 = 1 / (.5 * m + rho);
  assert(Fc >= 0 && Fc <= 1);
  lsx_debug("make_lpf(n=%i Fc=%.7g β=%g ρ=%g scale=%g)", num_taps, Fc, beta,
            rho, scale);
  if (h)
    for (i = 0; i <= m / 2; ++i) {
      double z = i - .5 * m, x = z * 3.14159265358979323846, y = z * mult1;
      h[i] = x ? sin(Fc * x) / x : Fc;
      h[i] *= lsx_bessel_I_0(beta * sqrt(1 - y * y)) * mult;
      if (m - i != i)
        h[m - i] = h[i];
    }
  return h;
}


x86 assembly (clang, -O0):
<lsx_make_lpf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
movslq -0x4(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1080 <lsx_bessel_I_0@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe35(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe1d(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x61(%rbp)
jb     1216 <lsx_make_lpf+0xb6>
movsd  0xdf5(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
setae  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
lea    0xddf(%rip),%rdi
call   1030 <lsx_debug@plt>
cmpq   $0x0,-0x38(%rbp)
je     13c5 <lsx_make_lpf+0x265>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
cmp    %ecx,%eax
jg     13c0 <lsx_make_lpf+0x260>
cvtsi2sdl -0x2c(%rbp),%xmm1
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  0xd90(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd73(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12d3 <lsx_make_lpf+0x173>
jp     12d3 <lsx_make_lpf+0x173>
jmp    12f1 <lsx_make_lpf+0x191>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1050 <sin@plt>
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    12fb <lsx_make_lpf+0x19b>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xcb9(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1080 <lsx_bessel_I_0@plt>
mulsd  -0x40(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
sub    -0x2c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     13ad <lsx_make_lpf+0x24d>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13b2 <lsx_make_lpf+0x252>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1258 <lsx_make_lpf+0xf8>
jmp    13c5 <lsx_make_lpf+0x265>
mov    -0x38(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lsx_make_lpf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %edi,%r12d
movslq %edi,%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,%r14
movsd  0x20(%rsp),%xmm0
call   1080 <lsx_bessel_I_0@plt>
xorpd  %xmm1,%xmm1
movsd  0x18(%rsp),%xmm2
ucomisd %xmm1,%xmm2
movsd  0xe51(%rip),%xmm1
setae  %al
ucomisd %xmm2,%xmm1
movsd  %xmm0,0x28(%rsp)
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xe50(%rip),%rdi
mov    %r12d,%esi
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
call   1030 <lsx_debug@plt>
movsd  0x18(%rsp),%xmm1
test   %r14,%r14
je     1340 <lsx_make_lpf+0x1e0>
test   %r12d,%r12d
js     1340 <lsx_make_lpf+0x1e0>
add    $0xffffffff,%r12d
xorps  %xmm3,%xmm3
cvtsi2sd %r12d,%xmm3
movsd  0x10(%rsp),%xmm0
divsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xdca(%rip),%xmm0
mulsd  %xmm3,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  0xdc0(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x30(%rsp)
mov    %r12d,%r15d
shr    $0x1f,%r15d
add    %r12d,%r15d
sar    %r15d
movslq %r12d,%rax
add    $0x1,%r15d
lea    (%r14,%rax,8),%rbx
xor    %ebp,%ebp
mulsd  0xd9c(%rip),%xmm3
movsd  %xmm3,0x38(%rsp)
jmp    129b <lsx_make_lpf+0x13b>
nopl   0x0(%rax)
add    $0x1,%rbp
add    $0xffffffff,%r12d
add    $0xfffffffffffffff8,%rbx
cmp    %rbp,%r15
movsd  0x18(%rsp),%xmm1
je     1340 <lsx_make_lpf+0x1e0>
xorps  %xmm2,%xmm2
cvtsi2sd %ebp,%xmm2
addsd  0x38(%rsp),%xmm2
movapd %xmm2,%xmm3
mulsd  0xd64(%rip),%xmm3
ucomisd 0xd64(%rip),%xmm3
movapd %xmm1,%xmm0
jne    12c4 <lsx_make_lpf+0x164>
jnp    12e9 <lsx_make_lpf+0x189>
movapd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
movsd  %xmm3,0x28(%rsp)
call   1050 <sin@plt>
movsd  0x8(%rsp),%xmm2
divsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0x30(%rsp),%xmm2
mulsd  %xmm2,%xmm2
movsd  0xd07(%rip),%xmm0
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
mulsd  0x20(%rsp),%xmm0
call   1080 <lsx_bessel_I_0@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbp,8)
mov    %r12d,%eax
cmp    %rax,%rbp
je     1280 <lsx_make_lpf+0x120>
movsd  %xmm0,(%rbx)
jmp    1280 <lsx_make_lpf+0x120>
mov    %r14,%rax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"make_lpf(n=%i Fc=%.7g \CE\B2=%g \CF\81=%g scale=%g)\00"
define double* @lsx_make_lpf(i32 %0, double %1, double %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %12
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 8
%24 = call double* @malloc(i64 %23)
store double* %24, double** %13
%25 = load double, double* %10
%26 = load double, double* %8
%27 = call double @lsx_bessel_I_0(double %26)
%28 = fdiv double %25, %27
store double %28, double* %14
%29 = load i32, i32* %12
%30 = sitofp i32 %29 to double
%31 = load double, double* %9
%32 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %30, double %31)
%33 = fdiv double 1.000000e+00, %32
store double %33, double* %15
%34 = load double, double* %7
%35 = fcmp oge double %34, 0.000000e+00
br i1 %35, label %36, label %39
36: ; preds = %5
%37 = load double, double* %7
%38 = fcmp ole double %37, 1.000000e+00
br label %39
39: ; preds = %36, %5
%40 = phi i1 [ false, %5 ], [ %38, %36 ]
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32, i32* %6
%44 = load double, double* %7
%45 = load double, double* %8
%46 = load double, double* %9
%47 = load double, double* %10
%48 = call i32 @lsx_debug(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %43, double %44, double %45, double %46, double %47)
%49 = load double*, double** %13
%50 = icmp ne double* %49, null
br i1 %50, label %51, label %124
51: ; preds = %39
store i32 0, i32* %11
br label %52
52: ; preds = %120, %51
%53 = load i32, i32* %11
%54 = load i32, i32* %12
%55 = sdiv i32 %54, 2
%56 = icmp sle i32 %53, %55
br i1 %56, label %57, label %123
57: ; preds = %52
%58 = load i32, i32* %11
%59 = sitofp i32 %58 to double
%60 = load i32, i32* %12
%61 = sitofp i32 %60 to double
%62 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %61, double %59)
store double %62, double* %16
%63 = load double, double* %16
%64 = fmul double %63, 0x400921FB54442D18
store double %64, double* %17
%65 = load double, double* %16
%66 = load double, double* %15
%67 = fmul double %65, %66
store double %67, double* %18
%68 = load double, double* %17
%69 = fcmp une double %68, 0.000000e+00
br i1 %69, label %70, label %77
70: ; preds = %57
%71 = load double, double* %7
%72 = load double, double* %17
%73 = fmul double %71, %72
%74 = call double @sin(double %73)
%75 = load double, double* %17
%76 = fdiv double %74, %75
br label %79
77: ; preds = %57
%78 = load double, double* %7
br label %79
79: ; preds = %77, %70
%80 = phi double [ %76, %70 ], [ %78, %77 ]
%81 = load double*, double** %13
%82 = load i32, i32* %11
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
store double %80, double* %84
%85 = load double, double* %8
%86 = load double, double* %18
%87 = load double, double* %18
%88 = fneg double %86
%89 = call double @llvm.fmuladd.f64(double %88, double %87, double 1.000000e+00)
%90 = fptosi double %89 to i32
%91 = call double @sqrt(i32 %90)
%92 = fmul double %85, %91
%93 = call double @lsx_bessel_I_0(double %92)
%94 = load double, double* %14
%95 = fmul double %93, %94
%96 = load double*, double** %13
%97 = load i32, i32* %11
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %96, i64 %98
%100 = load double, double* %99
%101 = fmul double %100, %95
store double %101, double* %99
%102 = load i32, i32* %12
%103 = load i32, i32* %11
%104 = sub nsw i32 %102, %103
%105 = load i32, i32* %11
%106 = icmp ne i32 %104, %105
br i1 %106, label %107, label %119
107: ; preds = %79
%108 = load double*, double** %13
%109 = load i32, i32* %11
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds double, double* %108, i64 %110
%112 = load double, double* %111
%113 = load double*, double** %13
%114 = load i32, i32* %12
%115 = load i32, i32* %11
%116 = sub nsw i32 %114, %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %113, i64 %117
store double %112, double* %118
br label %119
119: ; preds = %107, %79
br label %120
120: ; preds = %119
%121 = load i32, i32* %11
%122 = add nsw i32 %121, 1
store i32 %122, i32* %11
br label %52
123: ; preds = %52
br label %124
124: ; preds = %123, %39
%125 = load double*, double** %13
ret double* %125
}

LLVM IR (-O2):
@.str = [44 x i8] c"make_lpf(n=%i Fc=%.7g \CE\B2=%g \CF\81=%g scale=%g)\00"
define noalias double* @lsx_make_lpf(i32 %0, double %1, double %2, double %3, double %4) {
%6 = add nsw i32 %0, -1
%7 = sext i32 %0 to i64
%8 = shl nsw i64 %7, 3
%9 = tail call double* @malloc(i64 %8)
%10 = tail call double @lsx_bessel_I_0(double %2)
%11 = fdiv double %4, %10
%12 = sitofp i32 %6 to double
%13 = tail call double @llvm.fmuladd.f64(double %12, double 5.000000e-01, double %3)
%14 = fdiv double 1.000000e+00, %13
%15 = fcmp oge double %1, 0.000000e+00
%16 = fcmp ole double %1, 1.000000e+00
%17 = and i1 %15, %16
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = tail call i32 @lsx_debug(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %0, double %1, double %2, double %3, double %4)
%21 = icmp eq double* %9, null
%22 = icmp slt i32 %0, 0
%23 = or i1 %21, %22
br i1 %23, label %61, label %24
24: ; preds = %5
%25 = sdiv i32 %6, 2
%26 = sext i32 %6 to i64
%27 = add nuw nsw i32 %25, 1
%28 = zext i32 %27 to i64
br label %29
29: ; preds = %24, %58
%30 = phi i64 [ 0, %24 ], [ %59, %58 ]
%31 = trunc i64 %30 to i32
%32 = sitofp i32 %31 to double
%33 = tail call double @llvm.fmuladd.f64(double %12, double -5.000000e-01, double %32)
%34 = fmul double %33, 0x400921FB54442D18
%35 = fmul double %14, %33
%36 = fcmp une double %34, 0.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %29
%38 = fmul double %34, %1
%39 = tail call double @sin(double %38)
%40 = fdiv double %39, %34
br label %41
41: ; preds = %29, %37
%42 = phi double [ %40, %37 ], [ %1, %29 ]
%43 = getelementptr inbounds double, double* %9, i64 %30
%44 = fneg double %35
%45 = tail call double @llvm.fmuladd.f64(double %44, double %35, double 1.000000e+00)
%46 = fptosi double %45 to i32
%47 = tail call double @sqrt(i32 %46)
%48 = fmul double %47, %2
%49 = tail call double @lsx_bessel_I_0(double %48)
%50 = fmul double %11, %49
%51 = fmul double %42, %50
store double %51, double* %43
%52 = sub nsw i32 %6, %31
%53 = zext i32 %52 to i64
%54 = icmp eq i64 %30, %53
br i1 %54, label %58, label %55
55: ; preds = %41
%56 = sub nsw i64 %26, %30
%57 = getelementptr inbounds double, double* %9, i64 %56
store double %51, double* %57
br label %58
58: ; preds = %55, %41
%59 = add nuw nsw i64 %30, 1
%60 = icmp eq i64 %59, %28
br i1 %60, label %61, label %29
61: ; preds = %58, %5
ret double* %9
}