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

; 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, i8, i8, 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], ptr, %struct.ImVec2, [5 x i8], float, float, i32, 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], 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.3 = external hidden unnamed_addr constant [117 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [23 x i8], align 1
@__PRETTY_FUNCTION__._ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii = external hidden unnamed_addr constant [61 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [79 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: mustprogress uwtable
define dso_local void @_ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii(ptr noundef nonnull align 8 dereferenceable(14280) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !11
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !11
  %13 = load ptr, ptr %6, align 8
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %5
  br label %59

17:                                               ; preds = %5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %18)
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %23

21:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.3, i32 noundef 1437, ptr noundef @__PRETTY_FUNCTION__._ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii) #4
  unreachable

22:                                               ; No predecessors!
  br label %23

23:                                               ; preds = %22, %20
  %24 = load i32, ptr %10, align 4, !tbaa !11
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %29, label %26

26:                                               ; preds = %23
  %27 = load i32, ptr %10, align 4, !tbaa !11
  %28 = call noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef %27)
  br label %29

29:                                               ; preds = %26, %23
  %30 = phi i1 [ true, %23 ], [ %28, %26 ]
  br i1 %30, label %31, label %32

31:                                               ; preds = %29
  br label %34

32:                                               ; preds = %29
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.3, i32 noundef 1438, ptr noundef @__PRETTY_FUNCTION__._ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii) #4
  unreachable

33:                                               ; No predecessors!
  br label %34

34:                                               ; preds = %33, %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %35 = load i32, ptr %10, align 4, !tbaa !11
  %36 = icmp ne i32 %35, -1
  br i1 %36, label %37, label %39

37:                                               ; preds = %34
  %38 = load i32, ptr %10, align 4, !tbaa !11
  br label %41

39:                                               ; preds = %34
  %40 = load i32, ptr %8, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %39, %37
  %42 = phi i32 [ %38, %37 ], [ %40, %39 ]
  store i32 %42, ptr %11, align 4, !tbaa !11
  %43 = load i32, ptr %11, align 4, !tbaa !11
  %44 = call noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef %43)
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 1, ptr %12, align 4
  br label %57

46:                                               ; preds = %41
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = getelementptr inbounds %struct.ImGuiIO, ptr %13, i32 0, i32 55
  %49 = load i32, ptr %11, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [652 x i32], ptr %48, i64 0, i64 %50
  store i32 %47, ptr %51, align 4, !tbaa !11
  %52 = load i32, ptr %11, align 4, !tbaa !11
  %53 = getelementptr inbounds %struct.ImGuiIO, ptr %13, i32 0, i32 55
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [652 x i32], ptr %53, i64 0, i64 %55
  store i32 %52, ptr %56, align 4, !tbaa !11
  store i32 0, ptr %12, align 4
  br label %57

57:                                               ; preds = %46, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %58 = load i32, ptr %12, align 4
  switch i32 %58, label %60 [
    i32 0, label %59
    i32 1, label %59
  ]

59:                                               ; preds = %57, %57, %16
  ret void

60:                                               ; preds = %57
  unreachable
}

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

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

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 = { 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 #3 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS8ImGuiKey", !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.3 = external hidden unnamed_addr constant [117 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [23 x i8], align 1
@__PRETTY_FUNCTION__._ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii = external hidden unnamed_addr constant [61 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [79 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: mustprogress nounwind uwtable
define dso_local void @_ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(14280) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 align 2 {
  %6 = icmp eq i32 %1, 0
  br i1 %6, label %23, label %7

7:                                                ; preds = %5
  %8 = tail call noundef zeroext i1 @_ZN5ImGui10IsNamedKeyE8ImGuiKey(i32 noundef %1)
  br i1 %8, label %10, label %9

9:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.3, i32 noundef 1437, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii) #3
  unreachable

10:                                               ; preds = %7
  %11 = icmp eq i32 %4, -1
  br i1 %11, label %.critedge, label %12

12:                                               ; preds = %10
  %13 = tail call noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef %4)
  br i1 %13, label %.critedge, label %14

14:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.3, i32 noundef 1438, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii) #3
  unreachable

.critedge:                                        ; preds = %10, %12
  %15 = phi i32 [ %2, %10 ], [ %4, %12 ]
  %16 = tail call noundef zeroext i1 @_ZN5ImGui11IsLegacyKeyE8ImGuiKey(i32 noundef %15)
  br i1 %16, label %17, label %23

17:                                               ; preds = %.critedge
  %18 = getelementptr inbounds i8, ptr %0, i64 248
  %19 = sext i32 %15 to i64
  %20 = getelementptr inbounds [652 x i32], ptr %18, i64 0, i64 %19
  store i32 %1, ptr %20, align 4, !tbaa !5
  %21 = sext i32 %1 to i64
  %22 = getelementptr inbounds [652 x i32], ptr %18, i64 0, i64 %21
  store i32 %15, ptr %22, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %17, %.critedge, %5
  ret void
}

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

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

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 = { 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 = { 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 = { 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"}


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