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

@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.65 = 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 zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i8 @_ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn(ptr noundef %0) #3 {
  %2 = alloca i8, align 1
  %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 38
  %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.65, ptr noundef @.str.1, i32 noundef 2858, 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 23
  %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 zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef %23, i32 noundef 0)
  store i8 %24, ptr %2, align 1
  br label %60

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 = %54, %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 %57

30:                                               ; preds = %26
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ImGuiTableColumn, ptr %31, i32 0, i32 38
  %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 zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef %36, i32 noundef %37)
  %39 = zext i8 %38 to i32
  %40 = icmp eq i32 %35, %39
  br i1 %40, label %41, label %53

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

53:                                               ; preds = %30
  br label %54

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

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

59:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.44, ptr noundef @.str.1, i32 noundef 2864, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn) #4
  unreachable

60:                                               ; preds = %57, %22
  %61 = load i8, ptr %2, align 1
  ret i8 %61

62:                                               ; preds = %57
  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 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 = !{!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 [81 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.65 = 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 zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i8 @_ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 113
  %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.65, ptr noundef nonnull @.str.1, i32 noundef 2858, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui31TableGetColumnNextSortDirectionEP16ImGuiTableColumn) #3
  unreachable

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

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

.preheader.1:                                     ; preds = %.preheader.preheader
  %13 = load i8, ptr %2, align 1
  %14 = and i8 %13, 3
  %15 = tail call noundef zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %0, i32 noundef 1)
  %16 = icmp eq i8 %14, %15
  br i1 %16, label %22, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %17 = load i8, ptr %2, align 1
  %18 = and i8 %17, 3
  %19 = tail call noundef zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %0, i32 noundef 2)
  %20 = icmp eq i8 %18, %19
  br i1 %20, label %22, label %21

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

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

27:                                               ; preds = %6, %22
  %.zext.sink = phi i32 [ %.zext, %22 ], [ 0, %6 ]
  %28 = tail call noundef zeroext i8 @_ZL32TableGetColumnAvailSortDirectionP16ImGuiTableColumni(ptr noundef nonnull %0, i32 noundef %.zext.sink)
  ret i8 %28
}

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


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