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

; 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::TreeViewItem" = type <{ ptr, ptr, ptr, %"class.juce::OwnedArray.338", i32, i32, i32, i32, i32, i32, i8, [7 x i8] }>
%"class.juce::OwnedArray.338" = type { %"class.juce::ArrayAllocationBase.339", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.339" = type <{ %"class.juce::HeapBlock.340", i32, [4 x i8] }>
%"class.juce::HeapBlock.340" = 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: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce12TreeViewItem6isOpenEv(ptr noundef nonnull align 8 dereferenceable(73)) #1 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZNK4juce12TreeViewItem18getNextVisibleItemEb(ptr noundef nonnull align 8 dereferenceable(73) %0, i1 noundef zeroext %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %8 = zext i1 %1 to i8
  store i8 %8, ptr %5, align 1, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %21

12:                                               ; preds = %2
  %13 = call noundef zeroext i1 @_ZNK4juce12TreeViewItem6isOpenEv(ptr noundef nonnull align 8 dereferenceable(73) %9) #3
  br i1 %13, label %14, label %21

14:                                               ; preds = %12
  %15 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %9, i32 0, i32 3
  %16 = call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %15) #3
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %14
  %19 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %9, i32 0, i32 3
  %20 = call noundef ptr @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEEixEi(ptr noundef nonnull align 8 dereferenceable(20) %19, i32 noundef 0) #3
  store ptr %20, ptr %3, align 8
  br label %49

21:                                               ; preds = %14, %12, %2
  %22 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %9, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %48

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %26 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %9, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %27, i32 0, i32 3
  %29 = call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE7indexOfEPKS1_(ptr noundef nonnull align 8 dereferenceable(20) %28, ptr noundef %9) #3
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %6, align 4, !tbaa !19
  %31 = load i32, ptr %6, align 4, !tbaa !19
  %32 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %9, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %33, i32 0, i32 3
  %35 = call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %34) #3
  %36 = icmp sge i32 %31, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %25
  %38 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %9, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = call noundef ptr @_ZNK4juce12TreeViewItem18getNextVisibleItemEb(ptr noundef nonnull align 8 dereferenceable(73) %39, i1 noundef zeroext false) #3
  store ptr %40, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %47

41:                                               ; preds = %25
  %42 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %9, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %43, i32 0, i32 3
  %45 = load i32, ptr %6, align 4, !tbaa !19
  %46 = call noundef ptr @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEEixEi(ptr noundef nonnull align 8 dereferenceable(20) %44, i32 noundef %45) #3
  store ptr %46, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %47

47:                                               ; preds = %41, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %49

48:                                               ; preds = %21
  store ptr null, ptr %3, align 8
  br label %49

49:                                               ; preds = %48, %47, %18
  %50 = load ptr, ptr %3, align 8
  ret ptr %50
}

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 = { 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 #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 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 16}
!14 = !{!"_ZTSN4juce12TreeViewItemE", !6, i64 8, !6, i64 16, !15, i64 24, !18, i64 48, !18, i64 52, !18, i64 56, !18, i64 60, !18, i64 64, !18, i64 68, !10, i64 72, !10, i64 72, !10, i64 72, !10, i64 72, !10, i64 72, !10, i64 72, !18, i64 72}
!15 = !{!"_ZTSN4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEEE", !16, i64 0, !18, i64 16}
!16 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_12TreeViewItemENS_20DummyCriticalSectionEEE", !17, i64 0, !18, i64 8}
!17 = !{!"_ZTSN4juce9HeapBlockIPNS_12TreeViewItemELb0EEE", !6, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!18, !18, 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
declare dso_local noundef zeroext i1 @_ZNK4juce12TreeViewItem6isOpenEv(ptr noundef nonnull align 8 dereferenceable(73)) local_unnamed_addr #0 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZNK4juce12TreeViewItem18getNextVisibleItemEb(ptr noundef nonnull align 8 dereferenceable(73) %0, i1 noundef zeroext %1) local_unnamed_addr #0 align 2 {
tailrecurse.peel.begin:
  br i1 %1, label %2, label %8

2:                                                ; preds = %tailrecurse.peel.begin
  %3 = tail call noundef zeroext i1 @_ZNK4juce12TreeViewItem6isOpenEv(ptr noundef nonnull align 8 dereferenceable(73) %0) #2
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %5) #2
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %18, label %8

8:                                                ; preds = %4, %2, %tailrecurse.peel.begin
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %.not.peel = icmp eq ptr %10, null
  br i1 %.not.peel, label %.loopexit, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %10, i64 24
  %13 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE7indexOfEPKS1_(ptr noundef nonnull align 8 dereferenceable(20) %12, ptr noundef nonnull %0) #2
  %14 = add nsw i32 %13, 1
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 24
  %17 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %16) #2
  %.not6.peel = icmp slt i32 %14, %17
  br i1 %.not6.peel, label %.loopexit16, label %tailrecurse.peel.next

18:                                               ; preds = %4
  %19 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEEixEi(ptr noundef nonnull align 8 dereferenceable(20) %5, i32 noundef 0) #2
  br label %.loopexit

tailrecurse.peel.next:                            ; preds = %11, %20
  %.tr.in = phi ptr [ %21, %20 ], [ %9, %11 ]
  %.tr = load ptr, ptr %.tr.in, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.tr, i64 16
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !5
  %.not = icmp eq ptr %.pre, null
  br i1 %.not, label %.loopexit, label %20

20:                                               ; preds = %tailrecurse.peel.next
  %21 = getelementptr inbounds i8, ptr %.tr, i64 16
  %22 = getelementptr inbounds i8, ptr %.pre, i64 24
  %23 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE7indexOfEPKS1_(ptr noundef nonnull align 8 dereferenceable(20) %22, ptr noundef nonnull %.tr) #2
  %24 = add nsw i32 %23, 1
  %25 = load ptr, ptr %21, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 24
  %27 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %26) #2
  %.not6 = icmp slt i32 %24, %27
  br i1 %.not6, label %.loopexit16, label %tailrecurse.peel.next, !llvm.loop !15

.loopexit16:                                      ; preds = %20, %11
  %.lcssa13 = phi i32 [ %14, %11 ], [ %24, %20 ]
  %.lcssa12 = phi ptr [ %9, %11 ], [ %21, %20 ]
  %28 = load ptr, ptr %.lcssa12, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 24
  %30 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEEixEi(ptr noundef nonnull align 8 dereferenceable(20) %29, i32 noundef %.lcssa13) #2
  br label %.loopexit

.loopexit:                                        ; preds = %tailrecurse.peel.next, %8, %.loopexit16, %18
  %.1 = phi ptr [ %19, %18 ], [ %30, %.loopexit16 ], [ null, %8 ], [ null, %tailrecurse.peel.next ]
  ret ptr %.1
}

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 = { 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 = { 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, !7, i64 16}
!6 = !{!"_ZTSN4juce12TreeViewItemE", !7, i64 8, !7, i64 16, !10, i64 24, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !14, i64 72, !14, i64 72, !14, i64 72, !14, i64 72, !14, i64 72, !14, i64 72, !13, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEEE", !11, i64 0, !13, i64 16}
!11 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_12TreeViewItemENS_20DummyCriticalSectionEEE", !12, i64 0, !13, i64 8}
!12 = !{!"_ZTSN4juce9HeapBlockIPNS_12TreeViewItemELb0EEE", !7, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass