; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/Constraints (SwingTwistConstraintFrictionTest)

; 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::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.Test::PreUpdateParams" = type { float, [12 x i8], %struct.CameraState }
%struct.CameraState = type <{ %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", float, [12 x i8] }>
%class.SwingTwistConstraintFrictionTest = type { %class.Test, float, ptr }
%class.Test = type { ptr, ptr, ptr, ptr, ptr, ptr, i8, %"class.std::unordered_map" }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }

; 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: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16), float noundef, float noundef, float noundef) unnamed_addr #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3JPH16DegreesToRadiansEf(float noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN32SwingTwistConstraintFrictionTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 16 dereferenceable(80) %1) unnamed_addr #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca %"class.JPH::Vec3", align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.Test::PreUpdateParams", ptr %8, i32 0, i32 0
  %10 = load float, ptr %9, align 16, !tbaa !9
  %11 = getelementptr inbounds %class.SwingTwistConstraintFrictionTest, ptr %7, i32 0, i32 1
  %12 = load float, ptr %11, align 8, !tbaa !14
  %13 = fadd float %12, %10
  store float %13, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #7
  %14 = getelementptr inbounds %class.SwingTwistConstraintFrictionTest, ptr %7, i32 0, i32 1
  %15 = load float, ptr %14, align 8, !tbaa !14
  %16 = call noundef float @_ZSt4fmodff(float noundef %15, float noundef 5.000000e+00)
  %17 = fcmp ogt float %16, 2.500000e+00
  %18 = zext i1 %17 to i8
  store i8 %18, ptr %5, align 1, !tbaa !23
  %19 = load i8, ptr %5, align 1, !tbaa !23, !range !24, !noundef !25
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %26

21:                                               ; preds = %2
  %22 = getelementptr inbounds %class.SwingTwistConstraintFrictionTest, ptr %7, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !26
  call void @_ZN3JPH20SwingTwistConstraint18SetSwingMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %23, i32 noundef 0)
  %24 = getelementptr inbounds %class.SwingTwistConstraintFrictionTest, ptr %7, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !26
  call void @_ZN3JPH20SwingTwistConstraint18SetTwistMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %25, i32 noundef 0)
  br label %38

26:                                               ; preds = %2
  %27 = getelementptr inbounds %class.SwingTwistConstraintFrictionTest, ptr %7, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !26
  call void @_ZN3JPH20SwingTwistConstraint18SetSwingMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %28, i32 noundef 1)
  %29 = getelementptr inbounds %class.SwingTwistConstraintFrictionTest, ptr %7, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !26
  call void @_ZN3JPH20SwingTwistConstraint18SetTwistMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %30, i32 noundef 1)
  %31 = getelementptr inbounds %class.SwingTwistConstraintFrictionTest, ptr %7, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !26
  %33 = call noundef float @_ZN3JPH16DegreesToRadiansEf(float noundef 1.800000e+02)
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %6, float noundef %33, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %34 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %35 = load double, ptr %34, align 16
  %36 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  %37 = load double, ptr %36, align 8
  call void @_ZN3JPH20SwingTwistConstraint26SetTargetAngularVelocityCSENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(944) %32, double %35, double %37)
  br label %38

38:                                               ; preds = %26, %21
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #7
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4fmodff(float noundef, float noundef) #4

declare void @_ZN3JPH20SwingTwistConstraint18SetSwingMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944), i32 noundef) #5

declare void @_ZN3JPH20SwingTwistConstraint18SetTwistMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944), i32 noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH20SwingTwistConstraint26SetTargetAngularVelocityCSENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(944), double, double) #6 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 = { alwaysinline 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 = { 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 #4 = { 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 #5 = { "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 #6 = { 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 #7 = { 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, !11, i64 0}
!10 = !{!"_ZTSN4Test15PreUpdateParamsE", !11, i64 0, !12, i64 16}
!11 = !{!"float", !7, i64 0}
!12 = !{!"_ZTS11CameraState", !13, i64 0, !13, i64 16, !13, i64 32, !11, i64 48}
!13 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!14 = !{!15, !11, i64 112}
!15 = !{!"_ZTS32SwingTwistConstraintFrictionTest", !16, i64 0, !11, i64 112, !6, i64 120}
!16 = !{!"_ZTS4Test", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !17, i64 48, !18, i64 56}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !19, i64 0}
!19 = !{!"_ZTSSt10_HashtableIN3JPH6BodyIDESt4pairIKS1_NSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE", !6, i64 0, !20, i64 8, !21, i64 16, !20, i64 24, !22, i64 32, !6, i64 48}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!22 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !11, i64 0, !20, i64 8}
!23 = !{!17, !17, i64 0}
!24 = !{i8 0, i8 2}
!25 = !{}
!26 = !{!15, !6, i64 120}


; 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.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16), float noundef, float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3JPH16DegreesToRadiansEf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN32SwingTwistConstraintFrictionTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr nocapture noundef nonnull align 8 dereferenceable(128) %0, ptr nocapture noundef nonnull readonly align 16 dereferenceable(80) %1) unnamed_addr #2 align 2 {
  %3 = alloca %"class.JPH::Vec3", align 16
  %4 = load float, ptr %1, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 112
  %6 = load float, ptr %5, align 8, !tbaa !12
  %7 = fadd float %4, %6
  store float %7, ptr %5, align 8, !tbaa !12
  %8 = tail call noundef float @_ZSt4fmodff(float noundef %7, float noundef 5.000000e+00)
  %9 = fcmp ogt float %8, 2.500000e+00
  %10 = getelementptr inbounds i8, ptr %0, i64 120
  %11 = load ptr, ptr %10, align 8, !tbaa !22
  br i1 %9, label %12, label %14

12:                                               ; preds = %2
  tail call void @_ZN3JPH20SwingTwistConstraint18SetSwingMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %11, i32 noundef 0)
  %13 = load ptr, ptr %10, align 8, !tbaa !22
  tail call void @_ZN3JPH20SwingTwistConstraint18SetTwistMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %13, i32 noundef 0)
  br label %21

14:                                               ; preds = %2
  tail call void @_ZN3JPH20SwingTwistConstraint18SetSwingMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %11, i32 noundef 1)
  %15 = load ptr, ptr %10, align 8, !tbaa !22
  tail call void @_ZN3JPH20SwingTwistConstraint18SetTwistMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944) %15, i32 noundef 1)
  %16 = load ptr, ptr %10, align 8, !tbaa !22
  %17 = tail call noundef float @_ZN3JPH16DegreesToRadiansEf(float noundef 1.800000e+02)
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %3, float noundef %17, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %18 = load double, ptr %3, align 16
  %19 = getelementptr inbounds i8, ptr %3, i64 8
  %20 = load double, ptr %19, align 8
  call void @_ZN3JPH20SwingTwistConstraint26SetTargetAngularVelocityCSENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(944) %16, double %18, double %20)
  br label %21

21:                                               ; preds = %14, %12
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4fmodff(float noundef, float noundef) local_unnamed_addr #3

declare void @_ZN3JPH20SwingTwistConstraint18SetSwingMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944), i32 noundef) local_unnamed_addr #4

declare void @_ZN3JPH20SwingTwistConstraint18SetTwistMotorStateENS_11EMotorStateE(ptr noundef nonnull align 16 dereferenceable(944), i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH20SwingTwistConstraint26SetTargetAngularVelocityCSENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(944), double, double) local_unnamed_addr #5 align 2

attributes #0 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 = { alwaysinline 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 #2 = { 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 = { 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 #4 = { "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 #5 = { 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, !7, i64 0}
!6 = !{!"_ZTSN4Test15PreUpdateParamsE", !7, i64 0, !10, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS11CameraState", !11, i64 0, !11, i64 16, !11, i64 32, !7, i64 48}
!11 = !{!"_ZTSN3JPH4Vec3E", !8, i64 0}
!12 = !{!13, !7, i64 112}
!13 = !{!"_ZTS32SwingTwistConstraintFrictionTest", !14, i64 0, !7, i64 112, !15, i64 120}
!14 = !{!"_ZTS4Test", !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !16, i64 48, !17, i64 56}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"bool", !8, i64 0}
!17 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !18, i64 0}
!18 = !{!"_ZTSSt10_HashtableIN3JPH6BodyIDESt4pairIKS1_NSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE", !15, i64 0, !19, i64 8, !20, i64 16, !19, i64 24, !21, i64 32, !15, i64 48}
!19 = !{!"long", !8, i64 0}
!20 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !15, i64 0}
!21 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !7, i64 0, !19, i64 8}
!22 = !{!13, !15, i64 120}


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