; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qrigidbody.ll (ZN10QRigidBody10ApplyForceE7QVectorS0_b)

; 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.QBody = 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, [3 x 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 }
%class.QRigidBody = type { %class.QBody.base, i8, %struct.QVector, float, [4 x i8] }
%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 }>

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN10QRigidBody10ApplyForceE7QVectorS0_b(ptr noundef nonnull align 8 dereferenceable(308) %0, <2 x float> %1, <2 x float> %2, i1 noundef zeroext %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca %struct.QVector, align 4
  %7 = alloca %struct.QVector, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca %struct.QVector, align 4
  store <2 x float> %1, ptr %6, align 4
  store <2 x float> %2, ptr %7, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  %11 = zext i1 %3 to i8
  store i8 %11, ptr %9, align 1, !tbaa !9
  %12 = load ptr, ptr %8, align 8
  %13 = call noundef i32 @_ZN5QBody7GetModeEv(ptr noundef nonnull align 8 dereferenceable(293) %12)
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %19, label %15

15:                                               ; preds = %4
  %16 = call noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293) %12)
  %17 = zext i1 %16 to i32
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %15, %4
  store ptr %12, ptr %5, align 8
  br label %44

20:                                               ; preds = %15
  %21 = getelementptr inbounds %class.QBody, ptr %12, i32 0, i32 4
  %22 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %21, ptr noundef nonnull align 4 dereferenceable(8) %6)
  %23 = getelementptr inbounds %class.QRigidBody, ptr %12, i32 0, i32 1
  %24 = load i8, ptr %23, align 1, !tbaa !11, !range !28, !noundef !29
  %25 = trunc i8 %24 to i1
  %26 = zext i1 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %37

28:                                               ; preds = %20
  %29 = call <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  store <2 x float> %29, ptr %10, align 4
  %30 = load <2 x float>, ptr %10, align 4
  %31 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %7, <2 x float> %30)
  %32 = call noundef float @_ZN5QBody10GetInertiaEv(ptr noundef nonnull align 8 dereferenceable(293) %12)
  %33 = fdiv float %31, %32
  %34 = getelementptr inbounds %class.QBody, ptr %12, i32 0, i32 6
  %35 = load float, ptr %34, align 8, !tbaa !30
  %36 = fadd float %35, %33
  store float %36, ptr %34, align 8, !tbaa !30
  br label %37

37:                                               ; preds = %28, %20
  %38 = load i8, ptr %9, align 1, !tbaa !9, !range !28, !noundef !29
  %39 = trunc i8 %38 to i1
  %40 = zext i1 %39 to i32
  %41 = icmp eq i32 %40, 1
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  call void @_ZN5QBody20UpdateMeshTransformsEv(ptr noundef nonnull align 8 dereferenceable(293) %12)
  br label %43

43:                                               ; preds = %42, %37
  store ptr %12, ptr %5, align 8
  br label %44

44:                                               ; preds = %43, %19
  %45 = load ptr, ptr %5, align 8
  ret ptr %45
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293)) #1 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)) #1 align 2

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

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

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

declare void @_ZN5QBody20UpdateMeshTransformsEv(ptr noundef nonnull align 8 dereferenceable(293)) #5

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 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 = { 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 #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 = { mustprogress 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" }

!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 = !{!"bool", !7, i64 0}
!11 = !{!12, !10, i64 293}
!12 = !{!"_ZTS10QRigidBody", !13, i64 0, !10, i64 293, !15, i64 296, !14, i64 304}
!13 = !{!"_ZTS5QBody", !14, i64 8, !14, i64 12, !6, i64 16, !15, i64 24, !15, i64 32, !14, i64 40, !14, i64 44, !16, i64 48, !17, i64 76, !10, i64 80, !10, i64 81, !10, i64 82, !14, i64 84, !18, i64 88, !10, i64 92, !14, i64 96, !10, i64 100, !10, i64 101, !15, i64 104, !14, i64 112, !14, i64 116, !14, i64 120, !14, i64 124, !14, i64 128, !19, i64 132, !19, i64 136, !10, i64 140, !10, i64 141, !10, i64 142, !19, i64 144, !19, i64 148, !19, i64 152, !10, i64 156, !20, i64 160, !20, i64 192, !22, i64 224, !10, i64 256, !23, i64 264, !27, i64 288, !10, i64 292}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_ZTS7QVector", !14, i64 0, !14, i64 4}
!16 = !{!"_ZTS5QAABB", !15, i64 0, !15, i64 8, !15, i64 16, !14, i64 24}
!17 = !{!"_ZTSN5QBody5ModesE", !7, i64 0}
!18 = !{!"_ZTSN5QBody9BodyTypesE", !7, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"_ZTSSt8functionIFvP5QBodyEE", !21, i64 0, !6, i64 24}
!21 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!22 = !{!"_ZTSSt8functionIFbP5QBodyNS0_13CollisionInfoEEE", !21, i64 0, !6, i64 24}
!23 = !{!"_ZTSSt6vectorIP5QMeshSaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseIP5QMeshSaIS1_EE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!27 = !{!"_ZTSN5QBody16SimulationModelsE", !7, i64 0}
!28 = !{i8 0, i8 2}
!29 = !{}
!30 = !{!13, !14, i64 40}


; 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
define dso_local noundef nonnull ptr @_ZN10QRigidBody10ApplyForceE7QVectorS0_b(ptr noundef nonnull returned align 8 dereferenceable(308) %0, <2 x float> %1, <2 x float> %2, i1 noundef zeroext %3) unnamed_addr #0 align 2 {
  %5 = alloca %struct.QVector, align 8
  %6 = alloca %struct.QVector, align 8
  store <2 x float> %1, ptr %5, align 8
  store <2 x float> %2, ptr %6, align 8
  %7 = tail call noundef i32 @_ZN5QBody7GetModeEv(ptr noundef nonnull align 8 dereferenceable(293) %0)
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %27, label %9

9:                                                ; preds = %4
  %10 = tail call noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293) %0)
  br i1 %10, label %11, label %27

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN7QVectorpLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %12, ptr noundef nonnull align 4 dereferenceable(8) %5)
  %14 = getelementptr inbounds i8, ptr %0, i64 293
  %15 = load i8, ptr %14, align 1, !tbaa !5, !range !26, !noundef !27
  %16 = icmp eq i8 %15, 0
  br i1 %16, label %17, label %25

