; LLVM IR from ClementineAccount/Albuquerque :: lib/bullet/include/Bullet3Dynamics/ConstraintSolver (b3Generic6DofConstraint)

; 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.b3Transform = type { %class.b3Matrix3x3, %class.b3Vector3 }
%class.b3Matrix3x3 = type { [3 x %class.b3Vector3] }
%class.b3Vector3 = type { %union.anon.0 }
%union.anon.0 = type { [4 x float] }
%class.b3TypedConstraint = type { ptr, %struct.b3TypedObject, i32, %union.anon, float, i8, i8, i32, i32, i32, float, float, ptr }
%struct.b3TypedObject = type { i32 }
%union.anon = type { ptr }
%struct.b3RigidBodyData = type { %class.b3Vector3, %class.b3Quaternion, %class.b3Vector3, %class.b3Vector3, i32, float, float, float }
%class.b3Quaternion = type { %class.b3QuadWord }
%class.b3QuadWord = type { %union.anon.1 }
%union.anon.1 = type { [4 x float] }
%"struct.b3TypedConstraint::b3ConstraintInfo1" = type { i32, i32 }
%class.b3Generic6DofConstraint = type { %class.b3TypedConstraint, %class.b3Transform, %class.b3Transform, %class.b3TranslationalLimitMotor, [3 x %class.b3RotationalLimitMotor], %class.b3Transform, %class.b3Transform, %class.b3Vector3, [3 x %class.b3Vector3], %class.b3Vector3, float, float, float, i8, %class.b3Vector3, i8, i8, i32, [8 x i8] }
%class.b3TranslationalLimitMotor = type { %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, %class.b3Vector3, float, float, float, [3 x i8], [3 x i32], [4 x i8] }
%class.b3RotationalLimitMotor = type { float, float, float, float, float, float, float, float, float, float, float, i8, float, float, i32, 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 hidden void @_ZL24getCenterOfMassTransformRK15b3RigidBodyData(ptr dead_on_unwind noalias writable sret(%class.b3Transform) align 16, ptr noundef nonnull align 16 dereferenceable(80)) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN23b3Generic6DofConstraint21testAngularLimitMotorEi(ptr noundef nonnull align 16 dereferenceable(824), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN23b3Generic6DofConstraint8getInfo1EPN17b3TypedConstraint17b3ConstraintInfo1EPK15b3RigidBodyData(ptr noundef nonnull align 16 dereferenceable(824) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %class.b3Transform, align 16
  %8 = alloca %class.b3Transform, align 16
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #3
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.b3TypedConstraint, ptr %10, i32 0, i32 8
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds %struct.b3RigidBodyData, ptr %11, i64 %14
  call void @_ZL24getCenterOfMassTransformRK15b3RigidBodyData(ptr dead_on_unwind writable sret(%class.b3Transform) align 16 %7, ptr noundef nonnull align 16 dereferenceable(80) %15)
  call void @llvm.lifetime.start.p0(i64 64, ptr %8) #3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.b3TypedConstraint, ptr %10, i32 0, i32 9
  %18 = load i32, ptr %17, align 8, !tbaa !15
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds %struct.b3RigidBodyData, ptr %16, i64 %19
  call void @_ZL24getCenterOfMassTransformRK15b3RigidBodyData(ptr dead_on_unwind writable sret(%class.b3Transform) align 16 %8, ptr noundef nonnull align 16 dereferenceable(80) %20)
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN23b3Generic6DofConstraint19calculateTransformsERK11b3TransformS2_PK15b3RigidBodyData(ptr noundef nonnull align 16 dereferenceable(824) %10, ptr noundef nonnull align 16 dereferenceable(64) %7, ptr noundef nonnull align 16 dereferenceable(64) %8, ptr noundef %21)
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.b3TypedConstraint::b3ConstraintInfo1", ptr %22, i32 0, i32 0
  store i32 0, ptr %23, align 4, !tbaa !16
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.b3TypedConstraint::b3ConstraintInfo1", ptr %24, i32 0, i32 1
  store i32 6, ptr %25, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !19
  br label %26

26:                                               ; preds = %43, %3
  %27 = load i32, ptr %9, align 4, !tbaa !19
  %28 = icmp slt i32 %27, 3
  br i1 %28, label %29, label %46

29:                                               ; preds = %26
  %30 = getelementptr inbounds %class.b3Generic6DofConstraint, ptr %10, i32 0, i32 3
  %31 = load i32, ptr %9, align 4, !tbaa !19
  %32 = call noundef zeroext i1 @_ZN25b3TranslationalLimitMotor14needApplyForceEi(ptr noundef nonnull align 16 dereferenceable(188) %30, i32 noundef %31)
  br i1 %32, label %33, label %42

33:                                               ; preds = %29
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.b3TypedConstraint::b3ConstraintInfo1", ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !16
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 4, !tbaa !16
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.b3TypedConstraint::b3ConstraintInfo1", ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !18
  %41 = add nsw i32 %40, -1
  store i32 %41, ptr %39, align 4, !tbaa !18
  br label %42

42:                                               ; preds = %33, %29
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %9, align 4, !tbaa !19
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %9, align 4, !tbaa !19
  br label %26, !llvm.loop !20

46:                                               ; preds = %26
  store i32 0, ptr %9, align 4, !tbaa !19
  br label %47

47:                                               ; preds = %63, %46
  %48 = load i32, ptr %9, align 4, !tbaa !19
  %49 = icmp slt i32 %48, 3
  br i1 %49, label %50, label %66

50:                                               ; preds = %47
  %51 = load i32, ptr %9, align 4, !tbaa !19
  %52 = call noundef zeroext i1 @_ZN23b3Generic6DofConstraint21testAngularLimitMotorEi(ptr noundef nonnull align 16 dereferenceable(824) %10, i32 noundef %51)
  br i1 %52, label %53, label %62

53:                                               ; preds = %50
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.b3TypedConstraint::b3ConstraintInfo1", ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 4, !tbaa !16
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %55, align 4, !tbaa !16
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.b3TypedConstraint::b3ConstraintInfo1", ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !18
  %61 = add nsw i32 %60, -1
  store i32 %61, ptr %59, align 4, !tbaa !18
  br label %62

62:                                               ; preds = %53, %50
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %9, align 4, !tbaa !19
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %9, align 4, !tbaa !19
  br label %47, !llvm.loop !22

66:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN25b3TranslationalLimitMotor14needApplyForceEi(ptr noundef nonnull align 16 dereferenceable(188), i32 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 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 = { 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, !12, i64 36}
!10 = !{!"_ZTS17b3TypedConstraint", !11, i64 8, !12, i64 12, !7, i64 16, !13, i64 24, !14, i64 28, !14, i64 29, !12, i64 32, !12, i64 36, !12, i64 40, !13, i64 44, !13, i64 48, !6, i64 56}
!11 = !{!"_ZTS13b3TypedObject", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!10, !12, i64 40}
!16 = !{!17, !12, i64 0}
!17 = !{!"_ZTSN17b3TypedConstraint17b3ConstraintInfo1E", !12, i64 0, !12, i64 4}
!18 = !{!17, !12, i64 4}
!19 = !{!12, !12, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

%class.b3Transform = type { %class.b3Matrix3x3, %class.b3Vector3 }
%class.b3Matrix3x3 = type { [3 x %class.b3Vector3] }
%class.b3Vector3 = type { %union.anon.0 }
%union.anon.0 = type { [4 x float] }
%struct.b3RigidBodyData = type { %class.b3Vector3, %class.b3Quaternion, %class.b3Vector3, %class.b3Vector3, i32, float, float, float }
%class.b3Quaternion = type { %class.b3QuadWord }
%class.b3QuadWord = type { %union.anon.1 }
%union.anon.1 = type { [4 x float] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL24getCenterOfMassTransformRK15b3RigidBodyData(ptr dead_on_unwind noalias writable sret(%class.b3Transform) align 16, ptr noundef nonnull align 16 dereferenceable(80)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN23b3Generic6DofConstraint19calculateTransformsERK11b3TransformS2_PK15b3RigidBodyData(ptr noundef nonnull align 16 dereferenceable(824), ptr noundef nonnull align 16 dereferenceable(64), ptr noundef nonnull align 16 dereferenceable(64), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN23b3Generic6DofConstraint21testAngularLimitMotorEi(ptr noundef nonnull align 16 dereferenceable(824), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN23b3Generic6DofConstraint8getInfo1EPN17b3TypedConstraint17b3ConstraintInfo1EPK15b3RigidBodyData(ptr noundef nonnull align 16 dereferenceable(824) %0, ptr nocapture noundef %1, ptr noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca %class.b3Transform, align 16
  %5 = alloca %class.b3Transform, align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 36
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds %struct.b3RigidBodyData, ptr %2, i64 %8
  call void @_ZL24getCenterOfMassTransformRK15b3RigidBodyData(ptr dead_on_unwind nonnull writable sret(%class.b3Transform) align 16 %4, ptr noundef nonnull align 16 dereferenceable(80) %9)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #3
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds %struct.b3RigidBodyData, ptr %2, i64 %12
  call void @_ZL24getCenterOfMassTransformRK15b3RigidBodyData(ptr dead_on_unwind nonnull writable sret(%class.b3Transform) align 16 %5, ptr noundef nonnull align 16 dereferenceable(80) %13)
  call void @_ZN23b3Generic6DofConstraint19calculateTransformsERK11b3TransformS2_PK15b3RigidBodyData(ptr noundef nonnull align 16 dereferenceable(824) %0, ptr noundef nonnull align 16 dereferenceable(64) %4, ptr noundef nonnull align 16 dereferenceable(64) %5, ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #3
  store i32 0, ptr %1, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 6, ptr %14, align 4, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %0, i64 192
  %16 = call noundef zeroext i1 @_ZN25b3TranslationalLimitMotor14needApplyForceEi(ptr noundef nonnull align 16 dereferenceable(188) %15, i32 noundef 0)
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  %18 = load <2 x i32>, ptr %1, align 4, !tbaa !18
  %19 = add nsw <2 x i32> %18, <i32 1, i32 -1>
  store <2 x i32> %19, ptr %1, align 4, !tbaa !18
  br label %20

20:                                               ; preds = %3, %17
  %21 = call noundef zeroext i1 @_ZN25b3TranslationalLimitMotor14needApplyForceEi(ptr noundef nonnull align 16 dereferenceable(188) %15, i32 noundef 1)
  br i1 %21, label %22, label %25

22:                                               ; preds = %20
  %23 = load <2 x i32>, ptr %1, align 4, !tbaa !18
  %24 = add nsw <2 x i32> %23, <i32 1, i32 -1>
  store <2 x i32> %24, ptr %1, align 4, !tbaa !18
  br label %25

25:                                               ; preds = %22, %20
  %26 = call noundef zeroext i1 @_ZN25b3TranslationalLimitMotor14needApplyForceEi(ptr noundef nonnull align 16 dereferenceable(188) %15, i32 noundef 2)
  br i1 %26, label %27, label %.preheader.preheader

27:                                               ; preds = %25
  %28 = load <2 x i32>, ptr %1, align 4, !tbaa !18
  %29 = add nsw <2 x i32> %28, <i32 1, i32 -1>
  store <2 x i32> %29, ptr %1, align 4, !tbaa !18
  br label %.preheader.preheader

.preheader.preheader:                             ; preds = %27, %25
  %30 = call noundef zeroext i1 @_ZN23b3Generic6DofConstraint21testAngularLimitMotorEi(ptr noundef nonnull align 16 dereferenceable(824) %0, i32 noundef 0)
  br i1 %30, label %31, label %.preheader.1

31:                                               ; preds = %.preheader.preheader
  %32 = load <2 x i32>, ptr %1, align 4, !tbaa !18
  %33 = add nsw <2 x i32> %32, <i32 1, i32 -1>
  store <2 x i32> %33, ptr %1, align 4, !tbaa !18
  br label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader, %31
  %34 = call noundef zeroext i1 @_ZN23b3Generic6DofConstraint21testAngularLimitMotorEi(ptr noundef nonnull align 16 dereferenceable(824) %0, i32 noundef 1)
  br i1 %34, label %35, label %.preheader.2

35:                                               ; preds = %.preheader.1
  %36 = load <2 x i32>, ptr %1, align 4, !tbaa !18
  %37 = add nsw <2 x i32> %36, <i32 1, i32 -1>
  store <2 x i32> %37, ptr %1, align 4, !tbaa !18
  br label %.preheader.2

.preheader.2:                                     ; preds = %35, %.preheader.1
  %38 = call noundef zeroext i1 @_ZN23b3Generic6DofConstraint21testAngularLimitMotorEi(ptr noundef nonnull align 16 dereferenceable(824) %0, i32 noundef 2)
  br i1 %38, label %39, label %42

39:                                               ; preds = %.preheader.2
  %40 = load <2 x i32>, ptr %1, align 4, !tbaa !18
  %41 = add nsw <2 x i32> %40, <i32 1, i32 -1>
  store <2 x i32> %41, ptr %1, align 4, !tbaa !18
  br label %42

42:                                               ; preds = %39, %.preheader.2
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN25b3TranslationalLimitMotor14needApplyForceEi(ptr noundef nonnull align 16 dereferenceable(188), i32 noundef) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 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 = { 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, !8, i64 36}
!6 = !{!"_ZTS17b3TypedConstraint", !7, i64 8, !8, i64 12, !9, i64 16, !11, i64 24, !12, i64 28, !12, i64 29, !8, i64 32, !8, i64 36, !8, i64 40, !11, i64 44, !11, i64 48, !13, i64 56}
!7 = !{!"_ZTS13b3TypedObject", !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!6, !8, i64 40}
!15 = !{!16, !8, i64 0}
!16 = !{!"_ZTSN17b3TypedConstraint17b3ConstraintInfo1E", !8, i64 0, !8, i64 4}
!17 = !{!16, !8, i64 4}
!18 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass