; LLVM IR from zig-gamedev/zphysics :: libs/Jolt/Physics/Constraints/HingeConstraint.ll (ZN3JPH15HingeConstraint9SetLimitsEff)

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

%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::HingeConstraint" = type { %"class.JPH::TwoBodyConstraint", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Quat", i8, float, float, %"class.JPH::SpringSettings", float, %"class.JPH::MotorSettings", i32, float, float, float, %"class.JPH::Vec3", %"class.JPH::PointConstraintPart", %"class.JPH::HingeRotationConstraintPart", %"class.JPH::AngleConstraintPart", %"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::Quat" = type { %"class.JPH::Vec4" }
%"class.JPH::Vec4" = type { %union.anon.4 }
%union.anon.4 = type { <4 x float> }
%"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::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::HingeRotationConstraintPart" = type <{ %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Mat44", %"class.JPH::Mat44", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Matrix", %"class.JPH::Vector", [8 x i8] }>
%"class.JPH::Matrix" = type { [2 x %"class.JPH::Vector"] }
%"class.JPH::Vector" = type { [2 x float] }
%"class.JPH::AngleConstraintPart" = type { %"class.JPH::Vec3", %"class.JPH::Vec3", float, %"class.JPH::SpringPart", float }
%"class.JPH::SpringPart" = type { float, float }

@.str.2 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH15HingeConstraint9SetLimitsEff(ptr noundef nonnull align 16 dereferenceable(832) %0, float noundef %1, float noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca %"struct.JPH::AssertLastParam", align 1
  %8 = alloca %"struct.JPH::AssertLastParam", align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  br label %10

10:                                               ; preds = %3
  %11 = load float, ptr %5, align 4, !tbaa !9
  %12 = fcmp ole float %11, 0.000000e+00
  br i1 %12, label %13, label %16

13:                                               ; preds = %10
  %14 = load float, ptr %5, align 4, !tbaa !9
  %15 = fcmp oge float %14, 0xC00921FB60000000
  br i1 %15, label %19, label %16

16:                                               ; preds = %13, %10
  %17 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 139)
  br i1 %17, label %18, label %19

18:                                               ; preds = %16
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #2, !srcloc !11
  br label %19

19:                                               ; preds = %18, %16, %13
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  %22 = load float, ptr %6, align 4, !tbaa !9
  %23 = fcmp oge float %22, 0.000000e+00
  br i1 %23, label %24, label %27

24:                                               ; preds = %21
  %25 = load float, ptr %6, align 4, !tbaa !9
  %26 = fcmp ole float %25, 0x400921FB60000000
  br i1 %26, label %30, label %27

27:                                               ; preds = %24, %21
  %28 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.5, ptr noundef @.str.2, i32 noundef 140)
  br i1 %28, label %29, label %30

29:                                               ; preds = %27
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #2, !srcloc !12
  br label %30

30:                                               ; preds = %29, %27, %24
  br label %31

31:                                               ; preds = %30
  %32 = load float, ptr %5, align 4, !tbaa !9
  %33 = getelementptr inbounds %"class.JPH::HingeConstraint", ptr %9, i32 0, i32 9
  store float %32, ptr %33, align 4, !tbaa !13
  %34 = load float, ptr %6, align 4, !tbaa !9
  %35 = getelementptr inbounds %"class.JPH::HingeConstraint", ptr %9, i32 0, i32 10
  store float %34, ptr %35, align 8, !tbaa !37
  %36 = getelementptr inbounds %"class.JPH::HingeConstraint", ptr %9, i32 0, i32 9
  %37 = load float, ptr %36, align 4, !tbaa !13
  %38 = fcmp ogt float %37, 0xC00921FB60000000
  br i1 %38, label %39, label %43

39:                                               ; preds = %31
  %40 = getelementptr inbounds %"class.JPH::HingeConstraint", ptr %9, i32 0, i32 10
  %41 = load float, ptr %40, align 8, !tbaa !37
  %42 = fcmp olt float %41, 0x400921FB60000000
  br label %43

