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

; 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::TableListBox" = type <{ %"class.juce::ListBox", %"class.juce::ListBoxModel", %"class.juce::TableHeaderComponent::Listener", ptr, ptr, i32, i8, [3 x i8] }>
%"class.juce::ListBox" = type { %"class.juce::Component.base", %"class.juce::SettableTooltipClient", ptr, %"class.juce::ScopedPointer.286", %"class.juce::ScopedPointer.159", %"class.juce::ScopedPointer.287", i32, i32, i32, i32, i32, i8, i8, i8, i8, %"class.juce::SparseSet" }
%"class.juce::Component.base" = type <{ %"class.juce::MouseListener", %"class.juce::String", %"class.juce::String", ptr, %"class.juce::Rectangle", %"class.juce::ScopedPointer", %"class.juce::ScopedPointer.0", %"class.juce::Array", ptr, %"class.juce::MouseCursor", ptr, %"class.juce::ScopedPointer.1", %"class.juce::ScopedPointer.2", %"class.juce::ScopedPointer.3", %"class.juce::ListenerList", %"class.juce::NamedValueSet", %"class.juce::WeakReference<juce::Component>::Master", %union.anon, i8 }>
%"class.juce::MouseListener" = type { ptr }
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::Rectangle" = type { %"class.juce::Point", i32, i32 }
%"class.juce::Point" = type { i32, i32 }
%"class.juce::ScopedPointer" = type { ptr }
%"class.juce::ScopedPointer.0" = type { ptr }
%"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::MouseCursor" = type { ptr }
%"class.juce::ScopedPointer.1" = type { ptr }
%"class.juce::ScopedPointer.2" = type { ptr }
%"class.juce::ScopedPointer.3" = type { ptr }
%"class.juce::ListenerList" = type { %"class.juce::Array.4" }
%"class.juce::Array.4" = type { %"class.juce::ArrayAllocationBase.5", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.5" = type <{ %"class.juce::HeapBlock.6", i32, [4 x i8] }>
%"class.juce::HeapBlock.6" = type { ptr }
%"class.juce::NamedValueSet" = type { %"class.juce::Array.9" }
%"class.juce::Array.9" = type { %"class.juce::ArrayAllocationBase.10", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.10" = type <{ %"class.juce::HeapBlock.11", i32, [4 x i8] }>
%"class.juce::HeapBlock.11" = type { ptr }
%"class.juce::WeakReference<juce::Component>::Master" = type { %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }
%union.anon = type { i32 }
%"class.juce::SettableTooltipClient" = type { %"class.juce::TooltipClient", %"class.juce::String" }
%"class.juce::TooltipClient" = type { ptr }
%"class.juce::ScopedPointer.286" = type { ptr }
%"class.juce::ScopedPointer.159" = type { ptr }
%"class.juce::ScopedPointer.287" = type { ptr }
%"class.juce::SparseSet" = type { %"class.juce::Array.288" }
%"class.juce::Array.288" = type { %"class.juce::ArrayAllocationBase.289", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.289" = type <{ %"class.juce::HeapBlock.290", i32, [4 x i8] }>
%"class.juce::HeapBlock.290" = type { ptr }
%"class.juce::ListBoxModel" = type { ptr }
%"class.juce::TableHeaderComponent::Listener" = 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 uwtable
declare dso_local void @_ZN4juce20TableHeaderComponent14setColumnWidthEii(ptr noundef nonnull align 8 dereferenceable(308), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce12TableListBox14autoSizeColumnEi(ptr noundef nonnull align 8 dereferenceable(333) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %7 = getelementptr inbounds %"class.juce::TableListBox", ptr %6, i32 0, i32 4
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %18

10:                                               ; preds = %2
  %11 = getelementptr inbounds %"class.juce::TableListBox", ptr %6, i32 0, i32 4
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = load ptr, ptr %12, align 8, !tbaa !51
  %15 = getelementptr inbounds ptr, ptr %14, i64 10
  %16 = load ptr, ptr %15, align 8
  %17 = call noundef i32 %16(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef %13)
  br label %19

18:                                               ; preds = %2
  br label %19

19:                                               ; preds = %18, %10
  %20 = phi i32 [ %17, %10 ], [ 0, %18 ]
  store i32 %20, ptr %5, align 4, !tbaa !9
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = getelementptr inbounds %"class.juce::TableListBox", ptr %6, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !53
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN4juce20TableHeaderComponent14setColumnWidthEii(ptr noundef nonnull align 8 dereferenceable(308) %25, i32 noundef %26, i32 noundef %27)
  br label %28

28:                                               ; preds = %23, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 320}
!12 = !{!"_ZTSN4juce12TableListBoxE", !13, i64 0, !49, i64 296, !50, i64 304, !6, i64 312, !6, i64 320, !10, i64 328, !44, i64 332}
!13 = !{!"_ZTSN4juce7ListBoxE", !14, i64 0, !39, i64 200, !6, i64 216, !41, i64 224, !42, i64 232, !43, i64 240, !10, i64 248, !10, i64 252, !10, i64 256, !10, i64 260, !10, i64 264, !44, i64 268, !44, i64 269, !44, i64 270, !44, i64 271, !45, i64 272}
!14 = !{!"_ZTSN4juce9ComponentE", !15, i64 0, !16, i64 8, !16, i64 16, !6, i64 24, !18, i64 32, !20, i64 48, !21, i64 56, !22, i64 64, !6, i64 88, !25, i64 96, !6, i64 104, !26, i64 112, !27, i64 120, !28, i64 128, !29, i64 136, !33, i64 160, !37, i64 184, !7, i64 192, !7, i64 196}
!15 = !{!"_ZTSN4juce13MouseListenerE"}
!16 = !{!"_ZTSN4juce6StringE", !17, i64 0}
!17 = !{!"_ZTSN4juce16CharPointer_UTF8E", !6, i64 0}
!18 = !{!"_ZTSN4juce9RectangleIiEE", !19, i64 0, !10, i64 8, !10, i64 12}
!19 = !{!"_ZTSN4juce5PointIiEE", !10, i64 0, !10, i64 4}
!20 = !{!"_ZTSN4juce13ScopedPointerINS_9Component10PositionerEEE", !6, i64 0}
!21 = !{!"_ZTSN4juce13ScopedPointerINS_15AffineTransformEEE", !6, i64 0}
!22 = !{!"_ZTSN4juce5ArrayIPNS_9ComponentENS_20DummyCriticalSectionELi0EEE", !23, i64 0, !10, i64 16}
!23 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_9ComponentENS_20DummyCriticalSectionEEE", !24, i64 0, !10, i64 8}
!24 = !{!"_ZTSN4juce9HeapBlockIPNS_9ComponentELb0EEE", !6, i64 0}
!25 = !{!"_ZTSN4juce11MouseCursorE", !6, i64 0}
!26 = !{!"_ZTSN4juce13ScopedPointerINS_20CachedComponentImageEEE", !6, i64 0}
!27 = !{!"_ZTSN4juce13ScopedPointerINS_9Component17MouseListenerListEEE", !6, i64 0}
!28 = !{!"_ZTSN4juce13ScopedPointerINS_5ArrayIPNS_11KeyListenerENS_20DummyCriticalSectionELi0EEEEE", !6, i64 0}
!29 = !{!"_ZTSN4juce12ListenerListINS_17ComponentListenerENS_5ArrayIPS1_NS_20DummyCriticalSectionELi0EEEEE", !30, i64 0}
!30 = !{!"_ZTSN4juce5ArrayIPNS_17ComponentListenerENS_20DummyCriticalSectionELi0EEE", !31, i64 0, !10, i64 16}
!31 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_17ComponentListenerENS_20DummyCriticalSectionEEE", !32, i64 0, !10, i64 8}
!32 = !{!"_ZTSN4juce9HeapBlockIPNS_17ComponentListenerELb0EEE", !6, i64 0}
!33 = !{!"_ZTSN4juce13NamedValueSetE", !34, i64 0}
!34 = !{!"_ZTSN4juce5ArrayINS_13NamedValueSet10NamedValueENS_20DummyCriticalSectionELi0EEE", !35, i64 0, !10, i64 16}
!35 = !{!"_ZTSN4juce19ArrayAllocationBaseINS_13NamedValueSet10NamedValueENS_20DummyCriticalSectionEEE", !36, i64 0, !10, i64 8}
!36 = !{!"_ZTSN4juce9HeapBlockINS_13NamedValueSet10NamedValueELb0EEE", !6, i64 0}
!37 = !{!"_ZTSN4juce13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE6MasterE", !38, i64 0}
!38 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE13SharedPointerEEE", !6, i64 0}
!39 = !{!"_ZTSN4juce21SettableTooltipClientE", !40, i64 0, !16, i64 8}
!40 = !{!"_ZTSN4juce13TooltipClientE"}
!41 = !{!"_ZTSN4juce13ScopedPointerINS_7ListBox12ListViewportEEE", !6, i64 0}
!42 = !{!"_ZTSN4juce13ScopedPointerINS_9ComponentEEE", !6, i64 0}
!43 = !{!"_ZTSN4juce13ScopedPointerINS_13MouseListenerEEE", !6, i64 0}
!44 = !{!"bool", !7, i64 0}
!45 = !{!"_ZTSN4juce9SparseSetIiEE", !46, i64 0}
!46 = !{!"_ZTSN4juce5ArrayIiNS_20DummyCriticalSectionELi0EEE", !47, i64 0, !10, i64 16}
!47 = !{!"_ZTSN4juce19ArrayAllocationBaseIiNS_20DummyCriticalSectionEEE", !48, i64 0, !10, i64 8}
!48 = !{!"_ZTSN4juce9HeapBlockIiLb0EEE", !6, i64 0}
!49 = !{!"_ZTSN4juce12ListBoxModelE"}
!50 = !{!"_ZTSN4juce20TableHeaderComponent8ListenerE"}
!51 = !{!52, !52, i64 0}
!52 = !{!"vtable pointer", !8, i64 0}
!53 = !{!12, !6, i64 312}


; 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
declare dso_local void @_ZN4juce20TableHeaderComponent14setColumnWidthEii(ptr noundef nonnull align 8 dereferenceable(308), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce12TableListBox14autoSizeColumnEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(333) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 320
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.thread, label %5

5:                                                ; preds = %2
  %6 = load ptr, ptr %4, align 8, !tbaa !49
  %7 = getelementptr inbounds i8, ptr %6, i64 80
  %8 = load ptr, ptr %7, align 8
  %9 = tail call noundef i32 %8(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %1)
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %11, label %.thread

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 312
  %13 = load ptr, ptr %12, align 8, !tbaa !51
  tail call void @_ZN4juce20TableHeaderComponent14setColumnWidthEii(ptr noundef nonnull align 8 dereferenceable(308) %13, i32 noundef %1, i32 noundef %9)
  br label %.thread

.thread:                                          ; preds = %2, %11, %5
  ret void
}

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" }

!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, !12, i64 320}
!6 = !{!"_ZTSN4juce12TableListBoxE", !7, i64 0, !47, i64 296, !48, i64 304, !12, i64 312, !12, i64 320, !17, i64 328, !42, i64 332}
!7 = !{!"_ZTSN4juce7ListBoxE", !8, i64 0, !37, i64 200, !12, i64 216, !39, i64 224, !40, i64 232, !41, i64 240, !17, i64 248, !17, i64 252, !17, i64 256, !17, i64 260, !17, i64 264, !42, i64 268, !42, i64 269, !42, i64 270, !42, i64 271, !43, i64 272}
!8 = !{!"_ZTSN4juce9ComponentE", !9, i64 0, !10, i64 8, !10, i64 16, !12, i64 24, !15, i64 32, !18, i64 48, !19, i64 56, !20, i64 64, !12, i64 88, !23, i64 96, !12, i64 104, !24, i64 112, !25, i64 120, !26, i64 128, !27, i64 136, !31, i64 160, !35, i64 184, !13, i64 192, !13, i64 196}
!9 = !{!"_ZTSN4juce13MouseListenerE"}
!10 = !{!"_ZTSN4juce6StringE", !11, i64 0}
!11 = !{!"_ZTSN4juce16CharPointer_UTF8E", !12, i64 0}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"_ZTSN4juce9RectangleIiEE", !16, i64 0, !17, i64 8, !17, i64 12}
!16 = !{!"_ZTSN4juce5PointIiEE", !17, i64 0, !17, i64 4}
!17 = !{!"int", !13, i64 0}
!18 = !{!"_ZTSN4juce13ScopedPointerINS_9Component10PositionerEEE", !12, i64 0}
!19 = !{!"_ZTSN4juce13ScopedPointerINS_15AffineTransformEEE", !12, i64 0}
!20 = !{!"_ZTSN4juce5ArrayIPNS_9ComponentENS_20DummyCriticalSectionELi0EEE", !21, i64 0, !17, i64 16}
!21 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_9ComponentENS_20DummyCriticalSectionEEE", !22, i64 0, !17, i64 8}
!22 = !{!"_ZTSN4juce9HeapBlockIPNS_9ComponentELb0EEE", !12, i64 0}
!23 = !{!"_ZTSN4juce11MouseCursorE", !12, i64 0}
!24 = !{!"_ZTSN4juce13ScopedPointerINS_20CachedComponentImageEEE", !12, i64 0}
!25 = !{!"_ZTSN4juce13ScopedPointerINS_9Component17MouseListenerListEEE", !12, i64 0}
!26 = !{!"_ZTSN4juce13ScopedPointerINS_5ArrayIPNS_11KeyListenerENS_20DummyCriticalSectionELi0EEEEE", !12, i64 0}
!27 = !{!"_ZTSN4juce12ListenerListINS_17ComponentListenerENS_5ArrayIPS1_NS_20DummyCriticalSectionELi0EEEEE", !28, i64 0}
!28 = !{!"_ZTSN4juce5ArrayIPNS_17ComponentListenerENS_20DummyCriticalSectionELi0EEE", !29, i64 0, !17, i64 16}
!29 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_17ComponentListenerENS_20DummyCriticalSectionEEE", !30, i64 0, !17, i64 8}
!30 = !{!"_ZTSN4juce9HeapBlockIPNS_17ComponentListenerELb0EEE", !12, i64 0}
!31 = !{!"_ZTSN4juce13NamedValueSetE", !32, i64 0}
!32 = !{!"_ZTSN4juce5ArrayINS_13NamedValueSet10NamedValueENS_20DummyCriticalSectionELi0EEE", !33, i64 0, !17, i64 16}
!33 = !{!"_ZTSN4juce19ArrayAllocationBaseINS_13NamedValueSet10NamedValueENS_20DummyCriticalSectionEEE", !34, i64 0, !17, i64 8}
!34 = !{!"_ZTSN4juce9HeapBlockINS_13NamedValueSet10NamedValueELb0EEE", !12, i64 0}
!35 = !{!"_ZTSN4juce13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE6MasterE", !36, i64 0}
!36 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE13SharedPointerEEE", !12, i64 0}
!37 = !{!"_ZTSN4juce21SettableTooltipClientE", !38, i64 0, !10, i64 8}
!38 = !{!"_ZTSN4juce13TooltipClientE"}
!39 = !{!"_ZTSN4juce13ScopedPointerINS_7ListBox12ListViewportEEE", !12, i64 0}
!40 = !{!"_ZTSN4juce13ScopedPointerINS_9ComponentEEE", !12, i64 0}
!41 = !{!"_ZTSN4juce13ScopedPointerINS_13MouseListenerEEE", !12, i64 0}
!42 = !{!"bool", !13, i64 0}
!43 = !{!"_ZTSN4juce9SparseSetIiEE", !44, i64 0}
!44 = !{!"_ZTSN4juce5ArrayIiNS_20DummyCriticalSectionELi0EEE", !45, i64 0, !17, i64 16}
!45 = !{!"_ZTSN4juce19ArrayAllocationBaseIiNS_20DummyCriticalSectionEEE", !46, i64 0, !17, i64 8}
!46 = !{!"_ZTSN4juce9HeapBlockIiLb0EEE", !12, i64 0}
!47 = !{!"_ZTSN4juce12ListBoxModelE"}
!48 = !{!"_ZTSN4juce20TableHeaderComponent8ListenerE"}
!49 = !{!50, !50, i64 0}
!50 = !{!"vtable pointer", !14, i64 0}
!51 = !{!6, !12, i64 312}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass