; 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::BodyLockRead" = type { %"class.JPH::BodyLockBase.11" }
%"class.JPH::BodyLockBase.11" = 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: 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body8IsStaticEv(ptr noundef nonnull align 16 dereferenceable(122)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH12BodyLockReadCI2NS_12BodyLockBaseILb0EKNS_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 #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH12BodyLockBaseILb0EKNS_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 @_ZNK3JPH12BodyLockBaseILb0EKNS_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 @_ZNK3JPH12BodyLockBaseILb0EKNS_4BodyEE7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH4Vec35sZeroEv() #5 align 2

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

22:                                               ; preds = %4
  br i1 %21, label %23, label %55

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %24 = invoke noundef nonnull align 16 dereferenceable(122) ptr @_ZNK3JPH12BodyLockBaseILb0EKNS_4BodyEE7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %25 unwind label %47

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

28:                                               ; preds = %25
  br i1 %27, label %51, label %29

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

36:                                               ; preds = %29
  %37 = getelementptr inbounds %"class.JPH::Vec3", ptr %5, i32 0, i32 0
  %38 = getelementptr inbounds %union.anon, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds { double, double }, ptr %38, i32 0, i32 0
  %40 = extractvalue { double, double } %35, 0
  store double %40, ptr %39, align 16
  %41 = getelementptr inbounds { double, double }, ptr %38, i32 0, i32 1
  %42 = extractvalue { double, double } %35, 1
  store double %42, ptr %41, align 8
  store i32 1, ptr %14, align 4
  br label %52

43:                                               ; preds = %55, %4
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %10, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %11, align 4
  br label %68

47:                                               ; preds = %29, %25, %23
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %10, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %68

51:                                               ; preds = %28
  store i32 0, ptr %14, align 4
  br label %52

52:                                               ; preds = %51, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %53 = load i32, ptr %14, align 4
  switch i32 %53, label %64 [
    i32 0, label %54
  ]

54:                                               ; preds = %52
  br label %55

55:                                               ; preds = %54, %22
  %56 = invoke { double, double } @_ZN3JPH4Vec35sZeroEv()
          to label %57 unwind label %43

57:                                               ; preds = %55
  %58 = getelementptr inbounds %"class.JPH::Vec3", ptr %5, i32 0, i32 0
  %59 = getelementptr inbounds %union.anon, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds { double, double }, ptr %59, i32 0, i32 0
  %61 = extractvalue { double, double } %56, 0
  store double %61, ptr %60, align 16
  %62 = getelementptr inbounds { double, double }, ptr %59, i32 0, i32 1
  %63 = extractvalue { double, double } %56, 1
  store double %63, ptr %62, align 8
  store i32 1, ptr %14, align 4
  br label %64

64:                                               ; preds = %57, %52
  call void @_ZN3JPH12BodyLockBaseILb0EKNS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #7
  %65 = getelementptr inbounds %"class.JPH::Vec3", ptr %5, i32 0, i32 0
  %66 = getelementptr inbounds %union.anon, ptr %65, i32 0, i32 0
  %67 = load { double, double }, ptr %66, align 16
  ret { double, double } %67

68:                                               ; preds = %47, %43
  call void @_ZN3JPH12BodyLockBaseILb0EKNS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #7
  br label %69

69:                                               ; preds = %68
  %70 = load ptr, ptr %10, align 8
  %71 = load i32, ptr %11, align 4
  %72 = insertvalue { ptr, i32 } poison, ptr %70, 0
  %73 = insertvalue { ptr, i32 } %72, i32 %71, 1
  resume { ptr, i32 } %73
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Body16GetPointVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122), double, double) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 uwtable "min-legal-vector-width"="128" "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, !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}


; 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::BodyLockRead" = type { %"class.JPH::BodyLockBase.11" }
%"class.JPH::BodyLockBase.11" = 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH4Body8IsStaticEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH12BodyLockReadCI2NS_12BodyLockBaseILb0EKNS_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 #2 align 2

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

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

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH4Vec35sZeroEv() local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZNK3JPH13BodyInterface16GetPointVelocityERKNS_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 #5 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.JPH::BodyLockRead", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  call void @_ZN3JPH12BodyLockReadCI2NS_12BodyLockBaseILb0EKNS_4BodyEEEERKNS_17BodyLockInterfaceERKNS_6BodyIDE(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %7 = call noundef zeroext i1 @_ZNK3JPH12BodyLockBaseILb0EKNS_4BodyEE9SucceededEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  br i1 %7, label %8, label %.thread

8:                                                ; preds = %4
  %9 = invoke noundef nonnull align 16 dereferenceable(122) ptr @_ZNK3JPH12BodyLockBaseILb0EKNS_4BodyEE7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %10 unwind label %16

10:                                               ; preds = %8
  %11 = call noundef zeroext i1 @_ZNK3JPH4Body8IsStaticEv(ptr noundef nonnull align 16 dereferenceable(122) %9)
  br i1 %11, label %.thread, label %12

12:                                               ; preds = %10
  %13 = invoke { double, double } @_ZNK3JPH4Body16GetPointVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %9, double %2, double %3)
          to label %19 unwind label %16

14:                                               ; preds = %.thread
  %15 = landingpad { ptr, i32 }
          cleanup
  br label %20

16:                                               ; preds = %12, %8
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %20

.thread:                                          ; preds = %10, %4
  %18 = invoke { double, double } @_ZN3JPH4Vec35sZeroEv()
          to label %19 unwind label %14

19:                                               ; preds = %.thread, %12
  %.pn14 = phi { double, double } [ %13, %12 ], [ %18, %.thread ]
  call void @_ZN3JPH12BodyLockBaseILb0EKNS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  ret { double, double } %.pn14

20:                                               ; preds = %16, %14
  %.pn = phi { ptr, i32 } [ %15, %14 ], [ %17, %16 ]
  call void @_ZN3JPH12BodyLockBaseILb0EKNS_4BodyEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  resume { ptr, i32 } %.pn
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Body16GetPointVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122), double, double) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { 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 #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 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 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 = { 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"}


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