; LLVM IR from PepcyCh/bisemutum-engine :: bisemutum/thirdparty/ImGuizmo/example/imgui.ll (ZN5ImGui10GetKeyNameE8ImGuiKey)

; 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.ImGuiIO = type { i32, i32, %struct.ImVec2, float, float, ptr, ptr, float, float, float, float, float, float, float, ptr, ptr, float, i8, ptr, %struct.ImVec2, i8, i8, i8, i8, i8, i8, i8, i8, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, i32, %struct.ImVec2, [652 x i32], [652 x i8], [16 x float], %struct.ImVec2, [5 x i8], float, float, i8, i8, i8, i8, i32, [652 x %struct.ImGuiKeyData], i8, %struct.ImVec2, [5 x %struct.ImVec2], [5 x double], [5 x i8], [5 x i8], [5 x i16], [5 x i16], [5 x i8], [5 x i8], [5 x i8], [5 x float], [5 x float], [5 x float], float, i8, i8, i8, i8, i16, %struct.ImVector }
%struct.ImGuiKeyData = type { i8, float, float, float }
%struct.ImVec2 = type { float, float }
%struct.ImVector = type { i32, i32, ptr }

@.str.4 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.159 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui10GetKeyNameE8ImGuiKey = external hidden unnamed_addr constant [40 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [8 x i8], align 1
@_ZL9GKeyNames = external hidden constant [140 x ptr], align 16

; 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 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(14264) ptr @_ZN5ImGui5GetIOEv() #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN5ImGui10GetKeyNameE8ImGuiKey(i32 noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = call noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef %6)
  br i1 %7, label %8, label %39

8:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %9 = call noundef nonnull align 8 dereferenceable(14264) ptr @_ZN5ImGui5GetIOEv()
  store ptr %9, ptr %4, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.ImGuiIO, ptr %10, i32 0, i32 53
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [652 x i32], ptr %11, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp eq i32 %15, -1
  br i1 %16, label %17, label %18

17:                                               ; preds = %8
  store ptr @.str.159, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %36

18:                                               ; preds = %8
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.ImGuiIO, ptr %19, i32 0, i32 53
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [652 x i32], ptr %20, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %24)
  br i1 %25, label %26, label %27

26:                                               ; preds = %18
  br label %29

27:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.160, ptr noundef @.str.4, i32 noundef 7796, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui10GetKeyNameE8ImGuiKey) #6
  unreachable

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28, %26
  %30 = load ptr, ptr %4, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.ImGuiIO, ptr %30, i32 0, i32 53
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [652 x i32], ptr %31, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !11
  store i32 %35, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %5, align 4
  br label %36

36:                                               ; preds = %29, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %37 = load i32, ptr %5, align 4
  switch i32 %37, label %55 [
    i32 0, label %38
    i32 1, label %53
  ]

38:                                               ; preds = %36
  br label %39

39:                                               ; preds = %38, %1
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  store ptr @.str.161, ptr %2, align 8
  br label %53

43:                                               ; preds = %39
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %44)
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  store ptr @.str.162, ptr %2, align 8
  br label %53

47:                                               ; preds = %43
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sub nsw i32 %48, 512
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [140 x ptr], ptr @_ZL9GKeyNames, i64 0, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  store ptr %52, ptr %2, align 8
  br label %53

53:                                               ; preds = %47, %46, %42, %36
  %54 = load ptr, ptr %2, align 8
  ret ptr %54

55:                                               ; preds = %36
  unreachable
}

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 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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

@.str.4 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.159 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui10GetKeyNameE8ImGuiKey = external hidden unnamed_addr constant [40 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [8 x i8], align 1
@_ZL9GKeyNames = external hidden local_unnamed_addr constant [140 x ptr], align 16

; 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 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(14264) ptr @_ZN5ImGui5GetIOEv() local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN5ImGui10GetKeyNameE8ImGuiKey(i32 noundef %0) local_unnamed_addr #2 {
  %2 = tail call noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef %0)
  br i1 %2, label %3, label %14

3:                                                ; preds = %1
  %4 = tail call noundef nonnull align 8 dereferenceable(14264) ptr @_ZN5ImGui5GetIOEv()
  %5 = getelementptr inbounds i8, ptr %4, i64 248
  %6 = sext i32 %0 to i64
  %7 = getelementptr inbounds [652 x i32], ptr %5, i64 0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp eq i32 %8, -1
  br i1 %9, label %23, label %10

10:                                               ; preds = %3
  %11 = tail call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %8)
  br i1 %11, label %.thread, label %12

12:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.160, ptr noundef nonnull @.str.4, i32 noundef 7796, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui10GetKeyNameE8ImGuiKey) #3
  unreachable

.thread:                                          ; preds = %10
  %13 = load i32, ptr %7, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %.thread, %1
  %.113 = phi i32 [ %0, %1 ], [ %13, %.thread ]
  %15 = icmp eq i32 %.113, 0
  br i1 %15, label %23, label %16

16:                                               ; preds = %14
  %17 = tail call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %.113)
  br i1 %17, label %18, label %23

18:                                               ; preds = %16
  %19 = add nsw i32 %.113, -512
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [140 x ptr], ptr @_ZL9GKeyNames, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %3, %16, %14, %18
  %.1 = phi ptr [ %22, %18 ], [ @.str.161, %14 ], [ @.str.162, %16 ], [ @.str.159, %3 ]
  ret ptr %.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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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