; 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 uwtable
define dso_local void @_ZN3JPH16SixDOFConstraint24CacheRotationMotorActiveEv(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 16
  %5 = getelementptr inbounds [6 x i32], ptr %4, i64 0, i64 3
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %24, label %8

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.JPH::SixDOFConstraint", ptr %3, i32 0, i32 16
  %10 = getelementptr inbounds [6 x i32], ptr %9, i64 0, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %24, label %13

13:                                               ; preds = %8
  %14 = getelementptr inbounds %"class.JPH::SixDOFConstraint", ptr %3, i32 0, i32 16
  %15 = getelementptr inbounds [6 x i32], ptr %14, i64 0, i64 5
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %24, label %18

18:                                               ; preds = %13
  %19 = call noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856) %3, i32 noundef 3)
  br i1 %19, label %24, label %20

20:                                               ; preds = %18
  %21 = call noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856) %3, i32 noundef 4)
  br i1 %21, label %24, label %22

22:                                               ; preds = %20
  %23 = call noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856) %3, i32 noundef 5)
  br label %24

24:                                               ; preds = %22, %20, %18, %13, %8, %1
  %25 = phi i1 [ true, %20 ], [ true, %18 ], [ true, %13 ], [ true, %8 ], [ true, %1 ], [ %23, %22 ]
  %26 = getelementptr inbounds %"class.JPH::SixDOFConstraint", ptr %3, i32 0, i32 8
  %27 = zext i1 %25 to i8
  store i8 %27, ptr %26, align 1, !tbaa !11
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856), i32 noundef) #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, !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 = !{!"_ZTSN3JPH11EMotorStateE", !7, i64 0}
!11 = !{!12, !19, i64 115}
!12 = !{!"_ZTSN3JPH16SixDOFConstraintE", !13, i64 0, !21, i64 48, !21, i64 64, !22, i64 80, !22, i64 96, !7, i64 112, !7, i64 113, !19, i64 114, !19, i64 115, !7, i64 116, !19, i64 117, !7, i64 120, !7, i64 144, !7, i64 168, !7, i64 204, !7, i64 372, !7, i64 396, !21, i64 432, !21, i64 448, !21, i64 464, !22, i64 480, !7, i64 496, !7, i64 544, !7, i64 592, !7, i64 604, !24, i64 800, !26, i64 1040, !31, i64 1312, !7, i64 1520, !7, i64 1712}
!13 = !{!"_ZTSN3JPH17TwoBodyConstraintE", !14, i64 0, !6, i64 32, !6, i64 40}
!14 = !{!"_ZTSN3JPH10ConstraintE", !15, i64 8, !18, i64 12, !18, i64 16, !7, i64 20, !7, i64 21, !19, i64 22, !20, i64 24}
!15 = !{!"_ZTSN3JPH9RefTargetINS_10ConstraintEEE", !16, i64 0}
!16 = !{!"_ZTSSt6atomicIjE", !17, i64 0}
!17 = !{!"_ZTSSt13__atomic_baseIjE", !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!22 = !{!"_ZTSN3JPH4QuatE", !23, i64 0}
!23 = !{!"_ZTSN3JPH4Vec4E", !7, i64 0}
!24 = !{!"_ZTSN3JPH19PointConstraintPartE", !21, i64 0, !21, i64 16, !25, i64 32, !25, i64 96, !25, i64 160, !21, i64 224}
!25 = !{!"_ZTSN3JPH5Mat44E", !7, i64 0}
!26 = !{!"_ZTSN3JPH24SwingTwistConstraintPartE", !7, i64 0, !27, i64 1, !28, i64 4, !28, i64 8, !28, i64 12, !28, i64 16, !28, i64 20, !28, i64 24, !28, i64 28, !28, i64 32, !28, i64 36, !28, i64 40, !28, i64 44, !28, i64 48, !28, i64 52, !28, i64 56, !28, i64 60, !28, i64 64, !21, i64 80, !21, i64 96, !21, i64 112, !29, i64 128, !29, i64 176, !29, i64 224}
!27 = !{!"_ZTSN3JPH10ESwingTypeE", !7, i64 0}
!28 = !{!"float", !7, i64 0}
!29 = !{!"_ZTSN3JPH19AngleConstraintPartE", !21, i64 0, !21, i64 16, !28, i64 32, !30, i64 36, !28, i64 44}
!30 = !{!"_ZTSN3JPH10SpringPartE", !28, i64 0, !28, i64 4}
!31 = !{!"_ZTSN3JPH27RotationEulerConstraintPartE", !25, i64 0, !25, i64 64, !25, i64 128, !21, 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 uwtable
define dso_local void @_ZN3JPH16SixDOFConstraint24CacheRotationMotorActiveEv(ptr noundef nonnull align 16 dereferenceable(1856) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 408
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  %4 = getelementptr inbounds i8, ptr %0, i64 412
  %5 = load i32, ptr %4, align 4
  %.not1 = icmp eq i32 %5, 0
  %or.cond = select i1 %.not, i1 %.not1, i1 false
  %6 = getelementptr inbounds i8, ptr %0, i64 416
  %7 = load i32, ptr %6, align 16
  %.not2 = icmp eq i32 %7, 0
  %or.cond5 = select i1 %or.cond, i1 %.not2, i1 false
  br i1 %or.cond5, label %8, label %15

8:                                                ; preds = %1
  %9 = tail call noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856) %0, i32 noundef 3)
  br i1 %9, label %15, label %10

10:                                               ; preds = %8
  %11 = tail call noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856) %0, i32 noundef 4)
  br i1 %11, label %15, label %12

12:                                               ; preds = %10
  %13 = tail call noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856) %0, i32 noundef 5)
  %14 = zext i1 %13 to i8
  br label %15

15:                                               ; preds = %12, %10, %8, %1
  %16 = phi i8 [ 1, %10 ], [ 1, %8 ], [ 1, %1 ], [ %14, %12 ]
  %17 = getelementptr inbounds i8, ptr %0, i64 115
  store i8 %16, ptr %17, align 1, !tbaa !9
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH16SixDOFConstraint11HasFrictionENS_24SixDOFConstraintSettings5EAxisE(ptr noundef nonnull align 16 dereferenceable(1856), i32 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, !6, i64 0}
!6 = !{!"_ZTSN3JPH11EMotorStateE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !17, i64 115}
!10 = !{!"_ZTSN3JPH16SixDOFConstraintE", !11, i64 0, !20, i64 48, !20, i64 64, !21, i64 80, !21, i64 96, !7, i64 112, !7, i64 113, !17, i64 114, !17, i64 115, !7, i64 116, !17, 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}
!11 = !{!"_ZTSN3JPH17TwoBodyConstraintE", !12, i64 0, !19, i64 32, !19, i64 40}
!12 = !{!"_ZTSN3JPH10ConstraintE", !13, i64 8, !16, i64 12, !16, i64 16, !7, i64 20, !7, i64 21, !17, i64 22, !18, i64 24}
!13 = !{!"_ZTSN3JPH9RefTargetINS_10ConstraintEEE", !14, i64 0}
!14 = !{!"_ZTSSt6atomicIjE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIjE", !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"any pointer", !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}


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