; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/General (KinematicTest)

; 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.KinematicTest = type { %class.Test, [2 x 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: mustprogress uwtable
define dso_local void @_ZN13KinematicTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 16 dereferenceable(80) %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.JPH::Vec3", align 16
  %7 = alloca %"class.JPH::Vec3", align 16
  %8 = alloca %"class.JPH::Vec3", align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %54, %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 2
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %57

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  %15 = getelementptr inbounds %class.KinematicTest, ptr %9, i32 0, i32 1
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [2 x ptr], ptr %15, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = call { double, double } @_ZNK3JPH4Body23GetCenterOfMassPositionEv(ptr noundef nonnull align 16 dereferenceable(122) %19)
  %21 = getelementptr inbounds %"class.JPH::Vec3", ptr %6, i32 0, i32 0
  %22 = getelementptr inbounds %union.anon, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 0
  %24 = extractvalue { double, double } %20, 0
  store double %24, ptr %23, align 16
  %25 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 1
  %26 = extractvalue { double, double } %20, 1
  store double %26, ptr %25, align 8
  %27 = call noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16) %6)
  %28 = fcmp oge float %27, 5.000000e+00
  br i1 %28, label %29, label %39

29:                                               ; preds = %14
  %30 = getelementptr inbounds %class.KinematicTest, ptr %9, i32 0, i32 1
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2 x ptr], ptr %30, i64 0, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %7, float noundef 2.000000e+00, float noundef 0.000000e+00, float noundef -1.000000e+01)
  %35 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  %36 = load double, ptr %35, align 16
  %37 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  %38 = load double, ptr %37, align 8
  call void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %34, double %36, double %38)
  br label %53

39:                                               ; preds = %14
  %40 = call noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16) %6)
  %41 = fcmp ole float %40, -5.000000e+00
  br i1 %41, label %42, label %52

42:                                               ; preds = %39
  %43 = getelementptr inbounds %class.KinematicTest, ptr %9, i32 0, i32 1
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2 x ptr], ptr %43, i64 0, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %8, float noundef 2.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+01)
  %48 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %49 = load double, ptr %48, align 16
  %50 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %51 = load double, ptr %50, align 8
  call void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %47, double %49, double %51)
  br label %52

52:                                               ; preds = %42, %39
  br label %53

53:                                               ; preds = %52, %29
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %5, align 4, !tbaa !9
  br label %10, !llvm.loop !11

57:                                               ; preds = %13
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Body23GetCenterOfMassPositionEv(ptr noundef nonnull align 16 dereferenceable(122)) #3 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122), double, double) #2 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 = { 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 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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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: 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: 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: mustprogress uwtable
define dso_local void @_ZN13KinematicTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(128) %0, ptr nocapture noundef nonnull readnone align 16 dereferenceable(80) %1) unnamed_addr #2 align 2 {
  %3 = alloca %"class.JPH::Vec3", align 16
  %4 = alloca %"class.JPH::Vec3", align 16
  %5 = alloca %"class.JPH::Vec3", align 16
  %6 = getelementptr inbounds i8, ptr %0, i64 112
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = tail call { double, double } @_ZNK3JPH4Body23GetCenterOfMassPositionEv(ptr noundef nonnull align 16 dereferenceable(122) %10)
  %12 = extractvalue { double, double } %11, 0
  store double %12, ptr %3, align 16
  %13 = extractvalue { double, double } %11, 1
  store double %13, ptr %7, align 8
  %14 = call noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16) %3)
  %15 = fcmp ult float %14, 5.000000e+00
  br i1 %15, label %20, label %16

16:                                               ; preds = %2
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %4, float noundef 2.000000e+00, float noundef 0.000000e+00, float noundef -1.000000e+01)
  %18 = load double, ptr %4, align 16
  %19 = load double, ptr %8, align 8
  call void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %17, double %18, double %19)
  br label %27

20:                                               ; preds = %2
  %21 = call noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16) %3)
  %22 = fcmp ugt float %21, -5.000000e+00
  br i1 %22, label %27, label %23

23:                                               ; preds = %20
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %5, float noundef 2.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+01)
  %25 = load double, ptr %5, align 16
  %26 = load double, ptr %9, align 8
  call void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %24, double %25, double %26)
  br label %27

27:                                               ; preds = %20, %23, %16
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %28 = getelementptr inbounds i8, ptr %0, i64 120
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = call { double, double } @_ZNK3JPH4Body23GetCenterOfMassPositionEv(ptr noundef nonnull align 16 dereferenceable(122) %29)
  %31 = extractvalue { double, double } %30, 0
  store double %31, ptr %3, align 16
  %32 = extractvalue { double, double } %30, 1
  store double %32, ptr %7, align 8
  %33 = call noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16) %3)
  %34 = fcmp ult float %33, 5.000000e+00
  br i1 %34, label %39, label %35

35:                                               ; preds = %27
  %36 = load ptr, ptr %28, align 8, !tbaa !5
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %4, float noundef 2.000000e+00, float noundef 0.000000e+00, float noundef -1.000000e+01)
  %37 = load double, ptr %4, align 16
  %38 = load double, ptr %8, align 8
  call void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %36, double %37, double %38)
  br label %46

39:                                               ; preds = %27
  %40 = call noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16) %3)
  %41 = fcmp ugt float %40, -5.000000e+00
  br i1 %41, label %46, label %42

42:                                               ; preds = %39
  %43 = load ptr, ptr %28, align 8, !tbaa !5
  call void @_ZN3JPH4Vec3C2Efff(ptr noundef nonnull align 16 dereferenceable(16) %5, float noundef 2.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+01)
  %44 = load double, ptr %5, align 16
  %45 = load double, ptr %9, align 8
  call void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122) %43, double %44, double %45)
  br label %46

46:                                               ; preds = %42, %39, %35
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Body23GetCenterOfMassPositionEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #3 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3JPH4Vec34GetZEv(ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH4Body17SetLinearVelocityENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(122), double, double) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { 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 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 = { 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 #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"}


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