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

; 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: 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) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9QParticle27ApplyForceToParticleSegmentEPS_S0_7QVectorS1_(ptr noundef %0, ptr noundef %1, <2 x float> %2, <2 x float> %3) #3 align 2 {
  %5 = alloca %struct.QVector, align 4
  %6 = alloca %struct.QVector, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.QVector, align 4
  %10 = alloca %struct.QVector, align 4
  %11 = alloca %struct.QVector, align 4
  %12 = alloca %struct.QVector, align 4
  %13 = alloca float, align 4
  %14 = alloca %struct.QVector, align 4
  %15 = alloca %struct.QVector, align 4
  %16 = alloca %struct.QVector, align 4
  %17 = alloca float, align 4
  %18 = alloca %struct.QVector, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = alloca %struct.QVector, align 4
  %23 = alloca %struct.QVector, align 4
  %24 = alloca %struct.QVector, align 4
  %25 = alloca %struct.QVector, align 4
  store <2 x float> %2, ptr %5, align 4
  store <2 x float> %3, ptr %6, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.QParticle, ptr %26, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %27, i64 8, i1 false), !tbaa.struct !9
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.QParticle, ptr %28, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %29, i64 8, i1 false), !tbaa.struct !9
  %30 = load <2 x float>, ptr %10, align 4
  %31 = load <2 x float>, ptr %11, align 4
  %32 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %30, <2 x float> %31)
  store <2 x float> %32, ptr %9, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %33 = call <2 x float> @_ZNK7QVector10NormalizedEv(ptr noundef nonnull align 4 dereferenceable(8) %9)
  store <2 x float> %33, ptr %12, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %34 = call noundef float @_ZNK7QVector6LengthEv(ptr noundef nonnull align 4 dereferenceable(8) %9)
  store float %34, ptr %13, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !9
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.QParticle, ptr %35, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %36, i64 8, i1 false), !tbaa.struct !9
  %37 = load <2 x float>, ptr %15, align 4
  %38 = load <2 x float>, ptr %16, align 4
  %39 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %37, <2 x float> %38)
  store <2 x float> %39, ptr %14, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !9
  %40 = load <2 x float>, ptr %18, align 4
  %41 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %14, <2 x float> %40)
  store float %41, ptr %17, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  %42 = load float, ptr %17, align 4, !tbaa !10
  %43 = fcmp olt float %42, 0.000000e+00
  br i1 %43, label %44, label %49

44:                                               ; preds = %4
  %45 = load float, ptr %17, align 4, !tbaa !10
  %46 = load float, ptr %13, align 4, !tbaa !10
  %47 = fcmp ogt float %45, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %44
  store float 5.000000e-01, ptr %19, align 4, !tbaa !10
  store float 5.000000e-01, ptr %20, align 4, !tbaa !10
  br label %60

49:                                               ; preds = %44, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  %50 = load float, ptr %13, align 4, !tbaa !10
  %51 = fdiv float 1.000000e+00, %50
  store float %51, ptr %21, align 4, !tbaa !10
  %52 = load float, ptr %13, align 4, !tbaa !10
  %53 = load float, ptr %17, align 4, !tbaa !10
  %54 = fsub float %52, %53
  %55 = load float, ptr %21, align 4, !tbaa !10
  %56 = fmul float %54, %55
  store float %56, ptr %19, align 4, !tbaa !10
  %57 = load float, ptr %17, align 4, !tbaa !10
  %58 = load float, ptr %21, align 4, !tbaa !10
  %59 = fmul float %57, %58
  store float %59, ptr %20, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %60

60:                                               ; preds = %49, %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %61 = load float, ptr %19, align 4, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !9
  %62 = load <2 x float>, ptr %23, align 4
  %63 = call <2 x float> @_Zmlf7QVector(float noundef %61, <2 x float> %62)
  store <2 x float> %63, ptr %22, align 4
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %class.QParticle, ptr %64, i32 0, i32 1
  %66 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %65, ptr noundef nonnull align 4 dereferenceable(8) %22)
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  %67 = load float, ptr %20, align 4, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !9
  %68 = load <2 x float>, ptr %25, align 4
  %69 = call <2 x float> @_Zmlf7QVector(float noundef %67, <2 x float> %68)
  store <2 x float> %69, ptr %24, align 4
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %class.QParticle, ptr %70, i32 0, i32 1
  %72 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %71, ptr noundef nonnull align 4 dereferenceable(8) %24)
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmi7QVectorS_(<2 x float>, <2 x float>) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZNK7QVector10NormalizedEv(ptr noundef nonnull align 4 dereferenceable(8)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK7QVector6LengthEv(ptr noundef nonnull align 4 dereferenceable(8)) #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) #6 align 2

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmlf7QVector(float noundef, <2 x float>) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { inlinehint 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 #5 = { 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 #6 = { inlinehint mustprogress nounwind 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 #7 = { 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 4, !10, i64 4, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !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.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 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 #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9QParticle27ApplyForceToParticleSegmentEPS_S0_7QVectorS1_(ptr noundef %0, ptr noundef %1, <2 x float> %2, <2 x float> %3) local_unnamed_addr #2 align 2 {
  %5 = alloca %struct.QVector, align 8
  %6 = alloca %struct.QVector, align 8
  %7 = alloca %struct.QVector, align 8
  %8 = alloca %struct.QVector, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %9 = getelementptr inbounds i8, ptr %1, i64 4
  %.sroa.017.0.copyload = load <2 x float>, ptr %9, align 4
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %.sroa.016.0.copyload = load <2 x float>, ptr %10, align 4
  %11 = tail call <2 x float> @_Zmi7QVectorS_(<2 x float> %.sroa.017.0.copyload, <2 x float> %.sroa.016.0.copyload)
  store <2 x float> %11, ptr %5, align 8
  %12 = call <2 x float> @_ZNK7QVector10NormalizedEv(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %13 = call noundef float @_ZNK7QVector6LengthEv(ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %.sroa.010.0.copyload = load <2 x float>, ptr %10, align 4
  %14 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %3, <2 x float> %.sroa.010.0.copyload)
  store <2 x float> %14, ptr %6, align 8
  %15 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %6, <2 x float> %12)
  %16 = fcmp olt float %15, 0.000000e+00
  %17 = fcmp ogt float %15, %13
  %or.cond = and i1 %16, %17
  %18 = fdiv float 1.000000e+00, %13
  %19 = fsub float %13, %15
  %20 = fmul float %18, %19
  %21 = fmul float %18, %15
  %.026 = select i1 %or.cond, float 5.000000e-01, float %21
  %.0 = select i1 %or.cond, float 5.000000e-01, float %20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %22 = call <2 x float> @_Zmlf7QVector(float noundef %.0, <2 x float> %2)
  store <2 x float> %22, ptr %7, align 8
  %23 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %24 = call <2 x float> @_Zmlf7QVector(float noundef %.026, <2 x float> %2)
  store <2 x float> %24, ptr %8, align 8
  %25 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %9, ptr noundef nonnull align 4 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmi7QVectorS_(<2 x float>, <2 x float>) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZNK7QVector10NormalizedEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmlf7QVector(float noundef, <2 x float>) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { inlinehint 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 #4 = { 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 #5 = { inlinehint mustprogress nounwind 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 #6 = { 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)"}


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