; LLVM IR from hadryansalles/Luz :: deps/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 [72 x i8], align 1
@.str.226 = external hidden unnamed_addr constant [134 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji = external hidden unnamed_addr constant [60 x i8], align 1
@.str.227 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load ptr, ptr @GImGui, align 8, !tbaa !11
  store ptr %9, ptr %7, align 8, !tbaa !11
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = call noundef zeroext i1 @_ZN5ImGui18IsNamedKeyOrModKeyE8ImGuiKey(i32 noundef %10)
  br i1 %11, label %12, label %21

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

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

19:                                               ; preds = %15, %12
  %20 = phi i1 [ true, %12 ], [ %18, %15 ]
  br label %21

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

23:                                               ; preds = %21
  br label %26

24:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.226, ptr noundef @.str.3, i32 noundef 9981, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji) #5
  unreachable

25:                                               ; No predecessors!
  br label %26

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

30:                                               ; preds = %26
  br label %33

31:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.227, ptr noundef @.str.3, i32 noundef 9982, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji) #5
  unreachable

32:                                               ; No predecessors!
  br label %33

33:                                               ; preds = %32, %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %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, 2048
  %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, 1024
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %56, label %51

51:                                               ; preds = %33
  %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, %33
  %57 = phi i1 [ true, %33 ], [ %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) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  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 = { nounwind }
attributes #5 = { 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 = !{!"_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 [72 x i8], align 1
@.str.226 = external hidden unnamed_addr constant [134 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji = external hidden unnamed_addr constant [60 x i8], align 1
@.str.227 = 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 = load ptr, ptr @GImGui, align 8, !tbaa !5
  %5 = tail call noundef zeroext i1 @_ZN5ImGui18IsNamedKeyOrModKeyE8ImGuiKey(i32 noundef %0)
  br i1 %5, label %6, label %.critedge

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

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

9:                                                ; preds = %6
  %10 = and i32 %2, -3073
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.227, ptr noundef nonnull @.str.3, i32 noundef 9982, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui11SetKeyOwnerE8ImGuiKeyji) #3
  unreachable

13:                                               ; preds = %9
  %14 = tail call noundef ptr @_ZN5ImGui15GetKeyOwnerDataEP12ImGuiContext8ImGuiKey(ptr noundef %4, 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, 2047
  %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, 1024
  %.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