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

; 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> }
%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::SliderConstraintSettings" = type <{ %"class.JPH::TwoBodyConstraintSettings", i32, i8, [3 x i8], %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", float, float, %"class.JPH::SpringSettings", float, %"class.JPH::MotorSettings", [12 x i8] }>
%"class.JPH::TwoBodyConstraintSettings" = type { %"class.JPH::ConstraintSettings" }
%"class.JPH::ConstraintSettings" = type { %"class.JPH::SerializableObject", %"class.JPH::RefTarget", i8, i32, i32, i32, float, i64 }
%"class.JPH::SerializableObject" = type { ptr }
%"class.JPH::RefTarget" = 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 }

@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [98 x i8], align 1

; 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
define dso_local void @_ZN3JPH24SliderConstraintSettings13SetSliderAxisENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(208) %0, double %1, double %2) #1 align 2 {
  %4 = alloca %"class.JPH::Vec3", align 16
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.JPH::AssertLastParam", align 1
  %7 = alloca %"class.JPH::Vec3", align 16
  %8 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 0
  store double %1, ptr %8, align 16
  %9 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 1
  store double %2, ptr %9, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  br label %11

11:                                               ; preds = %3
  %12 = getelementptr inbounds %"class.JPH::SliderConstraintSettings", ptr %10, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %18, label %15

15:                                               ; preds = %11
  %16 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 43)
  br i1 %16, label %17, label %18

17:                                               ; preds = %15
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !26
  br label %18

18:                                               ; preds = %17, %15, %11
  br label %19

19:                                               ; preds = %18
  %20 = getelementptr inbounds %"class.JPH::SliderConstraintSettings", ptr %10, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %20, ptr align 16 %4, i64 16, i1 false), !tbaa.struct !27
  %21 = getelementptr inbounds %"class.JPH::SliderConstraintSettings", ptr %10, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %21, ptr align 16 %20, i64 16, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  %22 = call { double, double } @_ZNK3JPH4Vec326GetNormalizedPerpendicularEv(ptr noundef nonnull align 16 dereferenceable(16) %4)
  %23 = getelementptr inbounds %"class.JPH::Vec3", ptr %7, i32 0, i32 0
  %24 = getelementptr inbounds %union.anon, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds { double, double }, ptr %24, i32 0, i32 0
  %26 = extractvalue { double, double } %22, 0
  store double %26, ptr %25, align 16
  %27 = getelementptr inbounds { double, double }, ptr %24, i32 0, i32 1
  %28 = extractvalue { double, double } %22, 1
  store double %28, ptr %27, align 8
  %29 = getelementptr inbounds %"class.JPH::SliderConstraintSettings", ptr %10, i32 0, i32 9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %29, ptr align 16 %7, i64 16, i1 false), !tbaa.struct !27
  %30 = getelementptr inbounds %"class.JPH::SliderConstraintSettings", ptr %10, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %30, ptr align 16 %29, i64 16, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Vec326GetNormalizedPerpendicularEv(ptr noundef nonnull align 16 dereferenceable(16)) #4 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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { alwaysinline 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 #5 = { 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, !21, i64 40}
!10 = !{!"_ZTSN3JPH24SliderConstraintSettingsE", !11, i64 0, !21, i64 40, !18, i64 44, !22, i64 48, !22, i64 64, !22, i64 80, !22, i64 96, !22, i64 112, !22, i64 128, !19, i64 144, !19, i64 148, !23, i64 152, !19, i64 164, !25, i64 168}
!11 = !{!"_ZTSN3JPH25TwoBodyConstraintSettingsE", !12, i64 0}
!12 = !{!"_ZTSN3JPH18ConstraintSettingsE", !13, i64 0, !14, i64 8, !18, i64 12, !17, i64 16, !17, i64 20, !17, i64 24, !19, i64 28, !20, i64 32}
!13 = !{!"_ZTSN3JPH18SerializableObjectE"}
!14 = !{!"_ZTSN3JPH9RefTargetINS_18ConstraintSettingsEEE", !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 = !{!"float", !7, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSN3JPH16EConstraintSpaceE", !7, i64 0}
!22 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!23 = !{!"_ZTSN3JPH14SpringSettingsE", !24, i64 0, !7, i64 4, !19, i64 8}
!24 = !{!"_ZTSN3JPH11ESpringModeE", !7, i64 0}
!25 = !{!"_ZTSN3JPH13MotorSettingsE", !23, i64 0, !19, i64 12, !19, i64 16, !19, i64 20, !19, i64 24}
!26 = !{i64 2158333818}
!27 = !{i64 0, i64 16, !28}
!28 = !{!7, !7, i64 0}


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

@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [98 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH24SliderConstraintSettings13SetSliderAxisENS_4Vec3E(ptr nocapture noundef nonnull align 16 dereferenceable(208) %0, double %1, double %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"class.JPH::Vec3", align 16
  store double %1, ptr %4, align 16
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store double %2, ptr %5, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %12, label %9

9:                                                ; preds = %3
  %10 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 43)
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !24
  br label %12

12:                                               ; preds = %3, %9, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %13, ptr noundef nonnull align 16 dereferenceable(16) %4, i64 16, i1 false), !tbaa.struct !25
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %14, ptr noundef nonnull align 16 dereferenceable(16) %4, i64 16, i1 false)
  %15 = call { double, double } @_ZNK3JPH4Vec326GetNormalizedPerpendicularEv(ptr noundef nonnull align 16 dereferenceable(16) %4)
  %16 = extractvalue { double, double } %15, 0
  %17 = extractvalue { double, double } %15, 1
  %18 = getelementptr inbounds i8, ptr %0, i64 128
  store double %16, ptr %18, align 16
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 136
  store double %17, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !26
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %19, ptr noundef nonnull align 16 dereferenceable(16) %18, i64 16, i1 false), !tbaa.struct !25
  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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Vec326GetNormalizedPerpendicularEv(ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #3 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" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { alwaysinline 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 = { 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, !19, i64 40}
!6 = !{!"_ZTSN3JPH24SliderConstraintSettingsE", !7, i64 0, !19, i64 40, !16, i64 44, !20, i64 48, !20, i64 64, !20, i64 80, !20, i64 96, !20, i64 112, !20, i64 128, !17, i64 144, !17, i64 148, !21, i64 152, !17, i64 164, !23, i64 168}
!7 = !{!"_ZTSN3JPH25TwoBodyConstraintSettingsE", !8, i64 0}
!8 = !{!"_ZTSN3JPH18ConstraintSettingsE", !9, i64 0, !10, i64 8, !16, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !17, i64 28, !18, i64 32}
!9 = !{!"_ZTSN3JPH18SerializableObjectE"}
!10 = !{!"_ZTSN3JPH9RefTargetINS_18ConstraintSettingsEEE", !11, i64 0}
!11 = !{!"_ZTSSt6atomicIjE", !12, i64 0}
!12 = !{!"_ZTSSt13__atomic_baseIjE", !13, i64 0}
!13 = !{!"int", !14, i64 0}
!14 = !{!"omnipotent char", !15, i64 0}
!15 = !{!"Simple C++ TBAA"}
!16 = !{!"bool", !14, i64 0}
!17 = !{!"float", !14, i64 0}
!18 = !{!"long", !14, i64 0}
!19 = !{!"_ZTSN3JPH16EConstraintSpaceE", !14, i64 0}
!20 = !{!"_ZTSN3JPH4Vec3E", !14, i64 0}
!21 = !{!"_ZTSN3JPH14SpringSettingsE", !22, i64 0, !14, i64 4, !17, i64 8}
!22 = !{!"_ZTSN3JPH11ESpringModeE", !14, i64 0}
!23 = !{!"_ZTSN3JPH13MotorSettingsE", !21, i64 0, !17, i64 12, !17, i64 16, !17, i64 20, !17, i64 24}
!24 = !{i64 2158333818}
!25 = !{i64 0, i64 16, !26}
!26 = !{!14, !14, i64 0}


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