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

; 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.ImGuiKeyData = type { i8, float, float, float }

; 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: mustprogress uwtable
declare dso_local noundef ptr @_ZN5ImGui10GetKeyDataE8ImGuiKey(i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN5ImGui19GetKeyPressedAmountE8ImGuiKeyff(i32 noundef, float noundef, float noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5ImGui14IsKeyPressedExE8ImGuiKeyi(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca i8, align 1
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = call noundef ptr @_ZN5ImGui10GetKeyDataE8ImGuiKey(i32 noundef %12)
  store ptr %13, ptr %6, align 8, !tbaa !11
  %14 = load ptr, ptr %6, align 8, !tbaa !11
  %15 = getelementptr inbounds %struct.ImGuiKeyData, ptr %14, i32 0, i32 0
  %16 = load i8, ptr %15, align 4, !tbaa !13, !range !17, !noundef !18
  %17 = trunc i8 %16 to i1
  br i1 %17, label %19, label %18

18:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %57

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %20 = load ptr, ptr %6, align 8, !tbaa !11
  %21 = getelementptr inbounds %struct.ImGuiKeyData, ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !19
  store float %22, ptr %8, align 4, !tbaa !20
  %23 = load float, ptr %8, align 4, !tbaa !20
  %24 = fcmp olt float %23, 0.000000e+00
  br i1 %24, label %25, label %26

25:                                               ; preds = %19
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %56

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  %27 = load float, ptr %8, align 4, !tbaa !20
  %28 = fcmp oeq float %27, 0.000000e+00
  %29 = zext i1 %28 to i8
  store i8 %29, ptr %9, align 1, !tbaa !21
  %30 = load i8, ptr %9, align 1, !tbaa !21, !range !17, !noundef !18
  %31 = trunc i8 %30 to i1
  br i1 %31, label %50, label %32

32:                                               ; preds = %26
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = and i32 %33, 1
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %50

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %37 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN5ImGui22GetTypematicRepeatRateEiPfS0_(i32 noundef %37, ptr noundef %10, ptr noundef %11)
  %38 = load float, ptr %8, align 4, !tbaa !20
  %39 = load float, ptr %10, align 4, !tbaa !20
  %40 = fcmp ogt float %38, %39
  br i1 %40, label %41, label %47

41:                                               ; preds = %36
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load float, ptr %10, align 4, !tbaa !20
  %44 = load float, ptr %11, align 4, !tbaa !20
  %45 = call noundef i32 @_ZN5ImGui19GetKeyPressedAmountE8ImGuiKeyff(i32 noundef %42, float noundef %43, float noundef %44)
  %46 = icmp sgt i32 %45, 0
  br label %47

47:                                               ; preds = %41, %36
  %48 = phi i1 [ false, %36 ], [ %46, %41 ]
  %49 = zext i1 %48 to i8
  store i8 %49, ptr %9, align 1, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %50

50:                                               ; preds = %47, %32, %26
  %51 = load i8, ptr %9, align 1, !tbaa !21, !range !17, !noundef !18
  %52 = trunc i8 %51 to i1
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %55

54:                                               ; preds = %50
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %55

55:                                               ; preds = %54, %53
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  br label %56

56:                                               ; preds = %55, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %57

57:                                               ; preds = %56, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %58 = load i1, ptr %3, align 1
  ret i1 %58
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !15, i64 0}
!14 = !{!"_ZTS12ImGuiKeyData", !15, i64 0, !16, i64 4, !16, i64 8, !16, i64 12}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!14, !16, i64 4}
!20 = !{!16, !16, i64 0}
!21 = !{!15, !15, 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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5ImGui10GetKeyDataE8ImGuiKey(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5ImGui22GetTypematicRepeatRateEiPfS0_(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN5ImGui19GetKeyPressedAmountE8ImGuiKeyff(i32 noundef, float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5ImGui14IsKeyPressedExE8ImGuiKeyi(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = tail call noundef ptr @_ZN5ImGui10GetKeyDataE8ImGuiKey(i32 noundef %0)
  %6 = load i8, ptr %5, align 4, !tbaa !5, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %24

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %5, i64 4
  %10 = load float, ptr %9, align 4, !tbaa !13
  %11 = fcmp olt float %10, 0.000000e+00
  br i1 %11, label %24, label %12

12:                                               ; preds = %8
  %13 = fcmp oeq float %10, 0.000000e+00
  %14 = and i32 %1, 1
  %.not = icmp eq i32 %14, 0
  %or.cond = or i1 %.not, %13
  br i1 %or.cond, label %24, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @_ZN5ImGui22GetTypematicRepeatRateEiPfS0_(i32 noundef %1, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %16 = load float, ptr %3, align 4, !tbaa !14
  %17 = fcmp ogt float %10, %16
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = load float, ptr %4, align 4, !tbaa !14
  %20 = call noundef i32 @_ZN5ImGui19GetKeyPressedAmountE8ImGuiKeyff(i32 noundef %0, float noundef %16, float noundef %19)
  %21 = icmp sgt i32 %20, 0
  br label %22

22:                                               ; preds = %18, %15
  %23 = phi i1 [ false, %15 ], [ %21, %18 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %24

24:                                               ; preds = %12, %22, %8, %2
  %.2 = phi i1 [ false, %2 ], [ false, %8 ], [ %13, %12 ], [ %23, %22 ]
  ret i1 %.2
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !7, i64 0}
!6 = !{!"_ZTS12ImGuiKeyData", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !10, i64 4}
!14 = !{!10, !10, i64 0}


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