; LLVM IR from yangfengzzz/DigitalVox3 :: vox.render/maths/plane.ll (ZN3vox4math9normalizeERKNS0_5PlaneE)

; 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.vox::math::Plane" = type { %"struct.vox::math::Float3", float }
%"struct.vox::math::Float3" = type { float, float, float }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN3vox4math9normalizeERKNS0_5PlaneE(ptr noundef nonnull align 4 dereferenceable(16) %0) #2 {
  %2 = alloca %"struct.vox::math::Plane", align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca %"struct.vox::math::Float3", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %"struct.vox::math::Plane", ptr %7, i32 0, i32 0
  store ptr %8, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call noundef float @_ZN3vox4math6LengthERKNS0_6Float3E(ptr noundef nonnull align 4 dereferenceable(12) %9)
  %11 = fpext float %10 to double
  %12 = fdiv double 1.000000e+00, %11
  store double %12, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.vox::math::Float3", ptr %13, i32 0, i32 0
  %15 = load float, ptr %14, align 4, !tbaa !11
  %16 = fpext float %15 to double
  %17 = load double, ptr %5, align 8, !tbaa !9
  %18 = fmul double %16, %17
  %19 = fptrunc double %18 to float
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.vox::math::Float3", ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !14
  %23 = fpext float %22 to double
  %24 = load double, ptr %5, align 8, !tbaa !9
  %25 = fmul double %23, %24
  %26 = fptrunc double %25 to float
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.vox::math::Float3", ptr %27, i32 0, i32 2
  %29 = load float, ptr %28, align 4, !tbaa !15
  %30 = fpext float %29 to double
  %31 = load double, ptr %5, align 8, !tbaa !9
  %32 = fmul double %30, %31
  %33 = fptrunc double %32 to float
  call void @_ZN3vox4math6Float3C2Efff(ptr noundef nonnull align 4 dereferenceable(12) %6, float noundef %19, float noundef %26, float noundef %33)
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.vox::math::Plane", ptr %34, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !16
  %37 = fpext float %36 to double
  %38 = load double, ptr %5, align 8, !tbaa !9
  %39 = fmul double %37, %38
  %40 = fptrunc double %39 to float
  call void @_ZN3vox4math5PlaneC2ERKNS0_6Float3Ef(ptr noundef nonnull align 4 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(12) %6, float noundef %40)
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %41 = load { <2 x float>, <2 x float> }, ptr %2, align 4
  ret { <2 x float>, <2 x float> } %41
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3vox4math6LengthERKNS0_6Float3E(ptr noundef nonnull align 4 dereferenceable(12)) #3

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

attributes #0 = { 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 = { 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 #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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN3vox4math6Float3E", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{!12, !13, i64 8}
!16 = !{!17, !13, i64 12}
!17 = !{!"_ZTSN3vox4math5PlaneE", !12, i64 0, !13, i64 12}


; 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.vox::math::Plane" = type { %"struct.vox::math::Float3", float }
%"struct.vox::math::Float3" = type { float, float, 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 nounwind uwtable
declare dso_local void @_ZN3vox4math5PlaneC2ERKNS0_6Float3Ef(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12), float noundef) unnamed_addr #1 align 2

; 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
define dso_local { <2 x float>, <2 x float> } @_ZN3vox4math9normalizeERKNS0_5PlaneE(ptr noundef nonnull align 4 dereferenceable(16) %0) local_unnamed_addr #1 {
  %2 = alloca %"struct.vox::math::Plane", align 8
  %3 = alloca %"struct.vox::math::Float3", align 4
  %4 = tail call noundef float @_ZN3vox4math6LengthERKNS0_6Float3E(ptr noundef nonnull align 4 dereferenceable(12) %0)
  %5 = fpext float %4 to double
  %6 = fdiv double 1.000000e+00, %5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  %7 = load float, ptr %0, align 4, !tbaa !5
  %8 = fpext float %7 to double
  %9 = fmul double %6, %8
  %10 = fptrunc double %9 to float
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load float, ptr %11, align 4, !tbaa !10
  %13 = fpext float %12 to double
  %14 = fmul double %6, %13
  %15 = fptrunc double %14 to float
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = fpext float %17 to double
  %19 = fmul double %6, %18
  %20 = fptrunc double %19 to float
  call void @_ZN3vox4math6Float3C2Efff(ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef %10, float noundef %15, float noundef %20)
  %21 = getelementptr inbounds i8, ptr %0, i64 12
  %22 = load float, ptr %21, align 4, !tbaa !12
  %23 = fpext float %22 to double
  %24 = fmul double %6, %23
  %25 = fptrunc double %24 to float
  call void @_ZN3vox4math5PlaneC2ERKNS0_6Float3Ef(ptr noundef nonnull align 4 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef %25)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #3
  %.fca.0.load = load <2 x float>, ptr %2, align 8
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds i8, ptr %2, i64 8
  %.fca.1.load = load <2 x float>, ptr %.fca.1.gep, align 8
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.fca.1.load, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

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


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