#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 M_PI;
double exp(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double, double);
double pow(int, double);
int /*<<< orphan*/ stderr;
void lowShelfCoefficients(int gain, double frequency, double F_s, double *b0,
                          double *b1, double *a1) {
  double f1, f2;
  if (gain == 0) {
    *b0 = 1;
    *b1 = 0;
    *a1 = 0;
    return;
  }
  if (gain > 0) {
    f2 = frequency;
    f1 = f2 * pow(10, (double)(gain) / 20);
  } else {
    f1 = frequency;
    f2 = f1 * pow(10, (double)(-gain) / 20);
  }
  fprintf(stderr, "f1=%lf, f2=%lf\n", f1, f2);
  *b0 = -1;
  *b1 = exp(-2 * M_PI * f2 / F_s);
  *a1 = -exp(-2 * M_PI * f1 / F_s);
}


x86 assembly (clang, -O0):
<lowShelfCoefficients>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1186 <lowShelfCoefficients+0x56>
mov    -0x20(%rbp),%rax
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12b7 <lowShelfCoefficients+0x187>
cmpl   $0x0,-0x4(%rbp)
jle    11d5 <lowShelfCoefficients+0xa5>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe4f(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xa,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1219 <lowShelfCoefficients+0xe9>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe06(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xa,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xde5(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
movsd  0xdc4(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    0x2d99(%rip),%rax
imul   $0xfffffffe,(%rax),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <exp@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x2d6d(%rip),%rax
imul   $0xfffffffe,(%rax),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <exp@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lowShelfCoefficients>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
test   %edi,%edi
je     117d <lowShelfCoefficients+0x4d>
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
jle    119a <lowShelfCoefficients+0x6a>
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
divsd  0xe9d(%rip),%xmm0
mov    $0xa,%edi
call   1050 <pow@plt>
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm2
jmp    11c3 <lowShelfCoefficients+0x93>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rbx)
movq   $0x0,(%r15)
xorpd  %xmm0,%xmm0
jmp    124d <lowShelfCoefficients+0x11d>
neg    %edi
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
divsd  0xe55(%rip),%xmm0
mov    $0xa,%edi
call   1050 <pow@plt>
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movapd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
movapd %xmm2,%xmm0
call   1030 <fprintf@plt>
movabs $0xbff0000000000000,%rax
mov    %rax,(%rbx)
mov    0x2dec(%rip),%rbx
mov    (%rbx),%eax
add    %eax,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <exp@plt>
movsd  %xmm0,(%r15)
mov    (%rbx),%eax
add    %eax,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <exp@plt>
xorpd  0xdc3(%rip),%xmm0
movsd  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"f1=%lf, f2=%lf\0A\00"
@M_PI = global i32 0
define void @lowShelfCoefficients(i32 %0, double %1, double %2, double* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca double
store i32 %0, i32* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %6
%18 = load double*, double** %10
store double 1.000000e+00, double* %18
%19 = load double*, double** %11
store double 0.000000e+00, double* %19
%20 = load double*, double** %12
store double 0.000000e+00, double* %20
br label %68
21: ; preds = %6
%22 = load i32, i32* %7
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %21
%25 = load double, double* %8
store double %25, double* %14
%26 = load double, double* %14
%27 = load i32, i32* %7
%28 = sitofp i32 %27 to double
%29 = fdiv double %28, 2.000000e+01
%30 = call double @pow(i32 10, double %29)
%31 = fmul double %26, %30
store double %31, double* %13
br label %41
32: ; preds = %21
%33 = load double, double* %8
store double %33, double* %13
%34 = load double, double* %13
%35 = load i32, i32* %7
%36 = sub nsw i32 0, %35
%37 = sitofp i32 %36 to double
%38 = fdiv double %37, 2.000000e+01
%39 = call double @pow(i32 10, double %38)
%40 = fmul double %34, %39
store double %40, double* %14
br label %41
41: ; preds = %32, %24
%42 = load i32, i32* @stderr
%43 = load double, double* %13
%44 = load double, double* %14
%45 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %43, double %44)
%46 = load double*, double** %10
store double -1.000000e+00, double* %46
%47 = load i32, i32* @M_PI
%48 = mul nsw i32 -2, %47
%49 = sitofp i32 %48 to double
%50 = load double, double* %14
%51 = fmul double %49, %50
%52 = load double, double* %9
%53 = fdiv double %51, %52
%54 = fptosi double %53 to i32
%55 = call double @exp(i32 %54)
%56 = load double*, double** %11
store double %55, double* %56
%57 = load i32, i32* @M_PI
%58 = mul nsw i32 -2, %57
%59 = sitofp i32 %58 to double
%60 = load double, double* %13
%61 = fmul double %59, %60
%62 = load double, double* %9
%63 = fdiv double %61, %62
%64 = fptosi double %63 to i32
%65 = call double @exp(i32 %64)
%66 = fneg double %65
%67 = load double*, double** %12
store double %66, double* %67
br label %68
68: ; preds = %41, %17
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"f1=%lf, f2=%lf\0A\00"
@M_PI = global i32 0
define void @lowShelfCoefficients(i32 %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = icmp eq i32 %0, 0
br i1 %7, label %8, label %9
8: ; preds = %6
store double 1.000000e+00, double* %3
store double 0.000000e+00, double* %4
br label %42
9: ; preds = %6
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %16
11: ; preds = %9
%12 = sitofp i32 %0 to double
%13 = fdiv double %12, 2.000000e+01
%14 = tail call double @pow(i32 10, double %13)
%15 = fmul double %14, %1
br label %22
16: ; preds = %9
%17 = sub nsw i32 0, %0
%18 = sitofp i32 %17 to double
%19 = fdiv double %18, 2.000000e+01
%20 = tail call double @pow(i32 10, double %19)
%21 = fmul double %20, %1
br label %22
22: ; preds = %16, %11
%23 = phi double [ %15, %11 ], [ %1, %16 ]
%24 = phi double [ %1, %11 ], [ %21, %16 ]
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %23, double %24)
store double -1.000000e+00, double* %3
%27 = load i32, i32* @M_PI
%28 = mul nsw i32 %27, -2
%29 = sitofp i32 %28 to double
%30 = fmul double %24, %29
%31 = fdiv double %30, %2
%32 = fptosi double %31 to i32
%33 = tail call double @exp(i32 %32)
store double %33, double* %4
%34 = load i32, i32* @M_PI
%35 = mul nsw i32 %34, -2
%36 = sitofp i32 %35 to double
%37 = fmul double %23, %36
%38 = fdiv double %37, %2
%39 = fptosi double %38 to i32
%40 = tail call double @exp(i32 %39)
%41 = fneg double %40
br label %42
42: ; preds = %22, %8
%43 = phi double [ %41, %22 ], [ 0.000000e+00, %8 ]
store double %43, double* %5
ret void
}