#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ lowShelfCoefficients(int, int, int, double *, double *,
                                        double *);
int /*<<< orphan*/ printf(char *, double);
int scanf(char *, double *);
int /*<<< orphan*/ stderr;
int main(void) {
  unsigned long samples_processed = 0;
  double b0, b1, a1, x, xprev, y, yprev;
  lowShelfCoefficients((12), 300, 44100, &b0, &b1, &a1);
  xprev = yprev = 0;
  fprintf(stderr, "Coefficients:\n");
  fprintf(stderr, "b0=%lf\nb1=%lf\na1=%lf\n", b0, b1, a1);
  while (scanf("%lf", &x) == 1) {
    y = b0 * x + b1 * xprev + a1 * yprev;
    xprev = x;
    yprev = y;
    printf("%lf\n", y);
    if (++samples_processed % 44100 == 0) {
      fprintf(stderr, "%lu seconds processed\n", samples_processed / 44100);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0xc,%edi
mov    $0x12c,%esi
mov    $0xac44,%edx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1040 <lowShelfCoefficients@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xe52(%rip),%rsi
mov    $0x3,%al
call   1050 <fprintf@plt>
lea    0xe5a(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1282 <main+0x142>
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    $0xac44,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    127d <main+0x13d>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    $0xac44,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11c4 <main+0x84>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0x20(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x10(%rsp),%r9
mov    $0xc,%edi
mov    $0x12c,%esi
mov    $0xac44,%edx
call   1040 <lowShelfCoefficients@plt>
mov    0x2e68(%rip),%rbx
mov    (%rbx),%edi
lea    0xe7f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe6c(%rip),%rsi
mov    $0x3,%al
call   1050 <fprintf@plt>
lea    0xe74(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    128a <main+0x14a>
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
lea    0xe4c(%rip),%r14
lea    0xe4a(%rip),%r12
lea    0x8(%rsp),%r13
xorpd  %xmm2,%xmm2
jmp    1210 <main+0xd0>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
cmp    $0x1,%eax
movsd  0x30(%rsp),%xmm0
movsd  0x28(%rsp),%xmm2
jne    128a <main+0x14a>
mov    %rbx,%rax
movabs $0x17c6f8c751f176dd,%rcx
f8 c6 17
mul    %rcx
mov    %rdx,%rbp
shr    $0xc,%rbp
imul   $0xac44,%rbp,%r15
movsd  0x8(%rsp),%xmm3
mulsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
movsd  %xmm3,0x28(%rsp)
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
mov    %r14,%rdi
movsd  %xmm0,0x30(%rsp)
call   1030 <printf@plt>
cmp    %r15,%rbx
jne    11f0 <main+0xb0>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11f0 <main+0xb0>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"Coefficients:\0A\00"
@.str.1 = [22 x i8] c"b0=%lf\0Ab1=%lf\0Aa1=%lf\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [5 x i8] c"%lf\0A\00"
@.str.4 = [23 x i8] c"%lu seconds processed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
store i64 0, i64* %2
%10 = call i32 @lowShelfCoefficients(i32 12, i32 300, i32 44100, double* %3, double* %4, double* %5)
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %7
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = load double, double* %3
%15 = load double, double* %4
%16 = load double, double* %5
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %14, double %15, double %16)
br label %18
18: ; preds = %44, %0
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %6)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %45
21: ; preds = %18
%22 = load double, double* %3
%23 = load double, double* %6
%24 = load double, double* %4
%25 = load double, double* %7
%26 = fmul double %24, %25
%27 = call double @llvm.fmuladd.f64(double %22, double %23, double %26)
%28 = load double, double* %5
%29 = load double, double* %9
%30 = call double @llvm.fmuladd.f64(double %28, double %29, double %27)
store double %30, double* %8
%31 = load double, double* %6
store double %31, double* %7
%32 = load double, double* %8
store double %32, double* %9
%33 = load double, double* %8
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %33)
%35 = load i64, i64* %2
%36 = add i64 %35, 1
store i64 %36, i64* %2
%37 = urem i64 %36, 44100
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %21
%40 = load i32, i32* @stderr
%41 = load i64, i64* %2
%42 = udiv i64 %41, 44100
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 %42)
br label %44
44: ; preds = %39, %21
br label %18
45: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"Coefficients:\0A\00"
@.str.1 = [22 x i8] c"b0=%lf\0Ab1=%lf\0Aa1=%lf\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [5 x i8] c"%lf\0A\00"
@.str.4 = [23 x i8] c"%lu seconds processed\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = call i32 @lowShelfCoefficients(i32 12, i32 300, i32 44100, double* %1, double* %2, double* %3)
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = load double, double* %1
%14 = load double, double* %2
%15 = load double, double* %3
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %13, double %14, double %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %41
19: ; preds = %0, %38
%20 = phi double [ %29, %38 ], [ 0.000000e+00, %0 ]
%21 = phi i64 [ %31, %38 ], [ 0, %0 ]
%22 = phi double [ %24, %38 ], [ 0.000000e+00, %0 ]
%23 = load double, double* %1
%24 = load double, double* %4
%25 = load double, double* %2
%26 = fmul double %22, %25
%27 = call double @llvm.fmuladd.f64(double %23, double %24, double %26)
%28 = load double, double* %3
%29 = call double @llvm.fmuladd.f64(double %28, double %20, double %27)
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = add i64 %21, 1
%32 = urem i64 %31, 44100
%33 = udiv i64 %31, 44100
%34 = icmp eq i64 %32, 0
br i1 %34, label %35, label %38
35: ; preds = %19
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 %33)
br label %38
38: ; preds = %35, %19
%39 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%40 = icmp eq i32 %39, 1
br i1 %40, label %19, label %41
41: ; preds = %38, %0
ret i32 0
}