; LLVM IR from TobiasKozel/VAE :: external/portaudio/qa/loopback/src (biquad_filter)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.BiquadFilter_s = type { double, double, double, double, double, double, double, double, double, double, double, double }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden void @BiquadFilter_CalculateCommon(ptr noundef, double noundef, double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @BiquadFilter_SetupNotch(ptr noundef %0, double noundef %1, double noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %9 = load double, ptr %5, align 8, !tbaa !9
  %10 = fcmp olt double %9, 0x3EB0C6F7A0B5ED8D
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  store double 0x3EB0C6F7A0B5ED8D, ptr %5, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %11, %3
  %13 = load double, ptr %6, align 8, !tbaa !9
  %14 = fcmp olt double %13, 1.000000e-05
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store double 1.000000e-05, ptr %6, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %15, %12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load double, ptr %5, align 8, !tbaa !9
  %19 = load double, ptr %6, align 8, !tbaa !9
  call void @BiquadFilter_CalculateCommon(ptr noundef %17, double noundef %18, double noundef %19)
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.BiquadFilter_s, ptr %20, i32 0, i32 11
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = fadd double 1.000000e+00, %22
  %24 = fdiv double 1.000000e+00, %23
  store double %24, ptr %7, align 8, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.BiquadFilter_s, ptr %25, i32 0, i32 9
  %27 = load double, ptr %26, align 8, !tbaa !13
  %28 = fadd double 1.000000e+00, %27
  store double %28, ptr %8, align 8, !tbaa !9
  %29 = load double, ptr %7, align 8, !tbaa !9
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.BiquadFilter_s, ptr %30, i32 0, i32 4
  store double %29, ptr %31, align 8, !tbaa !14
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.BiquadFilter_s, ptr %32, i32 0, i32 9
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = fmul double -2.000000e+00, %34
  %36 = load double, ptr %7, align 8, !tbaa !9
  %37 = fmul double %35, %36
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.BiquadFilter_s, ptr %38, i32 0, i32 5
  store double %37, ptr %39, align 8, !tbaa !15
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.BiquadFilter_s, ptr %40, i32 0, i32 4
  %42 = load double, ptr %41, align 8, !tbaa !14
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.BiquadFilter_s, ptr %43, i32 0, i32 6
  store double %42, ptr %44, align 8, !tbaa !16
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.BiquadFilter_s, ptr %45, i32 0, i32 5
  %47 = load double, ptr %46, align 8, !tbaa !15
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.BiquadFilter_s, ptr %48, i32 0, i32 7
  store double %47, ptr %49, align 8, !tbaa !17
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.BiquadFilter_s, ptr %50, i32 0, i32 11
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = fsub double 1.000000e+00, %52
  %54 = load double, ptr %7, align 8, !tbaa !9
  %55 = fmul double %53, %54
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.BiquadFilter_s, ptr %56, i32 0, i32 8
  store double %55, ptr %57, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 88}
!12 = !{!"BiquadFilter_s", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88}
!13 = !{!12, !10, i64 72}
!14 = !{!12, !10, i64 32}
!15 = !{!12, !10, i64 40}
!16 = !{!12, !10, i64 48}
!17 = !{!12, !10, i64 56}
!18 = !{!12, !10, i64 64}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
declare hidden void @BiquadFilter_CalculateCommon(ptr noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @BiquadFilter_SetupNotch(ptr noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = fcmp olt double %1, 0x3EB0C6F7A0B5ED8D
  %.0 = select i1 %4, double 0x3EB0C6F7A0B5ED8D, double %1
  %5 = fcmp olt double %2, 1.000000e-05
  %.019 = select i1 %5, double 1.000000e-05, double %2
  tail call void @BiquadFilter_CalculateCommon(ptr noundef %0, double noundef %.0, double noundef %.019)
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = fadd double %7, 1.000000e+00
  %9 = fdiv double 1.000000e+00, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 72
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store double %9, ptr %11, align 8, !tbaa !10
  %12 = load double, ptr %10, align 8, !tbaa !11
  %13 = fmul double %12, -2.000000e+00
  %14 = fmul double %9, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  store double %14, ptr %15, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  store double %9, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  store double %14, ptr %17, align 8, !tbaa !14
  %18 = fsub double 1.000000e+00, %7
  %19 = fmul double %18, %9
  %20 = getelementptr inbounds i8, ptr %0, i64 64
  store double %19, ptr %20, align 8, !tbaa !15
  ret void
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 88}
!6 = !{!"BiquadFilter_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 32}
!11 = !{!6, !7, i64 72}
!12 = !{!6, !7, i64 40}
!13 = !{!6, !7, i64 48}
!14 = !{!6, !7, i64 56}
!15 = !{!6, !7, i64 64}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass