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

; 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 }
%"class.resampler::PolyphaseResampler" = type { %"class.resampler::MultiChannelResampler.base", i32 }
%"class.resampler::MultiChannelResampler.base" = type <{ ptr, %"class.std::vector", i32, i32, %"class.std::vector", %"class.std::vector", i32, i32, i32, [4 x i8], %"class.resampler::HyperbolicCosineWindow", i32 }>

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

; 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) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9resampler22PolyphaseResamplerMono9readFrameEPf(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %10, i32 0, i32 1
  %12 = getelementptr inbounds %"class.resampler::PolyphaseResampler", ptr %10, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = sext i32 %13 to i64
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %14) #3
  store ptr %15, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %16 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %10, i32 0, i32 4
  %17 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %10, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !21
  %19 = mul nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %20) #3
  store ptr %21, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %22 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %10, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !22
  %24 = ashr i32 %23, 2
  store i32 %24, ptr %8, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !23
  br label %25

25:                                               ; preds = %63, %2
  %26 = load i32, ptr %9, align 4, !tbaa !23
  %27 = load i32, ptr %8, align 4, !tbaa !23
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %66

30:                                               ; preds = %25
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds float, ptr %31, i32 1
  store ptr %32, ptr %7, align 8, !tbaa !5
  %33 = load float, ptr %31, align 4, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds float, ptr %34, i32 1
  store ptr %35, ptr %6, align 8, !tbaa !5
  %36 = load float, ptr %34, align 4, !tbaa !9
  %37 = load float, ptr %5, align 4, !tbaa !9
  %38 = call float @llvm.fmuladd.f32(float %33, float %36, float %37)
  store float %38, ptr %5, align 4, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds float, ptr %39, i32 1
  store ptr %40, ptr %7, align 8, !tbaa !5
  %41 = load float, ptr %39, align 4, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds float, ptr %42, i32 1
  store ptr %43, ptr %6, align 8, !tbaa !5
  %44 = load float, ptr %42, align 4, !tbaa !9
  %45 = load float, ptr %5, align 4, !tbaa !9
  %46 = call float @llvm.fmuladd.f32(float %41, float %44, float %45)
  store float %46, ptr %5, align 4, !tbaa !9
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds float, ptr %47, i32 1
  store ptr %48, ptr %7, align 8, !tbaa !5
  %49 = load float, ptr %47, align 4, !tbaa !9
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds float, ptr %50, i32 1
  store ptr %51, ptr %6, align 8, !tbaa !5
  %52 = load float, ptr %50, align 4, !tbaa !9
  %53 = load float, ptr %5, align 4, !tbaa !9
  %54 = call float @llvm.fmuladd.f32(float %49, float %52, float %53)
  store float %54, ptr %5, align 4, !tbaa !9
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds float, ptr %55, i32 1
  store ptr %56, ptr %7, align 8, !tbaa !5
  %57 = load float, ptr %55, align 4, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds float, ptr %58, i32 1
  store ptr %59, ptr %6, align 8, !tbaa !5
  %60 = load float, ptr %58, align 4, !tbaa !9
  %61 = load float, ptr %5, align 4, !tbaa !9
  %62 = call float @llvm.fmuladd.f32(float %57, float %60, float %61)
  store float %62, ptr %5, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %30
  %64 = load i32, ptr %9, align 4, !tbaa !23
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %9, align 4, !tbaa !23
  br label %25, !llvm.loop !24

66:                                               ; preds = %29
  %67 = getelementptr inbounds %"class.resampler::PolyphaseResampler", ptr %10, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %10, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !22
  %71 = add nsw i32 %68, %70
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %"class.resampler::MultiChannelResampler", ptr %10, i32 0, i32 1
  %74 = call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %73) #3
  %75 = urem i64 %72, %74
  %76 = trunc i64 %75 to i32
  %77 = getelementptr inbounds %"class.resampler::PolyphaseResampler", ptr %10, i32 0, i32 1
  store i32 %76, ptr %77, align 4, !tbaa !11
  %78 = load float, ptr %5, align 4, !tbaa !9
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds float, ptr %79, i64 0
  store float %78, ptr %80, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!11 = !{!12, !18, i64 124}
!12 = !{!"_ZTSN9resampler18PolyphaseResamplerE", !13, i64 0, !18, i64 124}
!13 = !{!"_ZTSN9resampler21MultiChannelResamplerE", !14, i64 8, !18, i64 32, !18, i64 36, !14, i64 40, !14, i64 64, !18, i64 88, !18, i64 92, !18, i64 96, !19, i64 104, !18, i64 120}
!14 = !{!"_ZTSSt6vectorIfSaIfEE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTSN9resampler22HyperbolicCosineWindowE", !20, i64 0, !20, i64 8}
!20 = !{!"double", !7, i64 0}
!21 = !{!13, !18, i64 36}
!22 = !{!13, !18, i64 32}
!23 = !{!18, !18, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9resampler22PolyphaseResamplerMono9readFrameEPf(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr nocapture noundef writeonly %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = getelementptr inbounds i8, ptr %0, i64 124
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %6) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = getelementptr inbounds i8, ptr %0, i64 36
  %10 = load i32, ptr %9, align 4, !tbaa !18
  %11 = sext i32 %10 to i64
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %11) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load i32, ptr %13, align 8, !tbaa !19
  %15 = ashr i32 %14, 2
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.017.lcssa = phi float [ 0.000000e+00, %2 ], [ %42, %.lr.ph ]
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = add nsw i32 %17, %14
  %19 = sext i32 %18 to i64
  %20 = tail call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #2
  %21 = urem i64 %19, %20
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %4, align 4, !tbaa !5
  store float %.017.lcssa, ptr %1, align 4, !tbaa !20
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.023 = phi i32 [ %43, %.lr.ph ], [ 0, %2 ]
  %.01722 = phi float [ %42, %.lr.ph ], [ 0.000000e+00, %2 ]
  %.01821 = phi ptr [ %38, %.lr.ph ], [ %12, %2 ]
  %.01920 = phi ptr [ %40, %.lr.ph ], [ %7, %2 ]
  %23 = getelementptr inbounds i8, ptr %.01821, i64 4
  %24 = load float, ptr %.01821, align 4, !tbaa !20
  %25 = getelementptr inbounds i8, ptr %.01920, i64 4
  %26 = load float, ptr %.01920, align 4, !tbaa !20
  %27 = tail call float @llvm.fmuladd.f32(float %24, float %26, float %.01722)
  %28 = getelementptr inbounds i8, ptr %.01821, i64 8
  %29 = load float, ptr %23, align 4, !tbaa !20
  %30 = getelementptr inbounds i8, ptr %.01920, i64 8
  %31 = load float, ptr %25, align 4, !tbaa !20
  %32 = tail call float @llvm.fmuladd.f32(float %29, float %31, float %27)
  %33 = getelementptr inbounds i8, ptr %.01821, i64 12
  %34 = load float, ptr %28, align 4, !tbaa !20
  %35 = getelementptr inbounds i8, ptr %.01920, i64 12
  %36 = load float, ptr %30, align 4, !tbaa !20
  %37 = tail call float @llvm.fmuladd.f32(float %34, float %36, float %32)
  %38 = getelementptr inbounds i8, ptr %.01821, i64 16
  %39 = load float, ptr %33, align 4, !tbaa !20
  %40 = getelementptr inbounds i8, ptr %.01920, i64 16
  %41 = load float, ptr %35, align 4, !tbaa !20
  %42 = tail call float @llvm.fmuladd.f32(float %39, float %41, float %37)
  %43 = add nuw nsw i32 %.023, 1
  %exitcond.not = icmp eq i32 %43, %15
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !22
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !15, i64 124}
!6 = !{!"_ZTSN9resampler18PolyphaseResamplerE", !7, i64 0, !15, i64 124}
!7 = !{!"_ZTSN9resampler21MultiChannelResamplerE", !8, i64 8, !15, i64 32, !15, i64 36, !8, i64 40, !8, i64 64, !15, i64 88, !15, i64 92, !15, i64 96, !16, i64 104, !15, i64 120}
!8 = !{!"_ZTSSt6vectorIfSaIfEE", !9, i64 0}
!9 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !11, i64 0}
!11 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"int", !13, i64 0}
!16 = !{!"_ZTSN9resampler22HyperbolicCosineWindowE", !17, i64 0, !17, i64 8}
!17 = !{!"double", !13, i64 0}
!18 = !{!7, !15, i64 36}
!19 = !{!7, !15, i64 32}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !13, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass