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

; 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.resampler::MultiChannelResampler" = type <{ ptr, %"class.std::vector", i32, i32, %"class.std::vector", %"class.std::vector", i32, i32, i32, [4 x i8], %"class.resampler::HyperbolicCosineWindow", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.resampler::HyperbolicCosineWindow" = type { double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9resampler24PolyphaseResamplerStereo10writeFrameEPKf(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %9, i32 0, i32 3
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr %10, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %14, label %18

14:                                               ; preds = %2
  %15 = call noundef i32 @_ZNK9resampler21MultiChannelResampler10getNumTapsEv(ptr noundef nonnull align 8 dereferenceable(124) %9)
  %16 = sub nsw i32 %15, 1
  %17 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %9, i32 0, i32 3
  store i32 %16, ptr %17, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %14, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %19 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %9, i32 0, i32 4
  %20 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %9, i32 0, i32 3
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = mul nsw i32 %21, 2
  %23 = sext i32 %22 to i64
  %24 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %23) #3
  store ptr %24, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %25 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %9, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !18
  %27 = mul nsw i32 %26, 2
  store i32 %27, ptr %6, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds float, ptr %28, i64 0
  %30 = load float, ptr %29, align 4, !tbaa !20
  store float %30, ptr %7, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds float, ptr %31, i64 1
  %33 = load float, ptr %32, align 4, !tbaa !20
  store float %33, ptr %8, align 4, !tbaa !20
  %34 = load float, ptr %7, align 4, !tbaa !20
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds float, ptr %35, i64 0
  store float %34, ptr %36, align 4, !tbaa !20
  %37 = load float, ptr %8, align 4, !tbaa !20
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds float, ptr %38, i64 1
  store float %37, ptr %39, align 4, !tbaa !20
  %40 = load float, ptr %7, align 4, !tbaa !20
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %6, align 4, !tbaa !19
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  store float %40, ptr %44, align 4, !tbaa !20
  %45 = load float, ptr %8, align 4, !tbaa !20
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !19
  %48 = add nsw i32 1, %47
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %46, i64 %49
  store float %45, ptr %50, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  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 void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 nosync nounwind willreturn memory(argmem: readwrite) }
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, !15, i64 36}
!10 = !{!"_ZTSN9resampler21MultiChannelResamplerE", !11, i64 8, !15, i64 32, !15, i64 36, !11, i64 40, !11, i64 64, !15, i64 88, !15, i64 92, !15, i64 96, !16, i64 104, !15, i64 120}
!11 = !{!"_ZTSSt6vectorIfSaIfEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN9resampler22HyperbolicCosineWindowE", !17, i64 0, !17, i64 8}
!17 = !{!"double", !7, i64 0}
!18 = !{!10, !15, i64 32}
!19 = !{!15, !15, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}


; 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 nounwind uwtable
define dso_local void @_ZN9resampler24PolyphaseResamplerStereo10writeFrameEPKf(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr nocapture noundef readonly %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 36
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr %3, align 4, !tbaa !5
  %6 = icmp slt i32 %4, 1
  br i1 %6, label %7, label %10

7:                                                ; preds = %2
  %8 = tail call noundef i32 @_ZNK9resampler21MultiChannelResampler10getNumTapsEv(ptr noundef nonnull align 8 dereferenceable(124) %0)
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr %3, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %7, %2
  %11 = phi i32 [ %9, %7 ], [ %5, %2 ]
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = shl nsw i32 %11, 1
  %14 = sext i32 %13 to i64
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %14) #1
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %18 = shl nsw i32 %17, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds float, ptr %15, i64 %19
  %21 = load <2 x float>, ptr %1, align 4, !tbaa !18
  store <2 x float> %21, ptr %15, align 4, !tbaa !18
  store <2 x float> %21, ptr %20, align 4, !tbaa !18
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9resampler21MultiChannelResampler10getNumTapsEv(ptr noundef nonnull align 8 dereferenceable(124)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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 = !{!"_ZTSN9resampler21MultiChannelResamplerE", !7, i64 8, !14, i64 32, !14, i64 36, !7, i64 40, !7, i64 64, !14, i64 88, !14, i64 92, !14, i64 96, !15, i64 104, !14, i64 120}
!7 = !{!"_ZTSSt6vectorIfSaIfEE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"int", !12, i64 0}
!15 = !{!"_ZTSN9resampler22HyperbolicCosineWindowE", !16, i64 0, !16, i64 8}
!16 = !{!"double", !12, i64 0}
!17 = !{!6, !14, i64 32}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !12, i64 0}


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