; LLVM IR from xhub/reshop :: gui/external/imgui (imgui_tables)

; 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.ImGuiTableColumn = type <{ i32, float, float, float, float, float, float, float, float, %struct.ImRect, i32, float, float, float, float, float, float, float, i16, i16, i16, i16, i16, i16, i16, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }
%struct.ImVec2 = type { float, float }
%struct.ImGuiTable = type <{ i32, i32, ptr, ptr, %struct.ImSpan, %struct.ImSpan.41, %struct.ImSpan.42, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i16, i16, float, 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, 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, %struct.ImVector.43, %struct.ImGuiTableColumnSortSpecs, [4 x i8], %struct.ImVector.44, %struct.ImGuiTableSortSpecs, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, 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.41 = type { ptr, ptr }
%struct.ImSpan.42 = type { ptr, ptr }
%struct.ImGuiTextBuffer = type { %struct.ImVector.28 }
%struct.ImVector.28 = type { i32, i32, ptr }
%struct.ImGuiTableInstanceData = type { i32, float, float, float, i32, i32 }
%struct.ImVector.43 = type { i32, i32, ptr }
%struct.ImGuiTableColumnSortSpecs = type <{ i32, i16, i16, i8, [3 x i8] }>
%struct.ImVector.44 = type { i32, i32, ptr }
%struct.ImGuiTableSortSpecs = type <{ ptr, i32, i8, [3 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui27TableFixColumnSortDirectionEP10ImGuiTableP16ImGuiTableColumn(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %5, i32 0, i32 23
  %7 = load i16, ptr %6, align 2, !tbaa !9
  %8 = sext i16 %7 to i32
  %9 = icmp eq i32 %8, -1
  br i1 %9, label %24, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %11, i32 0, i32 38
  %13 = load i8, ptr %12, align 1
  %14 = lshr i8 %13, 4
  %15 = zext i8 %14 to i32
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %16, i32 0, i32 38
  %18 = load i8, ptr %17, align 1
  %19 = and i8 %18, 3
  %20 = zext i8 %19 to i32
  %21 = shl i32 1, %20
  %22 = and i32 %15, %21
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %10, %2
  br label %36

25:                                               ; preds = %10
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = call noundef zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef %26, i32 noundef 0)
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %28, i32 0, i32 38
  %30 = load i8, ptr %29, align 1
  %31 = and i8 %27, 3
  %32 = and i8 %30, -4
  %33 = or i8 %32, %31
  store i8 %33, ptr %29, align 1
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ImGuiTable, ptr %34, i32 0, i32 95
  store i8 1, ptr %35, align 1, !tbaa !17
  br label %36

36:                                               ; preds = %25, %24
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef, i32 noundef) #1

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

!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, !15, i64 94}
!10 = !{!"_ZTS16ImGuiTableColumn", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !13, i64 36, !11, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !15, i64 84, !15, i64 86, !15, i64 88, !15, i64 90, !15, i64 92, !15, i64 94, !15, i64 96, !15, i64 98, !15, i64 100, !16, i64 102, !16, i64 103, !16, i64 104, !16, i64 105, !16, i64 106, !16, i64 107, !16, i64 108, !16, i64 109, !7, i64 110, !7, i64 111, !7, i64 112, !7, i64 113, !7, i64 113, !7, i64 113, !7, i64 114}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"_ZTS6ImRect", !14, i64 0, !14, i64 8}
!14 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!15 = !{!"short", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!18, !16, i64 569}
!18 = !{!"_ZTS10ImGuiTable", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !19, i64 24, !20, i64 40, !21, i64 56, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !15, i64 120, !15, i64 122, !12, i64 124, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !11, i64 148, !11, i64 150, !11, i64 152, !7, i64 156, !11, i64 164, !11, i64 168, !12, i64 172, !12, i64 176, !12, i64 180, !12, i64 184, !12, i64 188, !12, i64 192, !12, i64 196, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !12, i64 224, !12, i64 228, !12, i64 232, !12, i64 236, !13, i64 240, !13, i64 256, !13, i64 272, !13, i64 288, !13, i64 304, !13, i64 320, !13, i64 336, !13, i64 352, !13, i64 368, !6, i64 384, !6, i64 392, !22, i64 400, !6, i64 416, !24, i64 424, !25, i64 448, !26, i64 464, !28, i64 480, !29, i64 496, !15, i64 512, !15, i64 514, !15, i64 516, !15, i64 518, !15, i64 520, !15, i64 522, !15, i64 524, !15, i64 526, !15, i64 528, !15, i64 530, !15, i64 532, !15, i64 534, !15, i64 536, !15, i64 538, !15, i64 540, !15, i64 542, !15, i64 544, !15, i64 546, !15, i64 548, !15, i64 550, !15, i64 552, !15, i64 554, !15, i64 556, !15, i64 558, !15, i64 560, !15, i64 562, !15, i64 564, !16, i64 566, !16, i64 567, !16, i64 568, !16, i64 569, !16, i64 570, !16, i64 571, !16, i64 572, !16, i64 573, !16, i64 574, !16, i64 575, !16, i64 576, !16, i64 577, !16, i64 578, !16, i64 579, !16, i64 580, !16, i64 581, !16, i64 582, !16, i64 583, !16, i64 584, !16, i64 585}
!19 = !{!"_ZTS6ImSpanI16ImGuiTableColumnE", !6, i64 0, !6, i64 8}
!20 = !{!"_ZTS6ImSpanIsE", !6, i64 0, !6, i64 8}
!21 = !{!"_ZTS6ImSpanI18ImGuiTableCellDataE", !6, i64 0, !6, i64 8}
!22 = !{!"_ZTS15ImGuiTextBuffer", !23, i64 0}
!23 = !{!"_ZTS8ImVectorIcE", !11, i64 0, !11, i64 4, !6, i64 8}
!24 = !{!"_ZTS22ImGuiTableInstanceData", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !11, i64 16, !11, i64 20}
!25 = !{!"_ZTS8ImVectorI22ImGuiTableInstanceDataE", !11, i64 0, !11, i64 4, !6, i64 8}
!26 = !{!"_ZTS25ImGuiTableColumnSortSpecs", !11, i64 0, !15, i64 4, !15, i64 6, !27, i64 8}
!27 = !{!"_ZTS18ImGuiSortDirection", !7, i64 0}
!28 = !{!"_ZTS8ImVectorI25ImGuiTableColumnSortSpecsE", !11, i64 0, !11, i64 4, !6, i64 8}
!29 = !{!"_ZTS19ImGuiTableSortSpecs", !6, i64 0, !11, i64 8, !16, i64 12}


