; LLVM IR from l1mey112/yr11-physics-applied :: cimgui/imgui/imgui_tables.ll (ZN5ImGui22TableGetColumnResizeIDEPK10ImGuiTableii)

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

%struct.ImGuiTable = type <{ i32, i32, ptr, ptr, %struct.ImSpan, %struct.ImSpan.35, %struct.ImSpan.36, i64, i64, i64, i64, i32, i32, i32, i32, i32, i32, i16, i16, float, float, float, float, float, i32, i32, [2 x i32], i32, i32, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, ptr, ptr, %struct.ImGuiTextBuffer, ptr, %struct.ImGuiTableInstanceData, [4 x i8], %struct.ImVector.37, %struct.ImGuiTableColumnSortSpecs, [4 x i8], %struct.ImVector.38, %struct.ImGuiTableSortSpecs, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, [6 x i8] }>
%struct.ImSpan = type { ptr, ptr }
%struct.ImSpan.35 = type { ptr, ptr }
%struct.ImSpan.36 = type { ptr, ptr }
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }
%struct.ImVec2 = type { float, float }
%struct.ImGuiTextBuffer = type { %struct.ImVector.24 }
%struct.ImVector.24 = type { i32, i32, ptr }
%struct.ImGuiTableInstanceData = type { float, float, float }
%struct.ImVector.37 = type { i32, i32, ptr }
%struct.ImGuiTableColumnSortSpecs = type <{ i32, i16, i16, i8, [3 x i8] }>
%struct.ImVector.38 = type { i32, i32, ptr }
%struct.ImGuiTableSortSpecs = type <{ ptr, i32, i8, [3 x i8] }>

@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [48 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui22TableGetColumnResizeIDEPK10ImGuiTableii = external hidden unnamed_addr constant [68 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN5ImGui22TableGetColumnResizeIDEPK10ImGuiTableii(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = icmp sge i32 %8, 0
  br i1 %9, label %10, label %16

10:                                               ; preds = %3
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ImGuiTable, ptr %12, i32 0, i32 14
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp slt i32 %11, %14
  br label %16

16:                                               ; preds = %10, %3
  %17 = phi i1 [ false, %3 ], [ %15, %10 ]
  br i1 %17, label %18, label %19

18:                                               ; preds = %16
  br label %21

19:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.44, ptr noundef @.str.2, i32 noundef 1621, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui22TableGetColumnResizeIDEPK10ImGuiTableii) #3
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ImGuiTable, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !29
  %25 = add i32 %24, 1
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ImGuiTable, ptr %27, i32 0, i32 14
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = mul nsw i32 %26, %29
  %31 = add i32 %25, %30
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = add i32 %31, %32
  store i32 %33, ptr %7, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %34
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { noreturn nounwind }
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 116}
!12 = !{!"_ZTS10ImGuiTable", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 40, !15, i64 56, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !17, i64 128, !17, i64 130, !18, i64 132, !18, i64 136, !18, i64 140, !18, i64 144, !18, i64 148, !10, i64 152, !10, i64 154, !10, i64 156, !7, i64 160, !10, i64 168, !10, i64 172, !18, i64 176, !18, i64 180, !18, i64 184, !18, i64 188, !18, i64 192, !18, i64 196, !18, i64 200, !18, i64 204, !18, i64 208, !18, i64 212, !18, i64 216, !18, i64 220, !18, i64 224, !18, i64 228, !18, i64 232, !18, i64 236, !19, i64 240, !19, i64 256, !19, i64 272, !19, i64 288, !19, i64 304, !19, i64 320, !19, i64 336, !19, i64 352, !19, i64 368, !6, i64 384, !6, i64 392, !21, i64 400, !6, i64 416, !23, i64 424, !24, i64 440, !25, i64 456, !26, i64 472, !27, i64 488, !7, i64 504, !7, i64 505, !7, i64 506, !7, i64 507, !7, i64 508, !7, i64 509, !7, i64 510, !7, i64 511, !7, i64 512, !7, i64 513, !7, i64 514, !7, i64 515, !7, i64 516, !7, i64 517, !7, i64 518, !7, i64 519, !7, i64 520, !7, i64 521, !7, i64 522, !7, i64 523, !7, i64 524, !7, i64 525, !7, i64 526, !7, i64 527, !7, i64 528, !28, i64 529, !28, i64 530, !28, i64 531, !28, i64 532, !28, i64 533, !28, i64 534, !28, i64 535, !28, i64 536, !28, i64 537, !28, i64 538, !28, i64 539, !28, i64 540, !28, i64 541, !28, i64 542, !28, i64 543, !28, i64 544, !28, i64 545}
!13 = !{!"_ZTS6ImSpanI16ImGuiTableColumnE", !6, i64 0, !6, i64 8}
!14 = !{!"_ZTS6ImSpanIaE", !6, i64 0, !6, i64 8}
!15 = !{!"_ZTS6ImSpanI18ImGuiTableCellDataE", !6, i64 0, !6, i64 8}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!"_ZTS6ImRect", !20, i64 0, !20, i64 8}
!20 = !{!"_ZTS6ImVec2", !18, i64 0, !18, i64 4}
!21 = !{!"_ZTS15ImGuiTextBuffer", !22, i64 0}
!22 = !{!"_ZTS8ImVectorIcE", !10, i64 0, !10, i64 4, !6, i64 8}
!23 = !{!"_ZTS22ImGuiTableInstanceData", !18, i64 0, !18, i64 4, !18, i64 8}
!24 = !{!"_ZTS8ImVectorI22ImGuiTableInstanceDataE", !10, i64 0, !10, i64 4, !6, i64 8}
!25 = !{!"_ZTS25ImGuiTableColumnSortSpecs", !10, i64 0, !17, i64 4, !17, i64 6, !10, i64 8}
!26 = !{!"_ZTS8ImVectorI25ImGuiTableColumnSortSpecsE", !10, i64 0, !10, i64 4, !6, i64 8}
!27 = !{!"_ZTS19ImGuiTableSortSpecs", !6, i64 0, !10, i64 8, !28, i64 12}
!28 = !{!"bool", !7, i64 0}
!29 = !{!12, !10, 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"

@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [48 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui22TableGetColumnResizeIDEPK10ImGuiTableii = external hidden unnamed_addr constant [68 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN5ImGui22TableGetColumnResizeIDEPK10ImGuiTableii(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = icmp sgt i32 %1, -1
  br i1 %4, label %5, label %.critedge

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 116
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, %1
  br i1 %8, label %9, label %.critedge

.critedge:                                        ; preds = %3, %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.44, ptr noundef nonnull @.str.2, i32 noundef 1621, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui22TableGetColumnResizeIDEPK10ImGuiTableii) #2
  unreachable

9:                                                ; preds = %5
  %10 = load i32, ptr %0, align 8, !tbaa !27
  %11 = mul nsw i32 %7, %2
  %12 = add nuw nsw i32 %1, 1
  %13 = add i32 %12, %11
  %14 = add i32 %13, %10
  ret i32 %14
}

attributes #0 = { noreturn 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 #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 = { noreturn 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 116}
!6 = !{!"_ZTS10ImGuiTable", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 40, !13, i64 56, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !7, i64 104, !7, i64 108, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !15, i64 128, !15, i64 130, !16, i64 132, !16, i64 136, !16, i64 140, !16, i64 144, !16, i64 148, !7, i64 152, !7, i64 154, !7, i64 156, !8, i64 160, !7, i64 168, !7, i64 172, !16, i64 176, !16, i64 180, !16, i64 184, !16, i64 188, !16, i64 192, !16, i64 196, !16, i64 200, !16, i64 204, !16, i64 208, !16, i64 212, !16, i64 216, !16, i64 220, !16, i64 224, !16, i64 228, !16, i64 232, !16, i64 236, !17, i64 240, !17, i64 256, !17, i64 272, !17, i64 288, !17, i64 304, !17, i64 320, !17, i64 336, !17, i64 352, !17, i64 368, !10, i64 384, !10, i64 392, !19, i64 400, !10, i64 416, !21, i64 424, !22, i64 440, !23, i64 456, !24, i64 472, !25, i64 488, !8, i64 504, !8, i64 505, !8, i64 506, !8, i64 507, !8, i64 508, !8, i64 509, !8, i64 510, !8, i64 511, !8, i64 512, !8, i64 513, !8, i64 514, !8, i64 515, !8, i64 516, !8, i64 517, !8, i64 518, !8, i64 519, !8, i64 520, !8, i64 521, !8, i64 522, !8, i64 523, !8, i64 524, !8, i64 525, !8, i64 526, !8, i64 527, !8, i64 528, !26, i64 529, !26, i64 530, !26, i64 531, !26, i64 532, !26, i64 533, !26, i64 534, !26, i64 535, !26, i64 536, !26, i64 537, !26, i64 538, !26, i64 539, !26, i64 540, !26, i64 541, !26, i64 542, !26, i64 543, !26, i64 544, !26, i64 545}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS6ImSpanI16ImGuiTableColumnE", !10, i64 0, !10, i64 8}
!12 = !{!"_ZTS6ImSpanIaE", !10, i64 0, !10, i64 8}
!13 = !{!"_ZTS6ImSpanI18ImGuiTableCellDataE", !10, i64 0, !10, i64 8}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!"float", !8, i64 0}
!17 = !{!"_ZTS6ImRect", !18, i64 0, !18, i64 8}
!18 = !{!"_ZTS6ImVec2", !16, i64 0, !16, i64 4}
!19 = !{!"_ZTS15ImGuiTextBuffer", !20, i64 0}
!20 = !{!"_ZTS8ImVectorIcE", !7, i64 0, !7, i64 4, !10, i64 8}
!21 = !{!"_ZTS22ImGuiTableInstanceData", !16, i64 0, !16, i64 4, !16, i64 8}
!22 = !{!"_ZTS8ImVectorI22ImGuiTableInstanceDataE", !7, i64 0, !7, i64 4, !10, i64 8}
!23 = !{!"_ZTS25ImGuiTableColumnSortSpecs", !7, i64 0, !15, i64 4, !15, i64 6, !7, i64 8}
!24 = !{!"_ZTS8ImVectorI25ImGuiTableColumnSortSpecsE", !7, i64 0, !7, i64 4, !10, i64 8}
!25 = !{!"_ZTS19ImGuiTableSortSpecs", !10, i64 0, !7, i64 8, !26, i64 12}
!26 = !{!"bool", !8, i64 0}
!27 = !{!6, !7, i64 0}


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