17:                                               ; preds = %11
  %18 = call <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %19 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %6, <2 x float> %18)
  %20 = call noundef float @_ZN5QBody10GetInertiaEv(ptr noundef nonnull align 8 dereferenceable(293) %0)
  %21 = fdiv float %19, %20
  %22 = getelementptr inbounds i8, ptr %0, i64 40
  %23 = load float, ptr %22, align 8, !tbaa !28
  %24 = fadd float %23, %21
  store float %24, ptr %22, align 8, !tbaa !28
  br label %25

25:                                               ; preds = %17, %11
  br i1 %3, label %26, label %27

26:                                               ; preds = %25
  call void @_ZN5QBody20UpdateMeshTransformsEv(ptr noundef nonnull align 8 dereferenceable(293) %0)
  br label %27

27:                                               ; preds = %25, %26, %4, %9
  ret ptr %0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293)) local_unnamed_addr #1 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 #1 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 #2 align 2

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

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

declare void @_ZN5QBody20UpdateMeshTransformsEv(ptr noundef nonnull align 8 dereferenceable(293)) local_unnamed_addr #5

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 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 = { 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 #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 = { mustprogress 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" }

!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, !15, i64 293}
!6 = !{!"_ZTS10QRigidBody", !7, i64 0, !15, i64 293, !12, i64 296, !8, i64 304}
!7 = !{!"_ZTS5QBody", !8, i64 8, !8, i64 12, !11, i64 16, !12, i64 24, !12, i64 32, !8, i64 40, !8, i64 44, !13, i64 48, !14, i64 76, !15, i64 80, !15, i64 81, !15, i64 82, !8, i64 84, !16, i64 88, !15, i64 92, !8, i64 96, !15, i64 100, !15, i64 101, !12, i64 104, !8, i64 112, !8, i64 116, !8, i64 120, !8, i64 124, !8, i64 128, !17, i64 132, !17, i64 136, !15, i64 140, !15, i64 141, !15, i64 142, !17, i64 144, !17, i64 148, !17, i64 152, !15, i64 156, !18, i64 160, !18, i64 192, !20, i64 224, !15, i64 256, !21, i64 264, !25, i64 288, !15, i64 292}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTS7QVector", !8, i64 0, !8, i64 4}
!13 = !{!"_ZTS5QAABB", !12, i64 0, !12, i64 8, !12, i64 16, !8, i64 24}
!14 = !{!"_ZTSN5QBody5ModesE", !9, i64 0}
!15 = !{!"bool", !9, i64 0}
!16 = !{!"_ZTSN5QBody9BodyTypesE", !9, i64 0}
!17 = !{!"int", !9, i64 0}
!18 = !{!"_ZTSSt8functionIFvP5QBodyEE", !19, i64 0, !11, i64 24}
!19 = !{!"_ZTSSt14_Function_base", !9, i64 0, !11, i64 16}
!20 = !{!"_ZTSSt8functionIFbP5QBodyNS0_13CollisionInfoEEE", !19, i64 0, !11, i64 24}
!21 = !{!"_ZTSSt6vectorIP5QMeshSaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseIP5QMeshSaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!25 = !{!"_ZTSN5QBody16SimulationModelsE", !9, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!7, !8, i64 40}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass