; 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: 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_Filter(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.BiquadFilter_s, ptr %21, i32 0, i32 4
  %23 = load double, ptr %22, align 8, !tbaa !11
  store double %23, ptr %12, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.BiquadFilter_s, ptr %24, i32 0, i32 5
  %26 = load double, ptr %25, align 8, !tbaa !15
  store double %26, ptr %13, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.BiquadFilter_s, ptr %27, i32 0, i32 6
  %29 = load double, ptr %28, align 8, !tbaa !16
  store double %29, ptr %14, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.BiquadFilter_s, ptr %30, i32 0, i32 7
  %32 = load double, ptr %31, align 8, !tbaa !17
  store double %32, ptr %15, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.BiquadFilter_s, ptr %33, i32 0, i32 8
  %35 = load double, ptr %34, align 8, !tbaa !18
  store double %35, ptr %16, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.BiquadFilter_s, ptr %36, i32 0, i32 0
  %38 = load double, ptr %37, align 8, !tbaa !19
  store double %38, ptr %17, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.BiquadFilter_s, ptr %39, i32 0, i32 1
  %41 = load double, ptr %40, align 8, !tbaa !20
  store double %41, ptr %18, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.BiquadFilter_s, ptr %42, i32 0, i32 2
  %44 = load double, ptr %43, align 8, !tbaa !21
  store double %44, ptr %19, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.BiquadFilter_s, ptr %45, i32 0, i32 3
  %47 = load double, ptr %46, align 8, !tbaa !22
  store double %47, ptr %20, align 8, !tbaa !14
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %95, %4
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %52, label %98

52:                                               ; preds = %48
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %53, i64 %55
  %57 = load float, ptr %56, align 4, !tbaa !23
  %58 = fpext float %57 to double
  store double %58, ptr %10, align 8, !tbaa !14
  %59 = load double, ptr %12, align 8, !tbaa !14
  %60 = load double, ptr %10, align 8, !tbaa !14
  %61 = load double, ptr %13, align 8, !tbaa !14
  %62 = load double, ptr %17, align 8, !tbaa !14
  %63 = fmul double %61, %62
  %64 = call double @llvm.fmuladd.f64(double %59, double %60, double %63)
  %65 = load double, ptr %14, align 8, !tbaa !14
  %66 = load double, ptr %18, align 8, !tbaa !14
  %67 = call double @llvm.fmuladd.f64(double %65, double %66, double %64)
  %68 = load double, ptr %15, align 8, !tbaa !14
  %69 = load double, ptr %19, align 8, !tbaa !14
  %70 = fneg double %68
  %71 = call double @llvm.fmuladd.f64(double %70, double %69, double %67)
  %72 = load double, ptr %16, align 8, !tbaa !14
  %73 = load double, ptr %20, align 8, !tbaa !14
  %74 = fneg double %72
  %75 = call double @llvm.fmuladd.f64(double %74, double %73, double %71)
  store double %75, ptr %11, align 8, !tbaa !14
  %76 = load double, ptr %11, align 8, !tbaa !14
  %77 = fptrunc double %76 to float
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = load i32, ptr %9, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds float, ptr %78, i64 %80
  store float %77, ptr %81, align 4, !tbaa !23
  %82 = load double, ptr %17, align 8, !tbaa !14
  store double %82, ptr %18, align 8, !tbaa !14
  %83 = load double, ptr %10, align 8, !tbaa !14
  store double %83, ptr %17, align 8, !tbaa !14
  %84 = load double, ptr %19, align 8, !tbaa !14
  store double %84, ptr %20, align 8, !tbaa !14
  %85 = load double, ptr %11, align 8, !tbaa !14
  store double %85, ptr %19, align 8, !tbaa !14
  %86 = load i32, ptr %9, align 4, !tbaa !9
  %87 = and i32 %86, 7
  %88 = icmp eq i32 %87, 0
  br i1 %88, label %89, label %94

89:                                               ; preds = %52
  %90 = load double, ptr %19, align 8, !tbaa !14
  %91 = fadd double %90, 1.000000e-26
  store double %91, ptr %19, align 8, !tbaa !14
  %92 = load double, ptr %20, align 8, !tbaa !14
  %93 = fsub double %92, 1.000000e-26
  store double %93, ptr %20, align 8, !tbaa !14
  br label %94

94:                                               ; preds = %89, %52
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %9, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %9, align 4, !tbaa !9
  br label %48, !llvm.loop !25

98:                                               ; preds = %48
  %99 = load double, ptr %17, align 8, !tbaa !14
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.BiquadFilter_s, ptr %100, i32 0, i32 0
  store double %99, ptr %101, align 8, !tbaa !19
  %102 = load double, ptr %18, align 8, !tbaa !14
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.BiquadFilter_s, ptr %103, i32 0, i32 1
  store double %102, ptr %104, align 8, !tbaa !20
  %105 = load double, ptr %19, align 8, !tbaa !14
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.BiquadFilter_s, ptr %106, i32 0, i32 2
  store double %105, ptr %107, align 8, !tbaa !21
  %108 = load double, ptr %20, align 8, !tbaa !14
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.BiquadFilter_s, ptr %109, i32 0, i32 3
  store double %108, ptr %110, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 32}
