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

; 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::SixDOFConstraint" = type { %"class.JPH::TwoBodyConstraint", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Quat", %"class.JPH::Quat", i8, i8, i8, i8, i8, i8, [6 x float], [6 x float], [3 x %"class.JPH::SpringSettings"], [6 x %"class.JPH::MotorSettings"], [6 x float], [6 x i32], %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Quat", [3 x %"class.JPH::Vec3"], [3 x %"class.JPH::Vec3"], [3 x float], [3 x %"class.JPH::AxisConstraintPart"], %"class.JPH::PointConstraintPart", %"class.JPH::SwingTwistConstraintPart", %"class.JPH::RotationEulerConstraintPart", [3 x %"class.JPH::AxisConstraintPart"], [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::SpringSettings" = type { i8, %union.anon.2, float }
%union.anon.2 = type { float }
%"class.JPH::MotorSettings" = type { %"class.JPH::SpringSettings", float, float, float, 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 }
%"class.JPH::RotationEulerConstraintPart" = type { %"class.JPH::Mat44", %"class.JPH::Mat44", %"class.JPH::Mat44", %"class.JPH::Vec3" }
%"class.JPH::AxisConstraintPart" = type { %"class.JPH::Float3", %"class.JPH::Float3", %"class.JPH::Float3", %"class.JPH::Float3", float, %"class.JPH::SpringPart", float }
%"class.JPH::Float3" = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3JPH16SixDOFConstraint20CacheHasSpringLimitsEv(ptr noundef nonnull align 16 dereferenceable(1856) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.JPH::SixDOFConstraint", ptr %3, i32 0, i32 13
  %5 = getelementptr inbounds [3 x %"class.JPH::SpringSettings"], ptr %4, i64 0, i64 0
  %6 = getelementptr inbounds %"class.JPH::SpringSettings", ptr %5, i32 0, i32 1
  %7 = load float, ptr %6, align 4, !tbaa !9
  %8 = fcmp ogt float %7, 0.000000e+00
  br i1 %8, label %21, label %9

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.JPH::SixDOFConstraint", ptr %3, i32 0, i32 13
  %11 = getelementptr inbounds [3 x %"class.JPH::SpringSettings"], ptr %10, i64 0, i64 1
  %12 = getelementptr inbounds %"class.JPH::SpringSettings", ptr %11, i32 0, i32 1
  %13 = load float, ptr %12, align 4, !tbaa !9
  %14 = fcmp ogt float %13, 0.000000e+00
  br i1 %14, label %21, label %15

15:                                               ; preds = %9
  %16 = getelementptr inbounds %"class.JPH::SixDOFConstraint", ptr %3, i32 0, i32 13
  %17 = getelementptr inbounds [3 x %"class.JPH::SpringSettings"], ptr %16, i64 0, i64 2
  %18 = getelementptr inbounds %"class.JPH::SpringSettings", ptr %17, i32 0, i32 1
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = fcmp ogt float %19, 0.000000e+00
  br label %21

21:                                               ; preds = %15, %9, %1
  %22 = phi i1 [ true, %9 ], [ true, %1 ], [ %20, %15 ]
  %23 = getelementptr inbounds %"class.JPH::SixDOFConstraint", ptr %3, i32 0, i32 10
  %24 = zext i1 %22 to i8
  store i8 %24, ptr %23, align 1, !tbaa !10
  ret void
}

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

!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 = !{!7, !7, i64 0}
!10 = !{!11, !18, i64 117}
!11 = !{!"_ZTSN3JPH16SixDOFConstraintE", !12, i64 0, !20, i64 48, !20, i64 64, !21, i64 80, !21, i64 96, !7, i64 112, !7, i64 113, !18, i64 114, !18, i64 115, !7, i64 116, !18, i64 117, !7, i64 120, !7, i64 144, !7, i64 168, !7, i64 204, !7, i64 372, !7, i64 396, !20, i64 432, !20, i64 448, !20, i64 464, !21, i64 480, !7, i64 496, !7, i64 544, !7, i64 592, !7, i64 604, !23, i64 800, !25, i64 1040, !30, i64 1312, !7, i64 1520, !7, i64 1712}
!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 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!21 = !{!"_ZTSN3JPH4QuatE", !22, i64 0}
!22 = !{!"_ZTSN3JPH4Vec4E", !7, i64 0}
!23 = !{!"_ZTSN3JPH19PointConstraintPartE", !20, i64 0, !20, i64 16, !24, i64 32, !24, i64 96, !24, i64 160, !20, i64 224}
!24 = !{!"_ZTSN3JPH5Mat44E", !7, i64 0}
!25 = !{!"_ZTSN3JPH24SwingTwistConstraintPartE", !7, i64 0, !26, i64 1, !27, i64 4, !27, i64 8, !27, i64 12, !27, i64 16, !27, i64 20, !27, i64 24, !27, i64 28, !27, i64 32, !27, i64 36, !27, i64 40, !27, i64 44, !27, i64 48, !27, i64 52, !27, i64 56, !27, i64 60, !27, i64 64, !20, i64 80, !20, i64 96, !20, i64 112, !28, i64 128, !28, i64 176, !28, i64 224}
!26 = !{!"_ZTSN3JPH10ESwingTypeE", !7, i64 0}
!27 = !{!"float", !7, i64 0}
!28 = !{!"_ZTSN3JPH19AngleConstraintPartE", !20, i64 0, !20, i64 16, !27, i64 32, !29, i64 36, !27, i64 44}
!29 = !{!"_ZTSN3JPH10SpringPartE", !27, i64 0, !27, i64 4}
!30 = !{!"_ZTSN3JPH27RotationEulerConstraintPartE", !24, i64 0, !24, i64 64, !24, i64 128, !20, i64 192}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN3JPH16SixDOFConstraint20CacheHasSpringLimitsEv(ptr nocapture noundef nonnull align 16 dereferenceable(1856) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 172
  %3 = load float, ptr %2, align 4, !tbaa !5
  %4 = fcmp ogt float %3, 0.000000e+00
  %5 = getelementptr inbounds i8, ptr %0, i64 184
  %6 = load float, ptr %5, align 8
  %7 = fcmp ogt float %6, 0.000000e+00
  %or.cond = select i1 %4, i1 true, i1 %7
  %8 = getelementptr inbounds i8, ptr %0, i64 196
  %9 = load float, ptr %8, align 4
  %10 = fcmp ogt float %9, 0.000000e+00
  %narrow = select i1 %or.cond, i1 true, i1 %10
  %11 = zext i1 %narrow to i8
  %12 = getelementptr inbounds i8, ptr %0, i64 117
  store i8 %11, ptr %12, align 1, !tbaa !8
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !16, i64 117}
!9 = !{!"_ZTSN3JPH16SixDOFConstraintE", !10, i64 0, !19, i64 48, !19, i64 64, !20, i64 80, !20, i64 96, !6, i64 112, !6, i64 113, !16, i64 114, !16, i64 115, !6, i64 116, !16, i64 117, !6, i64 120, !6, i64 144, !6, i64 168, !6, i64 204, !6, i64 372, !6, i64 396, !19, i64 432, !19, i64 448, !19, i64 464, !20, i64 480, !6, i64 496, !6, i64 544, !6, i64 592, !6, i64 604, !22, i64 800, !24, i64 1040, !29, i64 1312, !6, i64 1520, !6, i64 1712}
!10 = !{!"_ZTSN3JPH17TwoBodyConstraintE", !11, i64 0, !18, i64 32, !18, i64 40}
!11 = !{!"_ZTSN3JPH10ConstraintE", !12, i64 8, !15, i64 12, !15, i64 16, !6, i64 20, !6, i64 21, !16, i64 22, !17, i64 24}
!12 = !{!"_ZTSN3JPH9RefTargetINS_10ConstraintEEE", !13, i64 0}
!13 = !{!"_ZTSSt6atomicIjE", !14, i64 0}
!14 = !{!"_ZTSSt13__atomic_baseIjE", !15, i64 0}
!15 = !{!"int", !6, i64 0}
!16 = !{!"bool", !6, i64 0}
!17 = !{!"long", !6, i64 0}
!18 = !{!"any pointer", !6, i64 0}
!19 = !{!"_ZTSN3JPH4Vec3E", !6, i64 0}
!20 = !{!"_ZTSN3JPH4QuatE", !21, i64 0}
!21 = !{!"_ZTSN3JPH4Vec4E", !6, i64 0}
!22 = !{!"_ZTSN3JPH19PointConstraintPartE", !19, i64 0, !19, i64 16, !23, i64 32, !23, i64 96, !23, i64 160, !19, i64 224}
!23 = !{!"_ZTSN3JPH5Mat44E", !6, i64 0}
!24 = !{!"_ZTSN3JPH24SwingTwistConstraintPartE", !6, i64 0, !25, i64 1, !26, i64 4, !26, i64 8, !26, i64 12, !26, i64 16, !26, i64 20, !26, i64 24, !26, i64 28, !26, i64 32, !26, i64 36, !26, i64 40, !26, i64 44, !26, i64 48, !26, i64 52, !26, i64 56, !26, i64 60, !26, i64 64, !19, i64 80, !19, i64 96, !19, i64 112, !27, i64 128, !27, i64 176, !27, i64 224}
!25 = !{!"_ZTSN3JPH10ESwingTypeE", !6, i64 0}
!26 = !{!"float", !6, i64 0}
!27 = !{!"_ZTSN3JPH19AngleConstraintPartE", !19, i64 0, !19, i64 16, !26, i64 32, !28, i64 36, !26, i64 44}
!28 = !{!"_ZTSN3JPH10SpringPartE", !26, i64 0, !26, i64 4}
!29 = !{!"_ZTSN3JPH27RotationEulerConstraintPartE", !23, i64 0, !23, i64 64, !23, i64 128, !19, i64 192}


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