; LLVM IR from hadryansalles/Luz :: deps/imgui/imgui_widgets.ll (ZN5ImGui14TabBarCloseTabEP11ImGuiTabBarP12ImGuiTabItem)

; 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.ImGuiTabItem = type <{ i32, i32, ptr, i32, i32, float, float, float, float, i32, i16, i16, i8, [7 x i8] }>
%struct.ImGuiTabBar = type { %struct.ImVector.43, i32, i32, i32, i32, i32, i32, i32, %struct.ImRect, float, float, float, float, float, float, float, float, float, float, float, float, i32, i16, i8, i8, i8, i8, i16, i16, float, %struct.ImVec2, %struct.ImVec2, %struct.ImGuiTextBuffer }
%struct.ImVector.43 = type { i32, i32, ptr }
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }
%struct.ImVec2 = type { float, float }
%struct.ImGuiTextBuffer = type { %struct.ImVector.33 }
%struct.ImVector.33 = type { i32, i32, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui14TabBarCloseTabEP11ImGuiTabBarP12ImGuiTabItem(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.ImGuiTabItem, ptr %5, i32 0, i32 1
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = and i32 %7, 2097152
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %47

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ImGuiTabItem, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = and i32 %14, 257
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %35

17:                                               ; preds = %11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ImGuiTabItem, ptr %18, i32 0, i32 12
  store i8 1, ptr %19, align 8, !tbaa !15
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImGuiTabBar, ptr %20, i32 0, i32 5
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ImGuiTabItem, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !23
  %26 = icmp eq i32 %22, %25
  br i1 %26, label %27, label %34

27:                                               ; preds = %17
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ImGuiTabItem, ptr %28, i32 0, i32 3
  store i32 -1, ptr %29, align 8, !tbaa !24
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ImGuiTabBar, ptr %30, i32 0, i32 4
  store i32 0, ptr %31, align 4, !tbaa !25
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ImGuiTabBar, ptr %32, i32 0, i32 3
  store i32 0, ptr %33, align 8, !tbaa !26
  br label %34

34:                                               ; preds = %27, %17
  br label %47

35:                                               ; preds = %11
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ImGuiTabBar, ptr %36, i32 0, i32 5
  %38 = load i32, ptr %37, align 8, !tbaa !16
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ImGuiTabItem, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !23
  %42 = icmp ne i32 %38, %41
  br i1 %42, label %43, label %46

43:                                               ; preds = %35
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN5ImGui16TabBarQueueFocusEP11ImGuiTabBarP12ImGuiTabItem(ptr noundef %44, ptr noundef %45)
  br label %46

46:                                               ; preds = %43, %35
  br label %47

47:                                               ; preds = %46, %34, %10
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5ImGui16TabBarQueueFocusEP11ImGuiTabBarP12ImGuiTabItem(ptr noundef, ptr 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 = { 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, !11, i64 4}
!10 = !{!"_ZTS12ImGuiTabItem", !11, i64 0, !11, i64 4, !6, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !11, i64 40, !13, i64 44, !13, i64 46, !14, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!10, !14, i64 48}
!16 = !{!17, !11, i64 32}
!17 = !{!"_ZTS11ImGuiTabBar", !18, i64 0, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !19, i64 44, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !11, i64 108, !13, i64 112, !7, i64 114, !14, i64 115, !14, i64 116, !14, i64 117, !13, i64 118, !13, i64 120, !12, i64 124, !20, i64 128, !20, i64 136, !21, i64 144}
!18 = !{!"_ZTS8ImVectorI12ImGuiTabItemE", !11, i64 0, !11, i64 4, !6, i64 8}
!19 = !{!"_ZTS6ImRect", !20, i64 0, !20, i64 8}
!20 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!21 = !{!"_ZTS15ImGuiTextBuffer", !22, i64 0}
!22 = !{!"_ZTS8ImVectorIcE", !11, i64 0, !11, i64 4, !6, i64 8}
!23 = !{!10, !11, i64 0}
!24 = !{!10, !11, i64 16}
!25 = !{!17, !11, i64 28}
!26 = !{!17, !11, i64 24}


; 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 @_ZN5ImGui14TabBarCloseTabEP11ImGuiTabBarP12ImGuiTabItem(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = and i32 %4, 2097152
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %24

6:                                                ; preds = %2
  %7 = and i32 %4, 257
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %19

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %1, i64 48
  store i8 1, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %13 = load i32, ptr %1, align 8, !tbaa !22
  %14 = icmp eq i32 %12, %13
  br i1 %14, label %15, label %24

15:                                               ; preds = %9
  %16 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 -1, ptr %16, align 8, !tbaa !23
  %17 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 0, ptr %17, align 4, !tbaa !24
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 0, ptr %18, align 8, !tbaa !25
  br label %24

19:                                               ; preds = %6
  %20 = getelementptr inbounds i8, ptr %0, i64 32
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = load i32, ptr %1, align 8, !tbaa !22
  %.not12 = icmp eq i32 %21, %22
  br i1 %.not12, label %24, label %23

23:                                               ; preds = %19
  tail call void @_ZN5ImGui16TabBarQueueFocusEP11ImGuiTabBarP12ImGuiTabItem(ptr noundef nonnull %0, ptr noundef nonnull %1)
  br label %24

24:                                               ; preds = %19, %23, %9, %15, %2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5ImGui16TabBarQueueFocusEP11ImGuiTabBarP12ImGuiTabItem(ptr noundef, ptr noundef) local_unnamed_addr #0

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

!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 4}
!6 = !{!"_ZTS12ImGuiTabItem", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 16, !7, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !12, i64 44, !12, i64 46, !13, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!6, !13, i64 48}
!15 = !{!16, !7, i64 32}
!16 = !{!"_ZTS11ImGuiTabBar", !17, i64 0, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !18, i64 44, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !7, i64 108, !12, i64 112, !8, i64 114, !13, i64 115, !13, i64 116, !13, i64 117, !12, i64 118, !12, i64 120, !11, i64 124, !19, i64 128, !19, i64 136, !20, i64 144}
!17 = !{!"_ZTS8ImVectorI12ImGuiTabItemE", !7, i64 0, !7, i64 4, !10, i64 8}
!18 = !{!"_ZTS6ImRect", !19, i64 0, !19, i64 8}
!19 = !{!"_ZTS6ImVec2", !11, i64 0, !11, i64 4}
!20 = !{!"_ZTS15ImGuiTextBuffer", !21, i64 0}
!21 = !{!"_ZTS8ImVectorIcE", !7, i64 0, !7, i64 4, !10, i64 8}
!22 = !{!6, !7, i64 0}
!23 = !{!6, !7, i64 16}
!24 = !{!16, !7, i64 28}
!25 = !{!16, !7, i64 24}


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