; LLVM IR from kdrag0n/fxdsp :: external/oboe/src/flowgraph (SampleRateConverter)

; 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.oboe::flowgraph::FlowGraphFilter" = type { %"class.oboe::flowgraph::FlowGraphNode", %"class.oboe::flowgraph::FlowGraphPortFloatInput", %"class.oboe::flowgraph::FlowGraphPortFloatOutput" }
%"class.oboe::flowgraph::FlowGraphNode" = type { ptr, i64, %"class.std::vector", i8, i8, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.oboe::flowgraph::FlowGraphPortFloatInput" = type { %"class.oboe::flowgraph::FlowGraphPortFloat", ptr }
%"class.oboe::flowgraph::FlowGraphPortFloat" = type { %"class.oboe::flowgraph::FlowGraphPort.base", i32, %"class.std::unique_ptr" }
%"class.oboe::flowgraph::FlowGraphPort.base" = type <{ ptr, ptr, i32 }>
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }
%"class.oboe::flowgraph::FlowGraphPortFloatOutput" = type { %"class.oboe::flowgraph::FlowGraphPortFloat" }
%"class.oboe::flowgraph::SampleRateConverter" = type { %"class.oboe::flowgraph::FlowGraphFilter", ptr, i32, i32, i64 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4oboe9flowgraph19SampleRateConverter16isInputAvailableEv(ptr noundef nonnull align 8 dereferenceable(144)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4oboe9flowgraph19SampleRateConverter17getNextInputFrameEv(ptr noundef nonnull align 8 dereferenceable(144)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4oboe9flowgraph19SampleRateConverter9onProcessEi(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = getelementptr inbounds %"class.oboe::flowgraph::FlowGraphFilter", ptr %9, i32 0, i32 2
  %11 = call noundef ptr @_ZN4oboe9flowgraph18FlowGraphPortFloat9getBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %12 = getelementptr inbounds %"class.oboe::flowgraph::FlowGraphFilter", ptr %9, i32 0, i32 2
  %13 = call noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20) %12)
  store i32 %13, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %14 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %14, ptr %7, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %41, %2
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %18, label %42

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %9, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = call noundef zeroext i1 @_ZNK9resampler21MultiChannelResampler13isWriteNeededEv(ptr noundef nonnull align 8 dereferenceable(124) %20)
  br i1 %21, label %22, label %31

22:                                               ; preds = %18
  %23 = call noundef zeroext i1 @_ZN4oboe9flowgraph19SampleRateConverter16isInputAvailableEv(ptr noundef nonnull align 8 dereferenceable(144) %9)
  br i1 %23, label %24, label %29

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %25 = call noundef ptr @_ZN4oboe9flowgraph19SampleRateConverter17getNextInputFrameEv(ptr noundef nonnull align 8 dereferenceable(144) %9)
  store ptr %25, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %9, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN9resampler21MultiChannelResampler14writeNextFrameEPKf(ptr noundef nonnull align 8 dereferenceable(124) %27, ptr noundef %28)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %30

29:                                               ; preds = %22
  br label %42

30:                                               ; preds = %24
  br label %41

31:                                               ; preds = %18
  %32 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %9, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN9resampler21MultiChannelResampler13readNextFrameEPf(ptr noundef nonnull align 8 dereferenceable(124) %33, ptr noundef %34)
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = sext i32 %35 to i64
  %38 = getelementptr inbounds float, ptr %36, i64 %37
  store ptr %38, ptr %5, align 8, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %7, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %31, %30
  br label %15, !llvm.loop !31

42:                                               ; preds = %29, %15
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = sub nsw i32 %43, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i32 %45
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9resampler21MultiChannelResampler13isWriteNeededEv(ptr noundef nonnull align 8 dereferenceable(124)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9resampler21MultiChannelResampler14writeNextFrameEPKf(ptr noundef nonnull align 8 dereferenceable(124), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9resampler21MultiChannelResampler13readNextFrameEPf(ptr noundef nonnull align 8 dereferenceable(124), ptr noundef) #0 align 2

attributes #0 = { mustprogress 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 = { 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, !6, i64 120}
!12 = !{!"_ZTSN4oboe9flowgraph19SampleRateConverterE", !13, i64 0, !6, i64 120, !10, i64 128, !10, i64 132, !15, i64 136}
!13 = !{!"_ZTSN4oboe9flowgraph15FlowGraphFilterE", !14, i64 0, !21, i64 48, !30, i64 88}
!14 = !{!"_ZTSN4oboe9flowgraph13FlowGraphNodeE", !15, i64 8, !16, i64 16, !20, i64 40, !20, i64 41, !10, i64 44}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSSt6vectorISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTSN4oboe9flowgraph23FlowGraphPortFloatInputE", !22, i64 0, !6, i64 32}
!22 = !{!"_ZTSN4oboe9flowgraph18FlowGraphPortFloatE", !23, i64 0, !10, i64 20, !24, i64 24}
!23 = !{!"_ZTSN4oboe9flowgraph13FlowGraphPortE", !6, i64 8, !10, i64 16}
!24 = !{!"_ZTSSt10unique_ptrIA_fSt14default_deleteIS0_EE", !25, i64 0}
!25 = !{!"_ZTSSt15__uniq_ptr_dataIfSt14default_deleteIA_fELb1ELb1EE", !26, i64 0}
!26 = !{!"_ZTSSt15__uniq_ptr_implIfSt14default_deleteIA_fEE", !27, i64 0}
!27 = !{!"_ZTSSt5tupleIJPfSt14default_deleteIA_fEEE", !28, i64 0}
!28 = !{!"_ZTSSt11_Tuple_implILm0EJPfSt14default_deleteIA_fEEE", !29, i64 0}
!29 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !6, i64 0}
!30 = !{!"_ZTSN4oboe9flowgraph24FlowGraphPortFloatOutputE", !22, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"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 uwtable
declare dso_local noundef zeroext i1 @_ZN4oboe9flowgraph19SampleRateConverter16isInputAvailableEv(ptr noundef nonnull align 8 dereferenceable(144)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4oboe9flowgraph19SampleRateConverter17getNextInputFrameEv(ptr noundef nonnull align 8 dereferenceable(144)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4oboe9flowgraph19SampleRateConverter9onProcessEi(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  %4 = tail call noundef ptr @_ZN4oboe9flowgraph18FlowGraphPortFloat9getBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %3)
  %5 = tail call noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20) %3)
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = sext i32 %5 to i64
  br label %9

9:                                                ; preds = %.lr.ph, %21
  %.012 = phi ptr [ %4, %.lr.ph ], [ %.1, %21 ]
  %.0911 = phi i32 [ %1, %.lr.ph ], [ %.110, %21 ]
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = tail call noundef zeroext i1 @_ZNK9resampler21MultiChannelResampler13isWriteNeededEv(ptr noundef nonnull align 8 dereferenceable(124) %10)
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = tail call noundef zeroext i1 @_ZN4oboe9flowgraph19SampleRateConverter16isInputAvailableEv(ptr noundef nonnull align 8 dereferenceable(144) %0)
  br i1 %13, label %14, label %._crit_edge

14:                                               ; preds = %12
  %15 = tail call noundef ptr @_ZN4oboe9flowgraph19SampleRateConverter17getNextInputFrameEv(ptr noundef nonnull align 8 dereferenceable(144) %0)
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void @_ZN9resampler21MultiChannelResampler14writeNextFrameEPKf(ptr noundef nonnull align 8 dereferenceable(124) %16, ptr noundef %15)
  br label %21

17:                                               ; preds = %9
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void @_ZN9resampler21MultiChannelResampler13readNextFrameEPf(ptr noundef nonnull align 8 dereferenceable(124) %18, ptr noundef %.012)
  %19 = getelementptr inbounds float, ptr %.012, i64 %8
  %20 = add nsw i32 %.0911, -1
  br label %21

21:                                               ; preds = %17, %14
  %.110 = phi i32 [ %.0911, %14 ], [ %20, %17 ]
  %.1 = phi ptr [ %.012, %14 ], [ %19, %17 ]
  %22 = icmp sgt i32 %.110, 0
  br i1 %22, label %9, label %._crit_edge, !llvm.loop !29

._crit_edge:                                      ; preds = %21, %12, %2
  %.09.lcssa = phi i32 [ %1, %2 ], [ %.0911, %12 ], [ %.110, %21 ]
  %23 = sub nsw i32 %1, %.09.lcssa
  ret i32 %23
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4oboe9flowgraph18FlowGraphPortFloat9getBufferEv(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9resampler21MultiChannelResampler13isWriteNeededEv(ptr noundef nonnull align 8 dereferenceable(124)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9resampler21MultiChannelResampler14writeNextFrameEPKf(ptr noundef nonnull align 8 dereferenceable(124), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9resampler21MultiChannelResampler13readNextFrameEPf(ptr noundef nonnull align 8 dereferenceable(124), ptr noundef) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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 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, !16, i64 120}
!6 = !{!"_ZTSN4oboe9flowgraph19SampleRateConverterE", !7, i64 0, !16, i64 120, !18, i64 128, !18, i64 132, !9, i64 136}
!7 = !{!"_ZTSN4oboe9flowgraph15FlowGraphFilterE", !8, i64 0, !19, i64 48, !28, i64 88}
!8 = !{!"_ZTSN4oboe9flowgraph13FlowGraphNodeE", !9, i64 8, !12, i64 16, !17, i64 40, !17, i64 41, !18, i64 44}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSSt6vectorISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !10, i64 0}
!17 = !{!"bool", !10, i64 0}
!18 = !{!"int", !10, i64 0}
!19 = !{!"_ZTSN4oboe9flowgraph23FlowGraphPortFloatInputE", !20, i64 0, !16, i64 32}
!20 = !{!"_ZTSN4oboe9flowgraph18FlowGraphPortFloatE", !21, i64 0, !18, i64 20, !22, i64 24}
!21 = !{!"_ZTSN4oboe9flowgraph13FlowGraphPortE", !16, i64 8, !18, i64 16}
!22 = !{!"_ZTSSt10unique_ptrIA_fSt14default_deleteIS0_EE", !23, i64 0}
!23 = !{!"_ZTSSt15__uniq_ptr_dataIfSt14default_deleteIA_fELb1ELb1EE", !24, i64 0}
!24 = !{!"_ZTSSt15__uniq_ptr_implIfSt14default_deleteIA_fEE", !25, i64 0}
!25 = !{!"_ZTSSt5tupleIJPfSt14default_deleteIA_fEEE", !26, i64 0}
!26 = !{!"_ZTSSt11_Tuple_implILm0EJPfSt14default_deleteIA_fEEE", !27, i64 0}
!27 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !16, i64 0}
!28 = !{!"_ZTSN4oboe9flowgraph24FlowGraphPortFloatOutputE", !20, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass