; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/juce_audio_basics.ll (ZN4juce9IIRFilter14processSamplesEPfi)

; 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"

%"class.juce::GenericScopedLock.26" = type { ptr }
%"class.juce::IIRFilter" = type <{ %"class.juce::SpinLock", %"class.juce::IIRCoefficients", float, float, i8, [3 x i8] }>
%"class.juce::SpinLock" = type { %"class.juce::Atomic" }
%"class.juce::Atomic" = type { i32, [4 x i8] }
%"class.juce::IIRCoefficients" = type { [5 x float] }

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_8SpinLockEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_8SpinLockEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce9IIRFilter14processSamplesEPfi(ptr noundef nonnull align 8 dereferenceable(37) %0, ptr noundef %1, i32 noundef %2) #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.juce::GenericScopedLock.26", align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %19 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 0
  call void @_ZN4juce17GenericScopedLockINS_8SpinLockEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %19) #4
  %20 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 4
  %21 = load i8, ptr %20, align 4, !tbaa !11, !range !18, !noundef !19
  %22 = trunc i8 %21 to i1
  br i1 %22, label %23, label %106

23:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %24 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 1
  %25 = getelementptr inbounds %"class.juce::IIRCoefficients", ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds [5 x float], ptr %25, i64 0, i64 0
  %27 = load float, ptr %26, align 8, !tbaa !20
  store float %27, ptr %8, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %28 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 1
  %29 = getelementptr inbounds %"class.juce::IIRCoefficients", ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds [5 x float], ptr %29, i64 0, i64 1
  %31 = load float, ptr %30, align 4, !tbaa !20
  store float %31, ptr %9, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %32 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 1
  %33 = getelementptr inbounds %"class.juce::IIRCoefficients", ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds [5 x float], ptr %33, i64 0, i64 2
  %35 = load float, ptr %34, align 8, !tbaa !20
  store float %35, ptr %10, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %36 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 1
  %37 = getelementptr inbounds %"class.juce::IIRCoefficients", ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds [5 x float], ptr %37, i64 0, i64 3
  %39 = load float, ptr %38, align 4, !tbaa !20
  store float %39, ptr %11, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %40 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 1
  %41 = getelementptr inbounds %"class.juce::IIRCoefficients", ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds [5 x float], ptr %41, i64 0, i64 4
  %43 = load float, ptr %42, align 8, !tbaa !20
  store float %43, ptr %12, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %44 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 2
  %45 = load float, ptr %44, align 4, !tbaa !21
  store float %45, ptr %13, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %46 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 3
  %47 = load float, ptr %46, align 8, !tbaa !22
  store float %47, ptr %14, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %84, %23
  %49 = load i32, ptr %15, align 4, !tbaa !9
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %87

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = load i32, ptr %15, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds float, ptr %54, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !20
  store float %58, ptr %16, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %59 = load float, ptr %8, align 4, !tbaa !20
  %60 = load float, ptr %16, align 4, !tbaa !20
  %61 = load float, ptr %13, align 4, !tbaa !20
  %62 = call float @llvm.fmuladd.f32(float %59, float %60, float %61)
  store float %62, ptr %17, align 4, !tbaa !20
  %63 = load float, ptr %17, align 4, !tbaa !20
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load i32, ptr %15, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %64, i64 %66
  store float %63, ptr %67, align 4, !tbaa !20
  %68 = load float, ptr %9, align 4, !tbaa !20
  %69 = load float, ptr %16, align 4, !tbaa !20
  %70 = load float, ptr %11, align 4, !tbaa !20
  %71 = load float, ptr %17, align 4, !tbaa !20
  %72 = fmul float %70, %71
  %73 = fneg float %72
  %74 = call float @llvm.fmuladd.f32(float %68, float %69, float %73)
  %75 = load float, ptr %14, align 4, !tbaa !20
  %76 = fadd float %74, %75
  store float %76, ptr %13, align 4, !tbaa !20
  %77 = load float, ptr %10, align 4, !tbaa !20
  %78 = load float, ptr %16, align 4, !tbaa !20
  %79 = load float, ptr %12, align 4, !tbaa !20
  %80 = load float, ptr %17, align 4, !tbaa !20
  %81 = fmul float %79, %80
  %82 = fneg float %81
  %83 = call float @llvm.fmuladd.f32(float %77, float %78, float %82)
  store float %83, ptr %14, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %84

84:                                               ; preds = %53
  %85 = load i32, ptr %15, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %15, align 4, !tbaa !9
  br label %48, !llvm.loop !23

87:                                               ; preds = %52
  %88 = load float, ptr %13, align 4, !tbaa !20
  %89 = fcmp olt float %88, 0xBE45798EE0000000
  br i1 %89, label %94, label %90

90:                                               ; preds = %87
  %91 = load float, ptr %13, align 4, !tbaa !20
  %92 = fcmp ogt float %91, 0x3E45798EE0000000
  br i1 %92, label %94, label %93

93:                                               ; preds = %90
  store float 0.000000e+00, ptr %13, align 4, !tbaa !20
  br label %94

94:                                               ; preds = %93, %90, %87
  %95 = load float, ptr %13, align 4, !tbaa !20
  %96 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 2
  store float %95, ptr %96, align 4, !tbaa !21
  %97 = load float, ptr %14, align 4, !tbaa !20
  %98 = fcmp olt float %97, 0xBE45798EE0000000
  br i1 %98, label %103, label %99

99:                                               ; preds = %94
  %100 = load float, ptr %14, align 4, !tbaa !20
  %101 = fcmp ogt float %100, 0x3E45798EE0000000
  br i1 %101, label %103, label %102

102:                                              ; preds = %99
  store float 0.000000e+00, ptr %14, align 4, !tbaa !20
  br label %103

103:                                              ; preds = %102, %99, %94
  %104 = load float, ptr %14, align 4, !tbaa !20
  %105 = getelementptr inbounds %"class.juce::IIRFilter", ptr %18, i32 0, i32 3
  store float %104, ptr %105, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %106

106:                                              ; preds = %103, %3
  call void @_ZN4juce17GenericScopedLockINS_8SpinLockEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { inlinehint mustprogress 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 #3 = { mustprogress 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 #4 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !17, i64 36}
!12 = !{!"_ZTSN4juce9IIRFilterE", !13, i64 0, !15, i64 8, !16, i64 28, !16, i64 32, !17, i64 36}
!13 = !{!"_ZTSN4juce8SpinLockE", !14, i64 0}
!14 = !{!"_ZTSN4juce6AtomicIiEE", !10, i64 0}
!15 = !{!"_ZTSN4juce15IIRCoefficientsE", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!16, !16, i64 0}
!21 = !{!12, !16, i64 28}
!22 = !{!12, !16, i64 32}
!23 = distinct !{!23, !24}
!24 = !{!"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"

%"class.juce::GenericScopedLock.26" = type { ptr }

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_8SpinLockEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_8SpinLockEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce9IIRFilter14processSamplesEPfi(ptr noundef nonnull align 8 dereferenceable(37) %0, ptr nocapture noundef %1, i32 noundef %2) local_unnamed_addr #3 align 2 {
  %4 = alloca %"class.juce::GenericScopedLock.26", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @_ZN4juce17GenericScopedLockINS_8SpinLockEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 36
  %6 = load i8, ptr %5, align 4, !tbaa !5, !range !15, !noundef !16
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %41

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load float, ptr %9, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  %12 = load float, ptr %11, align 4, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load float, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %0, i64 28
  %16 = load <2 x float>, ptr %15, align 4, !tbaa !17
  %17 = icmp sgt i32 %2, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %8
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load float, ptr %18, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %0, i64 20
  %21 = load float, ptr %20, align 4, !tbaa !17
  %22 = fneg float %21
  %23 = fneg float %19
  %wide.trip.count = zext nneg i32 %2 to i64
  %24 = extractelement <2 x float> %16, i64 0
  %25 = extractelement <2 x float> %16, i64 1
  br label %32

._crit_edge.loopexit:                             ; preds = %32
  %26 = insertelement <2 x float> poison, float %38, i64 0
  %27 = insertelement <2 x float> %26, float %40, i64 1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %8
  %28 = phi <2 x float> [ %16, %8 ], [ %27, %._crit_edge.loopexit ]
  %29 = call <2 x float> @llvm.fabs.v2f32(<2 x float> %28)
  %30 = fcmp ogt <2 x float> %29, <float 0x3E45798EE0000000, float 0x3E45798EE0000000>
  %31 = select <2 x i1> %30, <2 x float> %28, <2 x float> zeroinitializer
  store <2 x float> %31, ptr %15, align 4, !tbaa !17
  br label %41

32:                                               ; preds = %.lr.ph, %32
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %32 ]
  %.034 = phi float [ %24, %.lr.ph ], [ %38, %32 ]
  %.03033 = phi float [ %25, %.lr.ph ], [ %40, %32 ]
  %33 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %34 = load float, ptr %33, align 4, !tbaa !17
  %35 = call float @llvm.fmuladd.f32(float %10, float %34, float %.034)
  store float %35, ptr %33, align 4, !tbaa !17
  %36 = fmul float %35, %22
  %37 = call float @llvm.fmuladd.f32(float %12, float %34, float %36)
  %38 = fadd float %.03033, %37
  %39 = fmul float %35, %23
  %40 = call float @llvm.fmuladd.f32(float %14, float %34, float %39)
  %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.loopexit, label %32, !llvm.loop !18

41:                                               ; preds = %._crit_edge, %3
  call void @_ZN4juce17GenericScopedLockINS_8SpinLockEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fabs.v2f32(<2 x float>) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { inlinehint mustprogress 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 #3 = { mustprogress 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !14, i64 36}
!6 = !{!"_ZTSN4juce9IIRFilterE", !7, i64 0, !12, i64 8, !13, i64 28, !13, i64 32, !14, i64 36}
!7 = !{!"_ZTSN4juce8SpinLockE", !8, i64 0}
!8 = !{!"_ZTSN4juce6AtomicIiEE", !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN4juce15IIRCoefficientsE", !10, i64 0}
!13 = !{!"float", !10, i64 0}
!14 = !{!"bool", !10, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!13, !13, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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