43:                                               ; preds = %39, %31
  %44 = phi i1 [ false, %31 ], [ %42, %39 ]
  %45 = getelementptr inbounds %"class.JPH::HingeConstraint", ptr %9, i32 0, i32 8
  %46 = zext i1 %44 to i8
  store i8 %46, ptr %45, align 16, !tbaa !38
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

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" }
attributes #2 = { 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 = !{i64 2158154938}
!12 = !{i64 2158155338}
!13 = !{!14, !10, i64 164}
!14 = !{!"_ZTSN3JPH15HingeConstraintE", !15, i64 0, !23, i64 48, !23, i64 64, !23, i64 80, !23, i64 96, !23, i64 112, !23, i64 128, !24, i64 144, !21, i64 160, !10, i64 164, !10, i64 168, !26, i64 172, !10, i64 184, !28, i64 188, !29, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !23, i64 240, !30, i64 256, !32, i64 496, !35, i64 736, !35, i64 784}
!15 = !{!"_ZTSN3JPH17TwoBodyConstraintE", !16, i64 0, !6, i64 32, !6, i64 40}
!16 = !{!"_ZTSN3JPH10ConstraintE", !17, i64 8, !20, i64 12, !20, i64 16, !7, i64 20, !7, i64 21, !21, i64 22, !22, i64 24}
!17 = !{!"_ZTSN3JPH9RefTargetINS_10ConstraintEEE", !18, i64 0}
!18 = !{!"_ZTSSt6atomicIjE", !19, i64 0}
!19 = !{!"_ZTSSt13__atomic_baseIjE", !20, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!24 = !{!"_ZTSN3JPH4QuatE", !25, i64 0}
!25 = !{!"_ZTSN3JPH4Vec4E", !7, i64 0}
!26 = !{!"_ZTSN3JPH14SpringSettingsE", !27, i64 0, !7, i64 4, !10, i64 8}
!27 = !{!"_ZTSN3JPH11ESpringModeE", !7, i64 0}
!28 = !{!"_ZTSN3JPH13MotorSettingsE", !26, i64 0, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!29 = !{!"_ZTSN3JPH11EMotorStateE", !7, i64 0}
!30 = !{!"_ZTSN3JPH19PointConstraintPartE", !23, i64 0, !23, i64 16, !31, i64 32, !31, i64 96, !31, i64 160, !23, i64 224}
!31 = !{!"_ZTSN3JPH5Mat44E", !7, i64 0}
!32 = !{!"_ZTSN3JPH27HingeRotationConstraintPartE", !23, i64 0, !23, i64 16, !23, i64 32, !31, i64 48, !31, i64 112, !23, i64 176, !23, i64 192, !33, i64 208, !34, i64 224}
!33 = !{!"_ZTSN3JPH6MatrixILj2ELj2EEE", !7, i64 0}
!34 = !{!"_ZTSN3JPH6VectorILj2EEE", !7, i64 0}
!35 = !{!"_ZTSN3JPH19AngleConstraintPartE", !23, i64 0, !23, i64 16, !10, i64 32, !36, i64 36, !10, i64 44}
!36 = !{!"_ZTSN3JPH10SpringPartE", !10, i64 0, !10, i64 4}
!37 = !{!14, !10, i64 168}
!38 = !{!14, !21, i64 160}


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

@.str.2 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH15HingeConstraint9SetLimitsEff(ptr nocapture noundef nonnull writeonly align 16 dereferenceable(832) %0, float noundef %1, float noundef %2) local_unnamed_addr #0 align 2 {
  %4 = fcmp ole float %1, 0.000000e+00
  %5 = fcmp oge float %1, 0xC00921FB60000000
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %9, label %6

6:                                                ; preds = %3
  %7 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.2, i32 noundef 139)
  br i1 %7, label %8, label %9

8:                                                ; preds = %6
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #2, !srcloc !5
  br label %9

9:                                                ; preds = %3, %8, %6
  %10 = fcmp oge float %2, 0.000000e+00
  %11 = fcmp ole float %2, 0x400921FB60000000
  %or.cond3 = and i1 %10, %11
  br i1 %or.cond3, label %15, label %12

12:                                               ; preds = %9
  %13 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 140)
  br i1 %13, label %14, label %15

14:                                               ; preds = %12
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #2, !srcloc !6
  br label %15

