; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/Constraints (PathConstraintTest)

; 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.PathConstraintTest = type { %class.Test, [2 x %"class.JPH::Ref"], [2 x %"class.JPH::Ref.4"] }
%class.Test = type { ptr, ptr, ptr, ptr, ptr, ptr, i8, %"class.std::unordered_map" }
%"class.std::unordered_map" = 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.JPH::Ref" = type { ptr }
%"class.JPH::Ref.4" = type { ptr }
%"class.JPH::MotorSettings" = type { %"class.JPH::SpringSettings", float, float, float, float }
%"class.JPH::SpringSettings" = type { i8, %union.anon.18, float }
%union.anon.18 = type { float }

@_ZN18PathConstraintTest21sMaxMotorAccelerationE = external dso_local global float, align 4
@_ZN18PathConstraintTest10sFrequencyE = external dso_local global float, align 4
@_ZN18PathConstraintTest8sDampingE = external dso_local global float, align 4
@_ZN18PathConstraintTest24sMaxFrictionAccelerationE = external dso_local global float, align 4

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH3RefINS_14PathConstraintEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18PathConstraintTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 16 dereferenceable(80) %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = getelementptr inbounds %class.PathConstraintTest, ptr %10, i32 0, i32 2
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds [2 x %"class.JPH::Ref.4"], ptr %12, i64 0, i64 0
  store ptr %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds [2 x %"class.JPH::Ref.4"], ptr %14, i64 0, i64 0
  %16 = getelementptr inbounds %"class.JPH::Ref.4", ptr %15, i64 2
  store ptr %16, ptr %7, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %49, %2
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = icmp ne ptr %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %52

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = call noundef ptr @_ZNK3JPH3RefINS_14PathConstraintEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %23)
  store ptr %24, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = call noundef nonnull align 4 dereferenceable(28) ptr @_ZN3JPH14PathConstraint24GetPositionMotorSettingsEv(ptr noundef nonnull align 16 dereferenceable(1104) %25)
  store ptr %26, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load float, ptr @_ZN18PathConstraintTest21sMaxMotorAccelerationE, align 4, !tbaa !9
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = call noundef ptr @_ZNK3JPH17TwoBodyConstraint8GetBody2Ev(ptr noundef nonnull align 8 dereferenceable(48) %29)
  %31 = call noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122) %30)
  %32 = call noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182) %31)
  %33 = fdiv float %28, %32
  call void @_ZN3JPH13MotorSettings13SetForceLimitEf(ptr noundef nonnull align 4 dereferenceable(28) %27, float noundef %33)
  %34 = load float, ptr @_ZN18PathConstraintTest10sFrequencyE, align 4, !tbaa !9
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.JPH::MotorSettings", ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %"class.JPH::SpringSettings", ptr %36, i32 0, i32 1
  store float %34, ptr %37, align 4, !tbaa !11
  %38 = load float, ptr @_ZN18PathConstraintTest8sDampingE, align 4, !tbaa !9
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.JPH::MotorSettings", ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %"class.JPH::SpringSettings", ptr %40, i32 0, i32 2
  store float %38, ptr %41, align 4, !tbaa !12
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load float, ptr @_ZN18PathConstraintTest24sMaxFrictionAccelerationE, align 4, !tbaa !9
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = call noundef ptr @_ZNK3JPH17TwoBodyConstraint8GetBody2Ev(ptr noundef nonnull align 8 dereferenceable(48) %44)
  %46 = call noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122) %45)
  %47 = call noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182) %46)
  %48 = fdiv float %43, %47
  call void @_ZN3JPH14PathConstraint19SetMaxFrictionForceEf(ptr noundef nonnull align 16 dereferenceable(1104) %42, float noundef %48)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %49

49:                                               ; preds = %22
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.JPH::Ref.4", ptr %50, i32 1
  store ptr %51, ptr %6, align 8, !tbaa !5
  br label %17

52:                                               ; preds = %21
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(28) ptr @_ZN3JPH14PathConstraint24GetPositionMotorSettingsEv(ptr noundef nonnull align 16 dereferenceable(1104)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH13MotorSettings13SetForceLimitEf(ptr noundef nonnull align 4 dereferenceable(28), float noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH14PathConstraint19SetMaxFrictionForceEf(ptr noundef nonnull align 16 dereferenceable(1104), float noundef) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { inlinehint 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 8}
!13 = !{!"_ZTSN3JPH13MotorSettingsE", !14, i64 0, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!14 = !{!"_ZTSN3JPH14SpringSettingsE", !15, i64 0, !7, i64 4, !10, i64 8}
!15 = !{!"_ZTSN3JPH11ESpringModeE", !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"

@_ZN18PathConstraintTest21sMaxMotorAccelerationE = external dso_local local_unnamed_addr global float, align 4
@_ZN18PathConstraintTest10sFrequencyE = external dso_local local_unnamed_addr global float, align 4
@_ZN18PathConstraintTest8sDampingE = external dso_local local_unnamed_addr global float, align 4
@_ZN18PathConstraintTest24sMaxFrictionAccelerationE = external dso_local local_unnamed_addr global float, align 4

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18PathConstraintTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr nocapture noundef nonnull readnone align 16 dereferenceable(80) %1) unnamed_addr #1 align 2 {
  %.0.ptr = getelementptr inbounds i8, ptr %0, i64 128
  %3 = tail call noundef ptr @_ZNK3JPH3RefINS_14PathConstraintEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %.0.ptr)
  %4 = tail call noundef nonnull align 4 dereferenceable(28) ptr @_ZN3JPH14PathConstraint24GetPositionMotorSettingsEv(ptr noundef nonnull align 16 dereferenceable(1104) %3)
  %5 = load float, ptr @_ZN18PathConstraintTest21sMaxMotorAccelerationE, align 4, !tbaa !5
  %6 = tail call noundef ptr @_ZNK3JPH17TwoBodyConstraint8GetBody2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %7 = tail call noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122) %6)
  %8 = tail call noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182) %7)
  %9 = fdiv float %5, %8
  tail call void @_ZN3JPH13MotorSettings13SetForceLimitEf(ptr noundef nonnull align 4 dereferenceable(28) %4, float noundef %9)
  %10 = load float, ptr @_ZN18PathConstraintTest10sFrequencyE, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %4, i64 4
  store float %10, ptr %11, align 4, !tbaa !9
  %12 = load float, ptr @_ZN18PathConstraintTest8sDampingE, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  store float %12, ptr %13, align 4, !tbaa !10
  %14 = load float, ptr @_ZN18PathConstraintTest24sMaxFrictionAccelerationE, align 4, !tbaa !5
  %15 = tail call noundef ptr @_ZNK3JPH17TwoBodyConstraint8GetBody2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %16 = tail call noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122) %15)
  %17 = tail call noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182) %16)
  %18 = fdiv float %14, %17
  tail call void @_ZN3JPH14PathConstraint19SetMaxFrictionForceEf(ptr noundef nonnull align 16 dereferenceable(1104) %3, float noundef %18)
  %.0.ptr.1 = getelementptr inbounds i8, ptr %0, i64 136
  %19 = tail call noundef ptr @_ZNK3JPH3RefINS_14PathConstraintEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %.0.ptr.1)
  %20 = tail call noundef nonnull align 4 dereferenceable(28) ptr @_ZN3JPH14PathConstraint24GetPositionMotorSettingsEv(ptr noundef nonnull align 16 dereferenceable(1104) %19)
  %21 = load float, ptr @_ZN18PathConstraintTest21sMaxMotorAccelerationE, align 4, !tbaa !5
  %22 = tail call noundef ptr @_ZNK3JPH17TwoBodyConstraint8GetBody2Ev(ptr noundef nonnull align 8 dereferenceable(48) %19)
  %23 = tail call noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122) %22)
  %24 = tail call noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182) %23)
  %25 = fdiv float %21, %24
  tail call void @_ZN3JPH13MotorSettings13SetForceLimitEf(ptr noundef nonnull align 4 dereferenceable(28) %20, float noundef %25)
  %26 = load float, ptr @_ZN18PathConstraintTest10sFrequencyE, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %20, i64 4
  store float %26, ptr %27, align 4, !tbaa !9
  %28 = load float, ptr @_ZN18PathConstraintTest8sDampingE, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %20, i64 8
  store float %28, ptr %29, align 4, !tbaa !10
  %30 = load float, ptr @_ZN18PathConstraintTest24sMaxFrictionAccelerationE, align 4, !tbaa !5
  %31 = tail call noundef ptr @_ZNK3JPH17TwoBodyConstraint8GetBody2Ev(ptr noundef nonnull align 8 dereferenceable(48) %19)
  %32 = tail call noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122) %31)
  %33 = tail call noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182) %32)
  %34 = fdiv float %30, %33
  tail call void @_ZN3JPH14PathConstraint19SetMaxFrictionForceEf(ptr noundef nonnull align 16 dereferenceable(1104) %19, float noundef %34)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(28) ptr @_ZN3JPH14PathConstraint24GetPositionMotorSettingsEv(ptr noundef nonnull align 16 dereferenceable(1104)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH13MotorSettings13SetForceLimitEf(ptr noundef nonnull align 4 dereferenceable(28), float noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH4Body19GetMotionPropertiesEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK3JPH16MotionProperties14GetInverseMassEv(ptr noundef nonnull align 16 dereferenceable(182)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH14PathConstraint19SetMaxFrictionForceEf(ptr noundef nonnull align 16 dereferenceable(1104), float noundef) local_unnamed_addr #2 align 2

attributes #0 = { 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 #1 = { 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 #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 = { inlinehint 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" }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 8}
!11 = !{!"_ZTSN3JPH13MotorSettingsE", !12, i64 0, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24}
!12 = !{!"_ZTSN3JPH14SpringSettingsE", !13, i64 0, !7, i64 4, !6, i64 8}
!13 = !{!"_ZTSN3JPH11ESpringModeE", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass