; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/extensions/qplatformerbody.ll (ZN15QPlatformerBody10ApplyForceE7QVector)

; 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.QPlatformerBody = type { %class.QRigidBody.base, i8, i8, i32, float, float, ptr, %struct.QVector, float, %struct.QVector, %struct.QVector, %struct.QVector, float, %struct.QVector, %struct.QVector, i8, i8, i32, float, float, i32, float, i32, i32, i32, i32, float, float }
%class.QRigidBody.base = type { %class.QBody.base, i8, %struct.QVector, float }
%class.QBody.base = type <{ ptr, float, float, ptr, %struct.QVector, %struct.QVector, float, float, %class.QAABB, i32, i8, i8, i8, i8, float, i32, i8, [3 x i8], float, i8, i8, [2 x i8], %struct.QVector, float, float, float, float, float, i32, i32, i8, i8, i8, i8, i32, i32, i32, i8, [3 x i8], %"class.std::function", %"class.std::function", %"class.std::function.0", i8, [7 x i8], %"class.std::vector", i32, i8 }>
%class.QAABB = type { %struct.QVector, %struct.QVector, %struct.QVector, float }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.std::function.0" = type { %"class.std::_Function_base", ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl" }
%"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl" = type { %"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZN7QVector4ZeroEv() #0 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) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_ZN5QBody11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(293)) #3 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN15QPlatformerBody10ApplyForceE7QVector(ptr noundef nonnull align 8 dereferenceable(440) %0, <2 x float> %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.QVector, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.QVector, align 4
  %7 = alloca %struct.QVector, align 4
  %8 = alloca %struct.QVector, align 4
  %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 %struct.QVector, align 4
  %14 = alloca %struct.QVector, align 4
  %15 = alloca %struct.QVector, align 4
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %17 = call <2 x float> @_ZN7QVector4ZeroEv()
  store <2 x float> %17, ptr %6, align 4
  %18 = call noundef zeroext i1 @_ZNK7QVectoreqERKS_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br i1 %18, label %19, label %20

19:                                               ; preds = %2
  store ptr %16, ptr %3, align 8
  br label %44

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %21 = getelementptr inbounds %class.QPlatformerBody, ptr %16, i32 0, i32 11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %21, i64 8, i1 false), !tbaa.struct !9
  %22 = load <2 x float>, ptr %8, align 4
  %23 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %4, <2 x float> %22)
  %24 = getelementptr inbounds %class.QPlatformerBody, ptr %16, i32 0, i32 11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %24, i64 8, i1 false), !tbaa.struct !9
  %25 = load <2 x float>, ptr %9, align 4
  %26 = call <2 x float> @_Zmlf7QVector(float noundef %23, <2 x float> %25)
  store <2 x float> %26, ptr %7, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %27 = getelementptr inbounds %class.QPlatformerBody, ptr %16, i32 0, i32 10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %27, i64 8, i1 false), !tbaa.struct !9
  %28 = load <2 x float>, ptr %11, align 4
  %29 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %4, <2 x float> %28)
  %30 = getelementptr inbounds %class.QPlatformerBody, ptr %16, i32 0, i32 10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %30, i64 8, i1 false), !tbaa.struct !9
  %31 = load <2 x float>, ptr %12, align 4
  %32 = call <2 x float> @_Zmlf7QVector(float noundef %29, <2 x float> %31)
  store <2 x float> %32, ptr %10, align 4
  %33 = getelementptr inbounds %class.QPlatformerBody, ptr %16, i32 0, i32 13
  %34 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %33, ptr noundef nonnull align 4 dereferenceable(8) %7)
  %35 = getelementptr inbounds %class.QPlatformerBody, ptr %16, i32 0, i32 14
  %36 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %35, ptr noundef nonnull align 4 dereferenceable(8) %10)
  %37 = call <2 x float> @_ZN5QBody11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(293) %16)
  store <2 x float> %37, ptr %14, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %4, i64 8, i1 false), !tbaa.struct !9
  %38 = load <2 x float>, ptr %14, align 4
  %39 = load <2 x float>, ptr %15, align 4
  %40 = call <2 x float> @_Zpl7QVectorS_(<2 x float> %38, <2 x float> %39)
  store <2 x float> %40, ptr %13, align 4
  %41 = load <2 x float>, ptr %13, align 4
  %42 = call noundef ptr @_ZN10QRigidBody21SetPositionAndCollideE7QVectorb(ptr noundef nonnull align 8 dereferenceable(308) %16, <2 x float> %41, i1 noundef zeroext true)
  %43 = call noundef ptr @_ZN5QBody6WakeUpEv(ptr noundef nonnull align 8 dereferenceable(293) %16)
  store ptr %16, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %44

44:                                               ; preds = %20, %19
  %45 = load ptr, ptr %3, align 8
  ret ptr %45
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7QVectoreqERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmlf7QVector(float noundef, <2 x float>) #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)) #5 align 2

declare noundef ptr @_ZN10QRigidBody21SetPositionAndCollideE7QVectorb(ptr noundef nonnull align 8 dereferenceable(308), <2 x float>, i1 noundef zeroext) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5QBody6WakeUpEv(ptr noundef nonnull align 8 dereferenceable(293)) #5 align 2

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { 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 = { "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 uwtable
declare dso_local <2 x float> @_ZN7QVector4ZeroEv() local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_ZN5QBody11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(293)) local_unnamed_addr #2 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 #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN15QPlatformerBody10ApplyForceE7QVector(ptr noundef nonnull returned align 8 dereferenceable(440) %0, <2 x float> %1) unnamed_addr #0 align 2 {
  %3 = alloca %struct.QVector, align 8
  %4 = alloca %struct.QVector, align 8
  %5 = alloca %struct.QVector, align 8
  %6 = alloca %struct.QVector, align 8
  store <2 x float> %1, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %7 = tail call <2 x float> @_ZN7QVector4ZeroEv()
  store <2 x float> %7, ptr %4, align 8
  %8 = call noundef zeroext i1 @_ZNK7QVectoreqERKS_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br i1 %8, label %24, label %9

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %10 = getelementptr inbounds i8, ptr %0, i64 364
  %.sroa.06.0.copyload = load <2 x float>, ptr %10, align 4
  %11 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %3, <2 x float> %.sroa.06.0.copyload)
  %.sroa.05.0.copyload = load <2 x float>, ptr %10, align 4
  %12 = call <2 x float> @_Zmlf7QVector(float noundef %11, <2 x float> %.sroa.05.0.copyload)
  store <2 x float> %12, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %13 = getelementptr inbounds i8, ptr %0, i64 356
  %.sroa.04.0.copyload = load <2 x float>, ptr %13, align 4
  %14 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %3, <2 x float> %.sroa.04.0.copyload)
  %.sroa.03.0.copyload = load <2 x float>, ptr %13, align 4
  %15 = call <2 x float> @_Zmlf7QVector(float noundef %14, <2 x float> %.sroa.03.0.copyload)
  store <2 x float> %15, ptr %6, align 8
  %16 = getelementptr inbounds i8, ptr %0, i64 376
  %17 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(8) %5)
  %18 = getelementptr inbounds i8, ptr %0, i64 384
  %19 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %18, ptr noundef nonnull align 4 dereferenceable(8) %6)
  %20 = call <2 x float> @_ZN5QBody11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(293) %0)
  %.sroa.0.0.copyload = load <2 x float>, ptr %3, align 8
  %21 = call <2 x float> @_Zpl7QVectorS_(<2 x float> %20, <2 x float> %.sroa.0.0.copyload)
  %22 = call noundef ptr @_ZN10QRigidBody21SetPositionAndCollideE7QVectorb(ptr noundef nonnull align 8 dereferenceable(308) %0, <2 x float> %21, i1 noundef zeroext true)
  %23 = call noundef ptr @_ZN5QBody6WakeUpEv(ptr noundef nonnull align 8 dereferenceable(293) %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %24

24:                                               ; preds = %2, %9
  ret ptr %0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmlf7QVector(float noundef, <2 x float>) local_unnamed_addr #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 #4 align 2

declare noundef ptr @_ZN10QRigidBody21SetPositionAndCollideE7QVectorb(ptr noundef nonnull align 8 dereferenceable(308), <2 x float>, i1 noundef zeroext) local_unnamed_addr #5

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { "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,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass