; LLVM IR from Razakhel/RaZ :: src/RaZ/Utils/Ray.ll (ZNK3Raz3Ray10intersectsERKNS_6VectorIfLm3EEEPNS_6RayHitE)

; 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.Raz::Vector" = type { %"struct.std::array" }
%"struct.std::array" = type { [3 x float] }
%"class.Raz::Ray" = type { %"class.Raz::Vector", %"class.Raz::Vector", %"class.Raz::Vector" }
%"struct.Raz::RayHit" = type { %"class.Raz::Vector", %"class.Raz::Vector", float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_6VectorIfLm3EEEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef %2) #0 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.Raz::Vector", align 4
  %9 = alloca { <2 x float>, float }, align 8
  %10 = alloca %"class.Raz::Vector", align 4
  %11 = alloca { <2 x float>, float }, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.Raz::Vector", align 4
  %14 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.Raz::Ray", ptr %15, i32 0, i32 0
  %18 = call noundef zeroext i1 @_ZNK3Raz6VectorIfLm3EEeqERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %16, ptr noundef nonnull align 4 dereferenceable(12) %17) #4
  br i1 %18, label %19, label %29

19:                                               ; preds = %3
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %28

22:                                               ; preds = %19
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.Raz::RayHit", ptr %24, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %23, i64 12, i1 false), !tbaa.struct !9
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.Raz::RayHit", ptr %26, i32 0, i32 2
  store float 0.000000e+00, ptr %27, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %22, %19
  store i1 true, ptr %4, align 1
  br label %60

29:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #4
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.Raz::Ray", ptr %15, i32 0, i32 0
  %32 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmiERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %30, ptr noundef nonnull align 4 dereferenceable(12) %31) #4
  %33 = getelementptr inbounds %"class.Raz::Vector", ptr %8, i32 0, i32 0
  %34 = getelementptr inbounds %"struct.std::array", ptr %33, i32 0, i32 0
  store { <2 x float>, float } %32, ptr %9, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 8 %9, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #4
  %35 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EE9normalizeIfEENS0_IT_Lm3EEEv(ptr noundef nonnull align 4 dereferenceable(12) %8) #4
  %36 = getelementptr inbounds %"class.Raz::Vector", ptr %10, i32 0, i32 0
  %37 = getelementptr inbounds %"struct.std::array", ptr %36, i32 0, i32 0
  store { <2 x float>, float } %35, ptr %11, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %37, ptr align 8 %11, i64 12, i1 false)
  %38 = getelementptr inbounds %"class.Raz::Ray", ptr %15, i32 0, i32 1
  %39 = call noundef float @_ZNK3Raz6VectorIfLm3EE3dotIfEET_RKS1_(ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %38) #4
  %40 = call noundef float @_ZNSt14numeric_limitsIfE7epsilonEv() #4
  %41 = call noundef zeroext i1 @_ZN3Raz10FloatUtils14areNearlyEqualIffEEbT_S2_T0_(float noundef %39, float noundef 1.000000e+00, float noundef %40) #4
  br i1 %41, label %43, label %42

42:                                               ; preds = %29
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %59

43:                                               ; preds = %29
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %58

46:                                               ; preds = %43
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.Raz::RayHit", ptr %48, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %47, i64 12, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #4
  %50 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEngEv(ptr noundef nonnull align 4 dereferenceable(12) %10) #4
  %51 = getelementptr inbounds %"class.Raz::Vector", ptr %13, i32 0, i32 0
  %52 = getelementptr inbounds %"struct.std::array", ptr %51, i32 0, i32 0
  store { <2 x float>, float } %50, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %52, ptr align 8 %14, i64 12, i1 false)
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.Raz::RayHit", ptr %53, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %54, ptr align 4 %13, i64 12, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #4
  %55 = call noundef float @_ZNK3Raz6VectorIfLm3EE13computeLengthIfEET_v(ptr noundef nonnull align 4 dereferenceable(12) %8) #4
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.Raz::RayHit", ptr %56, i32 0, i32 2
  store float %55, ptr %57, align 4, !tbaa !11
  br label %58

58:                                               ; preds = %46, %43
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %59

59:                                               ; preds = %58, %42
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #4
  br label %60

60:                                               ; preds = %59, %28
  %61 = load i1, ptr %4, align 1
  ret i1 %61
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3Raz6VectorIfLm3EEeqERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1 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) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmiERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EE9normalizeIfEENS0_IT_Lm3EEEv(ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3Raz10FloatUtils14areNearlyEqualIffEEbT_S2_T0_(float noundef, float noundef, float noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNSt14numeric_limitsIfE7epsilonEv() #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEngEv(ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

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

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

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 12, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !15, i64 24}
!12 = !{!"_ZTSN3Raz6RayHitE", !13, i64 0, !13, i64 12, !15, i64 24}
!13 = !{!"_ZTSN3Raz6VectorIfLm3EEE", !14, i64 0}
!14 = !{!"_ZTSSt5arrayIfLm3EE", !7, i64 0}
!15 = !{!"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.Raz::Vector" = type { %"struct.std::array" }
%"struct.std::array" = type { [3 x float] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_6VectorIfLm3EEEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef writeonly %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"class.Raz::Vector", align 8
  %5 = alloca %"class.Raz::Vector", align 8
  %6 = tail call noundef zeroext i1 @_ZNK3Raz6VectorIfLm3EEeqERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %0) #4
  br i1 %6, label %7, label %10

7:                                                ; preds = %3
  %.not24 = icmp eq ptr %2, null
  br i1 %.not24, label %23, label %8

8:                                                ; preds = %7
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !5
  %9 = getelementptr inbounds i8, ptr %2, i64 24
  store float 0.000000e+00, ptr %9, align 4, !tbaa !9
  br label %23

10:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  %11 = tail call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmiERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %0) #4
  %.fca.0.extract6 = extractvalue { <2 x float>, float } %11, 0
  %.fca.1.extract7 = extractvalue { <2 x float>, float } %11, 1
  store <2 x float> %.fca.0.extract6, ptr %4, align 8
  %.sroa.29.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store float %.fca.1.extract7, ptr %.sroa.29.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  %12 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EE9normalizeIfEENS0_IT_Lm3EEEv(ptr noundef nonnull align 4 dereferenceable(12) %4) #4
  %.fca.0.extract2 = extractvalue { <2 x float>, float } %12, 0
  %.fca.1.extract3 = extractvalue { <2 x float>, float } %12, 1
  store <2 x float> %.fca.0.extract2, ptr %5, align 8
  %.sroa.25.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract3, ptr %.sroa.25.0..sroa_idx, align 8
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = call noundef float @_ZNK3Raz6VectorIfLm3EE3dotIfEET_RKS1_(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %13) #4
  %15 = call noundef float @_ZNSt14numeric_limitsIfE7epsilonEv() #4
  %16 = call noundef zeroext i1 @_ZN3Raz10FloatUtils14areNearlyEqualIffEEbT_S2_T0_(float noundef %14, float noundef 1.000000e+00, float noundef %15) #4
  %.not = icmp ne ptr %2, null
  %or.cond.not = and i1 %.not, %16
  br i1 %or.cond.not, label %17, label %22

17:                                               ; preds = %10
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !5
  %18 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEngEv(ptr noundef nonnull align 4 dereferenceable(12) %5) #4
  %.fca.0.extract = extractvalue { <2 x float>, float } %18, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %18, 1
  %19 = getelementptr inbounds i8, ptr %2, i64 12
  store <2 x float> %.fca.0.extract, ptr %19, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 20
  store float %.fca.1.extract, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !6
  %20 = call noundef float @_ZNK3Raz6VectorIfLm3EE13computeLengthIfEET_v(ptr noundef nonnull align 4 dereferenceable(12) %4) #4
  %21 = getelementptr inbounds i8, ptr %2, i64 24
  store float %20, ptr %21, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %17, %10
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  br label %23

23:                                               ; preds = %7, %8, %22
  %.1 = phi i1 [ %16, %22 ], [ true, %8 ], [ true, %7 ]
  ret i1 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3Raz6VectorIfLm3EEeqERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 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) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmiERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EE9normalizeIfEENS0_IT_Lm3EEEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3Raz10FloatUtils14areNearlyEqualIffEEbT_S2_T0_(float noundef, float noundef, float noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNSt14numeric_limitsIfE7epsilonEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEngEv(ptr noundef nonnull align 4 dereferenceable(12)) local_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) #3

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

attributes #0 = { 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 #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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 12, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !13, i64 24}
!10 = !{!"_ZTSN3Raz6RayHitE", !11, i64 0, !11, i64 12, !13, i64 24}
!11 = !{!"_ZTSN3Raz6VectorIfLm3EEE", !12, i64 0}
!12 = !{!"_ZTSSt5arrayIfLm3EE", !7, i64 0}
!13 = !{!"float", !7, i64 0}


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