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

; 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::SwingTwistConstraint" = type { %"class.JPH::TwoBodyConstraint", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Quat", %"class.JPH::Quat", float, float, float, float, float, %"class.JPH::MotorSettings", %"class.JPH::MotorSettings", i32, i32, %"class.JPH::Vec3", %"class.JPH::Quat", [3 x %"class.JPH::Vec3"], %"class.JPH::PointConstraintPart", %"class.JPH::SwingTwistConstraintPart", [3 x %"class.JPH::AngleConstraintPart"] }
%"class.JPH::TwoBodyConstraint" = type { %"class.JPH::Constraint", ptr, ptr }
%"class.JPH::Constraint" = type { ptr, %"class.JPH::RefTarget.3", i32, i32, i8, i8, i8, i64 }
%"class.JPH::RefTarget.3" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::MotorSettings" = type { %"class.JPH::SpringSettings", float, float, float, float }
%"class.JPH::SpringSettings" = type { i8, %union.anon.2, float }
%union.anon.2 = type { float }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::Quat" = type { %"class.JPH::Vec4" }
%"class.JPH::Vec4" = type { %union.anon.4 }
%union.anon.4 = type { <4 x float> }
%"class.JPH::PointConstraintPart" = type { %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Mat44", %"class.JPH::Mat44", %"class.JPH::Mat44", %"class.JPH::Vec3" }
%"class.JPH::Mat44" = type { [4 x %"class.JPH::Vec4"] }
%"class.JPH::SwingTwistConstraintPart" = type { i8, i8, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::AngleConstraintPart", %"class.JPH::AngleConstraintPart", %"class.JPH::AngleConstraintPart" }
%"class.JPH::AngleConstraintPart" = type { %"class.JPH::Vec3", %"class.JPH::Vec3", float, %"class.JPH::SpringPart", float }
%"class.JPH::SpringPart" = type { float, float }

; 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 void @_ZN3JPH19AngleConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(48)) #1 align 2

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

14:                                               ; preds = %22, %1
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %25

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %20, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN3JPH19AngleConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(48) %21)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %22

22:                                               ; preds = %19
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.JPH::AngleConstraintPart", ptr %23, i32 1
  store ptr %24, ptr %4, align 8, !tbaa !5
  br label %14

25:                                               ; preds = %18
  %26 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %7, i32 0, i32 18
  call void @_ZN3JPH24SwingTwistConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(272) %26)
  %27 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %7, i32 0, i32 17
  call void @_ZN3JPH19PointConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(240) %27)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH24SwingTwistConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(272)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH19PointConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(240)) #4 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"}


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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH19AngleConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(48)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH20SwingTwistConstraint14ResetWarmStartEv(ptr noundef nonnull align 16 dereferenceable(944) %0) unnamed_addr #1 align 2 {
  %.0.ptr = getelementptr inbounds i8, ptr %0, i64 800
  tail call void @_ZN3JPH19AngleConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr)
  %.0.ptr.1 = getelementptr inbounds i8, ptr %0, i64 848
  tail call void @_ZN3JPH19AngleConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr.1)
  %.0.ptr.2 = getelementptr inbounds i8, ptr %0, i64 896
  tail call void @_ZN3JPH19AngleConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr.2)
  %2 = getelementptr inbounds i8, ptr %0, i64 528
  tail call void @_ZN3JPH24SwingTwistConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(272) %2)
  %3 = getelementptr inbounds i8, ptr %0, i64 288
  tail call void @_ZN3JPH19PointConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(240) %3)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH24SwingTwistConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(272)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH19PointConstraintPart10DeactivateEv(ptr noundef nonnull align 16 dereferenceable(240)) local_unnamed_addr #3 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)"}


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