; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Isect.ll (Z12R3IntersectsRK5R3RayRK6R3SpanP7R3PointPdS7_)

; 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"

@RN_EPSILON = external global double, align 8
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNK6R3Span3RayEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z11RNIsGreaterddd(double noundef, double noundef, double noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z9RNIsEqualddd(double noundef, double noundef, double noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z12R3IntersectsRK5R3RayS1_P7R3PointPdS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z12R3IntersectsRK5R3RayRK6R3SpanP7R3PointPdS7_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(80) %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store double 0.000000e+00, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNK6R3Span3RayEv(ptr noundef nonnull align 8 dereferenceable(80) %16)
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = call noundef i32 @_Z12R3IntersectsRK5R3RayS1_P7R3PointPdS4_(ptr noundef nonnull align 8 dereferenceable(48) %15, ptr noundef nonnull align 8 dereferenceable(48) %17, ptr noundef %18, ptr noundef %12, ptr noundef %13)
  switch i32 %19, label %72 [
    i32 0, label %20
    i32 4, label %21
    i32 3, label %22
    i32 1, label %51
  ]

20:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

21:                                               ; preds = %5
  store i32 4, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

22:                                               ; preds = %5
  %23 = load double, ptr %13, align 8, !tbaa !9
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = call noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80) %24)
  %26 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %27 = call noundef i32 @_Z11RNIsGreaterddd(double noundef %23, double noundef %25, double noundef %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %22
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

30:                                               ; preds = %22
  %31 = load double, ptr %13, align 8, !tbaa !9
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = call noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80) %32)
  %34 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %35 = call noundef i32 @_Z9RNIsEqualddd(double noundef %31, double noundef %33, double noundef %34)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %50

37:                                               ; preds = %30
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load double, ptr %12, align 8, !tbaa !9
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  store double %41, ptr %42, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %40, %37
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %49

46:                                               ; preds = %43
  %47 = load double, ptr %13, align 8, !tbaa !9
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  store double %47, ptr %48, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %46, %43
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

50:                                               ; preds = %30
  store i32 4, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

51:                                               ; preds = %5
  %52 = load double, ptr %13, align 8, !tbaa !9
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = call noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80) %53)
  %55 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %56 = call noundef i32 @_Z11RNIsGreaterddd(double noundef %52, double noundef %54, double noundef %55)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %51
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

59:                                               ; preds = %51
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %65

62:                                               ; preds = %59
  %63 = load double, ptr %12, align 8, !tbaa !9
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  store double %63, ptr %64, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %62, %59
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %71

68:                                               ; preds = %65
  %69 = load double, ptr %13, align 8, !tbaa !9
  %70 = load ptr, ptr %11, align 8, !tbaa !5
  store double %69, ptr %70, align 8, !tbaa !9
  br label %71

71:                                               ; preds = %68, %65
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

72:                                               ; preds = %5
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str)
  br label %73

73:                                               ; preds = %72
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str.1)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

74:                                               ; preds = %73, %71, %58, %50, %49, %29, %21, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %75 = load i32, ptr %6, align 4
  ret i32 %75
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = { "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 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 = { 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}


; 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"

@RN_EPSILON = external local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNK6R3Span3RayEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z11RNIsGreaterddd(double noundef, double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z9RNIsEqualddd(double noundef, double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z12R3IntersectsRK5R3RayS1_P7R3PointPdS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_Z12R3IntersectsRK5R3RayRK6R3SpanP7R3PointPdS7_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(80) %1, ptr noundef %2, ptr noundef writeonly %3, ptr noundef writeonly %4) local_unnamed_addr #4 {
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  %8 = tail call noundef nonnull align 8 dereferenceable(48) ptr @_ZNK6R3Span3RayEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %9 = call noundef i32 @_Z12R3IntersectsRK5R3RayS1_P7R3PointPdS4_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(48) %8, ptr noundef %2, ptr noundef nonnull %6, ptr noundef nonnull %7)
  switch i32 %9, label %37 [
    i32 0, label %38
    i32 4, label %38
    i32 3, label %10
    i32 1, label %26
  ]

10:                                               ; preds = %5
  %11 = load double, ptr %7, align 8, !tbaa !5
  %12 = call noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %13 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %14 = call noundef i32 @_Z11RNIsGreaterddd(double noundef %11, double noundef %12, double noundef %13)
  %.not19 = icmp eq i32 %14, 0
  br i1 %.not19, label %15, label %38

15:                                               ; preds = %10
  %16 = load double, ptr %7, align 8, !tbaa !5
  %17 = call noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %18 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %19 = call noundef i32 @_Z9RNIsEqualddd(double noundef %16, double noundef %17, double noundef %18)
  %.not20 = icmp eq i32 %19, 0
  br i1 %.not20, label %38, label %20

20:                                               ; preds = %15
  %.not21 = icmp eq ptr %3, null
  br i1 %.not21, label %23, label %21

21:                                               ; preds = %20
  %22 = load double, ptr %6, align 8, !tbaa !5
  store double %22, ptr %3, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %21, %20
  %.not22 = icmp eq ptr %4, null
  br i1 %.not22, label %38, label %24

24:                                               ; preds = %23
  %25 = load double, ptr %7, align 8, !tbaa !5
  store double %25, ptr %4, align 8, !tbaa !5
  br label %38

26:                                               ; preds = %5
  %27 = load double, ptr %7, align 8, !tbaa !5
  %28 = call noundef double @_ZNK6R3Span6LengthEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %29 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %30 = call noundef i32 @_Z11RNIsGreaterddd(double noundef %27, double noundef %28, double noundef %29)
  %.not = icmp eq i32 %30, 0
  br i1 %.not, label %31, label %38

31:                                               ; preds = %26
  %.not17 = icmp eq ptr %3, null
  br i1 %.not17, label %34, label %32

32:                                               ; preds = %31
  %33 = load double, ptr %6, align 8, !tbaa !5
  store double %33, ptr %3, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %32, %31
  %.not18 = icmp eq ptr %4, null
  br i1 %.not18, label %38, label %35

35:                                               ; preds = %34
  %36 = load double, ptr %7, align 8, !tbaa !5
  store double %36, ptr %4, align 8, !tbaa !5
  br label %38

37:                                               ; preds = %5
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str)
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str.1)
  br label %38

38:                                               ; preds = %5, %34, %35, %26, %15, %23, %24, %10, %5, %37
  %.0 = phi i32 [ 0, %37 ], [ %9, %5 ], [ 0, %10 ], [ 1, %24 ], [ 1, %23 ], [ 4, %15 ], [ 0, %26 ], [ 1, %35 ], [ 1, %34 ], [ %9, %5 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = { "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 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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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