; LLVM IR from khushmmehta/Scorch-V :: src/vendor/imgui/backends (imgui_impl_glfw)

; 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.ImGui_ImplGlfw_Data = type { ptr, i32, double, ptr, [9 x ptr], %struct.ImVec2, [348 x ptr], i8, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.ImVec2 = type { 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: mustprogress uwtable
declare hidden noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav() #1

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef) #1

declare noundef nonnull align 8 dereferenceable(14624) ptr @_ZN5ImGui5GetIOEv() #2

; 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
define dso_local void @_Z26ImGui_ImplGlfw_KeyCallbackP10GLFWwindowiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %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 ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = 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 !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %15 = call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  store ptr %15, ptr %11, align 8, !tbaa !5
  %16 = load ptr, ptr %11, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %16, i32 0, i32 15
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %32

20:                                               ; preds = %5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef %21)
  br i1 %22, label %23, label %32

23:                                               ; preds = %20
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %24, i32 0, i32 15
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = load i32, ptr %10, align 4, !tbaa !9
  call void %26(ptr noundef %27, i32 noundef %28, i32 noundef %29, i32 noundef %30, i32 noundef %31)
  br label %32

32:                                               ; preds = %23, %20, %5
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = icmp ne i32 %33, 1
  br i1 %34, label %35, label %39

35:                                               ; preds = %32
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  store i32 1, ptr %12, align 4
  br label %74

39:                                               ; preds = %35, %32
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef %40)
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = icmp sge i32 %41, 0
  br i1 %42, label %43, label %59

43:                                               ; preds = %39
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 348
  br i1 %45, label %46, label %59

46:                                               ; preds = %43
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = icmp eq i32 %47, 1
  br i1 %48, label %49, label %51

49:                                               ; preds = %46
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  br label %52

51:                                               ; preds = %46
  br label %52

52:                                               ; preds = %51, %49
  %53 = phi ptr [ %50, %49 ], [ null, %51 ]
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %54, i32 0, i32 6
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [348 x ptr], ptr %55, i64 0, i64 %57
  store ptr %53, ptr %58, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %52, %43, %39
  %60 = load i32, ptr %7, align 4, !tbaa !9
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = call noundef i32 @_ZL39ImGui_ImplGlfw_TranslateUntranslatedKeyii(i32 noundef %60, i32 noundef %61)
  store i32 %62, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %63 = call noundef nonnull align 8 dereferenceable(14624) ptr @_ZN5ImGui5GetIOEv()
  store ptr %63, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %64 = load i32, ptr %7, align 4, !tbaa !9
  %65 = call noundef i32 @_ZL28ImGui_ImplGlfw_KeyToImGuiKeyi(i32 noundef %64)
  store i32 %65, ptr %14, align 4, !tbaa !18
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = load i32, ptr %14, align 4, !tbaa !18
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = icmp eq i32 %68, 1
  call void @_ZN7ImGuiIO11AddKeyEventE8ImGuiKeyb(ptr noundef nonnull align 8 dereferenceable(14624) %66, i32 noundef %67, i1 noundef zeroext %69)
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = load i32, ptr %14, align 4, !tbaa !18
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii(ptr noundef nonnull align 8 dereferenceable(14624) %70, i32 noundef %71, i32 noundef %72, i32 noundef %73, i32 noundef -1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  store i32 0, ptr %12, align 4
  br label %74

74:                                               ; preds = %59, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %75 = load i32, ptr %12, align 4
  switch i32 %75, label %77 [
    i32 0, label %76
    i32 1, label %76
  ]

76:                                               ; preds = %74, %74
  ret void

77:                                               ; preds = %74
  unreachable
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL39ImGui_ImplGlfw_TranslateUntranslatedKeyii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL28ImGui_ImplGlfw_KeyToImGuiKeyi(i32 noundef) #3

declare void @_ZN7ImGuiIO11AddKeyEventE8ImGuiKeyb(ptr noundef nonnull align 8 dereferenceable(14624), i32 noundef, i1 noundef zeroext) #2

declare void @_ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii(ptr noundef nonnull align 8 dereferenceable(14624), i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

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 = { "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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 2944}
!12 = !{!"_ZTS19ImGui_ImplGlfw_Data", !6, i64 0, !13, i64 8, !14, i64 16, !6, i64 24, !7, i64 32, !15, i64 104, !7, i64 112, !17, i64 2896, !17, i64 2897, !17, i64 2898, !6, i64 2904, !6, i64 2912, !6, i64 2920, !6, i64 2928, !6, i64 2936, !6, i64 2944, !6, i64 2952, !6, i64 2960}
!13 = !{!"_ZTS13GlfwClientApi", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTS6ImVec2", !16, i64 0, !16, i64 4}
!16 = !{!"float", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"_ZTS8ImGuiKey", !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"

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef) local_unnamed_addr #0

declare noundef nonnull align 8 dereferenceable(14624) ptr @_ZN5ImGui5GetIOEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z26ImGui_ImplGlfw_KeyCallbackP10GLFWwindowiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  %7 = getelementptr inbounds i8, ptr %6, i64 2944
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %13, label %9

9:                                                ; preds = %5
  %10 = tail call noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef %0)
  br i1 %10, label %11, label %13

11:                                               ; preds = %9
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void %12(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4)
  br label %13

13:                                               ; preds = %11, %9, %5
  %or.cond = icmp ugt i32 %3, 1
  br i1 %or.cond, label %26, label %14

14:                                               ; preds = %13
  tail call void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef %0)
  %or.cond3 = icmp ult i32 %1, 348
  br i1 %or.cond3, label %15, label %21

15:                                               ; preds = %14
  %16 = icmp eq i32 %3, 1
  %17 = select i1 %16, ptr %0, ptr null
  %18 = getelementptr inbounds i8, ptr %6, i64 112
  %19 = zext nneg i32 %1 to i64
  %20 = getelementptr inbounds [348 x ptr], ptr %18, i64 0, i64 %19
  store ptr %17, ptr %20, align 8, !tbaa !15
  br label %21

21:                                               ; preds = %15, %14
  %22 = tail call noundef i32 @_ZL39ImGui_ImplGlfw_TranslateUntranslatedKeyii(i32 noundef %1, i32 noundef %2)
  %23 = tail call noundef nonnull align 8 dereferenceable(14624) ptr @_ZN5ImGui5GetIOEv()
  %24 = tail call noundef i32 @_ZL28ImGui_ImplGlfw_KeyToImGuiKeyi(i32 noundef %22)
  %25 = icmp eq i32 %3, 1
  tail call void @_ZN7ImGuiIO11AddKeyEventE8ImGuiKeyb(ptr noundef nonnull align 8 dereferenceable(14624) %23, i32 noundef %24, i1 noundef zeroext %25)
  tail call void @_ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii(ptr noundef nonnull align 8 dereferenceable(14624) %23, i32 noundef %24, i32 noundef %22, i32 noundef %2, i32 noundef -1)
  br label %26

26:                                               ; preds = %13, %21
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL39ImGui_ImplGlfw_TranslateUntranslatedKeyii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL28ImGui_ImplGlfw_KeyToImGuiKeyi(i32 noundef) local_unnamed_addr #2

declare void @_ZN7ImGuiIO11AddKeyEventE8ImGuiKeyb(ptr noundef nonnull align 8 dereferenceable(14624), i32 noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @_ZN7ImGuiIO21SetKeyEventNativeDataE8ImGuiKeyiii(ptr noundef nonnull align 8 dereferenceable(14624), i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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" }

!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 2944}
!6 = !{!"_ZTS19ImGui_ImplGlfw_Data", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !8, i64 32, !12, i64 104, !8, i64 112, !14, i64 2896, !14, i64 2897, !14, i64 2898, !7, i64 2904, !7, i64 2912, !7, i64 2920, !7, i64 2928, !7, i64 2936, !7, i64 2944, !7, i64 2952, !7, i64 2960}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS13GlfwClientApi", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"_ZTS6ImVec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!7, !7, i64 0}


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