15:                                               ; preds = %12, %14, %9
  %16 = getelementptr inbounds i8, ptr %0, i64 164
  store float %1, ptr %16, align 4, !tbaa !7
  %17 = getelementptr inbounds i8, ptr %0, i64 168
  store float %2, ptr %17, align 8, !tbaa !35
  %18 = fcmp ogt float %1, 0xC00921FB60000000
  %19 = fcmp olt float %2, 0x400921FB60000000
  %narrow = and i1 %18, %19
  %20 = zext i1 %narrow to i8
  %21 = getelementptr inbounds i8, ptr %0, i64 160
  store i8 %20, ptr %21, align 16, !tbaa !36
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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" }
attributes #2 = { 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 = !{i64 2158154938}
!6 = !{i64 2158155338}
!7 = !{!8, !23, i64 164}
!8 = !{!"_ZTSN3JPH15HingeConstraintE", !9, i64 0, !20, i64 48, !20, i64 64, !20, i64 80, !20, i64 96, !20, i64 112, !20, i64 128, !21, i64 144, !17, i64 160, !23, i64 164, !23, i64 168, !24, i64 172, !23, i64 184, !26, i64 188, !27, i64 216, !23, i64 220, !23, i64 224, !23, i64 228, !20, i64 240, !28, i64 256, !30, i64 496, !33, i64 736, !33, i64 784}
!9 = !{!"_ZTSN3JPH17TwoBodyConstraintE", !10, i64 0, !19, i64 32, !19, i64 40}
!10 = !{!"_ZTSN3JPH10ConstraintE", !11, i64 8, !14, i64 12, !14, i64 16, !15, i64 20, !15, i64 21, !17, i64 22, !18, i64 24}
!11 = !{!"_ZTSN3JPH9RefTargetINS_10ConstraintEEE", !12, i64 0}
!12 = !{!"_ZTSSt6atomicIjE", !13, i64 0}
!13 = !{!"_ZTSSt13__atomic_baseIjE", !14, i64 0}
!14 = !{!"int", !15, i64 0}
!15 = !{!"omnipotent char", !16, i64 0}
!16 = !{!"Simple C++ TBAA"}
!17 = !{!"bool", !15, i64 0}
!18 = !{!"long", !15, i64 0}
!19 = !{!"any pointer", !15, i64 0}
!20 = !{!"_ZTSN3JPH4Vec3E", !15, i64 0}
!21 = !{!"_ZTSN3JPH4QuatE", !22, i64 0}
!22 = !{!"_ZTSN3JPH4Vec4E", !15, i64 0}
!23 = !{!"float", !15, i64 0}
!24 = !{!"_ZTSN3JPH14SpringSettingsE", !25, i64 0, !15, i64 4, !23, i64 8}
!25 = !{!"_ZTSN3JPH11ESpringModeE", !15, i64 0}
!26 = !{!"_ZTSN3JPH13MotorSettingsE", !24, i64 0, !23, i64 12, !23, i64 16, !23, i64 20, !23, i64 24}
!27 = !{!"_ZTSN3JPH11EMotorStateE", !15, i64 0}
!28 = !{!"_ZTSN3JPH19PointConstraintPartE", !20, i64 0, !20, i64 16, !29, i64 32, !29, i64 96, !29, i64 160, !20, i64 224}
!29 = !{!"_ZTSN3JPH5Mat44E", !15, i64 0}
!30 = !{!"_ZTSN3JPH27HingeRotationConstraintPartE", !20, i64 0, !20, i64 16, !20, i64 32, !29, i64 48, !29, i64 112, !20, i64 176, !20, i64 192, !31, i64 208, !32, i64 224}
!31 = !{!"_ZTSN3JPH6MatrixILj2ELj2EEE", !15, i64 0}
!32 = !{!"_ZTSN3JPH6VectorILj2EEE", !15, i64 0}
!33 = !{!"_ZTSN3JPH19AngleConstraintPartE", !20, i64 0, !20, i64 16, !23, i64 32, !34, i64 36, !23, i64 44}
!34 = !{!"_ZTSN3JPH10SpringPartE", !23, i64 0, !23, i64 4}
!35 = !{!8, !23, i64 168}
!36 = !{!8, !17, i64 160}


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