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

@_ZTVN4oboe9flowgraph19SampleRateConverterE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4oboe9flowgraph19SampleRateConverterC2EiRN9resampler21MultiChannelResamplerE(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(124) %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  %10 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN4oboe9flowgraph15FlowGraphFilterC2Ei(ptr noundef nonnull align 8 dereferenceable(120) %9, i32 noundef %10)
  store ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTVN4oboe9flowgraph19SampleRateConverterE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %9, i32 0, i32 1
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %12, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %9, i32 0, i32 2
  store i32 0, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %9, i32 0, i32 3
  store i32 0, ptr %14, align 4, !tbaa !33
  %15 = getelementptr inbounds %"class.oboe::flowgraph::SampleRateConverter", ptr %9, i32 0, i32 4
  store i64 0, ptr %15, align 8, !tbaa !34
  invoke void @_ZN4oboe9flowgraph13FlowGraphNode26setDataPulledAutomaticallyEb(ptr noundef nonnull align 8 dereferenceable(48) %9, i1 noundef zeroext false)
          to label %16 unwind label %17

16:                                               ; preds = %3
  ret void

17:                                               ; preds = %3
  %18 = landingpad { ptr, i32 }
          cleanup
  %19 = extractvalue { ptr, i32 } %18, 0
  store ptr %19, ptr %7, align 8
  %20 = extractvalue { ptr, i32 } %18, 1
  store i32 %20, ptr %8, align 4
  call void @_ZN4oboe9flowgraph15FlowGraphFilterD2Ev(ptr noundef nonnull align 8 dereferenceable(120) %9) #2
  br label %21

21:                                               ; preds = %17
  %22 = load ptr, ptr %7, align 8
  %23 = load i32, ptr %8, align 4
  %24 = insertvalue { ptr, i32 } poison, ptr %22, 0
  %25 = insertvalue { ptr, i32 } %24, i32 %23, 1
  resume { ptr, i32 } %25
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4oboe9flowgraph15FlowGraphFilterC2Ei(ptr noundef nonnull align 8 dereferenceable(120), i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4oboe9flowgraph13FlowGraphNode26setDataPulledAutomaticallyEb(ptr noundef nonnull align 8 dereferenceable(48), i1 noundef zeroext) #1 align 2

declare i32 @__gxx_personality_v0(...)

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

@_ZTVN4oboe9flowgraph19SampleRateConverterE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4oboe9flowgraph19SampleRateConverterC2EiRN9resampler21MultiChannelResamplerE(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(124) %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4oboe9flowgraph15FlowGraphFilterC2Ei(ptr noundef nonnull align 8 dereferenceable(120) %0, i32 noundef %1)
  store ptr getelementptr inbounds inrange(-16, 40) (i8, ptr @_ZTVN4oboe9flowgraph19SampleRateConverterE, i64 16), ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %2, ptr %4, align 8, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %0, i64 128
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  tail call void @_ZN4oboe9flowgraph13FlowGraphNode26setDataPulledAutomaticallyEb(ptr noundef nonnull align 8 dereferenceable(48) %0, i1 noundef zeroext false)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4oboe9flowgraph15FlowGraphFilterC2Ei(ptr noundef nonnull align 8 dereferenceable(120), i32 noundef) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}


; Effective O3 passes: GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass