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

; 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.R3Point = type { [3 x double] }
%class.R3Plane = type { %class.R3Vector, double }
%class.R3Vector = type { [3 x double] }

@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [28 x i8], align 1

declare noundef i32 @_Z10R3ContainsRK11R3RectangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef nonnull align 8 dereferenceable(24)) #0

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

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

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #0

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

declare void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0

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

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z12R3IntersectsRK5R3RayRK11R3RectangleP7R3PointP8R3VectorPd(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(120) %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %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 %class.R3Point, align 8
  %13 = alloca double, align 8
  %14 = alloca %class.R3Plane, align 8
  %15 = 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
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = call noundef i32 @_ZNK11R3Rectangle7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(120) %16)
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  br label %55

20:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #4
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %12)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZNK11R3Rectangle5PlaneEv(ptr dead_on_unwind writable sret(%class.R3Plane) align 8 %14, ptr noundef nonnull align 8 dereferenceable(120) %22)
  %23 = call noundef i32 @_Z12R3IntersectsRK5R3RayRK7R3PlaneP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(48) %21, ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef %12, ptr noundef %13)
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #4
  switch i32 %23, label %52 [
    i32 0, label %24
    i32 1, label %25
    i32 3, label %51
  ]

24:                                               ; preds = %20
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %54

25:                                               ; preds = %20
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call noundef i32 @_Z10R3ContainsRK11R3RectangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(120) %26, ptr noundef nonnull align 8 dereferenceable(24) %12)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %54

30:                                               ; preds = %25
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %34, ptr noundef nonnull align 8 dereferenceable(24) %12)
  br label %36

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

39:                                               ; preds = %36
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3Rectangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(120) %40)
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %42, ptr noundef nonnull align 8 dereferenceable(24) %41)
  br label %44

44:                                               ; preds = %39, %36
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %50

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

50:                                               ; preds = %47, %44
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %54

51:                                               ; preds = %20
  store i32 4, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %54

52:                                               ; preds = %20
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str.2)
  br label %53

53:                                               ; preds = %52
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str.1)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %54

54:                                               ; preds = %53, %51, %50, %29, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #4
  br label %55

55:                                               ; preds = %54, %19
  %56 = load i32, ptr %6, align 4
  ret i32 %56
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK11R3Rectangle7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(120)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK11R3Rectangle5PlaneEv(ptr dead_on_unwind noalias writable sret(%class.R3Plane) align 8, ptr noundef nonnull align 8 dereferenceable(120)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3Rectangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(120)) #3 align 2

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

%class.R3Point = type { [3 x double] }
%class.R3Plane = type { %class.R3Vector, double }
%class.R3Vector = type { [3 x double] }

@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [28 x i8], align 1

declare noundef i32 @_Z10R3ContainsRK11R3RectangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0

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

declare void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0

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

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_Z12R3IntersectsRK5R3RayRK11R3RectangleP7R3PointP8R3VectorPd(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(120) %1, ptr noundef %2, ptr noundef %3, ptr noundef writeonly %4) local_unnamed_addr #2 {
  %6 = alloca %class.R3Point, align 8
  %7 = alloca double, align 8
  %8 = alloca %class.R3Plane, align 8
  %9 = tail call noundef i32 @_ZNK11R3Rectangle7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(120) %1)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %27

10:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #4
  call void @_ZNK11R3Rectangle5PlaneEv(ptr dead_on_unwind nonnull writable sret(%class.R3Plane) align 8 %8, ptr noundef nonnull align 8 dereferenceable(120) %1)
  %11 = call noundef i32 @_Z12R3IntersectsRK5R3RayRK7R3PlaneP7R3PointPd(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull %6, ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #4
  switch i32 %11, label %25 [
    i32 0, label %26
    i32 1, label %12
    i32 3, label %24
  ]

12:                                               ; preds = %10
  %13 = call noundef i32 @_Z10R3ContainsRK11R3RectangleRK7R3Point(ptr noundef nonnull align 8 dereferenceable(120) %1, ptr noundef nonnull align 8 dereferenceable(24) %6)
  %.not14 = icmp eq i32 %13, 0
  br i1 %.not14, label %26, label %14

14:                                               ; preds = %12
  %.not15 = icmp eq ptr %2, null
  br i1 %.not15, label %17, label %15

15:                                               ; preds = %14
  %16 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %6)
  br label %17

17:                                               ; preds = %15, %14
  %.not16 = icmp eq ptr %3, null
  br i1 %.not16, label %21, label %18

18:                                               ; preds = %17
  %19 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3Rectangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(120) %1)
  %20 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %19)
  br label %21

21:                                               ; preds = %18, %17
  %.not17 = icmp eq ptr %4, null
  br i1 %.not17, label %26, label %22

22:                                               ; preds = %21
  %23 = load double, ptr %7, align 8, !tbaa !5
  store double %23, ptr %4, align 8, !tbaa !5
  br label %26

24:                                               ; preds = %10
  br label %26

25:                                               ; preds = %10
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str.2)
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str.1)
  br label %26

26:                                               ; preds = %21, %22, %12, %10, %25, %24
  %.0 = phi i32 [ 0, %25 ], [ 4, %24 ], [ %11, %10 ], [ 0, %12 ], [ 1, %22 ], [ 1, %21 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  br label %27

27:                                               ; preds = %5, %26
  %.1 = phi i32 [ %.0, %26 ], [ 0, %5 ]
  ret i32 %.1
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK11R3Rectangle7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(120)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK11R3Rectangle5PlaneEv(ptr dead_on_unwind noalias writable sret(%class.R3Plane) align 8, ptr noundef nonnull align 8 dereferenceable(120)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3Rectangle6NormalEv(ptr noundef nonnull align 8 dereferenceable(120)) local_unnamed_addr #3 align 2

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