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

; 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

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

17:                                               ; preds = %3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef %18)
  br i1 %19, label %20, label %27

20:                                               ; preds = %17
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %21, i32 0, i32 11
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load double, ptr %5, align 8, !tbaa !9
  %26 = load double, ptr %6, align 8, !tbaa !9
  call void %23(ptr noundef %24, double noundef %25, double noundef %26)
  br label %27

27:                                               ; preds = %20, %17, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %28 = call noundef nonnull align 8 dereferenceable(14624) ptr @_ZN5ImGui5GetIOEv()
  store ptr %28, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ImGuiIO, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !17
  %32 = and i32 %31, 1024
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %44

34:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  call void @glfwGetWindowPos(ptr noundef %35, ptr noundef %9, ptr noundef %10)
  %36 = load i32, ptr %9, align 4, !tbaa !23
  %37 = sitofp i32 %36 to double
  %38 = load double, ptr %5, align 8, !tbaa !9
  %39 = fadd double %38, %37
  store double %39, ptr %5, align 8, !tbaa !9
  %40 = load i32, ptr %10, align 4, !tbaa !23
  %41 = sitofp i32 %40 to double
  %42 = load double, ptr %6, align 8, !tbaa !9
  %43 = fadd double %42, %41
  store double %43, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %44

44:                                               ; preds = %34, %27
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load double, ptr %5, align 8, !tbaa !9
  %47 = fptrunc double %46 to float
  %48 = load double, ptr %6, align 8, !tbaa !9
  %49 = fptrunc double %48 to float
  call void @_ZN7ImGuiIO16AddMousePosEventEff(ptr noundef nonnull align 8 dereferenceable(14624) %45, float noundef %47, float noundef %49)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %50 = load double, ptr %5, align 8, !tbaa !9
  %51 = fptrunc double %50 to float
  %52 = load double, ptr %6, align 8, !tbaa !9
  %53 = fptrunc double %52 to float
  call void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %11, float noundef %51, float noundef %53)
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %54, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %55, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !24
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

declare void @glfwGetWindowPos(ptr noundef, ptr noundef, ptr noundef) #2

declare void @_ZN7ImGuiIO16AddMousePosEventEff(ptr noundef nonnull align 8 dereferenceable(14624), float noundef, float noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !7, i64 0}
!11 = !{!12, !6, i64 2912}
!12 = !{!"_ZTS19ImGui_ImplGlfw_Data", !6, i64 0, !13, i64 8, !10, i64 16, !6, i64 24, !7, i64 32, !14, i64 104, !7, i64 112, !16, i64 2896, !16, i64 2897, !16, 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 = !{!"_ZTS6ImVec2", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!18, !19, i64 0}
!18 = !{!"_ZTS7ImGuiIO", !19, i64 0, !19, i64 4, !14, i64 8, !15, i64 16, !15, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !16, i64 60, !6, i64 64, !14, i64 72, !16, i64 80, !16, i64 81, !16, i64 82, !16, i64 83, !16, i64 84, !16, i64 85, !16, i64 86, !16, i64 87, !16, i64 88, !16, i64 89, !16, i64 90, !16, i64 91, !16, i64 92, !16, i64 93, !16, i64 94, !16, i64 95, !15, i64 96, !15, i64 100, !15, i64 104, !15, i64 108, !15, i64 112, !15, i64 116, !16, i64 120, !16, i64 121, !16, i64 122, !16, i64 123, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !20, i64 200, !16, i64 202, !16, i64 203, !16, i64 204, !16, i64 205, !16, i64 206, !16, i64 207, !16, i64 208, !15, i64 212, !19, i64 216, !19, i64 220, !19, i64 224, !19, i64 228, !14, i64 232, !7, i64 240, !7, i64 2904, !7, i64 3572, !6, i64 3640, !6, i64 3648, !14, i64 3656, !7, i64 3664, !15, i64 3672, !15, i64 3676, !21, i64 3680, !19, i64 3684, !16, i64 3688, !16, i64 3689, !16, i64 3690, !16, i64 3691, !19, i64 3692, !7, i64 3696, !16, i64 14352, !14, i64 14356, !7, i64 14364, !7, i64 14408, !7, i64 14448, !7, i64 14453, !7, i64 14458, !7, i64 14468, !7, i64 14478, !7, i64 14483, !7, i64 14488, !16, i64 14493, !7, i64 14496, !7, i64 14516, !7, i64 14536, !7, i64 14576, !15, i64 14596, !16, i64 14600, !16, i64 14601, !7, i64 14602, !16, i64 14603, !20, i64 14604, !22, i64 14608}
!19 = !{!"int", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!"_ZTS16ImGuiMouseSource", !7, i64 0}
!22 = !{!"_ZTS8ImVectorItE", !19, i64 0, !19, i64 4, !6, i64 8}
!23 = !{!19, !19, i64 0}
!24 = !{i64 0, i64 4, !25, i64 4, i64 4, !25}
!25 = !{!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"

%struct.ImVec2 = type { float, float }

; 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 uwtable
declare hidden noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav() local_unnamed_addr #1

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

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

; 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
define dso_local void @_Z32ImGui_ImplGlfw_CursorPosCallbackP10GLFWwindowdd(ptr noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %struct.ImVec2, align 8
  %7 = tail call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  %8 = getelementptr inbounds i8, ptr %7, i64 2912
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %14, label %10

10:                                               ; preds = %3
  %11 = tail call noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef %0)
  br i1 %11, label %12, label %14

12:                                               ; preds = %10
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  tail call void %13(ptr noundef %0, double noundef %1, double noundef %2)
  br label %14

14:                                               ; preds = %12, %10, %3
  %15 = tail call noundef nonnull align 8 dereferenceable(14624) ptr @_ZN5ImGui5GetIOEv()
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = and i32 %16, 1024
  %.not17 = icmp eq i32 %17, 0
  br i1 %.not17, label %25, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @glfwGetWindowPos(ptr noundef %0, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %19 = load i32, ptr %4, align 4, !tbaa !21
  %20 = sitofp i32 %19 to double
  %21 = fadd double %20, %1
  %22 = load i32, ptr %5, align 4, !tbaa !21
  %23 = sitofp i32 %22 to double
  %24 = fadd double %23, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %25

25:                                               ; preds = %18, %14
  %.016 = phi double [ %24, %18 ], [ %2, %14 ]
  %.0 = phi double [ %21, %18 ], [ %1, %14 ]
  %26 = fptrunc double %.0 to float
  %27 = fptrunc double %.016 to float
  call void @_ZN7ImGuiIO16AddMousePosEventEff(ptr noundef nonnull align 8 dereferenceable(14624) %15, float noundef %26, float noundef %27)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %6, float noundef %26, float noundef %27)
  %28 = getelementptr inbounds i8, ptr %7, i64 104
  %29 = load i64, ptr %6, align 8
  store i64 %29, ptr %28, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  ret void
}

declare void @glfwGetWindowPos(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN7ImGuiIO16AddMousePosEventEff(ptr noundef nonnull align 8 dereferenceable(14624), float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #3 align 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 = { "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, !7, i64 2912}
!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 = !{!16, !17, i64 0}
!16 = !{!"_ZTS7ImGuiIO", !17, i64 0, !17, i64 4, !12, i64 8, !13, i64 16, !13, i64 20, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !13, i64 56, !14, i64 60, !7, i64 64, !12, i64 72, !14, i64 80, !14, i64 81, !14, i64 82, !14, i64 83, !14, i64 84, !14, i64 85, !14, i64 86, !14, i64 87, !14, i64 88, !14, i64 89, !14, i64 90, !14, i64 91, !14, i64 92, !14, i64 93, !14, i64 94, !14, i64 95, !13, i64 96, !13, i64 100, !13, i64 104, !13, i64 108, !13, i64 112, !13, i64 116, !14, i64 120, !14, i64 121, !14, i64 122, !14, i64 123, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !18, i64 200, !14, i64 202, !14, i64 203, !14, i64 204, !14, i64 205, !14, i64 206, !14, i64 207, !14, i64 208, !13, i64 212, !17, i64 216, !17, i64 220, !17, i64 224, !17, i64 228, !12, i64 232, !8, i64 240, !8, i64 2904, !8, i64 3572, !7, i64 3640, !7, i64 3648, !12, i64 3656, !8, i64 3664, !13, i64 3672, !13, i64 3676, !19, i64 3680, !17, i64 3684, !14, i64 3688, !14, i64 3689, !14, i64 3690, !14, i64 3691, !17, i64 3692, !8, i64 3696, !14, i64 14352, !12, i64 14356, !8, i64 14364, !8, i64 14408, !8, i64 14448, !8, i64 14453, !8, i64 14458, !8, i64 14468, !8, i64 14478, !8, i64 14483, !8, i64 14488, !14, i64 14493, !8, i64 14496, !8, i64 14516, !8, i64 14536, !8, i64 14576, !13, i64 14596, !14, i64 14600, !14, i64 14601, !8, i64 14602, !14, i64 14603, !18, i64 14604, !20, i64 14608}
!17 = !{!"int", !8, i64 0}
!18 = !{!"short", !8, i64 0}
!19 = !{!"_ZTS16ImGuiMouseSource", !8, i64 0}
!20 = !{!"_ZTS8ImVectorItE", !17, i64 0, !17, i64 4, !7, i64 8}
!21 = !{!17, !17, i64 0}


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