; LLVM IR from St0wy/StowyPhysicsEngine :: StowyPhysicsEngine/src/math/Vector2.ll (ZNK3stw7Vector210NormalizedEv)

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNK3stw7Vector29MagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK3stw7Vector210NormalizedEv(ptr noundef nonnull align 4 dereferenceable(8) %0) #1 align 2 {
  %2 = alloca %"struct.stw::Vector2", align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %"struct.stw::Vector2", ptr %5, i32 0, i32 0
  %7 = load float, ptr %6, align 4, !tbaa !9
  %8 = fcmp oeq float %7, 0.000000e+00
  br i1 %8, label %9, label %14

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"struct.stw::Vector2", ptr %5, i32 0, i32 1
  %11 = load float, ptr %10, align 4, !tbaa !12
  %12 = fcmp oeq float %11, 0.000000e+00
  br i1 %12, label %13, label %14

13:                                               ; preds = %9
  call void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %2, float noundef 0.000000e+00, float noundef 0.000000e+00)
  br label %25

14:                                               ; preds = %9, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %15 = call noundef float @_ZNK3stw7Vector29MagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %16 = fdiv float 1.000000e+00, %15
  store float %16, ptr %4, align 4, !tbaa !13
  %17 = getelementptr inbounds %"struct.stw::Vector2", ptr %5, i32 0, i32 0
  %18 = load float, ptr %17, align 4, !tbaa !9
  %19 = load float, ptr %4, align 4, !tbaa !13
  %20 = fmul float %18, %19
  %21 = getelementptr inbounds %"struct.stw::Vector2", ptr %5, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !12
  %23 = load float, ptr %4, align 4, !tbaa !13
  %24 = fmul float %22, %23
  call void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %2, float noundef %20, float noundef %24)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %25

25:                                               ; preds = %14, %13
  %26 = load <2 x float>, ptr %2, align 4
  ret <2 x float> %26
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) 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 = { 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 = { 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 = !{!"_ZTSN3stw7Vector2E", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, 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"

%"struct.stw::Vector2" = type { float, float }

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNK3stw7Vector29MagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK3stw7Vector210NormalizedEv(ptr noundef nonnull align 4 dereferenceable(8) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"struct.stw::Vector2", align 8
  %3 = load float, ptr %0, align 4, !tbaa !5
  %4 = fcmp oeq float %3, 0.000000e+00
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load float, ptr %5, align 4
  %7 = fcmp oeq float %6, 0.000000e+00
  %or.cond = select i1 %4, i1 %7, i1 false
  br i1 %or.cond, label %8, label %9

8:                                                ; preds = %1
  call void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %2, float noundef 0.000000e+00, float noundef 0.000000e+00)
  br label %16

9:                                                ; preds = %1
  %10 = tail call noundef float @_ZNK3stw7Vector29MagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8) %0)
  %11 = fdiv float 1.000000e+00, %10
  %12 = load float, ptr %0, align 4, !tbaa !5
  %13 = fmul float %12, %11
  %14 = load float, ptr %5, align 4, !tbaa !10
  %15 = fmul float %11, %14
  call void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %2, float noundef %13, float noundef %15)
  br label %16

16:                                               ; preds = %9, %8
  %17 = load <2 x float>, ptr %2, align 8
  ret <2 x float> %17
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #2 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 = { 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 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)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTSN3stw7Vector2E", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}


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