; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/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, %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.35, %struct.ImSpan.36, ptr, ptr, ptr, 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, %struct.ImVector.37, %struct.ImGuiTableColumnSortSpecs, [4 x i8], %struct.ImVector.38, %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, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, [5 x i8] }>
%struct.ImSpan = type { ptr, ptr }
%struct.ImSpan.35 = type { ptr, ptr }
%struct.ImSpan.36 = type { ptr, ptr }
%struct.ImGuiTextBuffer = type { %struct.ImVector.24 }
%struct.ImVector.24 = type { i32, i32, ptr }
%struct.ImGuiTableInstanceData = type { i32, 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] }>

; 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 22
  %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 37
  %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 37
  %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 %37

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_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 90}
!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, !13, i64 32, !11, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !15, i64 80, !15, i64 82, !15, i64 84, !15, i64 86, !15, i64 88, !15, i64 90, !15, i64 92, !15, i64 94, !15, i64 96, !16, i64 98, !16, i64 99, !16, i64 100, !16, i64 101, !16, i64 102, !16, i64 103, !16, i64 104, !16, i64 105, !7, i64 106, !7, i64 107, !7, i64 108, !7, i64 109, !7, i64 109, !7, i64 109, !7, i64 110}
!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 549}
!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, !11, i64 144, !11, i64 146, !11, i64 148, !7, i64 152, !11, i64 160, !11, i64 164, !12, 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, !13, i64 232, !13, i64 248, !13, i64 264, !13, i64 280, !13, i64 296, !13, i64 312, !13, i64 328, !13, i64 344, !13, i64 360, !6, i64 376, !6, i64 384, !22, i64 392, !6, i64 408, !24, i64 416, !25, i64 432, !26, i64 448, !27, i64 464, !28, i64 480, !15, i64 496, !15, i64 498, !15, i64 500, !15, i64 502, !15, i64 504, !15, i64 506, !15, i64 508, !15, i64 510, !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, !16, i64 546, !16, i64 547, !16, i64 548, !16, i64 549, !16, i64 550, !16, i64 551, !16, i64 552, !16, i64 553, !16, i64 554, !16, i64 555, !16, i64 556, !16, i64 557, !16, i64 558, !16, i64 559, !16, i64 560, !16, i64 561, !16, i64 562}
!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}
!25 = !{!"_ZTS8ImVectorI22ImGuiTableInstanceDataE", !11, i64 0, !11, i64 4, !6, i64 8}
!26 = !{!"_ZTS25ImGuiTableColumnSortSpecs", !11, i64 0, !15, i64 4, !15, i64 6, !11, i64 8}
!27 = !{!"_ZTS8ImVectorI25ImGuiTableColumnSortSpecsE", !11, i64 0, !11, i64 4, !6, i64 8}
!28 = !{!"_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 90
  %4 = load i16, ptr %3, align 2, !tbaa !5
  %5 = icmp eq i16 %4, -1
  br i1 %5, label %23, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 109
  %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 %23

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_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 90}
!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, !11, i64 32, !7, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !13, i64 80, !13, i64 82, !13, i64 84, !13, i64 86, !13, i64 88, !13, i64 90, !13, i64 92, !13, i64 94, !13, i64 96, !14, i64 98, !14, i64 99, !14, i64 100, !14, i64 101, !14, i64 102, !14, i64 103, !14, i64 104, !14, i64 105, !8, i64 106, !8, i64 107, !8, i64 108, !8, i64 109, !8, i64 109, !8, i64 109, !8, i64 110}
!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 549}
!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, !7, i64 144, !7, i64 146, !7, i64 148, !8, i64 152, !7, i64 160, !7, i64 164, !10, 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, !11, i64 232, !11, i64 248, !11, i64 264, !11, i64 280, !11, i64 296, !11, i64 312, !11, i64 328, !11, i64 344, !11, i64 360, !17, i64 376, !17, i64 384, !21, i64 392, !17, i64 408, !23, i64 416, !24, i64 432, !25, i64 448, !26, i64 464, !27, i64 480, !13, i64 496, !13, i64 498, !13, i64 500, !13, i64 502, !13, i64 504, !13, i64 506, !13, i64 508, !13, i64 510, !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, !14, i64 546, !14, i64 547, !14, i64 548, !14, i64 549, !14, i64 550, !14, i64 551, !14, i64 552, !14, i64 553, !14, i64 554, !14, i64 555, !14, i64 556, !14, i64 557, !14, i64 558, !14, i64 559, !14, i64 560, !14, i64 561, !14, i64 562}
!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}
!24 = !{!"_ZTS8ImVectorI22ImGuiTableInstanceDataE", !7, i64 0, !7, i64 4, !17, i64 8}
!25 = !{!"_ZTS25ImGuiTableColumnSortSpecs", !7, i64 0, !13, i64 4, !13, i64 6, !7, i64 8}
!26 = !{!"_ZTS8ImVectorI25ImGuiTableColumnSortSpecsE", !7, i64 0, !7, i64 4, !17, i64 8}
!27 = !{!"_ZTS19ImGuiTableSortSpecs", !17, i64 0, !7, i64 8, !14, i64 12}


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