; 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: nounwind uwtable
define dso_local void @BiquadFilter_SetupHighPass(ptr noundef %0, double noundef %1, double noundef %2) #0 {
  %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 %8, align 8, !tbaa !9
  %30 = fmul double %29, 5.000000e-01
  %31 = load double, ptr %7, align 8, !tbaa !9
  %32 = fmul double %30, %31
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.BiquadFilter_s, ptr %33, i32 0, i32 4
  store double %32, ptr %34, align 8, !tbaa !14
  %35 = load double, ptr %8, align 8, !tbaa !9
  %36 = fneg double %35
  %37 = load double, ptr %7, align 8, !tbaa !9
  %38 = fmul double %36, %37
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.BiquadFilter_s, ptr %39, i32 0, i32 5
  store double %38, ptr %40, align 8, !tbaa !15
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.BiquadFilter_s, ptr %41, i32 0, i32 4
  %43 = load double, ptr %42, align 8, !tbaa !14
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.BiquadFilter_s, ptr %44, i32 0, i32 6
  store double %43, ptr %45, align 8, !tbaa !16
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.BiquadFilter_s, ptr %46, i32 0, i32 9
  %48 = load double, ptr %47, align 8, !tbaa !13
  %49 = fmul double -2.000000e+00, %48
  %50 = load double, ptr %7, align 8, !tbaa !9
  %51 = fmul double %49, %50
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.BiquadFilter_s, ptr %52, i32 0, i32 7
  store double %51, ptr %53, align 8, !tbaa !17
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.BiquadFilter_s, ptr %54, i32 0, i32 11
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = fsub double 1.000000e+00, %56
  %58 = load double, ptr %7, align 8, !tbaa !9
  %59 = fmul double %57, %58
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.BiquadFilter_s, ptr %60, i32 0, i32 8
  store double %59, ptr %61, 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
}

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

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

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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
define dso_local void @BiquadFilter_SetupHighPass(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
  %.021 = select i1 %5, double 1.000000e-05, double %2
  tail call void @BiquadFilter_CalculateCommon(ptr noundef %0, double noundef %.0, double noundef %.021)
  %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 = load double, ptr %10, align 8, !tbaa !10
  %12 = fadd double %11, 1.000000e+00
  %13 = fmul double %12, 5.000000e-01
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = fneg double %12
  %16 = insertelement <2 x double> poison, double %9, i64 0
  %17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
  %18 = insertelement <2 x double> poison, double %13, i64 0
  %19 = insertelement <2 x double> %18, double %15, i64 1
  %20 = fmul <2 x double> %17, %19
  store <2 x double> %20, ptr %14, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  %22 = extractelement <2 x double> %20, i64 0
  store double %22, ptr %21, align 8, !tbaa !12
  %23 = fmul double %11, -2.000000e+00
  %24 = fmul double %23, %9
  %25 = getelementptr inbounds i8, ptr %0, i64 56
  store double %24, ptr %25, align 8, !tbaa !13
  %26 = fsub double 1.000000e+00, %7
  %27 = fmul double %26, %9
  %28 = getelementptr inbounds i8, ptr %0, i64 64
  store double %27, ptr %28, align 8, !tbaa !14
  ret void
}

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

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 72}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 48}
!13 = !{!6, !7, i64 56}
!14 = !{!6, !7, i64 64}


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