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

; 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::BodyID" = type { i32 }
%"class.JPH::Ragdoll" = type { %"class.JPH::RefTarget.76", %"class.JPH::RefConst.77", %"class.JPH::Array.78", %"class.JPH::Array.81", ptr }
%"class.JPH::RefTarget.76" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::RefConst.77" = type { ptr }
%"class.JPH::Array.78" = type { i64, i64, ptr }
%"class.JPH::Array.81" = type { i64, i64, ptr }

; 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: 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 uwtable
declare hidden noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPHL17sGetBodyInterfaceEPNS_13PhysicsSystemEb(ptr noundef, i1 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH7Ragdoll27SetLinearAndAngularVelocityENS_4Vec3ES1_b(ptr noundef nonnull align 8 dereferenceable(72) %0, double %1, double %2, double %3, double %4, i1 noundef zeroext %5) #3 align 2 {
  %7 = alloca %"class.JPH::Vec3", align 16
  %8 = alloca %"class.JPH::Vec3", align 16
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca %"class.JPH::BodyID", align 4
  %16 = alloca %"class.JPH::Vec3", align 16
  %17 = alloca %"class.JPH::Vec3", align 16
  %18 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  store double %1, ptr %18, align 16
  %19 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  store double %2, ptr %19, align 8
  %20 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  store double %3, ptr %20, align 16
  %21 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  store double %4, ptr %21, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  %22 = zext i1 %5 to i8
  store i8 %22, ptr %10, align 1, !tbaa !9
  %23 = load ptr, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %24 = getelementptr inbounds %"class.JPH::Ragdoll", ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = load i8, ptr %10, align 1, !tbaa !9, !range !21, !noundef !22
  %27 = trunc i8 %26 to i1
  %28 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPHL17sGetBodyInterfaceEPNS_13PhysicsSystemEb(ptr noundef %25, i1 noundef zeroext %27)
  store ptr %28, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %29 = getelementptr inbounds %"class.JPH::Ragdoll", ptr %23, i32 0, i32 2
  store ptr %29, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = call noundef ptr @_ZN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %30)
  store ptr %31, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = call noundef ptr @_ZN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %32)
  store ptr %33, ptr %14, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %50, %6
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = load ptr, ptr %14, align 8, !tbaa !5
  %37 = icmp ne ptr %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %53

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %40, i64 4, i1 false), !tbaa.struct !23
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %16, ptr align 16 %7, i64 16, i1 false), !tbaa.struct !25
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %17, ptr align 16 %8, i64 16, i1 false), !tbaa.struct !25
  %42 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 0
  %43 = load double, ptr %42, align 16
  %44 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 1
  %45 = load double, ptr %44, align 8
  %46 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  %47 = load double, ptr %46, align 16
  %48 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  %49 = load double, ptr %48, align 8
  call void @_ZN3JPH13BodyInterface27SetLinearAndAngularVelocityERKNS_6BodyIDENS_4Vec3ES4_(ptr noundef nonnull align 8 dereferenceable(24) %41, ptr noundef nonnull align 4 dereferenceable(4) %15, double %43, double %45, double %47, double %49)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %50

50:                                               ; preds = %39
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.JPH::BodyID", ptr %51, i32 1
  store ptr %52, ptr %13, align 8, !tbaa !5
  br label %34

53:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  ret void
}

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

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

declare void @_ZN3JPH13BodyInterface27SetLinearAndAngularVelocityERKNS_6BodyIDENS_4Vec3ES4_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), double, double, double, double) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 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 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)"}
!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, !6, i64 64}
!12 = !{!"_ZTSN3JPH7RagdollE", !13, i64 0, !17, i64 8, !18, i64 16, !20, i64 40, !6, i64 64}
!13 = !{!"_ZTSN3JPH9RefTargetINS_7RagdollEEE", !14, i64 0}
!14 = !{!"_ZTSSt6atomicIjE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIjE", !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTSN3JPH8RefConstINS_15RagdollSettingsEEE", !6, i64 0}
!18 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !19, i64 0, !19, i64 8, !6, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTSN3JPH5ArrayINS_3RefINS_17TwoBodyConstraintEEENS_12STLAllocatorIS3_EEEE", !19, i64 0, !19, i64 8, !6, i64 16}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{i64 0, i64 4, !24}
!24 = !{!16, !16, i64 0}
!25 = !{i64 0, i64 16, !26}
!26 = !{!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::BodyID" = type { i32 }

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

; 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 hidden noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPHL17sGetBodyInterfaceEPNS_13PhysicsSystemEb(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH7Ragdoll27SetLinearAndAngularVelocityENS_4Vec3ES1_b(ptr noundef nonnull align 8 dereferenceable(72) %0, double %1, double %2, double %3, double %4, i1 noundef zeroext %5) local_unnamed_addr #2 align 2 {
  %7 = alloca %"class.JPH::BodyID", align 4
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPHL17sGetBodyInterfaceEPNS_13PhysicsSystemEb(ptr noundef %9, i1 noundef zeroext %5)
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = tail call noundef ptr @_ZN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %13 = tail call noundef ptr @_ZN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %.not14 = icmp eq ptr %12, %13
  br i1 %.not14, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %6
  ret void

.lr.ph:                                           ; preds = %6, %.lr.ph
  %.015 = phi ptr [ %15, %.lr.ph ], [ %12, %6 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %14 = load i32, ptr %.015, align 4, !tbaa !18
  store i32 %14, ptr %7, align 4, !tbaa !18
  call void @_ZN3JPH13BodyInterface27SetLinearAndAngularVelocityERKNS_6BodyIDENS_4Vec3ES4_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 4 dereferenceable(4) %7, double %1, double %2, double %3, double %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  %15 = getelementptr inbounds i8, ptr %.015, i64 4
  %.not = icmp eq ptr %15, %13
  br i1 %.not, label %._crit_edge, label %.lr.ph
}

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

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

declare void @_ZN3JPH13BodyInterface27SetLinearAndAngularVelocityERKNS_6BodyIDENS_4Vec3ES4_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), double, double, double, double) local_unnamed_addr #4

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 = { 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 = { 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 #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 = { 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, !14, i64 64}
!6 = !{!"_ZTSN3JPH7RagdollE", !7, i64 0, !13, i64 8, !15, i64 16, !17, i64 40, !14, i64 64}
!7 = !{!"_ZTSN3JPH9RefTargetINS_7RagdollEEE", !8, i64 0}
!8 = !{!"_ZTSSt6atomicIjE", !9, i64 0}
!9 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTSN3JPH8RefConstINS_15RagdollSettingsEEE", !14, i64 0}
!14 = !{!"any pointer", !11, i64 0}
!15 = !{!"_ZTSN3JPH5ArrayINS_6BodyIDENS_12STLAllocatorIS1_EEEE", !16, i64 0, !16, i64 8, !14, i64 16}
!16 = !{!"long", !11, i64 0}
!17 = !{!"_ZTSN3JPH5ArrayINS_3RefINS_17TwoBodyConstraintEEENS_12STLAllocatorIS3_EEEE", !16, i64 0, !16, i64 8, !14, i64 16}
!18 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass