; LLVM IR from wgtdkp/apollonia :: src/body.ll (ZN9apollonia4Body12ApplyImpulseERKNS_4Vec2ES3_)

; 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.apollonia::Vec2" = type { float, float }
%"class.apollonia::Body" = type { ptr, float, float, float, float, %"struct.apollonia::Vec2", %"struct.apollonia::Vec2", %"struct.apollonia::Mat22", %"struct.apollonia::Vec2", float, %"struct.apollonia::Vec2", float, float, float }
%"struct.apollonia::Mat22" = type { %"struct.std::array" }
%"struct.std::array" = type { [2 x %"struct.apollonia::Vec2"] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9apollonia4Body12ApplyImpulseERKNS_4Vec2ES3_(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.apollonia::Vec2", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %"class.apollonia::Body", ptr %8, i32 0, i32 2
  %11 = load float, ptr %10, align 4, !tbaa !9
  %12 = call <2 x float> @_ZN9apolloniamlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8) %9, float noundef %11)
  store <2 x float> %12, ptr %7, align 4
  %13 = getelementptr inbounds %"class.apollonia::Body", ptr %8, i32 0, i32 8
  call void @_ZN9apolloniapLERNS_4Vec2ERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %13, ptr noundef nonnull align 4 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %14 = getelementptr inbounds %"class.apollonia::Body", ptr %8, i32 0, i32 4
  %15 = load float, ptr %14, align 4, !tbaa !15
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef float @_ZN9apolloniaL5CrossERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(8) %17)
  %19 = getelementptr inbounds %"class.apollonia::Body", ptr %8, i32 0, i32 9
  %20 = load float, ptr %19, align 8, !tbaa !16
  %21 = call float @llvm.fmuladd.f32(float %15, float %18, float %20)
  store float %21, ptr %19, align 8, !tbaa !16
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZN9apolloniapLERNS_4Vec2ERKS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZN9apolloniamlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZN9apolloniaL5CrossERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

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 = { inlinehint 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 12}
!10 = !{!"_ZTSN9apollonia4BodyE", !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 32, !13, i64 40, !12, i64 56, !11, i64 64, !12, i64 68, !11, i64 76, !11, i64 80, !11, i64 84}
!11 = !{!"float", !7, i64 0}
!12 = !{!"_ZTSN9apollonia4Vec2E", !11, i64 0, !11, i64 4}
!13 = !{!"_ZTSN9apollonia5Mat22E", !14, i64 0}
!14 = !{!"_ZTSSt5arrayIN9apollonia4Vec2ELm2EE", !7, i64 0}
!15 = !{!10, !11, i64 20}
!16 = !{!10, !11, i64 64}


; 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.apollonia::Vec2" = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9apollonia4Body12ApplyImpulseERKNS_4Vec2ES3_(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"struct.apollonia::Vec2", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = tail call <2 x float> @_ZN9apolloniamlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8) %1, float noundef %6)
  store <2 x float> %7, ptr %4, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  call void @_ZN9apolloniapLERNS_4Vec2ERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = load float, ptr %9, align 4, !tbaa !13
  %11 = call noundef float @_ZN9apolloniaL5CrossERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %1)
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  %13 = load float, ptr %12, align 8, !tbaa !14
  %14 = call float @llvm.fmuladd.f32(float %10, float %11, float %13)
  store float %14, ptr %12, align 8, !tbaa !14
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZN9apolloniapLERNS_4Vec2ERKS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZN9apolloniamlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZN9apolloniaL5CrossERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

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 = { inlinehint 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 12}
!6 = !{!"_ZTSN9apollonia4BodyE", !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32, !11, i64 40, !10, i64 56, !7, i64 64, !10, i64 68, !7, i64 76, !7, i64 80, !7, i64 84}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN9apollonia4Vec2E", !7, i64 0, !7, i64 4}
!11 = !{!"_ZTSN9apollonia5Mat22E", !12, i64 0}
!12 = !{!"_ZTSSt5arrayIN9apollonia4Vec2ELm2EE", !8, i64 0}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 64}


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