; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Body (BodyInterface)

; 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.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::BodyLockWrite" = type { %"class.JPH::BodyLockBase" }
%"class.JPH::BodyLockBase" = type { ptr, ptr, ptr }
%"class.JPH::BodyInterface" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

; 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 uwtable
declare dso_local void @_ZN3JPH13BodyLockWriteCI2NS_12BodyLockBaseILb1ENS_4BodyEEEERKNS_17BodyLockInterfaceERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH12BodyLockBaseILb1ENS_4BodyEE9SucceededEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 16 dereferenceable(122) ptr @_ZNK3JPH12BodyLockBaseILb1ENS_4BodyEE7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(24)) #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) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body8IsStaticEv(ptr noundef nonnull align 16 dereferenceable(122)) #2 align 2

declare void @_ZN3JPH11BodyManager14ActivateBodiesEPKNS_6BodyIDEi(ptr noundef nonnull align 8 dereferenceable(297), ptr noundef, i32 noundef) #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body8IsActiveEv(ptr noundef nonnull align 16 dereferenceable(122)) #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Vec310IsNearZeroEf(ptr noundef nonnull align 16 dereferenceable(16), float noundef) #6 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH4Body24SetLinearVelocityClampedENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122), double, double) #7 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH13BodyInterface17SetLinearVelocityERKNS_6BodyIDENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, double %2, double %3) #7 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.JPH::Vec3", align 16
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.JPH::BodyLockWrite", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %"class.JPH::Vec3", align 16
  %13 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  store double %2, ptr %13, align 16
  %14 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  store double %3, ptr %14, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #8
  %16 = getelementptr inbounds %"class.JPH::BodyInterface", ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN3JPH13BodyLockWriteCI2NS_12BodyLockBaseILb1ENS_4BodyEEEERKNS_17BodyLockInterfaceERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %19 = invoke noundef zeroext i1 @_ZNK3JPH12BodyLockBaseILb1ENS_4BodyEE9SucceededEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
          to label %20 unwind label %45

20:                                               ; preds = %4
  br i1 %19, label %21, label %55

21:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  %22 = invoke noundef nonnull align 16 dereferenceable(122) ptr @_ZNK3JPH12BodyLockBaseILb1ENS_4BodyEE7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
          to label %23 unwind label %49

23:                                               ; preds = %21
  store ptr %22, ptr %11, align 8, !tbaa !5
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = invoke noundef zeroext i1 @_ZNK3JPH4Body8IsStaticEv(ptr noundef nonnull align 16 dereferenceable(122) %24)
          to label %26 unwind label %49

26:                                               ; preds = %23
  br i1 %25, label %54, label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %12, ptr align 16 %5, i64 16, i1 false), !tbaa.struct !11
  %29 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  %30 = load double, ptr %29, align 16
  %31 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  %32 = load double, ptr %31, align 8
  invoke void @_ZN3JPH4Body24SetLinearVelocityClampedENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %28, double %30, double %32)
          to label %33 unwind label %49

33:                                               ; preds = %27
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = invoke noundef zeroext i1 @_ZNK3JPH4Body8IsActiveEv(ptr noundef nonnull align 16 dereferenceable(122) %34)
          to label %36 unwind label %49

36:                                               ; preds = %33
  br i1 %35, label %53, label %37

37:                                               ; preds = %36
  %38 = invoke noundef zeroext i1 @_ZNK3JPH4Vec310IsNearZeroEf(ptr noundef nonnull align 16 dereferenceable(16) %5, float noundef 0x3D71979980000000)
          to label %39 unwind label %49

39:                                               ; preds = %37
  br i1 %38, label %53, label %40

40:                                               ; preds = %39
  %41 = getelementptr inbounds %"class.JPH::BodyInterface", ptr %15, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN3JPH11BodyManager14ActivateBodiesEPKNS_6BodyIDEi(ptr noundef nonnull align 8 dereferenceable(297) %42, ptr noundef %43, i32 noundef 1)
          to label %44 unwind label %49

44:                                               ; preds = %40
  br label %53

45:                                               ; preds = %4
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %9, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %10, align 4
  br label %56

49:                                               ; preds = %40, %37, %33, %27, %23, %21
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %9, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  br label %56

53:                                               ; preds = %44, %39, %36
  br label %54

54:                                               ; preds = %53, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  br label %55

55:                                               ; preds = %54, %20
  call void @_ZN3JPH12BodyLockBaseILb1ENS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #8
  ret void

56:                                               ; preds = %49, %45
  call void @_ZN3JPH12BodyLockBaseILb1ENS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #8
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %9, align 8
  %59 = load i32, ptr %10, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = { alwaysinline 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 #7 = { 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 #8 = { 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, !6, i64 0}
!10 = !{!"_ZTSN3JPH13BodyInterfaceE", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{i64 0, i64 16, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !6, i64 8}


; 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"

%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::BodyLockWrite" = type { %"class.JPH::BodyLockBase" }
%"class.JPH::BodyLockBase" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH13BodyLockWriteCI2NS_12BodyLockBaseILb1ENS_4BodyEEEERKNS_17BodyLockInterfaceERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH12BodyLockBaseILb1ENS_4BodyEE9SucceededEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body8IsStaticEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #2 align 2

declare void @_ZN3JPH11BodyManager14ActivateBodiesEPKNS_6BodyIDEi(ptr noundef nonnull align 8 dereferenceable(297), ptr noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body8IsActiveEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Vec310IsNearZeroEf(ptr noundef nonnull align 16 dereferenceable(16), float noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH4Body24SetLinearVelocityClampedENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122), double, double) local_unnamed_addr #6 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH13BodyInterface17SetLinearVelocityERKNS_6BodyIDENS_4Vec3E(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, double %2, double %3) local_unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.JPH::Vec3", align 16
  %6 = alloca %"class.JPH::BodyLockWrite", align 8
  store double %2, ptr %5, align 16
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  store double %3, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #7
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  call void @_ZN3JPH13BodyLockWriteCI2NS_12BodyLockBaseILb1ENS_4BodyEEEERKNS_17BodyLockInterfaceERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %9 = call noundef zeroext i1 @_ZNK3JPH12BodyLockBaseILb1ENS_4BodyEE9SucceededEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  br i1 %9, label %10, label %24

10:                                               ; preds = %4
  %11 = invoke noundef nonnull align 16 dereferenceable(122) ptr @_ZNK3JPH12BodyLockBaseILb1ENS_4BodyEE7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
          to label %12 unwind label %22

12:                                               ; preds = %10
  %13 = call noundef zeroext i1 @_ZNK3JPH4Body8IsStaticEv(ptr noundef nonnull align 16 dereferenceable(122) %11)
  br i1 %13, label %24, label %14

14:                                               ; preds = %12
  invoke void @_ZN3JPH4Body24SetLinearVelocityClampedENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %11, double %2, double %3)
          to label %15 unwind label %22

15:                                               ; preds = %14
  %16 = call noundef zeroext i1 @_ZNK3JPH4Body8IsActiveEv(ptr noundef nonnull align 16 dereferenceable(122) %11)
  br i1 %16, label %24, label %17

17:                                               ; preds = %15
  %18 = call noundef zeroext i1 @_ZNK3JPH4Vec310IsNearZeroEf(ptr noundef nonnull align 16 dereferenceable(16) %5, float noundef 0x3D71979980000000)
  br i1 %18, label %24, label %19

19:                                               ; preds = %17
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !10
  invoke void @_ZN3JPH11BodyManager14ActivateBodiesEPKNS_6BodyIDEi(ptr noundef nonnull align 8 dereferenceable(297) %21, ptr noundef nonnull %1, i32 noundef 1)
          to label %24 unwind label %22

22:                                               ; preds = %19, %14, %10
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3JPH12BodyLockBaseILb1ENS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #7
  resume { ptr, i32 } %23

24:                                               ; preds = %12, %19, %17, %15, %4
  call void @_ZN3JPH12BodyLockBaseILb1ENS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #7
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 = { alwaysinline 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 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTSN3JPH13BodyInterfaceE", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}


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