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

; 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.ImGuiKeyOwnerData = type <{ i32, i32, i8, i8, [2 x i8] }>

@GImGui = external dso_local global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [117 x i8], align 1
@.str.182 = external hidden unnamed_addr constant [134 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji = external hidden unnamed_addr constant [60 x i8], align 1
@.str.183 = external hidden unnamed_addr constant [55 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 dso_local noundef zeroext i1 @_ZN5ImGui18IsNamedKeyOrModKeyE8ImGuiKey(i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui11SetKeyOwnerE8ImGuiKeyji(i32 noundef %0, i32 noundef %1, i32 noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = call noundef zeroext i1 @_ZN5ImGui18IsNamedKeyOrModKeyE8ImGuiKey(i32 noundef %9)
  br i1 %10, label %11, label %20

11:                                               ; preds = %3
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %18, label %14

14:                                               ; preds = %11
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = and i32 %15, 192
  %17 = icmp ne i32 %16, 0
  br label %18

18:                                               ; preds = %14, %11
  %19 = phi i1 [ true, %11 ], [ %17, %14 ]
  br label %20

20:                                               ; preds = %18, %3
  %21 = phi i1 [ false, %3 ], [ %19, %18 ]
  br i1 %21, label %22, label %23

22:                                               ; preds = %20
  br label %25

23:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.182, ptr noundef @.str.3, i32 noundef 8896, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji) #4
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = and i32 %26, -193
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  br label %32

30:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.183, ptr noundef @.str.3, i32 noundef 8897, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji) #4
  unreachable

31:                                               ; No predecessors!
  br label %32

32:                                               ; preds = %31, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %33 = load ptr, ptr @GImGui, align 8, !tbaa !11
  store ptr %33, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %34 = load ptr, ptr %7, align 8, !tbaa !11
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = call noundef ptr @_ZN5ImGui15GetKeyOwnerDataEP12ImGuiContext8ImGuiKey(ptr noundef %34, i32 noundef %35)
  store ptr %36, ptr %8, align 8, !tbaa !11
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.ImGuiKeyOwnerData, ptr %38, i32 0, i32 1
  store i32 %37, ptr %39, align 4, !tbaa !13
  %40 = load ptr, ptr %8, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.ImGuiKeyOwnerData, ptr %40, i32 0, i32 0
  store i32 %37, ptr %41, align 4, !tbaa !16
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = and i32 %42, 128
  %44 = icmp ne i32 %43, 0
  %45 = load ptr, ptr %8, align 8, !tbaa !11
  %46 = getelementptr inbounds %struct.ImGuiKeyOwnerData, ptr %45, i32 0, i32 3
  %47 = zext i1 %44 to i8
  store i8 %47, ptr %46, align 1, !tbaa !17
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = and i32 %48, 64
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %56, label %51

51:                                               ; preds = %32
  %52 = load ptr, ptr %8, align 8, !tbaa !11
  %53 = getelementptr inbounds %struct.ImGuiKeyOwnerData, ptr %52, i32 0, i32 3
  %54 = load i8, ptr %53, align 1, !tbaa !17, !range !18, !noundef !19
  %55 = trunc i8 %54 to i1
  br label %56

56:                                               ; preds = %51, %32
  %57 = phi i1 [ true, %32 ], [ %55, %51 ]
  %58 = load ptr, ptr %8, align 8, !tbaa !11
  %59 = getelementptr inbounds %struct.ImGuiKeyOwnerData, ptr %58, i32 0, i32 2
  %60 = zext i1 %57 to i8
  store i8 %60, ptr %59, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5ImGui15GetKeyOwnerDataEP12ImGuiContext8ImGuiKey(ptr noundef, i32 noundef) #2

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 = !{!"_ZTS8ImGuiKey", !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, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !10, i64 4}
!14 = !{!"_ZTS17ImGuiKeyOwnerData", !10, i64 0, !10, i64 4, !15, i64 8, !15, i64 9}
!15 = !{!"bool", !7, i64 0}
!16 = !{!14, !10, i64 0}
!17 = !{!14, !15, i64 9}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!14, !15, 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"

@GImGui = external dso_local local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [117 x i8], align 1
@.str.182 = external hidden unnamed_addr constant [134 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji = external hidden unnamed_addr constant [60 x i8], align 1
@.str.183 = external hidden unnamed_addr constant [55 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 dso_local noundef zeroext i1 @_ZN5ImGui18IsNamedKeyOrModKeyE8ImGuiKey(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5ImGui11SetKeyOwnerE8ImGuiKeyji(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = tail call noundef zeroext i1 @_ZN5ImGui18IsNamedKeyOrModKeyE8ImGuiKey(i32 noundef %0)
  br i1 %4, label %5, label %.critedge

5:                                                ; preds = %3
  %6 = and i32 %2, 192
  %7 = or i32 %6, %1
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.critedge, label %8

.critedge:                                        ; preds = %3, %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.182, ptr noundef nonnull @.str.3, i32 noundef 8896, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji) #3
  unreachable

8:                                                ; preds = %5
  %9 = and i32 %2, -193
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.183, ptr noundef nonnull @.str.3, i32 noundef 8897, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji) #3
  unreachable

12:                                               ; preds = %8
  %13 = load ptr, ptr @GImGui, align 8, !tbaa !5
  %14 = tail call noundef ptr @_ZN5ImGui15GetKeyOwnerDataEP12ImGuiContext8ImGuiKey(ptr noundef %13, i32 noundef %0)
  %15 = getelementptr inbounds i8, ptr %14, i64 4
  store i32 %1, ptr %15, align 4, !tbaa !9
  store i32 %1, ptr %14, align 4, !tbaa !13
  %16 = icmp ugt i32 %2, 127
  %17 = getelementptr inbounds i8, ptr %14, i64 9
  %18 = zext i1 %16 to i8
  store i8 %18, ptr %17, align 1, !tbaa !14
  %19 = and i32 %2, 64
  %.not13 = icmp eq i32 %19, 0
  %spec.select = select i1 %.not13, i8 %18, i8 1
  %20 = getelementptr inbounds i8, ptr %14, i64 8
  store i8 %spec.select, ptr %20, align 4, !tbaa !15
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5ImGui15GetKeyOwnerDataEP12ImGuiContext8ImGuiKey(ptr noundef, i32 noundef) local_unnamed_addr #1

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, !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 = !{!"_ZTS17ImGuiKeyOwnerData", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 9}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !12, i64 9}
!15 = !{!10, !12, i64 8}


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