; LLVM IR from ThePhysicsGuys/Physics3D :: application/picker (ray)

; 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.P3D::Ray" = type { %"struct.P3D::PositionTemplate", %"struct.P3D::Vector.17" }
%"struct.P3D::PositionTemplate" = type { %"struct.P3D::Fix", %"struct.P3D::Fix", %"struct.P3D::Fix" }
%"struct.P3D::Fix" = type { i64 }
%"struct.P3D::Vector.17" = type { %union.anon.18 }
%union.anon.18 = type { [3 x double] }
%"struct.P3D::Vector.0" = type { %union.anon.1 }
%union.anon.1 = type { [3 x float] }
%"struct.P3D::Vector" = type { %union.anon }
%union.anon = type { [2 x float] }
%"class.P3D::Application::Screen" = type { %"class.P3D::Engine::Registry", ptr, ptr, %"struct.P3D::Vector.14", %"struct.P3D::Application::Camera", %"class.P3D::Engine::LayerStack", %"class.P3D::Application::EventHandler", %"class.Util::Properties", %"class.std::shared_ptr", ptr, ptr }
%"class.P3D::Engine::Registry" = type <{ %"class.std::set", %"class.std::vector", %"class.std::unordered_map", %"class.std::queue", i32, [4 x i8] }>
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned long, unsigned long, std::_Identity<unsigned long>, P3D::Engine::Registry<unsigned long>::entity_compare>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned long, unsigned long, std::_Identity<unsigned long>, P3D::Engine::Registry<unsigned long>::entity_compare>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *, std::allocator<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *, std::allocator<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *, std::allocator<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *, std::allocator<std::unordered_multimap<unsigned int, P3D::intrusive_ptr<P3D::RC>> *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<unsigned int, std::allocator<unsigned int>>::_Deque_impl" }
%"struct.std::_Deque_base<unsigned int, std::allocator<unsigned int>>::_Deque_impl" = type { %"struct.std::_Deque_base<unsigned int, std::allocator<unsigned int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<unsigned int, std::allocator<unsigned int>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.P3D::Vector.14" = type { %union.anon.15 }
%union.anon.15 = type { [2 x i32] }
%"struct.P3D::Application::Camera" = type { i8, double, double, %"struct.P3D::Vector.17", i8, double, double, %"struct.P3D::Vector.17", i8, i8, %"class.P3D::GlobalCFrame", double, double, i8, double, float, float, float, float, %"class.P3D::Matrix.20", %"class.P3D::Matrix.20", %"class.P3D::Matrix.20", %"class.P3D::Matrix.20", %"class.P3D::Matrix.20", ptr }
%"class.P3D::GlobalCFrame" = type { %"struct.P3D::PositionTemplate", %"class.P3D::MatrixRotationTemplate" }
%"class.P3D::MatrixRotationTemplate" = type { %"class.P3D::Matrix" }
%"class.P3D::Matrix" = type { [9 x double] }
%"class.P3D::Matrix.20" = type { [16 x float] }
%"class.P3D::Engine::LayerStack" = type <{ %"class.std::vector.21", i32, [4 x i8] }>
%"class.std::vector.21" = type { %"struct.std::_Vector_base.22" }
%"struct.std::_Vector_base.22" = type { %"struct.std::_Vector_base<P3D::Engine::Layer *, std::allocator<P3D::Engine::Layer *>>::_Vector_impl" }
%"struct.std::_Vector_base<P3D::Engine::Layer *, std::allocator<P3D::Engine::Layer *>>::_Vector_impl" = type { %"struct.std::_Vector_base<P3D::Engine::Layer *, std::allocator<P3D::Engine::Layer *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<P3D::Engine::Layer *, std::allocator<P3D::Engine::Layer *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.P3D::Application::EventHandler" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.Util::Properties" = type { %"class.std::__cxx11::basic_string", %"class.std::map" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon.29 }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon.29 = type { i64, [8 x i8] }
%"class.std::map" = type { %"class.std::_Rb_tree.30" }
%"class.std::_Rb_tree.30" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; 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 { <2 x float>, float } @_ZN3P3D11Application7calcRayERKNS0_6ScreenENS_6VectorIfLm2EEE(ptr noundef nonnull align 8 dereferenceable(1024), <2 x float>) #1

; 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) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D11Application11getMouseRayERKNS0_6ScreenERKNS_6VectorIfLm2EEE(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Ray") align 8 %0, ptr noundef nonnull align 8 dereferenceable(1024) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.P3D::PositionTemplate", align 8
  %7 = alloca %"struct.P3D::Vector.0", align 4
  %8 = alloca %"struct.P3D::Vector", align 4
  %9 = alloca { <2 x float>, float }, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %"class.P3D::Application::Screen", ptr %10, i32 0, i32 4
  %12 = getelementptr inbounds %"struct.P3D::Application::Camera", ptr %11, i32 0, i32 10
  call void @_ZNK3P3D12GlobalCFrame11getPositionEv(ptr dead_on_unwind writable sret(%"struct.P3D::PositionTemplate") align 8 %6, ptr noundef nonnull align 8 dereferenceable(96) %12)
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %14, i64 8, i1 false), !tbaa.struct !9
  %15 = getelementptr inbounds %"struct.P3D::Vector", ptr %8, i32 0, i32 0
  %16 = getelementptr inbounds %union.anon, ptr %15, i32 0, i32 0
  %17 = load <2 x float>, ptr %16, align 4
  %18 = call { <2 x float>, float } @_ZN3P3D11Application7calcRayERKNS0_6ScreenENS_6VectorIfLm2EEE(ptr noundef nonnull align 8 dereferenceable(1024) %13, <2 x float> %17)
  %19 = getelementptr inbounds %"struct.P3D::Vector.0", ptr %7, i32 0, i32 0
  %20 = getelementptr inbounds %union.anon.1, ptr %19, i32 0, i32 0
  store { <2 x float>, float } %18, ptr %9, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 8 %9, i64 12, i1 false)
  %21 = getelementptr inbounds %"struct.P3D::Ray", ptr %0, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %6, i64 24, i1 false), !tbaa.struct !11
  %22 = getelementptr inbounds %"struct.P3D::Ray", ptr %0, i32 0, i32 1
  call void @_ZNK3P3D6VectorIfLm3EEcvNS0_IT_Lm3EEEIdEEv(ptr dead_on_unwind writable sret(%"struct.P3D::Vector.17") align 8 %22, ptr noundef nonnull align 4 dereferenceable(12) %7) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNK3P3D12GlobalCFrame11getPositionEv(ptr dead_on_unwind noalias writable sret(%"struct.P3D::PositionTemplate") align 8, ptr noundef nonnull align 8 dereferenceable(96)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK3P3D6VectorIfLm3EEcvNS0_IT_Lm3EEEIdEEv(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Vector.17") align 8, ptr noundef nonnull align 4 dereferenceable(12)) #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{i64 0, i64 8, !10}
!10 = !{!7, !7, i64 0}
!11 = !{i64 0, i64 8, !12, i64 8, i64 8, !12, i64 16, i64 8, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !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"

%"struct.P3D::Ray" = type { %"struct.P3D::PositionTemplate", %"struct.P3D::Vector.17" }
%"struct.P3D::PositionTemplate" = type { %"struct.P3D::Fix", %"struct.P3D::Fix", %"struct.P3D::Fix" }
%"struct.P3D::Fix" = type { i64 }
%"struct.P3D::Vector.17" = type { %union.anon.18 }
%union.anon.18 = type { [3 x double] }
%"struct.P3D::Vector.0" = type { %union.anon.1 }
%union.anon.1 = type { [3 x 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 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 { <2 x float>, float } @_ZN3P3D11Application7calcRayERKNS0_6ScreenENS_6VectorIfLm2EEE(ptr noundef nonnull align 8 dereferenceable(1024), <2 x float>) local_unnamed_addr #1

; Function Attrs: mustprogress 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) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D11Application11getMouseRayERKNS0_6ScreenERKNS_6VectorIfLm2EEE(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Ray") align 8 %0, ptr noundef nonnull align 8 dereferenceable(1024) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %2) local_unnamed_addr #1 {
  %4 = alloca %"struct.P3D::PositionTemplate", align 8
  %5 = alloca %"struct.P3D::Vector.0", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  %6 = getelementptr inbounds i8, ptr %1, i64 344
  call void @_ZNK3P3D12GlobalCFrame11getPositionEv(ptr dead_on_unwind nonnull writable sret(%"struct.P3D::PositionTemplate") align 8 %4, ptr noundef nonnull align 8 dereferenceable(96) %6)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #5
  %.sroa.01.0.copyload = load <2 x float>, ptr %2, align 4, !tbaa !5
  %7 = call { <2 x float>, float } @_ZN3P3D11Application7calcRayERKNS0_6ScreenENS_6VectorIfLm2EEE(ptr noundef nonnull align 8 dereferenceable(1024) %1, <2 x float> %.sroa.01.0.copyload)
  %.fca.0.extract = extractvalue { <2 x float>, float } %7, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %7, 1
  store <2 x float> %.fca.0.extract, ptr %5, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false), !tbaa.struct !8
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  call void @_ZNK3P3D6VectorIfLm3EEcvNS0_IT_Lm3EEEIdEEv(ptr dead_on_unwind nonnull writable sret(%"struct.P3D::Vector.17") align 8 %8, ptr noundef nonnull align 4 dereferenceable(12) %5) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNK3P3D12GlobalCFrame11getPositionEv(ptr dead_on_unwind noalias writable sret(%"struct.P3D::PositionTemplate") align 8, ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK3P3D6VectorIfLm3EEcvNS0_IT_Lm3EEEIdEEv(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Vector.17") align 8, ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #4 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="64" "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{i64 0, i64 8, !9, i64 8, i64 8, !9, i64 16, i64 8, !9}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !6, i64 0}


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