; LLVM IR from Razakhel/RaZ :: src/RaZ/Utils/Shape.ll (ZNK3Raz4Line10intersectsERKNS_4AABBE)

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

; 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 { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmiERKS1_(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.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3Raz4Line10intersectsERKNS_4AABBE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) unnamed_addr #3 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.Raz::Ray", align 4
  %7 = alloca %"class.Raz::Vector", align 4
  %8 = alloca %"class.Raz::Vector", align 4
  %9 = alloca { <2 x float>, float }, align 8
  %10 = alloca { <2 x float>, float }, align 8
  %11 = alloca %"struct.Raz::RayHit", align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 36, ptr %6) #7
  %14 = getelementptr inbounds %"class.Raz::Line", ptr %13, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #7
  %15 = getelementptr inbounds %"class.Raz::Line", ptr %13, i32 0, i32 2
  %16 = getelementptr inbounds %"class.Raz::Line", ptr %13, i32 0, i32 1
  %17 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmiERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %15, ptr noundef nonnull align 4 dereferenceable(12) %16) #7
  %18 = getelementptr inbounds %"class.Raz::Vector", ptr %8, i32 0, i32 0
  %19 = getelementptr inbounds %"struct.std::array", ptr %18, i32 0, i32 0
  store { <2 x float>, float } %17, ptr %9, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 8 %9, i64 12, i1 false)
  %20 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EE9normalizeIfEENS0_IT_Lm3EEEv(ptr noundef nonnull align 4 dereferenceable(12) %8) #7
  %21 = getelementptr inbounds %"class.Raz::Vector", ptr %7, i32 0, i32 0
  %22 = getelementptr inbounds %"struct.std::array", ptr %21, i32 0, i32 0
  store { <2 x float>, float } %20, ptr %10, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 8 %10, i64 12, i1 false)
  call void @_ZN3Raz3RayC2ERKNS_6VectorIfLm3EEES4_(ptr noundef nonnull align 4 dereferenceable(36) %6, ptr noundef nonnull align 4 dereferenceable(12) %14, ptr noundef nonnull align 4 dereferenceable(12) %7) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 28, ptr %11) #7
  call void @_ZN3Raz6RayHitC2Ev(ptr noundef nonnull align 4 dereferenceable(28) %11) #7
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_4AABBEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36) %6, ptr noundef nonnull align 8 dereferenceable(32) %23, ptr noundef %11)
  br i1 %24, label %26, label %25

25:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %34

26:                                               ; preds = %2
  %27 = getelementptr inbounds %"struct.Raz::RayHit", ptr %11, i32 0, i32 2
  %28 = load float, ptr %27, align 4, !tbaa !9
  %29 = getelementptr inbounds %"struct.Raz::RayHit", ptr %11, i32 0, i32 2
  %30 = load float, ptr %29, align 4, !tbaa !9
  %31 = fmul float %28, %30
  %32 = call noundef float @_ZNK3Raz4Line20computeSquaredLengthEv(ptr noundef nonnull align 8 dereferenceable(32) %13)
  %33 = fcmp ole float %31, %32
  store i1 %33, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %34

34:                                               ; preds = %26, %25
  call void @llvm.lifetime.end.p0(i64 28, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 36, ptr %6) #7
  %35 = load i1, ptr %3, align 1
  ret i1 %35
}

; 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 void @_ZN3Raz3RayC2ERKNS_6VectorIfLm3EEES4_(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3Raz6RayHitC2Ev(ptr noundef nonnull align 4 dereferenceable(28)) unnamed_addr #4 align 2

declare noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_4AABBEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3Raz4Line20computeSquaredLengthEv(ptr noundef nonnull align 8 dereferenceable(32)) #6 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #5 = { "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 #6 = { 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 #7 = { 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, !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}


; 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::Ray" = type { %"class.Raz::Vector", %"class.Raz::Vector", %"class.Raz::Vector" }
%"class.Raz::Vector" = type { %"struct.std::array" }
%"struct.std::array" = type { [3 x float] }
%"struct.Raz::RayHit" = type { %"class.Raz::Vector", %"class.Raz::Vector", 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 { <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 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 noundef zeroext i1 @_ZNK3Raz4Line10intersectsERKNS_4AABBE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) unnamed_addr #2 align 2 {
  %3 = alloca %"class.Raz::Ray", align 4
  %4 = alloca %"class.Raz::Vector", align 8
  %5 = alloca %"class.Raz::Vector", align 8
  %6 = alloca %"struct.Raz::RayHit", align 4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %3) #6
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #6
  %8 = getelementptr inbounds i8, ptr %0, i64 20
  %9 = tail call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EEmiERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %7) #6
  %.fca.0.extract1 = extractvalue { <2 x float>, float } %9, 0
  %.fca.1.extract2 = extractvalue { <2 x float>, float } %9, 1
  store <2 x float> %.fca.0.extract1, ptr %5, align 8
  %.sroa.24.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract2, ptr %.sroa.24.0..sroa_idx, align 8
  %10 = call { <2 x float>, float } @_ZNK3Raz6VectorIfLm3EE9normalizeIfEENS0_IT_Lm3EEEv(ptr noundef nonnull align 4 dereferenceable(12) %5) #6
  %.fca.0.extract = extractvalue { <2 x float>, float } %10, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %10, 1
  store <2 x float> %.fca.0.extract, ptr %4, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @_ZN3Raz3RayC2ERKNS_6VectorIfLm3EEES4_(ptr noundef nonnull align 4 dereferenceable(36) %3, ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(12) %4) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %6) #6
  call void @_ZN3Raz6RayHitC2Ev(ptr noundef nonnull align 4 dereferenceable(28) %6) #6
  %11 = call noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_4AABBEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36) %3, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull %6)
  br i1 %11, label %12, label %18

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %6, i64 24
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = fmul float %14, %14
  %16 = call noundef float @_ZNK3Raz4Line20computeSquaredLengthEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %17 = fcmp ole float %15, %16
  br label %18

18:                                               ; preds = %2, %12
  %.0 = phi i1 [ %17, %12 ], [ false, %2 ]
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %3) #6
  ret i1 %.0
}

; 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 void @_ZN3Raz3RayC2ERKNS_6VectorIfLm3EEES4_(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3Raz6RayHitC2Ev(ptr noundef nonnull align 4 dereferenceable(28)) unnamed_addr #3 align 2

declare noundef zeroext i1 @_ZNK3Raz3Ray10intersectsERKNS_4AABBEPNS_6RayHitE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3Raz4Line20computeSquaredLengthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #5 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 = { 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 #3 = { inlinehint 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 = { "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 #5 = { 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 #6 = { 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, !11, i64 24}
!6 = !{!"_ZTSN3Raz6RayHitE", !7, i64 0, !7, i64 12, !11, i64 24}
!7 = !{!"_ZTSN3Raz6VectorIfLm3EEE", !8, i64 0}
!8 = !{!"_ZTSSt5arrayIfLm3EE", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}


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