; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qparticle.ll (ZN9QParticle10UpdateAABBEv)

; 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.QVector = type { float, float }
%class.QParticle = type <{ float, %struct.QVector, %struct.QVector, %struct.QVector, float, ptr, i8, [3 x i8], %struct.QVector, [4 x i8], %"class.std::vector", i8, i8, [2 x i8], %class.QAABB, i8, [7 x i8], %"class.std::unordered_set", %"class.std::unordered_set.5", %"class.std::unordered_set.5", i8, i8, [6 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl" }
%"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl" = type { %"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QVector, std::allocator<QVector>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.QAABB = type { %struct.QVector, %struct.QVector, %struct.QVector, float }
%"class.std::unordered_set" = 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 }
%"class.std::unordered_set.5" = type { %"class.std::_Hashtable.6" }
%"class.std::_Hashtable.6" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9QParticle10UpdateAABBEv(ptr noundef nonnull align 8 dereferenceable(290) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca %struct.QVector, align 4
  %5 = alloca float, align 4
  %6 = alloca %struct.QVector, align 4
  %7 = alloca float, align 4
  %8 = alloca %struct.QVector, align 4
  %9 = alloca float, align 4
  %10 = alloca %struct.QVector, align 4
  %11 = alloca %struct.QVector, align 4
  %12 = alloca %struct.QVector, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %14 = call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  store <2 x float> %14, ptr %4, align 4
  %15 = getelementptr inbounds %struct.QVector, ptr %4, i32 0, i32 0
  %16 = load float, ptr %15, align 4, !tbaa !9
  %17 = call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  %18 = fsub float %16, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  store float %18, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %19 = call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  store <2 x float> %19, ptr %6, align 4
  %20 = getelementptr inbounds %struct.QVector, ptr %6, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !9
  %22 = call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  %23 = fadd float %21, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  store float %23, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %24 = call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  store <2 x float> %24, ptr %8, align 4
  %25 = getelementptr inbounds %struct.QVector, ptr %8, i32 0, i32 1
  %26 = load float, ptr %25, align 4, !tbaa !13
  %27 = call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  %28 = fsub float %26, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  store float %28, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %29 = call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  store <2 x float> %29, ptr %10, align 4
  %30 = getelementptr inbounds %struct.QVector, ptr %10, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !13
  %32 = call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %13)
  %33 = fadd float %31, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  store float %33, ptr %9, align 4, !tbaa !12
  %34 = getelementptr inbounds %class.QParticle, ptr %13, i32 0, i32 14
  %35 = load float, ptr %3, align 4, !tbaa !12
  %36 = load float, ptr %7, align 4, !tbaa !12
  call void @_ZN7QVectorC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %11, float noundef %35, float noundef %36)
  %37 = load float, ptr %5, align 4, !tbaa !12
  %38 = load float, ptr %9, align 4, !tbaa !12
  call void @_ZN7QVectorC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %12, float noundef %37, float noundef %38)
  %39 = load <2 x float>, ptr %11, align 4
  %40 = load <2 x float>, ptr %12, align 4
  %41 = call noundef ptr @_ZN5QAABB9SetMinMaxE7QVectorS0_(ptr noundef nonnull align 4 dereferenceable(28) %34, <2 x float> %39, <2 x float> %40)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290)) #3 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5QAABB9SetMinMaxE7QVectorS0_(ptr noundef nonnull align 4 dereferenceable(28), <2 x float>, <2 x float>) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7QVectorC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #3 align 2

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 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 = { 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 = !{!"_ZTS7QVector", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}


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

%struct.QVector = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9QParticle10UpdateAABBEv(ptr noundef nonnull align 8 dereferenceable(290) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %struct.QVector, align 8
  %3 = alloca %struct.QVector, align 8
  %4 = tail call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %.sroa.05.0.vec.extract = extractelement <2 x float> %4, i64 0
  %5 = tail call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %6 = fsub float %.sroa.05.0.vec.extract, %5
  %7 = tail call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %.sroa.03.0.vec.extract = extractelement <2 x float> %7, i64 0
  %8 = tail call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %9 = fadd float %.sroa.03.0.vec.extract, %8
  %10 = tail call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %.sroa.01.4.vec.extract = extractelement <2 x float> %10, i64 1
  %11 = tail call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %12 = fsub float %.sroa.01.4.vec.extract, %11
  %13 = tail call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %.sroa.0.4.vec.extract = extractelement <2 x float> %13, i64 1
  %14 = tail call noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290) %0)
  %15 = fadd float %.sroa.0.4.vec.extract, %14
  %16 = getelementptr inbounds i8, ptr %0, i64 84
  call void @_ZN7QVectorC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %2, float noundef %6, float noundef %12)
  call void @_ZN7QVectorC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %9, float noundef %15)
  %17 = load <2 x float>, ptr %2, align 8
  %18 = load <2 x float>, ptr %3, align 8
  %19 = call noundef ptr @_ZN5QAABB9SetMinMaxE7QVectorS0_(ptr noundef nonnull align 4 dereferenceable(28) %16, <2 x float> %17, <2 x float> %18)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN9QParticle9GetRadiusEv(ptr noundef nonnull align 8 dereferenceable(290)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5QAABB9SetMinMaxE7QVectorS0_(ptr noundef nonnull align 4 dereferenceable(28), <2 x float>, <2 x float>) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7QVectorC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #2 align 2

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 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)"}


; Effective O3 passes: GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass