; 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::SampleRateConverter" = type { %"class.oboe::flowgraph::FlowGraphFilter", ptr, i32, i32, i64 }
%"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" }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4oboe9flowgraph19SampleRateConverter16isInputAvailableEv(ptr noundef nonnull align 8 dereferenceable(144) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 2
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 3
  %7 = load i32, ptr %6, align 4, !tbaa !30
  %8 = icmp sge i32 %5, %7
  br i1 %8, label %9, label %21

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 4
  %11 = load i64, ptr %10, align 8, !tbaa !31
  %12 = add nsw i64 %11, 1
  store i64 %12, ptr %10, align 8, !tbaa !31
  %13 = getelementptr inbounds %"class.oboe::flowgraph::FlowGraphFilter", ptr %3, i32 0, i32 1
  %14 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 4
  %15 = load i64, ptr %14, align 8, !tbaa !31
  %16 = getelementptr inbounds %"class.oboe::flowgraph::FlowGraphFilter", ptr %3, i32 0, i32 1
  %17 = call noundef i32 @_ZNK4oboe9flowgraph18FlowGraphPortFloat18getFramesPerBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %16)
  %18 = call noundef i32 @_ZN4oboe9flowgraph23FlowGraphPortFloatInput8pullDataEli(ptr noundef nonnull align 8 dereferenceable(40) %13, i64 noundef %15, i32 noundef %17)
  %19 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 3
  store i32 %18, ptr %19, align 4, !tbaa !30
  %20 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 2
  store i32 0, ptr %20, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %9, %1
  %22 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %3, i32 0, i32 3
  %25 = load i32, ptr %24, align 4, !tbaa !30
  %26 = icmp slt i32 %23, %25
  ret i1 %26
}

declare noundef i32 @_ZN4oboe9flowgraph23FlowGraphPortFloatInput8pullDataEli(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i32 noundef) unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4oboe9flowgraph18FlowGraphPortFloat18getFramesPerBufferEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 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 = { "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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !19, i64 128}
!10 = !{!"_ZTSN4oboe9flowgraph19SampleRateConverterE", !11, i64 0, !6, i64 120, !19, i64 128, !19, i64 132, !13, i64 136}
!11 = !{!"_ZTSN4oboe9flowgraph15FlowGraphFilterE", !12, i64 0, !20, i64 48, !29, i64 88}
!12 = !{!"_ZTSN4oboe9flowgraph13FlowGraphNodeE", !13, i64 8, !14, i64 16, !18, i64 40, !18, i64 41, !19, i64 44}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSSt6vectorISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"_ZTSN4oboe9flowgraph23FlowGraphPortFloatInputE", !21, i64 0, !6, i64 32}
!21 = !{!"_ZTSN4oboe9flowgraph18FlowGraphPortFloatE", !22, i64 0, !19, i64 20, !23, i64 24}
!22 = !{!"_ZTSN4oboe9flowgraph13FlowGraphPortE", !6, i64 8, !19, i64 16}
!23 = !{!"_ZTSSt10unique_ptrIA_fSt14default_deleteIS0_EE", !24, i64 0}
!24 = !{!"_ZTSSt15__uniq_ptr_dataIfSt14default_deleteIA_fELb1ELb1EE", !25, i64 0}
!25 = !{!"_ZTSSt15__uniq_ptr_implIfSt14default_deleteIA_fEE", !26, i64 0}
!26 = !{!"_ZTSSt5tupleIJPfSt14default_deleteIA_fEEE", !27, i64 0}
!27 = !{!"_ZTSSt11_Tuple_implILm0EJPfSt14default_deleteIA_fEEE", !28, i64 0}
!28 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !6, i64 0}
!29 = !{!"_ZTSN4oboe9flowgraph24FlowGraphPortFloatOutputE", !21, i64 0}
!30 = !{!10, !19, i64 132}
!31 = !{!10, !13, i64 136}


; 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
define dso_local noundef zeroext i1 @_ZN4oboe9flowgraph19SampleRateConverter16isInputAvailableEv(ptr noundef nonnull align 8 dereferenceable(144) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 128
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 132
  %5 = load i32, ptr %4, align 4, !tbaa !29
  %.not = icmp slt i32 %3, %5
  br i1 %.not, label %13, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 136
  %8 = load i64, ptr %7, align 8, !tbaa !30
  %9 = add nsw i64 %8, 1
  store i64 %9, ptr %7, align 8, !tbaa !30
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = tail call noundef i32 @_ZNK4oboe9flowgraph18FlowGraphPortFloat18getFramesPerBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
  %12 = tail call noundef i32 @_ZN4oboe9flowgraph23FlowGraphPortFloatInput8pullDataEli(ptr noundef nonnull align 8 dereferenceable(40) %10, i64 noundef %9, i32 noundef %11)
  store i32 %12, ptr %4, align 4, !tbaa !29
  store i32 0, ptr %2, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %6, %1
  %14 = phi i32 [ %12, %6 ], [ %5, %1 ]
  %15 = phi i32 [ 0, %6 ], [ %3, %1 ]
  %16 = icmp slt i32 %15, %14
  ret i1 %16
}

declare noundef i32 @_ZN4oboe9flowgraph23FlowGraphPortFloatInput8pullDataEli(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i32 noundef) unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4oboe9flowgraph18FlowGraphPortFloat18getFramesPerBufferEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 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 = { "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 = { 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, !18, i64 128}
!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 = !{!6, !18, i64 132}
!30 = !{!6, !9, i64 136}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass