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

@.str.1 = external hidden unnamed_addr constant [124 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn = external hidden unnamed_addr constant [78 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: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %6, i32 0, i32 37
  %8 = load i8, ptr %7, align 1
  %9 = lshr i8 %8, 2
  %10 = and i8 %9, 3
  %11 = zext i8 %10 to i32
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  br label %16

14:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.67, ptr noundef @.str.1, i32 noundef 2697, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn) #4
  unreachable

15:                                               ; No predecessors!
  br label %16

16:                                               ; preds = %15, %13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %17, i32 0, i32 22
  %19 = load i16, ptr %18, align 2, !tbaa !9
  %20 = sext i16 %19 to i32
  %21 = icmp eq i32 %20, -1
  br i1 %21, label %22, label %25

22:                                               ; preds = %16
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef %23, i32 noundef 0)
  store i32 %24, ptr %2, align 4
  br label %59

25:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !17
  br label %26

26:                                               ; preds = %53, %25
  %27 = load i32, ptr %4, align 4, !tbaa !17
  %28 = icmp slt i32 %27, 3
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 2, ptr %5, align 4
  br label %56

30:                                               ; preds = %26
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %31, i32 0, i32 37
  %33 = load i8, ptr %32, align 1
  %34 = and i8 %33, 3
  %35 = zext i8 %34 to i32
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !17
  %38 = call noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef %36, i32 noundef %37)
  %39 = icmp eq i32 %35, %38
  br i1 %39, label %40, label %52

40:                                               ; preds = %30
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !17
  %43 = add nsw i32 %42, 1
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %44, i32 0, i32 37
  %46 = load i8, ptr %45, align 1
  %47 = lshr i8 %46, 2
  %48 = and i8 %47, 3
  %49 = zext i8 %48 to i32
  %50 = srem i32 %43, %49
  %51 = call noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef %41, i32 noundef %50)
  store i32 %51, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %56

52:                                               ; preds = %30
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %4, align 4, !tbaa !17
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %4, align 4, !tbaa !17
  br label %26, !llvm.loop !18

56:                                               ; preds = %40, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %57 = load i32, ptr %5, align 4
  switch i32 %57, label %61 [
    i32 2, label %58
    i32 1, label %59
  ]

58:                                               ; preds = %56
  call void @__assert_fail(ptr noundef @.str.47, ptr noundef @.str.1, i32 noundef 2703, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn) #4
  unreachable

59:                                               ; preds = %56, %22
  %60 = load i32, ptr %2, align 4
  ret i32 %60

61:                                               ; preds = %56
  unreachable
}

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 = { 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 = { 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 #4 = { noreturn nounwind }
attributes #5 = { 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, !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 = !{!11, !11, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [124 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn = external hidden unnamed_addr constant [78 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: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 109
  %3 = load i8, ptr %2, align 1
  %4 = and i8 %3, 12
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %5, label %6

5:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.67, ptr noundef nonnull @.str.1, i32 noundef 2697, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn) #3
  unreachable

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 90
  %8 = load i16, ptr %7, align 2, !tbaa !5
  %9 = icmp eq i16 %8, -1
  br i1 %9, label %30, label %.preheader.preheader

.preheader.preheader:                             ; preds = %6
  %10 = and i8 %3, 3
  %11 = zext nneg i8 %10 to i32
  %12 = tail call noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %0, i32 noundef 0)
  %13 = icmp eq i32 %12, %11
  br i1 %13, label %25, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %14 = load i8, ptr %2, align 1
  %15 = and i8 %14, 3
  %16 = zext nneg i8 %15 to i32
  %17 = tail call noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %0, i32 noundef 1)
  %18 = icmp eq i32 %17, %16
  br i1 %18, label %25, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %19 = load i8, ptr %2, align 1
  %20 = and i8 %19, 3
  %21 = zext nneg i8 %20 to i32
  %22 = tail call noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %0, i32 noundef 2)
  %23 = icmp eq i32 %22, %21
  br i1 %23, label %25, label %24

24:                                               ; preds = %.preheader.2
  tail call void @__assert_fail(ptr noundef nonnull @.str.47, ptr noundef nonnull @.str.1, i32 noundef 2703, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn) #3
  unreachable

25:                                               ; preds = %.preheader.2, %.preheader.1, %.preheader.preheader
  %.01219.lcssa = phi i8 [ 1, %.preheader.preheader ], [ 2, %.preheader.1 ], [ 3, %.preheader.2 ]
  %26 = load i8, ptr %2, align 1
  %27 = lshr i8 %26, 2
  %28 = and i8 %27, 3
  %29 = urem i8 %.01219.lcssa, %28
  %.zext = zext nneg i8 %29 to i32
  br label %30

30:                                               ; preds = %6, %25
  %.zext.sink = phi i32 [ %.zext, %25 ], [ 0, %6 ]
  %31 = tail call noundef i32 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %0, i32 noundef %.zext.sink)
  ret i32 %31
}

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 = { 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 #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 }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass