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

; 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::ResamplingAudioSource" = type { %"class.juce::AudioSource", %"class.juce::OptionalScopedPointer.85", double, double, %"class.juce::AudioBuffer", i32, i32, double, [6 x double], %"class.juce::SpinLock", i32, %"class.juce::HeapBlock.106", %"class.juce::HeapBlock.107", %"class.juce::HeapBlock.108" }
%"class.juce::AudioSource" = type { ptr }
%"class.juce::OptionalScopedPointer.85" = type <{ %"class.juce::ScopedPointer.86", i8, [7 x i8] }>
%"class.juce::ScopedPointer.86" = type { ptr }
%"class.juce::AudioBuffer" = type <{ i32, i32, i64, ptr, %"class.juce::HeapBlock.0", [32 x ptr], i8, [7 x i8] }>
%"class.juce::HeapBlock.0" = type { ptr }
%"class.juce::SpinLock" = type { %"class.juce::Atomic" }
%"class.juce::Atomic" = type { i32, [4 x i8] }
%"class.juce::HeapBlock.106" = type { ptr }
%"class.juce::HeapBlock.107" = type { ptr }
%"class.juce::HeapBlock.108" = type { ptr }
%"struct.juce::ResamplingAudioSource::FilterState" = type { 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce21ResamplingAudioSource11applyFilterEPfiRNS0_11FilterStateE(ptr noundef nonnull align 8 dereferenceable(440) %0, ptr noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  br label %12

12:                                               ; preds = %61, %4
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr %7, align 4, !tbaa !9
  %15 = icmp sge i32 %14, 0
  br i1 %15, label %16, label %82

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load float, ptr %17, align 4, !tbaa !11
  %19 = fpext float %18 to double
  store double %19, ptr %9, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %20 = getelementptr inbounds %"class.juce::ResamplingAudioSource", ptr %11, i32 0, i32 8
  %21 = getelementptr inbounds [6 x double], ptr %20, i64 0, i64 0
  %22 = load double, ptr %21, align 8, !tbaa !13
  %23 = load double, ptr %9, align 8, !tbaa !13
  %24 = getelementptr inbounds %"class.juce::ResamplingAudioSource", ptr %11, i32 0, i32 8
  %25 = getelementptr inbounds [6 x double], ptr %24, i64 0, i64 1
  %26 = load double, ptr %25, align 8, !tbaa !13
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %27, i32 0, i32 0
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = fmul double %26, %29
  %31 = call double @llvm.fmuladd.f64(double %22, double %23, double %30)
  %32 = getelementptr inbounds %"class.juce::ResamplingAudioSource", ptr %11, i32 0, i32 8
  %33 = getelementptr inbounds [6 x double], ptr %32, i64 0, i64 2
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %35, i32 0, i32 1
  %37 = load double, ptr %36, align 8, !tbaa !17
  %38 = call double @llvm.fmuladd.f64(double %34, double %37, double %31)
  %39 = getelementptr inbounds %"class.juce::ResamplingAudioSource", ptr %11, i32 0, i32 8
  %40 = getelementptr inbounds [6 x double], ptr %39, i64 0, i64 4
  %41 = load double, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %42, i32 0, i32 2
  %44 = load double, ptr %43, align 8, !tbaa !18
  %45 = fneg double %41
  %46 = call double @llvm.fmuladd.f64(double %45, double %44, double %38)
  %47 = getelementptr inbounds %"class.juce::ResamplingAudioSource", ptr %11, i32 0, i32 8
  %48 = getelementptr inbounds [6 x double], ptr %47, i64 0, i64 5
  %49 = load double, ptr %48, align 8, !tbaa !13
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %50, i32 0, i32 3
  %52 = load double, ptr %51, align 8, !tbaa !19
  %53 = fneg double %49
  %54 = call double @llvm.fmuladd.f64(double %53, double %52, double %46)
  store double %54, ptr %10, align 8, !tbaa !13
  %55 = load double, ptr %10, align 8, !tbaa !13
  %56 = fcmp olt double %55, -1.000000e-08
  br i1 %56, label %61, label %57

57:                                               ; preds = %16
  %58 = load double, ptr %10, align 8, !tbaa !13
  %59 = fcmp ogt double %58, 1.000000e-08
  br i1 %59, label %61, label %60

60:                                               ; preds = %57
  store double 0.000000e+00, ptr %10, align 8, !tbaa !13
  br label %61

61:                                               ; preds = %60, %57, %16
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %62, i32 0, i32 0
  %64 = load double, ptr %63, align 8, !tbaa !15
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %65, i32 0, i32 1
  store double %64, ptr %66, align 8, !tbaa !17
  %67 = load double, ptr %9, align 8, !tbaa !13
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %68, i32 0, i32 0
  store double %67, ptr %69, align 8, !tbaa !15
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %70, i32 0, i32 2
  %72 = load double, ptr %71, align 8, !tbaa !18
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %73, i32 0, i32 3
  store double %72, ptr %74, align 8, !tbaa !19
  %75 = load double, ptr %10, align 8, !tbaa !13
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.juce::ResamplingAudioSource::FilterState", ptr %76, i32 0, i32 2
  store double %75, ptr %77, align 8, !tbaa !18
  %78 = load double, ptr %10, align 8, !tbaa !13
  %79 = fptrunc double %78 to float
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds float, ptr %80, i32 1
  store ptr %81, ptr %6, align 8, !tbaa !5
  store float %79, ptr %80, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %12, !llvm.loop !20

82:                                               ; preds = %12
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"_ZTSN4juce21ResamplingAudioSource11FilterStateE", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!17 = !{!16, !14, i64 8}
!18 = !{!16, !14, i64 16}
!19 = !{!16, !14, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN4juce21ResamplingAudioSource11applyFilterEPfiRNS0_11FilterStateE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(440) %0, ptr nocapture noundef %1, i32 noundef %2, ptr nocapture noundef nonnull align 8 dereferenceable(32) %3) local_unnamed_addr #1 align 2 {
  %5 = icmp sgt i32 %2, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %.promoted = load double, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 352
  %7 = getelementptr inbounds i8, ptr %0, i64 360
  %8 = getelementptr inbounds i8, ptr %0, i64 368
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  %10 = getelementptr inbounds i8, ptr %0, i64 384
  %11 = getelementptr inbounds i8, ptr %3, i64 16
  %12 = getelementptr inbounds i8, ptr %0, i64 392
  %13 = getelementptr inbounds i8, ptr %3, i64 24
  %.pre = load double, ptr %9, align 8, !tbaa !10
  %.pre24 = load double, ptr %11, align 8, !tbaa !11
  %.pre25 = load double, ptr %13, align 8, !tbaa !12
  br label %14

14:                                               ; preds = %.lr.ph, %14
  %15 = phi double [ %.pre25, %.lr.ph ], [ %16, %14 ]
  %16 = phi double [ %.pre24, %.lr.ph ], [ %spec.store.select, %14 ]
  %17 = phi double [ %.pre, %.lr.ph ], [ %18, %14 ]
  %.023 = phi ptr [ %1, %.lr.ph ], [ %36, %14 ]
  %.02022 = phi i32 [ %2, %.lr.ph ], [ %19, %14 ]
  %18 = phi double [ %.promoted, %.lr.ph ], [ %21, %14 ]
  %19 = add nsw i32 %.02022, -1
  %20 = load float, ptr %.023, align 4, !tbaa !13
  %21 = fpext float %20 to double
  %22 = load double, ptr %6, align 8, !tbaa !15
  %23 = load double, ptr %7, align 8, !tbaa !15
  %24 = fmul double %23, %18
  %25 = tail call double @llvm.fmuladd.f64(double %22, double %21, double %24)
  %26 = load double, ptr %8, align 8, !tbaa !15
  %27 = tail call double @llvm.fmuladd.f64(double %26, double %17, double %25)
  %28 = load double, ptr %10, align 8, !tbaa !15
  %29 = fneg double %28
  %30 = tail call double @llvm.fmuladd.f64(double %29, double %16, double %27)
  %31 = load double, ptr %12, align 8, !tbaa !15
  %32 = fneg double %31
  %33 = tail call double @llvm.fmuladd.f64(double %32, double %15, double %30)
  %34 = tail call double @llvm.fabs.f64(double %33)
  %or.cond = fcmp ogt double %34, 1.000000e-08
  %spec.store.select = select i1 %or.cond, double %33, double 0.000000e+00
  store double %18, ptr %9, align 8, !tbaa !10
  store double %21, ptr %3, align 8, !tbaa !5
  store double %16, ptr %13, align 8, !tbaa !12
  store double %spec.store.select, ptr %11, align 8, !tbaa !11
  %35 = fptrunc double %spec.store.select to float
  %36 = getelementptr inbounds i8, ptr %.023, i64 4
  store float %35, ptr %.023, align 4, !tbaa !13
  %37 = icmp ugt i32 %.02022, 1
  br i1 %37, label %14, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %14, %4
  ret void
}

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

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

!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 0}
!6 = !{!"_ZTSN4juce21ResamplingAudioSource11FilterStateE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass