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

; 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::ChannelCountConverter" = 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 i32 @_ZN4oboe9flowgraph21ChannelCountConverter9onProcessEi(ptr noundef nonnull align 8 dereferenceable(120) %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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %14 = getelementptr inbounds %"class.oboe::flowgraph::ChannelCountConverter", ptr %13, i32 0, i32 1
  %15 = call noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40) %14)
  store ptr %15, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %16 = getelementptr inbounds %"class.oboe::flowgraph::ChannelCountConverter", ptr %13, i32 0, i32 2
  %17 = call noundef ptr @_ZN4oboe9flowgraph18FlowGraphPortFloat9getBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %16)
  store ptr %17, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %18 = getelementptr inbounds %"class.oboe::flowgraph::ChannelCountConverter", ptr %13, i32 0, i32 1
  %19 = call noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20) %18)
  store i32 %19, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %20 = getelementptr inbounds %"class.oboe::flowgraph::ChannelCountConverter", ptr %13, i32 0, i32 2
  %21 = call noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20) %20)
  store i32 %21, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %64, %2
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %67

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %52, %27
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %55

33:                                               ; preds = %28
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i32, ptr %12, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %39, i64 %41
  store float %38, ptr %42, align 4, !tbaa !11
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = icmp eq i32 %43, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %33
  br label %50

47:                                               ; preds = %33
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  br label %50

50:                                               ; preds = %47, %46
  %51 = phi i32 [ 0, %46 ], [ %49, %47 ]
  store i32 %51, ptr %11, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %50
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %12, align 4, !tbaa !9
  br label %28, !llvm.loop !13

55:                                               ; preds = %32
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = sext i32 %56 to i64
  %59 = getelementptr inbounds float, ptr %57, i64 %58
  store ptr %59, ptr %5, align 8, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = sext i32 %60 to i64
  %63 = getelementptr inbounds float, ptr %61, i64 %62
  store ptr %63, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %64

64:                                               ; preds = %55
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %9, align 4, !tbaa !9
  br label %22, !llvm.loop !15

67:                                               ; preds = %26
  %68 = load i32, ptr %4, align 4, !tbaa !9
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret i32 %68
}

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

declare noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2

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

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

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

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 = { "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 = { 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 #4 = { 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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 i32 @_ZN4oboe9flowgraph21ChannelCountConverter9onProcessEi(ptr noundef nonnull align 8 dereferenceable(120) %0, i32 noundef returned %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = tail call noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40) %3)
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = tail call noundef ptr @_ZN4oboe9flowgraph18FlowGraphPortFloat9getBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %7 = tail call noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20) %3)
  %8 = tail call noundef i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20) %5)
  %9 = icmp sgt i32 %1, 0
  br i1 %9, label %.preheader.lr.ph, label %._crit_edge29

.preheader.lr.ph:                                 ; preds = %2
  %10 = icmp sgt i32 %8, 0
  %11 = sext i32 %7 to i64
  %12 = sext i32 %8 to i64
  br i1 %10, label %.preheader.us.preheader, label %._crit_edge29

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %wide.trip.count = zext nneg i32 %8 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %13 = icmp eq i32 %8, 1
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.01928.us = phi i32 [ %34, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %.02027.us = phi ptr [ %32, %._crit_edge.us ], [ %4, %.preheader.us.preheader ]
  %.02126.us = phi ptr [ %33, %._crit_edge.us ], [ %6, %.preheader.us.preheader ]
  br i1 %13, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %.01824.us = phi i32 [ %27, %.preheader.us.new ], [ 0, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %14 = sext i32 %.01824.us to i64
  %15 = getelementptr inbounds float, ptr %.02027.us, i64 %14
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds float, ptr %.02126.us, i64 %indvars.iv
  store float %16, ptr %17, align 4, !tbaa !5
  %18 = icmp eq i32 %.01824.us, %7
  %19 = add nsw i32 %.01824.us, 1
  %20 = select i1 %18, i32 0, i32 %19
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds float, ptr %.02027.us, i64 %21
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds float, ptr %.02126.us, i64 %indvars.iv.next
  store float %23, ptr %24, align 4, !tbaa !5
  %25 = icmp eq i32 %20, %7
  %26 = add nsw i32 %20, 1
  %27 = select i1 %25, i32 0, i32 %26
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !9

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %indvars.iv.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next.1, %.preheader.us.new ]
  %.01824.us.unr = phi i32 [ 0, %.preheader.us ], [ %27, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %28 = sext i32 %.01824.us.unr to i64
  %29 = getelementptr inbounds float, ptr %.02027.us, i64 %28
  %30 = load float, ptr %29, align 4, !tbaa !5
  %31 = getelementptr inbounds float, ptr %.02126.us, i64 %indvars.iv.unr
  store float %30, ptr %31, align 4, !tbaa !5
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %32 = getelementptr inbounds float, ptr %.02027.us, i64 %11
  %33 = getelementptr inbounds float, ptr %.02126.us, i64 %12
  %34 = add nuw nsw i32 %.01928.us, 1
  %exitcond32.not = icmp eq i32 %34, %1
  br i1 %exitcond32.not, label %._crit_edge29, label %.preheader.us, !llvm.loop !11

._crit_edge29:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %2
  ret i32 %1
}

declare noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1

; 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 i32 @_ZNK4oboe9flowgraph13FlowGraphPort18getSamplesPerFrameEv(ptr noundef nonnull align 8 dereferenceable(20)) 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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