; LLVM IR from yangfengzzz/DigitalVox3 :: vox.render/maths/ray.ll (ZN3vox4math3RayC2ESt8optionalINS0_6Float3EES4_)

; 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.std::optional" = type { %"struct.std::_Optional_base" }
%"struct.std::_Optional_base" = type { %"struct.std::_Optional_payload" }
%"struct.std::_Optional_payload" = type { %"struct.std::_Optional_payload_base.base", [3 x i8] }
%"struct.std::_Optional_payload_base.base" = type <{ %"union.std::_Optional_payload_base<vox::math::Float3>::_Storage", i8 }>
%"union.std::_Optional_payload_base<vox::math::Float3>::_Storage" = type { %"struct.vox::math::Float3" }
%"struct.vox::math::Float3" = type { float, float, float }
%"struct.vox::math::Ray" = type { %"struct.vox::math::Float3", %"struct.vox::math::Float3" }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3vox4math3RayC2ESt8optionalINS0_6Float3EES4_(ptr noundef nonnull align 4 dereferenceable(24) %0, <2 x float> %1, i64 %2, <2 x float> %3, i64 %4) unnamed_addr #0 align 2 {
  %6 = alloca %"class.std::optional", align 4
  %7 = alloca %"class.std::optional", align 4
  %8 = alloca ptr, align 8
  %9 = getelementptr inbounds { <2 x float>, i64 }, ptr %6, i32 0, i32 0
  store <2 x float> %1, ptr %9, align 4
  %10 = getelementptr inbounds { <2 x float>, i64 }, ptr %6, i32 0, i32 1
  store i64 %2, ptr %10, align 4
  %11 = getelementptr inbounds { <2 x float>, i64 }, ptr %7, i32 0, i32 0
  store <2 x float> %3, ptr %11, align 4
  %12 = getelementptr inbounds { <2 x float>, i64 }, ptr %7, i32 0, i32 1
  store i64 %4, ptr %12, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %8, align 8
  %14 = getelementptr inbounds %"struct.vox::math::Ray", ptr %13, i32 0, i32 0
  call void @_ZN3vox4math6Float3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %14)
  %15 = getelementptr inbounds %"struct.vox::math::Ray", ptr %13, i32 0, i32 1
  call void @_ZN3vox4math6Float3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %15)
  %16 = call noundef zeroext i1 @_ZNKSt8optionalIN3vox4math6Float3EEcvbEv(ptr noundef nonnull align 4 dereferenceable(16) %6) #5
  br i1 %16, label %17, label %20

17:                                               ; preds = %5
  %18 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNRSt8optionalIN3vox4math6Float3EE5valueEv(ptr noundef nonnull align 4 dereferenceable(16) %6)
  %19 = getelementptr inbounds %"struct.vox::math::Ray", ptr %13, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %18, i64 12, i1 false), !tbaa.struct !9
  br label %20

20:                                               ; preds = %17, %5
  %21 = call noundef zeroext i1 @_ZNKSt8optionalIN3vox4math6Float3EEcvbEv(ptr noundef nonnull align 4 dereferenceable(16) %7) #5
  br i1 %21, label %22, label %25

22:                                               ; preds = %20
  %23 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNRSt8optionalIN3vox4math6Float3EE5valueEv(ptr noundef nonnull align 4 dereferenceable(16) %7)
  %24 = getelementptr inbounds %"struct.vox::math::Ray", ptr %13, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %23, i64 12, i1 false), !tbaa.struct !9
  br label %25

25:                                               ; preds = %22, %20
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8optionalIN3vox4math6Float3EEcvbEv(ptr noundef nonnull align 4 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNRSt8optionalIN3vox4math6Float3EE5valueEv(ptr noundef nonnull align 4 dereferenceable(16)) #3 align 2

; 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) #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 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, 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"

%"class.std::optional" = type { %"struct.std::_Optional_base" }
%"struct.std::_Optional_base" = type { %"struct.std::_Optional_payload" }
%"struct.std::_Optional_payload" = type { %"struct.std::_Optional_payload_base.base", [3 x i8] }
%"struct.std::_Optional_payload_base.base" = type <{ %"union.std::_Optional_payload_base<vox::math::Float3>::_Storage", i8 }>
%"union.std::_Optional_payload_base<vox::math::Float3>::_Storage" = type { %"struct.vox::math::Float3" }
%"struct.vox::math::Float3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3vox4math3RayC2ESt8optionalINS0_6Float3EES4_(ptr noundef nonnull align 4 dereferenceable(24) %0, <2 x float> %1, i64 %2, <2 x float> %3, i64 %4) unnamed_addr #0 align 2 {
  %6 = alloca %"class.std::optional", align 8
  %7 = alloca %"class.std::optional", align 8
  store <2 x float> %1, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  store i64 %2, ptr %8, align 8
  store <2 x float> %3, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  store i64 %4, ptr %9, align 8
  tail call void @_ZN3vox4math6Float3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %0)
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  tail call void @_ZN3vox4math6Float3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10)
  %11 = call noundef zeroext i1 @_ZNKSt8optionalIN3vox4math6Float3EEcvbEv(ptr noundef nonnull align 4 dereferenceable(16) %6) #5
  br i1 %11, label %12, label %14

12:                                               ; preds = %5
  %13 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNRSt8optionalIN3vox4math6Float3EE5valueEv(ptr noundef nonnull align 4 dereferenceable(16) %6)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %13, i64 12, i1 false), !tbaa.struct !5
  br label %14

14:                                               ; preds = %12, %5
  %15 = call noundef zeroext i1 @_ZNKSt8optionalIN3vox4math6Float3EEcvbEv(ptr noundef nonnull align 4 dereferenceable(16) %7) #5
  br i1 %15, label %16, label %18

16:                                               ; preds = %14
  %17 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNRSt8optionalIN3vox4math6Float3EE5valueEv(ptr noundef nonnull align 4 dereferenceable(16) %7)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %17, i64 12, i1 false), !tbaa.struct !5
  br label %18

18:                                               ; preds = %16, %14
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8optionalIN3vox4math6Float3EEcvbEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNRSt8optionalIN3vox4math6Float3EE5valueEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress 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) #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 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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