; LLVM IR from Razakhel/RaZ :: src/RaZ/Utils/Ray.ll (ZNK3Raz3Ray10intersectsERKNS_5PlaneEPNS_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: 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) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_5PlaneEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef %2) #3 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca %"class.Raz::Vector", align 4
  %13 = alloca %"class.Raz::Vector", align 4
  %14 = alloca { <2 x float>, float }, align 8
  %15 = 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
  %16 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %17 = getelementptr inbounds %"class.Raz::Ray", ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3Raz5Plane9getNormalEv(ptr noundef nonnull align 8 dereferenceable(24) %18)
  %20 = call noundef float @_ZNK3Raz6VectorIfLm3EE3dotIfEET_RKS1_(ptr noundef nonnull align 4 dereferenceable(12) %17, ptr noundef nonnull align 4 dereferenceable(12) %19) #4
  store float %20, ptr %8, align 4, !tbaa !9
  %21 = load float, ptr %8, align 4, !tbaa !9
  %22 = fcmp oge float %21, 0.000000e+00
  br i1 %22, label %23, label %24

23:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %62

24:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %25 = getelementptr inbounds %"class.Raz::Ray", ptr %16, i32 0, i32 0
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3Raz5Plane9getNormalEv(ptr noundef nonnull align 8 dereferenceable(24) %26)
  %28 = call noundef float @_ZNK3Raz6VectorIfLm3EE3dotIfEET_RKS1_(ptr noundef nonnull align 4 dereferenceable(12) %25, ptr noundef nonnull align 4 dereferenceable(12) %27) #4
  store float %28, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call noundef float @_ZNK3Raz5Plane11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(24) %29)
  %31 = load float, ptr %10, align 4, !tbaa !9
  %32 = fsub float %30, %31
  %33 = load float, ptr %8, align 4, !tbaa !9
  %34 = fdiv float %32, %33
  store float %34, ptr %11, align 4, !tbaa !9
  %35 = load float, ptr %11, align 4, !tbaa !9
  %36 = fcmp ole float %35, 0.000000e+00
  br i1 %36, label %37, label %38

37:                                               ; preds = %24
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %61

38:                                               ; preds = %24
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %60

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

60:                                               ; preds = %41, %38
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %61

61:                                               ; preds = %60, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %62

62:                                               ; preds = %61, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %63 = load i1, ptr %4, align 1
  ret i1 %63
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3Raz5Plane9getNormalEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3Raz5Plane11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"="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 #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 = !{!"float", !7, i64 0}
!11 = !{i64 0, i64 12, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !10, i64 24}
!14 = !{!"_ZTSN3Raz6RayHitE", !15, i64 0, !15, i64 12, !10, i64 24}
!15 = !{!"_ZTSN3Raz6VectorIfLm3EEE", !16, i64 0}
!16 = !{!"_ZTSSt5arrayIfLm3EE", !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 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) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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 #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_5PlaneEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef writeonly %2) local_unnamed_addr #3 align 2 {
  %4 = alloca %"class.Raz::Vector", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3Raz5Plane9getNormalEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %7 = tail call noundef float @_ZNK3Raz6VectorIfLm3EE3dotIfEET_RKS1_(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %6) #4
  %8 = fcmp ult float %7, 0.000000e+00
  br i1 %8, label %9, label %22

9:                                                ; preds = %3
  %10 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3Raz5Plane9getNormalEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %11 = tail call noundef float @_ZNK3Raz6VectorIfLm3EE3dotIfEET_RKS1_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %10) #4
  %12 = tail call noundef float @_ZNK3Raz5Plane11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %13 = fsub float %12, %11
  %14 = fdiv float %13, %7
  %15 = fcmp ugt float %14, 0.000000e+00
  %.not = icmp ne ptr %2, null
  %or.cond.not = and i1 %.not, %15
  br i1 %or.cond.not, label %16, label %22

16:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  %17 = tail call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmlEf(ptr noundef nonnull align 4 dereferenceable(12) %5, float noundef %14) #4
  %.fca.0.extract1 = extractvalue { <2 x float>, float } %17, 0
  %.fca.1.extract2 = extractvalue { <2 x float>, float } %17, 1
  store <2 x float> %.fca.0.extract1, ptr %4, align 8
  %.sroa.24.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store float %.fca.1.extract2, ptr %.sroa.24.0..sroa_idx, align 8
  %18 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEplERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %4) #4
  %.fca.0.extract = extractvalue { <2 x float>, float } %18, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %18, 1
  store <2 x float> %.fca.0.extract, ptr %2, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  store float %.fca.1.extract, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  %19 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3Raz5Plane9getNormalEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %20 = getelementptr inbounds i8, ptr %2, i64 12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(12) %19, i64 12, i1 false), !tbaa.struct !8
  %21 = getelementptr inbounds i8, ptr %2, i64 24
  store float %14, ptr %21, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %9, %16, %3
  %.1 = phi i1 [ false, %3 ], [ true, %16 ], [ %15, %9 ]
  ret i1 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3Raz5Plane9getNormalEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3Raz5Plane11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

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

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


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