; 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
define dso_local void @_ZN5ImGui27TableFixColumnSortDirectionEP10ImGuiTableP16ImGuiTableColumn(ptr nocapture noundef writeonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 94
  %4 = load i16, ptr %3, align 2, !tbaa !5
  %5 = icmp eq i16 %4, -1
  br i1 %5, label %22, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 113
  %8 = load i8, ptr %7, align 1
  %9 = lshr i8 %8, 4
  %10 = zext nneg i8 %9 to i32
  %11 = and i8 %8, 3
  %12 = zext nneg i8 %11 to i32
  %13 = shl nuw nsw i32 1, %12
  %14 = and i32 %13, %10
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %22

15:                                               ; preds = %6
  %16 = tail call noundef zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %1, i32 noundef 0)
  %17 = load i8, ptr %7, align 1
  %18 = and i8 %16, 3
  %19 = and i8 %17, -4
  %20 = or disjoint i8 %19, %18
  store i8 %20, ptr %7, align 1
  %21 = getelementptr inbounds i8, ptr %0, i64 569
  store i8 1, ptr %21, align 1, !tbaa !15
  br label %22

22:                                               ; preds = %2, %6, %15
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef, i32 noundef) local_unnamed_addr #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" }

!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 94}
!6 = !{!"_ZTS16ImGuiTableColumn", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !11, i64 36, !7, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !13, i64 84, !13, i64 86, !13, i64 88, !13, i64 90, !13, i64 92, !13, i64 94, !13, i64 96, !13, i64 98, !13, i64 100, !14, i64 102, !14, i64 103, !14, i64 104, !14, i64 105, !14, i64 106, !14, i64 107, !14, i64 108, !14, i64 109, !8, i64 110, !8, i64 111, !8, i64 112, !8, i64 113, !8, i64 113, !8, i64 113, !8, i64 114}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"_ZTS6ImRect", !12, i64 0, !12, i64 8}
!12 = !{!"_ZTS6ImVec2", !10, i64 0, !10, i64 4}
!13 = !{!"short", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!16, !14, i64 569}
!16 = !{!"_ZTS10ImGuiTable", !7, i64 0, !7, i64 4, !17, i64 8, !17, i64 16, !18, i64 24, !19, i64 40, !20, i64 56, !17, i64 72, !17, i64 80, !17, i64 88, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108, !7, i64 112, !7, i64 116, !13, i64 120, !13, i64 122, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !7, i64 148, !7, i64 150, !7, i64 152, !8, i64 156, !7, i64 164, !7, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !10, i64 196, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !10, i64 232, !10, i64 236, !11, i64 240, !11, i64 256, !11, i64 272, !11, i64 288, !11, i64 304, !11, i64 320, !11, i64 336, !11, i64 352, !11, i64 368, !17, i64 384, !17, i64 392, !21, i64 400, !17, i64 416, !23, i64 424, !24, i64 448, !25, i64 464, !27, i64 480, !28, i64 496, !13, i64 512, !13, i64 514, !13, i64 516, !13, i64 518, !13, i64 520, !13, i64 522, !13, i64 524, !13, i64 526, !13, i64 528, !13, i64 530, !13, i64 532, !13, i64 534, !13, i64 536, !13, i64 538, !13, i64 540, !13, i64 542, !13, i64 544, !13, i64 546, !13, i64 548, !13, i64 550, !13, i64 552, !13, i64 554, !13, i64 556, !13, i64 558, !13, i64 560, !13, i64 562, !13, i64 564, !14, i64 566, !14, i64 567, !14, i64 568, !14, i64 569, !14, i64 570, !14, i64 571, !14, i64 572, !14, i64 573, !14, i64 574, !14, i64 575, !14, i64 576, !14, i64 577, !14, i64 578, !14, i64 579, !14, i64 580, !14, i64 581, !14, i64 582, !14, i64 583, !14, i64 584, !14, i64 585}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!"_ZTS6ImSpanI16ImGuiTableColumnE", !17, i64 0, !17, i64 8}
!19 = !{!"_ZTS6ImSpanIsE", !17, i64 0, !17, i64 8}
!20 = !{!"_ZTS6ImSpanI18ImGuiTableCellDataE", !17, i64 0, !17, i64 8}
!21 = !{!"_ZTS15ImGuiTextBuffer", !22, i64 0}
!22 = !{!"_ZTS8ImVectorIcE", !7, i64 0, !7, i64 4, !17, i64 8}
!23 = !{!"_ZTS22ImGuiTableInstanceData", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 20}
!24 = !{!"_ZTS8ImVectorI22ImGuiTableInstanceDataE", !7, i64 0, !7, i64 4, !17, i64 8}
!25 = !{!"_ZTS25ImGuiTableColumnSortSpecs", !7, i64 0, !13, i64 4, !13, i64 6, !26, i64 8}
!26 = !{!"_ZTS18ImGuiSortDirection", !8, i64 0}
!27 = !{!"_ZTS8ImVectorI25ImGuiTableColumnSortSpecsE", !7, i64 0, !7, i64 4, !17, i64 8}
!28 = !{!"_ZTS19ImGuiTableSortSpecs", !17, i64 0, !7, i64 8, !14, i64 12}


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