; LLVM IR from jrouwe/JoltPhysics :: UnitTests (PhysicsTestContext)

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

; 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: 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) #1

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

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZNK18PhysicsTestContext15PredictPositionEN3JPH4Vec3ES1_S1_f(ptr noundef nonnull align 8 dereferenceable(72) %0, double %1, double %2, double %3, double %4, double %5, double %6, float noundef %7) #3 align 2 {
  %9 = alloca %"class.JPH::Vec3", align 16
  %10 = alloca %"class.JPH::Vec3", align 16
  %11 = alloca %"class.JPH::Vec3", align 16
  %12 = alloca %"class.JPH::Vec3", align 16
  %13 = alloca ptr, align 8
  %14 = alloca float, align 4
  %15 = alloca %"class.JPH::Vec3", align 16
  %16 = alloca float, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %"class.JPH::Vec3", align 16
  %20 = alloca %"class.JPH::Vec3", align 16
  %21 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  store double %1, ptr %21, align 16
  %22 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  store double %2, ptr %22, align 8
  %23 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  store double %3, ptr %23, align 16
  %24 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  store double %4, ptr %24, align 8
  %25 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  store double %5, ptr %25, align 16
  %26 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  store double %6, ptr %26, align 8
  store ptr %0, ptr %13, align 8, !tbaa !5
  store float %7, ptr %14, align 4, !tbaa !9
  %27 = load ptr, ptr %13, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 %10, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %15, ptr align 16 %11, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %28 = call noundef float @_ZNK18PhysicsTestContext16GetStepDeltaTimeEv(ptr noundef nonnull align 8 dereferenceable(72) %27)
  store float %28, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %29 = load float, ptr %14, align 4, !tbaa !9
  %30 = load float, ptr %16, align 4, !tbaa !9
  %31 = fdiv float %29, %30
  %32 = call noundef float @_ZSt5roundf(float noundef %31)
  %33 = fptosi float %32 to i32
  store i32 %33, ptr %17, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !13
  br label %34

34:                                               ; preds = %66, %8
  %35 = load i32, ptr %18, align 4, !tbaa !13
  %36 = load i32, ptr %17, align 4, !tbaa !13
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %69

39:                                               ; preds = %34
  %40 = load float, ptr %16, align 4, !tbaa !9
  %41 = call { double, double } @_ZNK3JPH4Vec3mlEf(ptr noundef nonnull align 16 dereferenceable(16) %12, float noundef %40)
  %42 = getelementptr inbounds %"class.JPH::Vec3", ptr %19, i32 0, i32 0
  %43 = getelementptr inbounds %union.anon, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds { double, double }, ptr %43, i32 0, i32 0
  %45 = extractvalue { double, double } %41, 0
  store double %45, ptr %44, align 16
  %46 = getelementptr inbounds { double, double }, ptr %43, i32 0, i32 1
  %47 = extractvalue { double, double } %41, 1
  store double %47, ptr %46, align 8
  %48 = getelementptr inbounds { double, double }, ptr %19, i32 0, i32 0
  %49 = load double, ptr %48, align 16
  %50 = getelementptr inbounds { double, double }, ptr %19, i32 0, i32 1
  %51 = load double, ptr %50, align 8
  %52 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZN3JPH4Vec3pLES0_(ptr noundef nonnull align 16 dereferenceable(16) %15, double %49, double %51)
  %53 = load float, ptr %16, align 4, !tbaa !9
  %54 = call { double, double } @_ZNK3JPH4Vec3mlEf(ptr noundef nonnull align 16 dereferenceable(16) %15, float noundef %53)
  %55 = getelementptr inbounds %"class.JPH::Vec3", ptr %20, i32 0, i32 0
  %56 = getelementptr inbounds %union.anon, ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds { double, double }, ptr %56, i32 0, i32 0
  %58 = extractvalue { double, double } %54, 0
  store double %58, ptr %57, align 16
  %59 = getelementptr inbounds { double, double }, ptr %56, i32 0, i32 1
  %60 = extractvalue { double, double } %54, 1
  store double %60, ptr %59, align 8
  %61 = getelementptr inbounds { double, double }, ptr %20, i32 0, i32 0
  %62 = load double, ptr %61, align 16
  %63 = getelementptr inbounds { double, double }, ptr %20, i32 0, i32 1
  %64 = load double, ptr %63, align 8
  %65 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZN3JPH4Vec3pLES0_(ptr noundef nonnull align 16 dereferenceable(16) %9, double %62, double %64)
  br label %66

66:                                               ; preds = %39
  %67 = load i32, ptr %18, align 4, !tbaa !13
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %18, align 4, !tbaa !13
  br label %34, !llvm.loop !15

69:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #6
  %70 = getelementptr inbounds %"class.JPH::Vec3", ptr %9, i32 0, i32 0
  %71 = getelementptr inbounds %union.anon, ptr %70, i32 0, i32 0
  %72 = load { double, double }, ptr %71, align 16
  ret { double, double } %72
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK18PhysicsTestContext16GetStepDeltaTimeEv(ptr noundef nonnull align 8 dereferenceable(72)) #4 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Vec3mlEf(ptr noundef nonnull align 16 dereferenceable(16), float noundef) #5 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZN3JPH4Vec3pLES0_(ptr noundef nonnull align 16 dereferenceable(16), double, double) #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #6 = { 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 0, i64 16, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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: mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5roundf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZNK18PhysicsTestContext15PredictPositionEN3JPH4Vec3ES1_S1_f(ptr noundef nonnull align 8 dereferenceable(72) %0, double %1, double %2, double %3, double %4, double %5, double %6, float noundef %7) local_unnamed_addr #2 align 2 {
  %9 = alloca %"class.JPH::Vec3", align 16
  %10 = alloca %"class.JPH::Vec3", align 16
  %11 = alloca %"class.JPH::Vec3", align 16
  store double %5, ptr %10, align 16
  %12 = getelementptr inbounds i8, ptr %10, i64 8
  store double %6, ptr %12, align 8
  store double %1, ptr %9, align 16
  %.sroa.212.0..sroa_idx = getelementptr inbounds i8, ptr %9, i64 8
  store double %2, ptr %.sroa.212.0..sroa_idx, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %11) #5
  store double %3, ptr %11, align 16
  %.sroa.210.0..sroa_idx = getelementptr inbounds i8, ptr %11, i64 8
  store double %4, ptr %.sroa.210.0..sroa_idx, align 8, !tbaa !5
  %13 = tail call noundef float @_ZNK18PhysicsTestContext16GetStepDeltaTimeEv(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %14 = fdiv float %7, %13
  %15 = tail call noundef float @_ZSt5roundf(float noundef %14)
  %16 = fptosi float %15 to i32
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.fca.0.load.pre = load double, ptr %9, align 16
  %.fca.1.load.pre = load double, ptr %.sroa.212.0..sroa_idx, align 8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %8
  %.fca.1.load = phi double [ %.fca.1.load.pre, %._crit_edge.loopexit ], [ %2, %8 ]
  %.fca.0.load = phi double [ %.fca.0.load.pre, %._crit_edge.loopexit ], [ %1, %8 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %11) #5
  %.fca.0.insert = insertvalue { double, double } poison, double %.fca.0.load, 0
  %.fca.1.insert = insertvalue { double, double } %.fca.0.insert, double %.fca.1.load, 1
  ret { double, double } %.fca.1.insert

.lr.ph:                                           ; preds = %8, %.lr.ph
  %.013 = phi i32 [ %26, %.lr.ph ], [ 0, %8 ]
  %18 = call { double, double } @_ZNK3JPH4Vec3mlEf(ptr noundef nonnull align 16 dereferenceable(16) %10, float noundef %13)
  %19 = extractvalue { double, double } %18, 0
  %20 = extractvalue { double, double } %18, 1
  %21 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZN3JPH4Vec3pLES0_(ptr noundef nonnull align 16 dereferenceable(16) %11, double %19, double %20)
  %22 = call { double, double } @_ZNK3JPH4Vec3mlEf(ptr noundef nonnull align 16 dereferenceable(16) %11, float noundef %13)
  %23 = extractvalue { double, double } %22, 0
  %24 = extractvalue { double, double } %22, 1
  %25 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZN3JPH4Vec3pLES0_(ptr noundef nonnull align 16 dereferenceable(16) %9, double %23, double %24)
  %26 = add nuw nsw i32 %.013, 1
  %exitcond.not = icmp eq i32 %26, %16
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !8
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK18PhysicsTestContext16GetStepDeltaTimeEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #3 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Vec3mlEf(ptr noundef nonnull align 16 dereferenceable(16), float noundef) local_unnamed_addr #4 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZN3JPH4Vec3pLES0_(ptr noundef nonnull align 16 dereferenceable(16), double, double) local_unnamed_addr #4 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass