; 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.ImGuiTableSettings = type <{ i32, i32, float, i16, i16, i8, [3 x i8] }>
%struct.ImGuiTableColumnSettings = type <{ float, i32, i16, i16, i16, i8, i8 }>

@.str.104 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.111 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.112 = external hidden unnamed_addr constant [7 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: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN18ImGuiTableSettings17GetColumnSettingsEv(ptr noundef nonnull align 4 dereferenceable(17)) #1 align 2

declare noundef zeroext i1 @_ZN5ImGui8TreeNodeEPKvPKcz(ptr noundef, ptr noundef, ...) #2

declare void @_ZN5ImGui10BulletTextEPKcz(ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui22DebugNodeTableSettingsEP18ImGuiTableSettings(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.ImGuiTableSettings, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = zext i32 %8 to i64
  %10 = inttoptr i64 %9 to ptr
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ImGuiTableSettings, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ImGuiTableSettings, ptr %14, i32 0, i32 3
  %16 = load i16, ptr %15, align 4, !tbaa !15
  %17 = sext i16 %16 to i32
  %18 = call noundef zeroext i1 (ptr, ptr, ...) @_ZN5ImGui8TreeNodeEPKvPKcz(ptr noundef %10, ptr noundef @.str.104, i32 noundef %13, i32 noundef %17)
  br i1 %18, label %20, label %19

19:                                               ; preds = %1
  br label %111

20:                                               ; preds = %1
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ImGuiTableSettings, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !16
  call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef @.str.105, i32 noundef %23)
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ImGuiTableSettings, ptr %24, i32 0, i32 3
  %26 = load i16, ptr %25, align 4, !tbaa !15
  %27 = sext i16 %26 to i32
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ImGuiTableSettings, ptr %28, i32 0, i32 4
  %30 = load i16, ptr %29, align 2, !tbaa !17
  %31 = sext i16 %30 to i32
  call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef @.str.106, i32 noundef %27, i32 noundef %31)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !18
  br label %32

32:                                               ; preds = %107, %20
  %33 = load i32, ptr %3, align 4, !tbaa !18
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ImGuiTableSettings, ptr %34, i32 0, i32 3
  %36 = load i16, ptr %35, align 4, !tbaa !15
  %37 = sext i16 %36 to i32
  %38 = icmp slt i32 %33, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %110

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = call noundef ptr @_ZN18ImGuiTableSettings17GetColumnSettingsEv(ptr noundef nonnull align 4 dereferenceable(17) %41)
  %43 = load i32, ptr %3, align 4, !tbaa !18
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %42, i64 %44
  store ptr %45, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %46, i32 0, i32 4
  %48 = load i16, ptr %47, align 4, !tbaa !19
  %49 = sext i16 %48 to i32
  %50 = icmp ne i32 %49, -1
  br i1 %50, label %51, label %56

51:                                               ; preds = %40
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %52, i32 0, i32 5
  %54 = load i8, ptr %53, align 2
  %55 = and i8 %54, 3
  br label %57

56:                                               ; preds = %40
  br label %57

57:                                               ; preds = %56, %51
  %58 = phi i8 [ %55, %51 ], [ 0, %56 ]
  store i8 %58, ptr %5, align 1, !tbaa !21
  %59 = load i32, ptr %3, align 4, !tbaa !18
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %60, i32 0, i32 3
  %62 = load i16, ptr %61, align 2, !tbaa !23
  %63 = sext i16 %62 to i32
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %64, i32 0, i32 4
  %66 = load i16, ptr %65, align 4, !tbaa !19
  %67 = sext i16 %66 to i32
  %68 = load i8, ptr %5, align 1, !tbaa !21
  %69 = zext i8 %68 to i32
  %70 = icmp eq i32 %69, 1
  br i1 %70, label %71, label %72

71:                                               ; preds = %57
  br label %80

72:                                               ; preds = %57
  %73 = load i8, ptr %5, align 1, !tbaa !21
  %74 = zext i8 %73 to i32
  %75 = icmp eq i32 %74, 2
  br i1 %75, label %76, label %77

76:                                               ; preds = %72
  br label %78

77:                                               ; preds = %72
  br label %78

78:                                               ; preds = %77, %76
  %79 = phi ptr [ @.str.109, %76 ], [ @.str.110, %77 ]
  br label %80

80:                                               ; preds = %78, %71
  %81 = phi ptr [ @.str.108, %71 ], [ %79, %78 ]
  %82 = getelementptr inbounds [4 x i8], ptr %81, i64 0, i64 0
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %83, i32 0, i32 5
  %85 = load i8, ptr %84, align 2
  %86 = lshr i8 %85, 2
  %87 = and i8 %86, 1
  %88 = zext i8 %87 to i32
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %89, i32 0, i32 5
  %91 = load i8, ptr %90, align 2
  %92 = lshr i8 %91, 3
  %93 = and i8 %92, 1
  %94 = icmp ne i8 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %80
  br label %97

96:                                               ; preds = %80
  br label %97

97:                                               ; preds = %96, %95
  %98 = phi ptr [ @.str.111, %95 ], [ @.str.112, %96 ]
  %99 = getelementptr inbounds [7 x i8], ptr %98, i64 0, i64 0
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %100, i32 0, i32 0
  %102 = load float, ptr %101, align 4, !tbaa !24
  %103 = fpext float %102 to double
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %104, i32 0, i32 1
  %106 = load i32, ptr %105, align 4, !tbaa !25
  call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef @.str.107, i32 noundef %59, i32 noundef %63, i32 noundef %67, ptr noundef %82, i32 noundef %88, ptr noundef %99, double noundef %103, i32 noundef %106)
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %107

107:                                              ; preds = %97
  %108 = load i32, ptr %3, align 4, !tbaa !18
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %3, align 4, !tbaa !18
  br label %32, !llvm.loop !26

110:                                              ; preds = %39
  call void @_ZN5ImGui7TreePopEv()
  br label %111

111:                                              ; preds = %110, %19
  ret void
}

declare void @_ZN5ImGui7TreePopEv() #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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, !11, i64 0}
!10 = !{!"_ZTS18ImGuiTableSettings", !11, i64 0, !11, i64 4, !12, i64 8, !13, i64 12, !13, i64 14, !14, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!10, !13, i64 12}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !13, i64 14}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !13, i64 12}
!20 = !{!"_ZTS24ImGuiTableColumnSettings", !12, i64 0, !11, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !7, i64 14, !7, i64 14, !7, i64 14}
!21 = !{!22, !22, i64 0}
!22 = !{!"_ZTS18ImGuiSortDirection", !7, i64 0}
!23 = !{!20, !13, i64 10}
!24 = !{!20, !12, i64 0}
!25 = !{!20, !11, i64 4}
!26 = distinct !{!26, !27}
!27 = !{!"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"

%struct.ImGuiTableColumnSettings = type <{ float, i32, i16, i16, i16, i8, i8 }>

@.str.104 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.111 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.112 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN18ImGuiTableSettings17GetColumnSettingsEv(ptr noundef nonnull align 4 dereferenceable(17)) local_unnamed_addr #0 align 2

declare noundef zeroext i1 @_ZN5ImGui8TreeNodeEPKvPKcz(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare void @_ZN5ImGui10BulletTextEPKcz(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui22DebugNodeTableSettingsEP18ImGuiTableSettings(ptr noundef %0) local_unnamed_addr #2 {
  %2 = load i32, ptr %0, align 4, !tbaa !5
  %3 = zext i32 %2 to i64
  %4 = inttoptr i64 %3 to ptr
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i16, ptr %5, align 4, !tbaa !13
  %7 = sext i16 %6 to i32
  %8 = tail call noundef zeroext i1 (ptr, ptr, ...) @_ZN5ImGui8TreeNodeEPKvPKcz(ptr noundef %4, ptr noundef nonnull @.str.104, i32 noundef %2, i32 noundef %7)
  br i1 %8, label %9, label %44

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !14
  tail call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef nonnull @.str.105, i32 noundef %11)
  %12 = load i16, ptr %5, align 4, !tbaa !13
  %13 = sext i16 %12 to i32
  %14 = getelementptr inbounds i8, ptr %0, i64 14
  %15 = load i16, ptr %14, align 2, !tbaa !15
  %16 = sext i16 %15 to i32
  tail call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef nonnull @.str.106, i32 noundef %13, i32 noundef %16)
  %17 = load i16, ptr %5, align 4, !tbaa !13
  %18 = icmp sgt i16 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.thread24, %9
  tail call void @_ZN5ImGui7TreePopEv()
  br label %44

.lr.ph:                                           ; preds = %9, %.thread24
  %indvars.iv = phi i64 [ %indvars.iv.next, %.thread24 ], [ 0, %9 ]
  %19 = tail call noundef ptr @_ZN18ImGuiTableSettings17GetColumnSettingsEv(ptr noundef nonnull align 4 dereferenceable(17) %0)
  %20 = getelementptr inbounds %struct.ImGuiTableColumnSettings, ptr %19, i64 %indvars.iv
  %21 = getelementptr inbounds i8, ptr %20, i64 12
  %22 = load i16, ptr %21, align 4, !tbaa !16
  %.not = icmp eq i16 %22, -1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %20, i64 14
  %.pre = load i8, ptr %.phi.trans.insert, align 2
  %.fr27 = freeze i8 %.pre
  br i1 %.not, label %.thread24, label %23

23:                                               ; preds = %.lr.ph
  %24 = and i8 %.fr27, 3
  %25 = sext i16 %22 to i32
  %26 = icmp eq i8 %24, 1
  %27 = icmp eq i8 %24, 2
  %.str.109..str.110 = select i1 %27, ptr @.str.109, ptr @.str.110
  %spec.select = select i1 %26, ptr @.str.108, ptr %.str.109..str.110
  br label %.thread24

.thread24:                                        ; preds = %.lr.ph, %23
  %28 = phi i32 [ %25, %23 ], [ -1, %.lr.ph ]
  %29 = phi ptr [ %spec.select, %23 ], [ @.str.110, %.lr.ph ]
  %.in.in = getelementptr inbounds i8, ptr %20, i64 10
  %.in = load i16, ptr %.in.in, align 2, !tbaa !18
  %30 = sext i16 %.in to i32
  %31 = lshr i8 %.fr27, 2
  %32 = and i8 %31, 1
  %33 = zext nneg i8 %32 to i32
  %34 = and i8 %.fr27, 8
  %.not21 = icmp eq i8 %34, 0
  %35 = select i1 %.not21, ptr @.str.112, ptr @.str.111
  %36 = load float, ptr %20, align 4, !tbaa !19
  %37 = fpext float %36 to double
  %38 = getelementptr inbounds i8, ptr %20, i64 4
  %39 = load i32, ptr %38, align 4, !tbaa !20
  %40 = trunc nuw nsw i64 %indvars.iv to i32
  tail call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef nonnull @.str.107, i32 noundef %40, i32 noundef %30, i32 noundef %28, ptr noundef nonnull %29, i32 noundef %33, ptr noundef nonnull %35, double noundef %37, i32 noundef %39)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = load i16, ptr %5, align 4, !tbaa !13
  %42 = sext i16 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %.lr.ph, label %._crit_edge, !llvm.loop !21

44:                                               ; preds = %1, %._crit_edge
  ret void
}

declare void @_ZN5ImGui7TreePopEv() 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 = { "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 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, !7, i64 0}
!6 = !{!"_ZTS18ImGuiTableSettings", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 12, !11, i64 14, !12, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!6, !11, i64 12}
!14 = !{!6, !7, i64 4}
!15 = !{!6, !11, i64 14}
!16 = !{!17, !11, i64 12}
!17 = !{!"_ZTS24ImGuiTableColumnSettings", !10, i64 0, !7, i64 4, !11, i64 8, !11, i64 10, !11, i64 12, !8, i64 14, !8, i64 14, !8, i64 14}
!18 = !{!17, !11, i64 10}
!19 = !{!17, !10, i64 0}
!20 = !{!17, !7, i64 4}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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