; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qraycast.ll (ZN8QRaycast14UpdateContactsEv)

; 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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl" }
%"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl" = type { %"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.QVector = type { float, float }
%class.QRaycast = type { i32, i8, %struct.QVector, float, %struct.QVector, %struct.QVector, i8, %"class.std::vector", ptr }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8QRaycast14UpdateContactsEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::vector", align 8
  %4 = alloca %struct.QVector, align 4
  %5 = alloca %struct.QVector, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds %class.QRaycast, ptr %6, i32 0, i32 8
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  br label %25

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #4
  %12 = getelementptr inbounds %class.QRaycast, ptr %6, i32 0, i32 8
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %class.QRaycast, ptr %6, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 8 %14, i64 8, i1 false), !tbaa.struct !19
  %15 = getelementptr inbounds %class.QRaycast, ptr %6, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !19
  %16 = getelementptr inbounds %class.QRaycast, ptr %6, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !21
  %18 = getelementptr inbounds %class.QRaycast, ptr %6, i32 0, i32 6
  %19 = load i8, ptr %18, align 4, !tbaa !22, !range !23, !noundef !24
  %20 = trunc i8 %19 to i1
  %21 = load <2 x float>, ptr %4, align 4
  %22 = load <2 x float>, ptr %5, align 4
  call void @_ZN8QRaycast9RaycastToEP6QWorld7QVectorS2_ib(ptr dead_on_unwind writable sret(%"class.std::vector") align 8 %3, ptr noundef %13, <2 x float> %21, <2 x float> %22, i32 noundef %17, i1 noundef zeroext %20)
  %23 = getelementptr inbounds %class.QRaycast, ptr %6, i32 0, i32 7
  %24 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #4
  br label %25

25:                                               ; preds = %11, %10
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8QRaycast9RaycastToEP6QWorld7QVectorS2_ib(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8, ptr noundef, <2 x float>, <2 x float>, i32 noundef, i1 noundef zeroext) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !6, i64 64}
!10 = !{!"_ZTS8QRaycast", !11, i64 0, !12, i64 4, !13, i64 8, !14, i64 16, !13, i64 20, !13, i64 28, !12, i64 36, !15, i64 40, !6, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTS7QVector", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_ZTSSt6vectorIN8QRaycast7ContactESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN8QRaycast7ContactESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN8QRaycast7ContactESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN8QRaycast7ContactESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{i64 0, i64 4, !20, i64 4, i64 4, !20}
!20 = !{!14, !14, i64 0}
!21 = !{!10, !11, i64 0}
!22 = !{!10, !12, i64 36}
!23 = !{i8 0, i8 2}
!24 = !{}


; 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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl" }
%"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl" = type { %"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QRaycast::Contact, std::allocator<QRaycast::Contact>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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
define dso_local void @_ZN8QRaycast14UpdateContactsEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"class.std::vector", align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 64
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %15, label %6

6:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.01.0.copyload = load <2 x float>, ptr %7, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 20
  %.sroa.0.0.copyload = load <2 x float>, ptr %8, align 4
  %9 = load i32, ptr %0, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 36
  %11 = load i8, ptr %10, align 4, !tbaa !19, !range !20, !noundef !21
  %12 = trunc nuw i8 %11 to i1
  call void @_ZN8QRaycast9RaycastToEP6QWorld7QVectorS2_ib(ptr dead_on_unwind nonnull writable sret(%"class.std::vector") align 8 %2, ptr noundef nonnull %4, <2 x float> %.sroa.01.0.copyload, <2 x float> %.sroa.0.0.copyload, i32 noundef %9, i1 noundef zeroext %12)
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  call void @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #3
  br label %15

15:                                               ; preds = %1, %6
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8QRaycast9RaycastToEP6QWorld7QVectorS2_ib(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8, ptr noundef, <2 x float>, <2 x float>, i32 noundef, i1 noundef zeroext) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN8QRaycast7ContactESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 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 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, !17, i64 64}
!6 = !{!"_ZTS8QRaycast", !7, i64 0, !10, i64 4, !11, i64 8, !12, i64 16, !11, i64 20, !11, i64 28, !10, i64 36, !13, i64 40, !17, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS7QVector", !12, i64 0, !12, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"_ZTSSt6vectorIN8QRaycast7ContactESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN8QRaycast7ContactESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN8QRaycast7ContactESaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN8QRaycast7ContactESaIS1_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !10, i64 36}
!20 = !{i8 0, i8 2}
!21 = !{}


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