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

; 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.ImGuiWindow = type <{ ptr, ptr, i32, i32, ptr, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, float, float, float, float, float, float, float, float, i32, i32, i32, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i16, i16, i16, i16, i32, i8, i8, i8, i8, i32, i8, i8, i8, i8, i32, %struct.ImVec2, %struct.ImVec2, %struct.ImVector.9, %struct.ImGuiWindowTempData, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImRect, %struct.ImVec2ih, %struct.ImVec2ih, i32, float, float, [4 x i8], %struct.ImGuiStorage, %struct.ImVector.32, float, i32, ptr, %struct.ImDrawList, ptr, ptr, ptr, ptr, ptr, ptr, ptr, [2 x i32], [2 x %struct.ImRect], i32, i32, i32, i8, [3 x i8] }>
%struct.ImVec2 = type { float, float }
%struct.ImVector.9 = type { i32, i32, ptr }
%struct.ImGuiWindowTempData = type { %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, float, float, i8, i8, %struct.ImVec1, %struct.ImVec1, %struct.ImVec1, %struct.ImVec2, i32, i16, i16, i8, i8, i8, i8, %struct.ImVec2, %struct.ImGuiMenuColumns, i32, i32, %struct.ImVector.2, ptr, ptr, i32, i32, i32, float, float, %struct.ImVector.18, %struct.ImVector.18 }
%struct.ImVec1 = type { float }
%struct.ImGuiMenuColumns = type <{ i32, i32, i16, i16, i16, i16, i16, [4 x i16], [2 x i8] }>
%struct.ImVector.2 = type { i32, i32, ptr }
%struct.ImVector.18 = type { i32, i32, ptr }
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }
%struct.ImVec2ih = type { i16, i16 }
%struct.ImGuiStorage = type { %struct.ImVector.4 }
%struct.ImVector.4 = type { i32, i32, ptr }
%struct.ImVector.32 = type { i32, i32, ptr }
%struct.ImDrawList = type <{ %struct.ImVector.33, %struct.ImVector, %struct.ImVector.34, i32, i32, ptr, ptr, ptr, ptr, %struct.ImVector.35, %struct.ImVector.36, %struct.ImVector.0, %struct.ImDrawCmdHeader, %struct.ImDrawListSplitter, float, [4 x i8] }>
%struct.ImVector.33 = type { i32, i32, ptr }
%struct.ImVector = type { i32, i32, ptr }
%struct.ImVector.34 = type { i32, i32, ptr }
%struct.ImVector.35 = type { i32, i32, ptr }
%struct.ImVector.36 = type { i32, i32, ptr }
%struct.ImVector.0 = type { i32, i32, ptr }
%struct.ImDrawCmdHeader = type <{ %struct.ImVec4, ptr, i32, [4 x i8] }>
%struct.ImVec4 = type { float, float, float, float }
%struct.ImDrawListSplitter = type { i32, i32, %struct.ImVector.19 }
%struct.ImVector.19 = type { i32, i32, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5ImGui18SetWindowCollapsedEP11ImGuiWindowbi(ptr noundef %0, i1 noundef zeroext %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %7 = zext i1 %1 to i8
  store i8 %7, ptr %5, align 1, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %8 = load i32, ptr %6, align 4, !tbaa !11
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %20

10:                                               ; preds = %3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ImGuiWindow, ptr %11, i32 0, i32 58
  %13 = load i32, ptr %12, align 4
  %14 = shl i32 %13, 8
  %15 = ashr i32 %14, 24
  %16 = load i32, ptr %6, align 4, !tbaa !11
  %17 = and i32 %15, %16
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %10
  br label %39

20:                                               ; preds = %10, %3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ImGuiWindow, ptr %21, i32 0, i32 58
  %23 = load i32, ptr %22, align 4
  %24 = shl i32 %23, 8
  %25 = ashr i32 %24, 24
  %26 = and i32 %25, -15
  %27 = load i32, ptr %22, align 4
  %28 = and i32 %26, 255
  %29 = shl i32 %28, 16
  %30 = and i32 %27, -16711681
  %31 = or i32 %30, %29
  store i32 %31, ptr %22, align 4
  %32 = shl i32 %28, 24
  %33 = ashr i32 %32, 24
  %34 = load i8, ptr %5, align 1, !tbaa !9, !range !13, !noundef !14
  %35 = trunc i8 %34 to i1
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ImGuiWindow, ptr %36, i32 0, i32 34
  %38 = zext i1 %35 to i8
  store i8 %38, ptr %37, align 1, !tbaa !15
  br label %39

39:                                               ; preds = %20, %19
  ret void
}

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, !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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !10, i64 185}
!16 = !{!"_ZTS11ImGuiWindow", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !17, i64 32, !17, i64 40, !17, i64 48, !17, i64 56, !17, i64 64, !17, i64 72, !17, i64 80, !18, i64 88, !18, i64 92, !18, i64 96, !18, i64 100, !18, i64 104, !18, i64 108, !18, i64 112, !18, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !17, i64 132, !17, i64 140, !17, i64 148, !17, i64 156, !17, i64 164, !17, i64 172, !10, i64 180, !10, i64 181, !10, i64 182, !10, i64 183, !10, i64 184, !10, i64 185, !10, i64 186, !10, i64 187, !10, i64 188, !10, i64 189, !10, i64 190, !10, i64 191, !10, i64 192, !7, i64 193, !19, i64 194, !19, i64 196, !19, i64 198, !19, i64 200, !19, i64 202, !12, i64 204, !7, i64 208, !7, i64 209, !7, i64 210, !10, i64 211, !12, i64 212, !7, i64 216, !7, i64 217, !7, i64 218, !7, i64 219, !12, i64 220, !12, i64 221, !12, i64 222, !17, i64 224, !17, i64 232, !20, i64 240, !21, i64 256, !27, i64 488, !27, i64 504, !27, i64 520, !27, i64 536, !27, i64 552, !27, i64 568, !27, i64 584, !28, i64 600, !28, i64 604, !12, i64 608, !18, i64 612, !18, i64 616, !29, i64 624, !31, i64 640, !18, i64 656, !12, i64 660, !6, i64 664, !32, i64 672, !6, i64 872, !6, i64 880, !6, i64 888, !6, i64 896, !6, i64 904, !6, i64 912, !6, i64 920, !7, i64 928, !7, i64 936, !12, i64 968, !12, i64 972, !12, i64 976, !10, i64 980}
!17 = !{!"_ZTS6ImVec2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !7, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = !{!"_ZTS8ImVectorIjE", !12, i64 0, !12, i64 4, !6, i64 8}
!21 = !{!"_ZTS19ImGuiWindowTempData", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !17, i64 48, !18, i64 56, !18, i64 60, !10, i64 64, !10, i64 65, !22, i64 68, !22, i64 72, !22, i64 76, !17, i64 80, !23, i64 88, !19, i64 92, !19, i64 94, !10, i64 96, !10, i64 97, !10, i64 98, !10, i64 99, !17, i64 100, !24, i64 108, !12, i64 136, !12, i64 140, !25, i64 144, !6, i64 160, !6, i64 168, !12, i64 176, !12, i64 180, !12, i64 184, !18, i64 188, !18, i64 192, !26, i64 200, !26, i64 216}
!22 = !{!"_ZTS6ImVec1", !18, i64 0}
!23 = !{!"_ZTS13ImGuiNavLayer", !7, i64 0}
!24 = !{!"_ZTS16ImGuiMenuColumns", !12, i64 0, !12, i64 4, !19, i64 8, !19, i64 10, !19, i64 12, !19, i64 14, !19, i64 16, !7, i64 18}
!25 = !{!"_ZTS8ImVectorIP11ImGuiWindowE", !12, i64 0, !12, i64 4, !6, i64 8}
!26 = !{!"_ZTS8ImVectorIfE", !12, i64 0, !12, i64 4, !6, i64 8}
!27 = !{!"_ZTS6ImRect", !17, i64 0, !17, i64 8}
!28 = !{!"_ZTS8ImVec2ih", !19, i64 0, !19, i64 2}
!29 = !{!"_ZTS12ImGuiStorage", !30, i64 0}
!30 = !{!"_ZTS8ImVectorIN12ImGuiStorage16ImGuiStoragePairEE", !12, i64 0, !12, i64 4, !6, i64 8}
!31 = !{!"_ZTS8ImVectorI15ImGuiOldColumnsE", !12, i64 0, !12, i64 4, !6, i64 8}
!32 = !{!"_ZTS10ImDrawList", !33, i64 0, !34, i64 16, !35, i64 32, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !36, i64 88, !37, i64 104, !38, i64 120, !39, i64 136, !41, i64 168, !18, i64 192}
!33 = !{!"_ZTS8ImVectorI9ImDrawCmdE", !12, i64 0, !12, i64 4, !6, i64 8}
!34 = !{!"_ZTS8ImVectorItE", !12, i64 0, !12, i64 4, !6, i64 8}
!35 = !{!"_ZTS8ImVectorI10ImDrawVertE", !12, i64 0, !12, i64 4, !6, i64 8}
!36 = !{!"_ZTS8ImVectorI6ImVec4E", !12, i64 0, !12, i64 4, !6, i64 8}
!37 = !{!"_ZTS8ImVectorIPvE", !12, i64 0, !12, i64 4, !6, i64 8}
!38 = !{!"_ZTS8ImVectorI6ImVec2E", !12, i64 0, !12, i64 4, !6, i64 8}
!39 = !{!"_ZTS15ImDrawCmdHeader", !40, i64 0, !6, i64 16, !12, i64 24}
!40 = !{!"_ZTS6ImVec4", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12}
!41 = !{!"_ZTS18ImDrawListSplitter", !12, i64 0, !12, i64 4, !42, i64 8}
!42 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !12, i64 0, !12, i64 4, !6, i64 8}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN5ImGui18SetWindowCollapsedEP11ImGuiWindowbi(ptr nocapture noundef %0, i1 noundef zeroext %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = zext i1 %1 to i8
  %.not = icmp eq i32 %2, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 220
  %.pre = load i32, ptr %.phi.trans.insert, align 4
  br i1 %.not, label %._crit_edge, label %5

5:                                                ; preds = %3
  %6 = shl i32 %.pre, 8
  %7 = ashr i32 %6, 24
  %8 = and i32 %7, %2
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %13, label %._crit_edge

._crit_edge:                                      ; preds = %3, %5
  %10 = getelementptr inbounds i8, ptr %0, i64 220
  %11 = and i32 %.pre, -917505
  store i32 %11, ptr %10, align 4
  %12 = getelementptr inbounds i8, ptr %0, i64 185
  store i8 %4, ptr %12, align 1, !tbaa !5
  br label %13

13:                                               ; preds = %5, %._crit_edge
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !13, i64 185}
!6 = !{!"_ZTS11ImGuiWindow", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !11, i64 132, !11, i64 140, !11, i64 148, !11, i64 156, !11, i64 164, !11, i64 172, !13, i64 180, !13, i64 181, !13, i64 182, !13, i64 183, !13, i64 184, !13, i64 185, !13, i64 186, !13, i64 187, !13, i64 188, !13, i64 189, !13, i64 190, !13, i64 191, !13, i64 192, !8, i64 193, !14, i64 194, !14, i64 196, !14, i64 198, !14, i64 200, !14, i64 202, !10, i64 204, !8, i64 208, !8, i64 209, !8, i64 210, !13, i64 211, !10, i64 212, !8, i64 216, !8, i64 217, !8, i64 218, !8, i64 219, !10, i64 220, !10, i64 221, !10, i64 222, !11, i64 224, !11, i64 232, !15, i64 240, !16, i64 256, !22, i64 488, !22, i64 504, !22, i64 520, !22, i64 536, !22, i64 552, !22, i64 568, !22, i64 584, !23, i64 600, !23, i64 604, !10, i64 608, !12, i64 612, !12, i64 616, !24, i64 624, !26, i64 640, !12, i64 656, !10, i64 660, !7, i64 664, !27, i64 672, !7, i64 872, !7, i64 880, !7, i64 888, !7, i64 896, !7, i64 904, !7, i64 912, !7, i64 920, !8, i64 928, !8, i64 936, !10, i64 968, !10, i64 972, !10, i64 976, !13, i64 980}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!"_ZTS8ImVectorIjE", !10, i64 0, !10, i64 4, !7, i64 8}
!16 = !{!"_ZTS19ImGuiWindowTempData", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !12, i64 56, !12, i64 60, !13, i64 64, !13, i64 65, !17, i64 68, !17, i64 72, !17, i64 76, !11, i64 80, !18, i64 88, !14, i64 92, !14, i64 94, !13, i64 96, !13, i64 97, !13, i64 98, !13, i64 99, !11, i64 100, !19, i64 108, !10, i64 136, !10, i64 140, !20, i64 144, !7, i64 160, !7, i64 168, !10, i64 176, !10, i64 180, !10, i64 184, !12, i64 188, !12, i64 192, !21, i64 200, !21, i64 216}
!17 = !{!"_ZTS6ImVec1", !12, i64 0}
!18 = !{!"_ZTS13ImGuiNavLayer", !8, i64 0}
!19 = !{!"_ZTS16ImGuiMenuColumns", !10, i64 0, !10, i64 4, !14, i64 8, !14, i64 10, !14, i64 12, !14, i64 14, !14, i64 16, !8, i64 18}
!20 = !{!"_ZTS8ImVectorIP11ImGuiWindowE", !10, i64 0, !10, i64 4, !7, i64 8}
!21 = !{!"_ZTS8ImVectorIfE", !10, i64 0, !10, i64 4, !7, i64 8}
!22 = !{!"_ZTS6ImRect", !11, i64 0, !11, i64 8}
!23 = !{!"_ZTS8ImVec2ih", !14, i64 0, !14, i64 2}
!24 = !{!"_ZTS12ImGuiStorage", !25, i64 0}
!25 = !{!"_ZTS8ImVectorIN12ImGuiStorage16ImGuiStoragePairEE", !10, i64 0, !10, i64 4, !7, i64 8}
!26 = !{!"_ZTS8ImVectorI15ImGuiOldColumnsE", !10, i64 0, !10, i64 4, !7, i64 8}
!27 = !{!"_ZTS10ImDrawList", !28, i64 0, !29, i64 16, !30, i64 32, !10, i64 48, !10, i64 52, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !31, i64 88, !32, i64 104, !33, i64 120, !34, i64 136, !36, i64 168, !12, i64 192}
!28 = !{!"_ZTS8ImVectorI9ImDrawCmdE", !10, i64 0, !10, i64 4, !7, i64 8}
!29 = !{!"_ZTS8ImVectorItE", !10, i64 0, !10, i64 4, !7, i64 8}
!30 = !{!"_ZTS8ImVectorI10ImDrawVertE", !10, i64 0, !10, i64 4, !7, i64 8}
!31 = !{!"_ZTS8ImVectorI6ImVec4E", !10, i64 0, !10, i64 4, !7, i64 8}
!32 = !{!"_ZTS8ImVectorIPvE", !10, i64 0, !10, i64 4, !7, i64 8}
!33 = !{!"_ZTS8ImVectorI6ImVec2E", !10, i64 0, !10, i64 4, !7, i64 8}
!34 = !{!"_ZTS15ImDrawCmdHeader", !35, i64 0, !7, i64 16, !10, i64 24}
!35 = !{!"_ZTS6ImVec4", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!36 = !{!"_ZTS18ImDrawListSplitter", !10, i64 0, !10, i64 4, !37, i64 8}
!37 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !10, i64 0, !10, i64 4, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass