; LLVM IR from l1mey112/yr11-physics-applied :: cimgui/imgui/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 [86 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui10GetKeyNameE8ImGuiKey = external hidden unnamed_addr constant [40 x i8], align 1
@.str.163 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.164 = 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5ImGui25ConvertSingleModFlagToKeyE8ImGuiKey(i32 noundef) #2

; 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.161, 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.162, ptr noundef @.str.4, i32 noundef 7688, 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 %62 [
    i32 0, label %38
    i32 1, label %60
  ]

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.163, ptr %2, align 8
  br label %60

43:                                               ; preds = %39
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = and i32 %44, 63488
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %50

47:                                               ; preds = %43
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = call noundef i32 @_ZN5ImGui25ConvertSingleModFlagToKeyE8ImGuiKey(i32 noundef %48)
  store i32 %49, ptr %3, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %47, %43
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %51)
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  store ptr @.str.164, ptr %2, align 8
  br label %60

54:                                               ; preds = %50
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sub nsw i32 %55, 512
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [140 x ptr], ptr @_ZL9GKeyNames, i64 0, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  store ptr %59, ptr %2, align 8
  br label %60

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

62:                                               ; 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 [86 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui10GetKeyNameE8ImGuiKey = external hidden unnamed_addr constant [40 x i8], align 1
@.str.163 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.164 = 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5ImGui25ConvertSingleModFlagToKeyE8ImGuiKey(i32 noundef) local_unnamed_addr #1

; 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 %27, 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.162, ptr noundef nonnull @.str.4, i32 noundef 7688, 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
  %.115 = phi i32 [ %0, %1 ], [ %13, %.thread ]
  %15 = icmp eq i32 %.115, 0
  br i1 %15, label %27, label %16

16:                                               ; preds = %14
  %17 = and i32 %.115, 63488
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %20, label %18

18:                                               ; preds = %16
  %19 = tail call noundef i32 @_ZN5ImGui25ConvertSingleModFlagToKeyE8ImGuiKey(i32 noundef %.115)
  br label %20

20:                                               ; preds = %18, %16
  %.2 = phi i32 [ %19, %18 ], [ %.115, %16 ]
  %21 = tail call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %.2)
  br i1 %21, label %22, label %27

22:                                               ; preds = %20
  %23 = add nsw i32 %.2, -512
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [140 x ptr], ptr @_ZL9GKeyNames, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %3, %20, %14, %22
  %.1 = phi ptr [ %26, %22 ], [ @.str.163, %14 ], [ @.str.164, %20 ], [ @.str.161, %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