; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui (imgui_widgets)

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

; 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 uwtable
define dso_local noundef ptr @_ZN5ImGui17TabBarFindTabByIDEP11ImGuiTabBarj(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %40

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %34, %10
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ImGuiTabBar, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.ImVector.41, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp slt i32 %12, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %11
  store i32 2, ptr %7, align 4
  br label %37

19:                                               ; preds = %11
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImGuiTabBar, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = call noundef nonnull align 4 dereferenceable(41) ptr @_ZN8ImVectorI12ImGuiTabItemEixEi(ptr noundef nonnull align 8 dereferenceable(16) %21, i32 noundef %22)
  %24 = getelementptr inbounds %struct.ImGuiTabItem, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 4, !tbaa !21
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = icmp eq i32 %25, %26
  br i1 %27, label %28, label %33

28:                                               ; preds = %19
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ImGuiTabBar, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = call noundef nonnull align 4 dereferenceable(41) ptr @_ZN8ImVectorI12ImGuiTabItemEixEi(ptr noundef nonnull align 8 dereferenceable(16) %30, i32 noundef %31)
  store ptr %32, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %37

33:                                               ; preds = %19
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !23

37:                                               ; preds = %28, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %38 = load i32, ptr %7, align 4
  switch i32 %38, label %43 [
    i32 2, label %39
    i32 1, label %41
  ]

39:                                               ; preds = %37
  br label %40

40:                                               ; preds = %39, %2
  store ptr null, ptr %3, align 8
  br label %41

41:                                               ; preds = %40, %37
  %42 = load ptr, ptr %3, align 8
  ret ptr %42

43:                                               ; preds = %37
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(41) ptr @_ZN8ImVectorI12ImGuiTabItemEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS11ImGuiTabBar", !13, i64 0, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !14, i64 44, !16, i64 60, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !16, i64 80, !16, i64 84, !16, i64 88, !16, i64 92, !16, i64 96, !10, i64 100, !17, i64 104, !7, i64 106, !18, i64 107, !18, i64 108, !18, i64 109, !17, i64 110, !17, i64 112, !16, i64 116, !15, i64 120, !15, i64 128, !19, i64 136}
!13 = !{!"_ZTS8ImVectorI12ImGuiTabItemE", !10, i64 0, !10, i64 4, !6, i64 8}
!14 = !{!"_ZTS6ImRect", !15, i64 0, !15, i64 8}
!15 = !{!"_ZTS6ImVec2", !16, i64 0, !16, i64 4}
!16 = !{!"float", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTS15ImGuiTextBuffer", !20, i64 0}
!20 = !{!"_ZTS8ImVectorIcE", !10, i64 0, !10, i64 4, !6, i64 8}
!21 = !{!22, !10, i64 0}
!22 = !{!"_ZTS12ImGuiTabItem", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !16, i64 16, !16, i64 20, !16, i64 24, !16, i64 28, !10, i64 32, !17, i64 36, !17, i64 38, !18, i64 40}
!23 = distinct !{!23, !24}
!24 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN5ImGui17TabBarFindTabByIDEP11ImGuiTabBarj(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %.thread, label %.preheader

.preheader:                                       ; preds = %2
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %.preheader, %8
  %.01018 = phi i32 [ %9, %8 ], [ 0, %.preheader ]
  %5 = tail call noundef nonnull align 4 dereferenceable(41) ptr @_ZN8ImVectorI12ImGuiTabItemEixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.01018)
  %6 = load i32, ptr %5, align 4, !tbaa !19
  %7 = icmp eq i32 %6, %1
  br i1 %7, label %12, label %8

8:                                                ; preds = %.lr.ph
  %9 = add nuw nsw i32 %.01018, 1
  %10 = load i32, ptr %0, align 8, !tbaa !5
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.lr.ph, label %.thread, !llvm.loop !21

12:                                               ; preds = %.lr.ph
  %13 = tail call noundef nonnull align 4 dereferenceable(41) ptr @_ZN8ImVectorI12ImGuiTabItemEixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.01018)
  br label %.thread

.thread:                                          ; preds = %8, %.preheader, %2, %12
  %.1 = phi ptr [ %13, %12 ], [ null, %2 ], [ null, %.preheader ], [ null, %8 ]
  ret ptr %.1
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(41) ptr @_ZN8ImVectorI12ImGuiTabItemEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1 align 2

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, !8, i64 0}
!6 = !{!"_ZTS11ImGuiTabBar", !7, i64 0, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28, !8, i64 32, !8, i64 36, !8, i64 40, !12, i64 44, !14, i64 60, !14, i64 64, !14, i64 68, !14, i64 72, !14, i64 76, !14, i64 80, !14, i64 84, !14, i64 88, !14, i64 92, !14, i64 96, !8, i64 100, !15, i64 104, !9, i64 106, !16, i64 107, !16, i64 108, !16, i64 109, !15, i64 110, !15, i64 112, !14, i64 116, !13, i64 120, !13, i64 128, !17, i64 136}
!7 = !{!"_ZTS8ImVectorI12ImGuiTabItemE", !8, i64 0, !8, i64 4, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTS6ImRect", !13, i64 0, !13, i64 8}
!13 = !{!"_ZTS6ImVec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !9, i64 0}
!15 = !{!"short", !9, i64 0}
!16 = !{!"bool", !9, i64 0}
!17 = !{!"_ZTS15ImGuiTextBuffer", !18, i64 0}
!18 = !{!"_ZTS8ImVectorIcE", !8, i64 0, !8, i64 4, !11, i64 8}
!19 = !{!20, !8, i64 0}
!20 = !{!"_ZTS12ImGuiTabItem", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !8, i64 32, !15, i64 36, !15, i64 38, !16, i64 40}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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