; 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: mustprogress uwtable
declare dso_local void @_ZN3JPH9StreamOut5WriteERKNS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 16 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH20SwingTwistConstraint9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(944) %0, ptr noundef nonnull align 8 dereferenceable(18) %1) unnamed_addr #1 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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK3JPH10Constraint9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull align 8 dereferenceable(18) %10)
  %11 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 17
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK3JPH19PointConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(240) %11, ptr noundef nonnull align 8 dereferenceable(18) %12)
  %13 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 18
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK3JPH24SwingTwistConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(272) %13, ptr noundef nonnull align 8 dereferenceable(18) %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %15 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 19
  store ptr %15, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds [3 x %"class.JPH::AngleConstraintPart"], ptr %16, i64 0, i64 0
  store ptr %17, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds [3 x %"class.JPH::AngleConstraintPart"], ptr %18, i64 0, i64 0
  %20 = getelementptr inbounds %"class.JPH::AngleConstraintPart", ptr %19, i64 3
  store ptr %20, ptr %7, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %30, %2
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp ne ptr %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK3JPH19AngleConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(48) %28, ptr noundef nonnull align 8 dereferenceable(18) %29)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %30

30:                                               ; preds = %26
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.JPH::AngleConstraintPart", ptr %31, i32 1
  store ptr %32, ptr %6, align 8, !tbaa !5
  br label %21

33:                                               ; preds = %25
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 12
  call void @_ZN3JPH9StreamOut5WriteINS_11EMotorStateETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef nonnull align 4 dereferenceable(4) %36)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 8
  %39 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 13
  call void @_ZN3JPH9StreamOut5WriteINS_11EMotorStateETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef nonnull align 4 dereferenceable(4) %39)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  %42 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 14
  call void @_ZN3JPH9StreamOut5WriteERKNS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef nonnull align 16 dereferenceable(16) %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i64 8
  %45 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 15
  call void @_ZN3JPH9StreamOut5WriteINS_4QuatETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef nonnull align 16 dereferenceable(16) %45)
  ret void
}

declare void @_ZNK3JPH10Constraint9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(18)) unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH19PointConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(240), ptr noundef nonnull align 8 dereferenceable(18)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH24SwingTwistConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(272), ptr noundef nonnull align 8 dereferenceable(18)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH19AngleConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(18)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH9StreamOut5WriteINS_11EMotorStateETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH9StreamOut5WriteINS_4QuatETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 16 dereferenceable(16)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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: mustprogress uwtable
declare dso_local void @_ZN3JPH9StreamOut5WriteERKNS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH20SwingTwistConstraint9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(944) %0, ptr noundef nonnull align 8 dereferenceable(18) %1) unnamed_addr #0 align 2 {
  tail call void @_ZNK3JPH10Constraint9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(18) %1)
  %3 = getelementptr inbounds i8, ptr %0, i64 288
  tail call void @_ZNK3JPH19PointConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(240) %3, ptr noundef nonnull align 8 dereferenceable(18) %1)
  %4 = getelementptr inbounds i8, ptr %0, i64 528
  tail call void @_ZNK3JPH24SwingTwistConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(272) %4, ptr noundef nonnull align 8 dereferenceable(18) %1)
  %.0.ptr = getelementptr inbounds i8, ptr %0, i64 800
  tail call void @_ZNK3JPH19AngleConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr, ptr noundef nonnull align 8 dereferenceable(18) %1)
  %.0.ptr.1 = getelementptr inbounds i8, ptr %0, i64 848
  tail call void @_ZNK3JPH19AngleConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr.1, ptr noundef nonnull align 8 dereferenceable(18) %1)
  %.0.ptr.2 = getelementptr inbounds i8, ptr %0, i64 896
  tail call void @_ZNK3JPH19AngleConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr.2, ptr noundef nonnull align 8 dereferenceable(18) %1)
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = getelementptr inbounds i8, ptr %0, i64 188
  tail call void @_ZN3JPH9StreamOut5WriteINS_11EMotorStateETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 192
  tail call void @_ZN3JPH9StreamOut5WriteINS_11EMotorStateETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %8 = getelementptr inbounds i8, ptr %0, i64 208
  tail call void @_ZN3JPH9StreamOut5WriteERKNS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 16 dereferenceable(16) %8)
  %9 = getelementptr inbounds i8, ptr %0, i64 224
  tail call void @_ZN3JPH9StreamOut5WriteINS_4QuatETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 16 dereferenceable(16) %9)
  ret void
}

declare void @_ZNK3JPH10Constraint9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(18)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH19PointConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(240), ptr noundef nonnull align 8 dereferenceable(18)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH24SwingTwistConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(272), ptr noundef nonnull align 8 dereferenceable(18)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3JPH19AngleConstraintPart9SaveStateERNS_13StateRecorderE(ptr noundef nonnull align 16 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(18)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH9StreamOut5WriteINS_11EMotorStateETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH9StreamOut5WriteINS_4QuatETnNSt9enable_ifIXsr3stdE23is_trivially_copyable_vIT_EEbE4typeELb1EEEvRKS4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #0 align 2

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