; 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
define dso_local void @_ZN3JPH20SwingTwistConstraint27WarmStartVelocityConstraintEf(ptr noundef nonnull align 16 dereferenceable(944) %0, float noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %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 float %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 19
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds [3 x %"class.JPH::AngleConstraintPart"], ptr %11, i64 0, i64 0
  store ptr %12, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds [3 x %"class.JPH::AngleConstraintPart"], ptr %13, i64 0, i64 0
  %15 = getelementptr inbounds %"class.JPH::AngleConstraintPart", ptr %14, i64 3
  store ptr %15, ptr %7, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %29, %2
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = icmp ne ptr %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  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 %32

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.JPH::TwoBodyConstraint", ptr %9, i32 0, i32 1
  %25 = load ptr, ptr %24, align 16, !tbaa !11
  %26 = getelementptr inbounds %"class.JPH::TwoBodyConstraint", ptr %9, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !20
  %28 = load float, ptr %4, align 4, !tbaa !9
  call void @_ZN3JPH19AngleConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(48) %23, ptr noundef nonnull align 16 dereferenceable(122) %25, ptr noundef nonnull align 16 dereferenceable(122) %27, float noundef %28)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %29

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

32:                                               ; preds = %20
  %33 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 18
  %34 = getelementptr inbounds %"class.JPH::TwoBodyConstraint", ptr %9, i32 0, i32 1
  %35 = load ptr, ptr %34, align 16, !tbaa !11
  %36 = getelementptr inbounds %"class.JPH::TwoBodyConstraint", ptr %9, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !20
  %38 = load float, ptr %4, align 4, !tbaa !9
  call void @_ZN3JPH24SwingTwistConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(272) %33, ptr noundef nonnull align 16 dereferenceable(122) %35, ptr noundef nonnull align 16 dereferenceable(122) %37, float noundef %38)
  %39 = getelementptr inbounds %"class.JPH::SwingTwistConstraint", ptr %9, i32 0, i32 17
  %40 = getelementptr inbounds %"class.JPH::TwoBodyConstraint", ptr %9, i32 0, i32 1
  %41 = load ptr, ptr %40, align 16, !tbaa !11
  %42 = getelementptr inbounds %"class.JPH::TwoBodyConstraint", ptr %9, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !20
  %44 = load float, ptr %4, align 4, !tbaa !9
  call void @_ZN3JPH19PointConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(240) %39, ptr noundef nonnull align 16 dereferenceable(122) %41, ptr noundef nonnull align 16 dereferenceable(122) %43, float noundef %44)
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH19AngleConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(48), ptr noundef nonnull align 16 dereferenceable(122), ptr noundef nonnull align 16 dereferenceable(122), float noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH24SwingTwistConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(272), ptr noundef nonnull align 16 dereferenceable(122), ptr noundef nonnull align 16 dereferenceable(122), float noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH19PointConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(240), ptr noundef nonnull align 16 dereferenceable(122), ptr noundef nonnull align 16 dereferenceable(122), float noundef) #2 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 = { 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTSN3JPH17TwoBodyConstraintE", !13, i64 0, !6, i64 32, !6, i64 40}
!13 = !{!"_ZTSN3JPH10ConstraintE", !14, i64 8, !17, i64 12, !17, i64 16, !7, i64 20, !7, i64 21, !18, i64 22, !19, i64 24}
!14 = !{!"_ZTSN3JPH9RefTargetINS_10ConstraintEEE", !15, i64 0}
!15 = !{!"_ZTSSt6atomicIjE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIjE", !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!12, !6, i64 40}


; 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
define dso_local void @_ZN3JPH20SwingTwistConstraint27WarmStartVelocityConstraintEf(ptr noundef nonnull align 16 dereferenceable(944) %0, float noundef %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %.0.ptr = getelementptr inbounds i8, ptr %0, i64 800
  %5 = load ptr, ptr %3, align 16, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !17
  tail call void @_ZN3JPH19AngleConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr, ptr noundef nonnull align 16 dereferenceable(122) %5, ptr noundef nonnull align 16 dereferenceable(122) %6, float noundef %1)
  %.0.ptr.1 = getelementptr inbounds i8, ptr %0, i64 848
  %7 = load ptr, ptr %3, align 16, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !17
  tail call void @_ZN3JPH19AngleConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr.1, ptr noundef nonnull align 16 dereferenceable(122) %7, ptr noundef nonnull align 16 dereferenceable(122) %8, float noundef %1)
  %.0.ptr.2 = getelementptr inbounds i8, ptr %0, i64 896
  %9 = load ptr, ptr %3, align 16, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !17
  tail call void @_ZN3JPH19AngleConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(48) %.0.ptr.2, ptr noundef nonnull align 16 dereferenceable(122) %9, ptr noundef nonnull align 16 dereferenceable(122) %10, float noundef %1)
  %11 = getelementptr inbounds i8, ptr %0, i64 528
  %12 = load ptr, ptr %3, align 16, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !17
  tail call void @_ZN3JPH24SwingTwistConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(272) %11, ptr noundef nonnull align 16 dereferenceable(122) %12, ptr noundef nonnull align 16 dereferenceable(122) %13, float noundef %1)
  %14 = getelementptr inbounds i8, ptr %0, i64 288
  %15 = load ptr, ptr %3, align 16, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !17
  tail call void @_ZN3JPH19PointConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(240) %14, ptr noundef nonnull align 16 dereferenceable(122) %15, ptr noundef nonnull align 16 dereferenceable(122) %16, float noundef %1)
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH19AngleConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(48), ptr noundef nonnull align 16 dereferenceable(122), ptr noundef nonnull align 16 dereferenceable(122), float noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH24SwingTwistConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(272), ptr noundef nonnull align 16 dereferenceable(122), ptr noundef nonnull align 16 dereferenceable(122), float noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH19PointConstraintPart9WarmStartERNS_4BodyES2_f(ptr noundef nonnull align 16 dereferenceable(240), ptr noundef nonnull align 16 dereferenceable(122), ptr noundef nonnull align 16 dereferenceable(122), float noundef) local_unnamed_addr #1 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 = { 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)"}
!5 = !{!6, !16, i64 32}
!6 = !{!"_ZTSN3JPH17TwoBodyConstraintE", !7, i64 0, !16, i64 32, !16, i64 40}
!7 = !{!"_ZTSN3JPH10ConstraintE", !8, i64 8, !11, i64 12, !11, i64 16, !12, i64 20, !12, i64 21, !14, i64 22, !15, i64 24}
!8 = !{!"_ZTSN3JPH9RefTargetINS_10ConstraintEEE", !9, i64 0}
!9 = !{!"_ZTSSt6atomicIjE", !10, i64 0}
!10 = !{!"_ZTSSt13__atomic_baseIjE", !11, i64 0}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"bool", !12, i64 0}
!15 = !{!"long", !12, i64 0}
!16 = !{!"any pointer", !12, i64 0}
!17 = !{!6, !16, i64 40}


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