; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_audio_processors)

; 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.juce::AudioProcessor" = type { ptr, i32, ptr, %"class.juce::Array", %"class.juce::Component::SafePointer", double, i32, i32, i8, i8, i32, %"class.juce::CriticalSection", %"class.juce::CriticalSection", %"class.juce::OwnedArray", %"class.juce::OwnedArray", %"class.juce::String", %"class.juce::String", i32, i32, %"class.juce::OwnedArray.3" }
%"class.juce::Array" = type { %"class.juce::ArrayAllocationBase", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase" = type <{ %"class.juce::HeapBlock", i32, [4 x i8] }>
%"class.juce::HeapBlock" = type { ptr }
%"class.juce::Component::SafePointer" = type { %"class.juce::WeakReference" }
%"class.juce::WeakReference" = type { %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }
%"class.juce::CriticalSection" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.juce::OwnedArray" = type { %"class.juce::ArrayAllocationBase.0", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.0" = type <{ %"class.juce::HeapBlock.1", i32, [4 x i8] }>
%"class.juce::HeapBlock.1" = type { ptr }
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::OwnedArray.3" = type { %"class.juce::ArrayAllocationBase.4", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.4" = type <{ %"class.juce::HeapBlock.5", i32, [4 x i8] }>
%"class.juce::HeapBlock.5" = type { ptr }

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce14AudioProcessor20getChannelCountOfBusEbi(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext, i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK4juce14AudioProcessor35getChannelIndexInProcessBlockBufferEbii(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1, i32 noundef %2, i32 noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %11 = zext i1 %1 to i8
  store i8 %11, ptr %6, align 1, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  store i32 %3, ptr %8, align 4, !tbaa !11
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %13 = load i8, ptr %6, align 1, !tbaa !9, !range !13, !noundef !14
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %17

15:                                               ; preds = %4
  %16 = getelementptr inbounds %"class.juce::AudioProcessor", ptr %12, i32 0, i32 13
  br label %19

17:                                               ; preds = %4
  %18 = getelementptr inbounds %"class.juce::AudioProcessor", ptr %12, i32 0, i32 14
  br label %19

19:                                               ; preds = %17, %15
  %20 = phi ptr [ %16, %15 ], [ %18, %17 ]
  store ptr %20, ptr %9, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %19
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %43, %23
  %25 = load i32, ptr %10, align 4, !tbaa !11
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = call noundef i32 @_ZNK4juce10OwnedArrayINS_14AudioProcessor3BusENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %26) #3
  %28 = icmp slt i32 %25, %27
  br i1 %28, label %29, label %33

29:                                               ; preds = %24
  %30 = load i32, ptr %10, align 4, !tbaa !11
  %31 = load i32, ptr %7, align 4, !tbaa !11
  %32 = icmp slt i32 %30, %31
  br label %33

33:                                               ; preds = %29, %24
  %34 = phi i1 [ false, %24 ], [ %32, %29 ]
  br i1 %34, label %36, label %35

35:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %46

36:                                               ; preds = %33
  %37 = load i8, ptr %6, align 1, !tbaa !9, !range !13, !noundef !14
  %38 = trunc i8 %37 to i1
  %39 = load i32, ptr %10, align 4, !tbaa !11
  %40 = call noundef i32 @_ZNK4juce14AudioProcessor20getChannelCountOfBusEbi(ptr noundef nonnull align 8 dereferenceable(256) %12, i1 noundef zeroext %38, i32 noundef %39) #3
  %41 = load i32, ptr %8, align 4, !tbaa !11
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %8, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %36
  %44 = load i32, ptr %10, align 4, !tbaa !11
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %10, align 4, !tbaa !11
  br label %24, !llvm.loop !15

46:                                               ; preds = %35
  %47 = load i32, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret i32 %47
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { 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 #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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce14AudioProcessor20getChannelCountOfBusEbi(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK4juce14AudioProcessor35getChannelIndexInProcessBlockBufferEbii(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 align 2 {
  %.v = select i1 %1, i64 160, i64 184
  %5 = getelementptr inbounds i8, ptr %0, i64 %.v
  %6 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_14AudioProcessor3BusENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %5) #2
  %7 = icmp sgt i32 %6, 0
  %8 = icmp sgt i32 %2, 0
  %9 = and i1 %8, %7
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %4
  %.010.lcssa = phi i32 [ %3, %4 ], [ %11, %.lr.ph ]
  ret i32 %.010.lcssa

.lr.ph:                                           ; preds = %4, %.lr.ph
  %.012 = phi i32 [ %12, %.lr.ph ], [ 0, %4 ]
  %.01011 = phi i32 [ %11, %.lr.ph ], [ %3, %4 ]
  %10 = tail call noundef i32 @_ZNK4juce14AudioProcessor20getChannelCountOfBusEbi(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1, i32 noundef %.012) #2
  %11 = add nsw i32 %10, %.01011
  %12 = add nuw nsw i32 %.012, 1
  %13 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_14AudioProcessor3BusENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %5) #2
  %14 = icmp slt i32 %12, %13
  %15 = icmp slt i32 %12, %2
  %16 = and i1 %15, %14
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

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

attributes #0 = { inlinehint 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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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