!12 = !{!"BiquadFilter_s", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88}
!13 = !{!"double", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 40}
!16 = !{!12, !13, i64 48}
!17 = !{!12, !13, i64 56}
!18 = !{!12, !13, i64 64}
!19 = !{!12, !13, i64 0}
!20 = !{!12, !13, i64 8}
!21 = !{!12, !13, i64 16}
!22 = !{!12, !13, i64 24}
!23 = !{!24, !24, i64 0}
!24 = !{!"float", !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; 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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @BiquadFilter_Filter(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = load double, ptr %7, align 8, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = load double, ptr %0, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load <2 x double>, ptr %14, align 8, !tbaa !14
  %16 = icmp sgt i32 %3, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %17 = getelementptr inbounds i8, ptr %0, i64 64
  %18 = load double, ptr %17, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 56
  %20 = load double, ptr %19, align 8, !tbaa !16
  %21 = fneg double %20
  %22 = fneg double %18
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %23

23:                                               ; preds = %.lr.ph, %23
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %.04348 = phi double [ %13, %.lr.ph ], [ %.04447, %23 ]
  %.04447 = phi double [ %11, %.lr.ph ], [ %27, %23 ]
  %24 = phi <2 x double> [ %15, %.lr.ph ], [ %44, %23 ]
  %25 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %26 = load float, ptr %25, align 4, !tbaa !17
  %27 = fpext float %26 to double
  %28 = fmul double %8, %.04447
  %29 = tail call double @llvm.fmuladd.f64(double %6, double %27, double %28)
  %30 = tail call double @llvm.fmuladd.f64(double %10, double %.04348, double %29)
  %31 = extractelement <2 x double> %24, i64 0
  %32 = tail call double @llvm.fmuladd.f64(double %21, double %31, double %30)
  %33 = extractelement <2 x double> %24, i64 1
  %34 = tail call double @llvm.fmuladd.f64(double %22, double %33, double %32)
  %35 = fptrunc double %34 to float
  %36 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  store float %35, ptr %36, align 4, !tbaa !17
  %37 = and i64 %indvars.iv, 7
  %38 = icmp eq i64 %37, 0
  %39 = insertelement <2 x double> poison, double %34, i64 0
  %40 = shufflevector <2 x double> %39, <2 x double> %24, <2 x i32> <i32 0, i32 2>
  %41 = fadd <2 x double> %40, <double 1.000000e-26, double -1.000000e-26>
  %42 = insertelement <2 x i1> poison, i1 %38, i64 0
  %43 = shufflevector <2 x i1> %42, <2 x i1> poison, <2 x i32> zeroinitializer
  %44 = select <2 x i1> %43, <2 x double> %41, <2 x double> %40
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %23, !llvm.loop !19

._crit_edge:                                      ; preds = %23, %4
  %.044.lcssa = phi double [ %11, %4 ], [ %27, %23 ]
  %.043.lcssa = phi double [ %13, %4 ], [ %.04447, %23 ]
  %45 = phi <2 x double> [ %15, %4 ], [ %44, %23 ]
  store double %.044.lcssa, ptr %0, align 8, !tbaa !12
  store double %.043.lcssa, ptr %12, align 8, !tbaa !13
  store <2 x double> %45, ptr %14, align 8, !tbaa !14
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 32}
!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 40}
!11 = !{!6, !7, i64 48}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 64}
!16 = !{!6, !7, i64 56}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass