; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qparticle.ll (ZN9QParticle22ApplyAccumulatedForcesEv)

; 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.QVector = type { float, float }
%class.QParticle = type <{ float, %struct.QVector, %struct.QVector, %struct.QVector, float, ptr, i8, [3 x i8], %struct.QVector, [4 x i8], %"class.std::vector", i8, i8, [2 x i8], %class.QAABB, i8, [7 x i8], %"class.std::unordered_set", %"class.std::unordered_set.5", %"class.std::unordered_set.5", i8, i8, [6 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl" }
%"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl" = type { %"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.QAABB = type { %struct.QVector, %struct.QVector, %struct.QVector, float }
%"class.std::unordered_set" = 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::unordered_set.5" = type { %"class.std::_Hashtable.6" }
%"class.std::_Hashtable.6" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", 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> @_ZN7QVector4ZeroEv() #1 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) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9QParticle10ApplyForceE7QVector(ptr noundef nonnull align 8 dereferenceable(290), <2 x float>) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN9QParticle22ApplyAccumulatedForcesEv(ptr noundef nonnull align 8 dereferenceable(290) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.QVector, align 4
  %4 = alloca i64, align 8
  %5 = alloca float, align 4
  %6 = alloca %struct.QVector, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  %8 = getelementptr inbounds %class.QParticle, ptr %7, i32 0, i32 10
  %9 = call noundef i64 @_ZNKSt6vectorI7QVectorSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #4
  %10 = icmp ugt i64 %9, 0
  br i1 %10, label %11, label %35

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %12 = call <2 x float> @_ZN7QVector4ZeroEv()
  store <2 x float> %12, ptr %3, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %24, %11
  %14 = load i64, ptr %4, align 8, !tbaa !9
  %15 = getelementptr inbounds %class.QParticle, ptr %7, i32 0, i32 10
  %16 = call noundef i64 @_ZNKSt6vectorI7QVectorSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #4
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %27

19:                                               ; preds = %13
  %20 = getelementptr inbounds %class.QParticle, ptr %7, i32 0, i32 10
  %21 = load i64, ptr %4, align 8, !tbaa !9
  %22 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7QVectorSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %20, i64 noundef %21) #4
  %23 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %22)
  br label %24

24:                                               ; preds = %19
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = add i64 %25, 1
  store i64 %26, ptr %4, align 8, !tbaa !9
  br label %13, !llvm.loop !11

27:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %28 = getelementptr inbounds %class.QParticle, ptr %7, i32 0, i32 10
  %29 = call noundef i64 @_ZNKSt6vectorI7QVectorSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %28) #4
  %30 = uitofp i64 %29 to float
  store float %30, ptr %5, align 4, !tbaa !13
  %31 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectordVERKf(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %3, i64 8, i1 false), !tbaa.struct !15
  %32 = load <2 x float>, ptr %6, align 4
  %33 = call noundef ptr @_ZN9QParticle10ApplyForceE7QVector(ptr noundef nonnull align 8 dereferenceable(290) %7, <2 x float> %32)
  %34 = getelementptr inbounds %class.QParticle, ptr %7, i32 0, i32 10
  call void @_ZNSt6vectorI7QVectorSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %34) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %35

35:                                               ; preds = %27, %1
  ret ptr %7
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectordVERKf(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) #3 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 = { 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{i64 0, i64 4, !13, i64 4, i64 4, !13}


; 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.QVector = 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 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> @_ZN7QVector4ZeroEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9QParticle10ApplyForceE7QVector(ptr noundef nonnull align 8 dereferenceable(290), <2 x float>) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN9QParticle22ApplyAccumulatedForcesEv(ptr noundef nonnull returned align 8 dereferenceable(290) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %struct.QVector, align 8
  %3 = alloca float, align 4
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  %5 = tail call noundef i64 @_ZNKSt6vectorI7QVectorSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %18, label %6

6:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %7 = tail call <2 x float> @_ZN7QVector4ZeroEv()
  store <2 x float> %7, ptr %2, align 8
  %8 = tail call noundef i64 @_ZNKSt6vectorI7QVectorSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  %.not4 = icmp eq i64 %8, 0
  br i1 %.not4, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %9 = call noundef i64 @_ZNKSt6vectorI7QVectorSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  %10 = uitofp i64 %9 to float
  store float %10, ptr %3, align 4, !tbaa !5
  %11 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectordVERKf(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  %.sroa.0.0.copyload = load <2 x float>, ptr %2, align 8
  %12 = call noundef ptr @_ZN9QParticle10ApplyForceE7QVector(ptr noundef nonnull align 8 dereferenceable(290) %0, <2 x float> %.sroa.0.0.copyload)
  call void @_ZNSt6vectorI7QVectorSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br label %18

.lr.ph:                                           ; preds = %6, %.lr.ph
  %.03 = phi i64 [ %15, %.lr.ph ], [ 0, %6 ]
  %13 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7QVectorSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %.03) #3
  %14 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %13)
  %15 = add nuw i64 %.03, 1
  %16 = call noundef i64 @_ZNKSt6vectorI7QVectorSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  %17 = icmp ult i64 %15, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !9

18:                                               ; preds = %._crit_edge, %1
  ret ptr %0
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectordVERKf(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) local_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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass