; 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::AudioChannelSet" = type { %"class.juce::BigInteger" }
%"class.juce::BigInteger" = type <{ %"class.juce::HeapBlock.50", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock.50" = 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 void @_ZN4juce15AudioChannelSetD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK4juce14AudioProcessor21getChannelLayoutOfBusEbi(ptr dead_on_unwind noalias writable sret(%"class.juce::AudioChannelSet") align 8, ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext, i32 noundef) #2 align 2

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce15AudioChannelSet4sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) #3

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

20:                                               ; preds = %45, %4
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = load i32, ptr %9, align 4, !tbaa !11
  %24 = icmp slt i32 %22, %23
  store i1 false, ptr %12, align 1
  store i1 false, ptr %13, align 1
  br i1 %24, label %25, label %33

25:                                               ; preds = %20
  %26 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #4
  store i1 true, ptr %12, align 1
  %27 = load i8, ptr %6, align 1, !tbaa !9, !range !13, !noundef !14
  %28 = trunc i8 %27 to i1
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 4, !tbaa !11
  call void @_ZNK4juce14AudioProcessor21getChannelLayoutOfBusEbi(ptr dead_on_unwind writable sret(%"class.juce::AudioChannelSet") align 8 %11, ptr noundef nonnull align 8 dereferenceable(256) %15, i1 noundef zeroext %28, i32 noundef %30) #4
  store i1 true, ptr %13, align 1
  %31 = call noundef i32 @_ZNK4juce15AudioChannelSet4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %11) #4
  store i32 %31, ptr %10, align 4, !tbaa !11
  %32 = icmp sge i32 %26, %31
  br label %33

33:                                               ; preds = %25, %20
  %34 = phi i1 [ false, %20 ], [ %32, %25 ]
  %35 = load i1, ptr %13, align 1
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  call void @_ZN4juce15AudioChannelSetD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #4
  br label %37

37:                                               ; preds = %36, %33
  %38 = load i1, ptr %12, align 1
  br i1 %38, label %39, label %40

39:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #4
  br label %40

40:                                               ; preds = %39, %37
  br i1 %34, label %41, label %49

41:                                               ; preds = %40
  %42 = load i32, ptr %10, align 4, !tbaa !11
  %43 = load i32, ptr %7, align 4, !tbaa !11
  %44 = sub nsw i32 %43, %42
  store i32 %44, ptr %7, align 4, !tbaa !11
  br label %45

45:                                               ; preds = %41
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !11
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %46, align 4, !tbaa !11
  br label %20, !llvm.loop !15

49:                                               ; preds = %40
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = load i32, ptr %9, align 4, !tbaa !11
  %53 = icmp sge i32 %51, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  br label %57

55:                                               ; preds = %49
  %56 = load i32, ptr %7, align 4, !tbaa !11
  br label %57

57:                                               ; preds = %55, %54
  %58 = phi i32 [ -1, %54 ], [ %56, %55 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret i32 %58
}

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 "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 = !{!"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"

%"class.juce::AudioChannelSet" = type { %"class.juce::BigInteger" }
%"class.juce::BigInteger" = type <{ %"class.juce::HeapBlock.50", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock.50" = type { ptr }

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

; Function Attrs: mustprogress 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 void @_ZN4juce15AudioChannelSetD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK4juce14AudioProcessor21getChannelLayoutOfBusEbi(ptr dead_on_unwind noalias writable sret(%"class.juce::AudioChannelSet") align 8, ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce15AudioChannelSet4sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK4juce14AudioProcessor43getOffsetInBusBufferForAbsoluteChannelIndexEbiRi(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1, i32 noundef %2, ptr nocapture noundef nonnull align 4 dereferenceable(4) %3) local_unnamed_addr #2 align 2 {
  %5 = alloca %"class.juce::AudioChannelSet", align 8
  %6 = tail call noundef i32 @_ZNK4juce14AudioProcessor11getBusCountEb(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.critedge, label %.critedge.thread

.critedge:                                        ; preds = %4, %9
  %.01724 = phi i32 [ %10, %9 ], [ %2, %4 ]
  %storemerge23 = phi i32 [ %11, %9 ], [ 0, %4 ]
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #4
  call void @_ZNK4juce14AudioProcessor21getChannelLayoutOfBusEbi(ptr dead_on_unwind nonnull writable sret(%"class.juce::AudioChannelSet") align 8 %5, ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1, i32 noundef %storemerge23) #4
  %8 = call noundef i32 @_ZNK4juce15AudioChannelSet4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %5) #4
  %.not22 = icmp slt i32 %.01724, %8
  call void @_ZN4juce15AudioChannelSetD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %5) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  %.pre.pre = load i32, ptr %3, align 4, !tbaa !5
  br i1 %.not22, label %.critedge.thread, label %9

9:                                                ; preds = %.critedge
  %10 = sub nsw i32 %.01724, %8
  %11 = add nsw i32 %.pre.pre, 1
  store i32 %11, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %11, %6
  br i1 %12, label %.critedge, label %.critedge.thread, !llvm.loop !9

.critedge.thread:                                 ; preds = %.critedge, %9, %4
  %13 = phi i32 [ 0, %4 ], [ %11, %9 ], [ %.pre.pre, %.critedge ]
  %.017.lcssa = phi i32 [ %2, %4 ], [ %10, %9 ], [ %.01724, %.critedge ]
  %.not = icmp slt i32 %13, %6
  %14 = select i1 %.not, i32 %.017.lcssa, i32 -1
  ret i32 %14
}

attributes #0 = { mustprogress 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 "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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