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

; 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 i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce12TreeViewItem6isOpenEv(ptr noundef nonnull align 8 dereferenceable(73)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce12TreeViewItem15updatePositionsEi(ptr noundef nonnull align 8 dereferenceable(73) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 4
  store i32 %8, ptr %9, align 8, !tbaa !11
  %10 = load ptr, ptr %7, align 8, !tbaa !17
  %11 = getelementptr inbounds ptr, ptr %10, i64 6
  %12 = load ptr, ptr %11, align 8
  %13 = call noundef i32 %12(ptr noundef nonnull align 8 dereferenceable(73) %7)
  %14 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 5
  store i32 %13, ptr %14, align 4, !tbaa !19
  %15 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 5
  %16 = load i32, ptr %15, align 4, !tbaa !19
  %17 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 6
  store i32 %16, ptr %17, align 8, !tbaa !20
  %18 = load ptr, ptr %7, align 8, !tbaa !17
  %19 = getelementptr inbounds ptr, ptr %18, i64 5
  %20 = load ptr, ptr %19, align 8
  %21 = call noundef i32 %20(ptr noundef nonnull align 8 dereferenceable(73) %7)
  %22 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 7
  store i32 %21, ptr %22, align 4, !tbaa !21
  %23 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 7
  %24 = load i32, ptr %23, align 4, !tbaa !21
  %25 = call noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef %24, i32 noundef 0)
  %26 = call noundef i32 @_ZNK4juce12TreeViewItem10getIndentXEv(ptr noundef nonnull align 8 dereferenceable(73) %7) #4
  %27 = add nsw i32 %25, %26
  %28 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 8
  store i32 %27, ptr %28, align 8, !tbaa !22
  %29 = call noundef zeroext i1 @_ZNK4juce12TreeViewItem6isOpenEv(ptr noundef nonnull align 8 dereferenceable(73) %7) #4
  br i1 %29, label %30, label %69

30:                                               ; preds = %2
  %31 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 6
  %32 = load i32, ptr %31, align 8, !tbaa !20
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = add nsw i32 %33, %32
  store i32 %34, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %65, %30
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 3
  %38 = call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %37) #4
  %39 = icmp slt i32 %36, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %68

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %42 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 3
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = call noundef ptr @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %42, i32 noundef %43) #4
  store ptr %44, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN4juce12TreeViewItem15updatePositionsEi(ptr noundef nonnull align 8 dereferenceable(73) %45, i32 noundef %46)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %47, i32 0, i32 6
  %49 = load i32, ptr %48, align 8, !tbaa !20
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = add nsw i32 %50, %49
  store i32 %51, ptr %4, align 4, !tbaa !9
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %52, i32 0, i32 6
  %54 = load i32, ptr %53, align 8, !tbaa !20
  %55 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 6
  %56 = load i32, ptr %55, align 8, !tbaa !20
  %57 = add nsw i32 %56, %54
  store i32 %57, ptr %55, align 8, !tbaa !20
  %58 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 8
  %59 = load i32, ptr %58, align 8, !tbaa !22
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %60, i32 0, i32 8
  %62 = load i32, ptr %61, align 8, !tbaa !22
  %63 = call noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef %59, i32 noundef %62)
  %64 = getelementptr inbounds %"class.juce::TreeViewItem", ptr %7, i32 0, i32 8
  store i32 %63, ptr %64, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %65

65:                                               ; preds = %41
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %5, align 4, !tbaa !9
  br label %35, !llvm.loop !23

68:                                               ; preds = %40
  br label %69

69:                                               ; preds = %68, %2
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce12TreeViewItem10getIndentXEv(ptr noundef nonnull align 8 dereferenceable(73)) #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 = { 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 #3 = { 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 #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, !10, i64 48}
!12 = !{!"_ZTSN4juce12TreeViewItemE", !6, i64 8, !6, i64 16, !13, i64 24, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !16, i64 72, !16, i64 72, !16, i64 72, !16, i64 72, !16, i64 72, !16, i64 72, !10, i64 72}
!13 = !{!"_ZTSN4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEEE", !14, i64 0, !10, i64 16}
!14 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_12TreeViewItemENS_20DummyCriticalSectionEEE", !15, i64 0, !10, i64 8}
!15 = !{!"_ZTSN4juce9HeapBlockIPNS_12TreeViewItemELb0EEE", !6, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, i64 0}
!19 = !{!12, !10, i64 52}
!20 = !{!12, !10, i64 56}
!21 = !{!12, !10, i64 60}
!22 = !{!12, !10, i64 64}
!23 = distinct !{!23, !24}
!24 = !{!"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 i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef, i32 noundef) local_unnamed_addr #0

; 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: mustprogress uwtable
define dso_local void @_ZN4juce12TreeViewItem15updatePositionsEi(ptr noundef nonnull align 8 dereferenceable(73) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %1, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %0, align 8, !tbaa !15
  %5 = getelementptr inbounds i8, ptr %4, i64 48
  %6 = load ptr, ptr %5, align 8
  %7 = tail call noundef i32 %6(ptr noundef nonnull align 8 dereferenceable(73) %0)
  %8 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %7, ptr %8, align 4, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 %7, ptr %9, align 8, !tbaa !18
  %10 = load ptr, ptr %0, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %10, i64 40
  %12 = load ptr, ptr %11, align 8
  %13 = tail call noundef i32 %12(ptr noundef nonnull align 8 dereferenceable(73) %0)
  %14 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %13, ptr %14, align 4, !tbaa !19
  %15 = tail call noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef %13, i32 noundef 0)
  %16 = tail call noundef i32 @_ZNK4juce12TreeViewItem10getIndentXEv(ptr noundef nonnull align 8 dereferenceable(73) %0) #3
  %17 = add nsw i32 %16, %15
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 %17, ptr %18, align 8, !tbaa !20
  %19 = tail call noundef zeroext i1 @_ZNK4juce12TreeViewItem6isOpenEv(ptr noundef nonnull align 8 dereferenceable(73) %0) #3
  br i1 %19, label %20, label %.loopexit

20:                                               ; preds = %2
  %21 = load i32, ptr %9, align 8, !tbaa !18
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %22) #3
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %20
  %25 = add nsw i32 %21, %1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.013 = phi i32 [ %29, %.lr.ph ], [ %25, %.lr.ph.preheader ]
  %.01112 = phi i32 [ %36, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %26 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %22, i32 noundef %.01112) #3
  tail call void @_ZN4juce12TreeViewItem15updatePositionsEi(ptr noundef nonnull align 8 dereferenceable(73) %26, i32 noundef %.013)
  %27 = getelementptr inbounds i8, ptr %26, i64 56
  %28 = load i32, ptr %27, align 8, !tbaa !18
  %29 = add nsw i32 %28, %.013
  %30 = load i32, ptr %9, align 8, !tbaa !18
  %31 = add nsw i32 %30, %28
  store i32 %31, ptr %9, align 8, !tbaa !18
  %32 = load i32, ptr %18, align 8, !tbaa !20
  %33 = getelementptr inbounds i8, ptr %26, i64 64
  %34 = load i32, ptr %33, align 8, !tbaa !20
  %35 = tail call noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef %32, i32 noundef %34)
  store i32 %35, ptr %18, align 8, !tbaa !20
  %36 = add nuw nsw i32 %.01112, 1
  %37 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_12TreeViewItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %22) #3
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %.lr.ph, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %.lr.ph, %20, %2
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce12TreeViewItem10getIndentXEv(ptr noundef nonnull align 8 dereferenceable(73)) 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 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, !13, i64 48}
!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 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !9, i64 0}
!17 = !{!6, !13, i64 52}
!18 = !{!6, !13, i64 56}
!19 = !{!6, !13, i64 60}
!20 = !{!6, !13, i64 64}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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