; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics (R3SceneElement)

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

@R3null_vector = external global %class.R3Vector, align 8

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(56) ptr @_ZNK14R3SceneElement4BBoxEv(ptr noundef nonnull align 8 dereferenceable(96)) #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK14R3SceneElement5ShapeEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #0 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 i32 @_ZNK14R3SceneElement11FindClosestERK7R3PointPP7R3ShapePS0_P8R3VectorPddd(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, double noundef %6, double noundef %7) #2 align 2 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca %class.R3Point, align 8
  %24 = alloca double, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store double %6, ptr %16, align 8, !tbaa !9
  store double %7, ptr %17, align 8, !tbaa !9
  %25 = load ptr, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = call noundef nonnull align 8 dereferenceable(56) ptr @_ZNK14R3SceneElement4BBoxEv(ptr noundef nonnull align 8 dereferenceable(96) %25)
  %28 = call noundef double @_Z10R3DistanceRK7R3PointRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 8 dereferenceable(56) %27)
  store double %28, ptr %18, align 8, !tbaa !9
  %29 = load double, ptr %18, align 8, !tbaa !9
  %30 = load double, ptr %17, align 8, !tbaa !9
  %31 = fcmp ogt double %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %8
  store i32 0, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %88

33:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  store i32 0, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  store i32 0, ptr %21, align 4, !tbaa !11
  br label %34

34:                                               ; preds = %83, %33
  %35 = load i32, ptr %21, align 4, !tbaa !11
  %36 = call noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96) %25)
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 2, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  br label %86

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %40 = load i32, ptr %21, align 4, !tbaa !11
  %41 = call noundef ptr @_ZNK14R3SceneElement5ShapeEi(ptr noundef nonnull align 8 dereferenceable(96) %25, i32 noundef %40)
  store ptr %41, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %23) #4
  %42 = load ptr, ptr %22, align 8, !tbaa !5
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %42, align 8, !tbaa !13
  %45 = getelementptr inbounds ptr, ptr %44, i64 14
  %46 = load ptr, ptr %45, align 8
  call void %46(ptr dead_on_unwind writable sret(%class.R3Point) align 8 %23, ptr noundef nonnull align 8 dereferenceable(8) %42, ptr noundef nonnull align 8 dereferenceable(24) %43)
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 8 dereferenceable(24) %47)
  store double %48, ptr %24, align 8, !tbaa !9
  %49 = load double, ptr %24, align 8, !tbaa !9
  %50 = load double, ptr %16, align 8, !tbaa !9
  %51 = fcmp oge double %49, %50
  br i1 %51, label %52, label %82

52:                                               ; preds = %39
  %53 = load double, ptr %24, align 8, !tbaa !9
  %54 = load double, ptr %17, align 8, !tbaa !9
  %55 = fcmp ole double %53, %54
  br i1 %55, label %56, label %82

56:                                               ; preds = %52
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %62

59:                                               ; preds = %56
  %60 = load ptr, ptr %22, align 8, !tbaa !5
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %60, ptr %61, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %59, %56
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %68

65:                                               ; preds = %62
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %66, ptr noundef nonnull align 8 dereferenceable(24) %23)
  br label %68

68:                                               ; preds = %65, %62
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %74

71:                                               ; preds = %68
  %72 = load ptr, ptr %14, align 8, !tbaa !5
  %73 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %72, ptr noundef nonnull align 8 dereferenceable(24) @R3null_vector)
  br label %74

74:                                               ; preds = %71, %68
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %80

77:                                               ; preds = %74
  %78 = load double, ptr %24, align 8, !tbaa !9
  %79 = load ptr, ptr %15, align 8, !tbaa !5
  store double %78, ptr %79, align 8, !tbaa !9
  br label %80

80:                                               ; preds = %77, %74
  store i32 1, ptr %20, align 4, !tbaa !11
  %81 = load double, ptr %24, align 8, !tbaa !9
  store double %81, ptr %17, align 8, !tbaa !9
  br label %82

82:                                               ; preds = %80, %52, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %21, align 4, !tbaa !11
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %21, align 4, !tbaa !11
  br label %34, !llvm.loop !15

86:                                               ; preds = %38
  %87 = load i32, ptr %20, align 4, !tbaa !11
  store i32 %87, ptr %9, align 4
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  br label %88

88:                                               ; preds = %86, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  %89 = load i32, ptr %9, align 4
  ret i32 %89
}

declare noundef double @_Z10R3DistanceRK7R3PointRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(56)) #3

declare noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #3

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

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

attributes #0 = { 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 #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 = { "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}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

@R3null_vector = external global %class.R3Vector, align 8

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(56) ptr @_ZNK14R3SceneElement4BBoxEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK14R3SceneElement5ShapeEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) local_unnamed_addr #0 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 uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK14R3SceneElement11FindClosestERK7R3PointPP7R3ShapePS0_P8R3VectorPddd(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef writeonly %2, ptr noundef %3, ptr noundef %4, ptr noundef writeonly %5, double noundef %6, double noundef %7) local_unnamed_addr #2 align 2 {
  %9 = alloca %class.R3Point, align 8
  %10 = tail call noundef nonnull align 8 dereferenceable(56) ptr @_ZNK14R3SceneElement4BBoxEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %11 = tail call noundef double @_Z10R3DistanceRK7R3PointRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(56) %10)
  %12 = fcmp ogt double %11, %7
  br i1 %12, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %8
  %13 = tail call noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %.not = icmp eq ptr %2, null
  %.not36 = icmp eq ptr %3, null
  %.not37 = icmp eq ptr %4, null
  %.not38 = icmp eq ptr %5, null
  br i1 %.not36, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %29
  %.02641.us = phi double [ %.1.us, %29 ], [ %7, %.lr.ph ]
  %.02740.us = phi i32 [ %30, %29 ], [ 0, %.lr.ph ]
  %.02839.us = phi i32 [ %.129.us, %29 ], [ 0, %.lr.ph ]
  %15 = call noundef ptr @_ZNK14R3SceneElement5ShapeEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %.02740.us)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #4
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 112
  %18 = load ptr, ptr %17, align 8
  call void %18(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %19 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %20 = fcmp ult double %19, %6
  %21 = fcmp ugt double %19, %.02641.us
  %or.cond.us = select i1 %20, i1 true, i1 %21
  br i1 %or.cond.us, label %29, label %22

22:                                               ; preds = %.lr.ph.split.us
  br i1 %.not, label %24, label %23

23:                                               ; preds = %22
  store ptr %15, ptr %2, align 8, !tbaa !8
  br label %24

24:                                               ; preds = %23, %22
  br i1 %.not37, label %27, label %25

25:                                               ; preds = %24
  %26 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) @R3null_vector)
  br label %27

27:                                               ; preds = %25, %24
  br i1 %.not38, label %29, label %28

28:                                               ; preds = %27
  store double %19, ptr %5, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %28, %27, %.lr.ph.split.us
  %.129.us = phi i32 [ %.02839.us, %.lr.ph.split.us ], [ 1, %28 ], [ 1, %27 ]
  %.1.us = phi double [ %.02641.us, %.lr.ph.split.us ], [ %19, %28 ], [ %19, %27 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #4
  %30 = add nuw nsw i32 %.02740.us, 1
  %31 = call noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %.lr.ph.split.us, label %.loopexit, !llvm.loop !13

.lr.ph.split:                                     ; preds = %.lr.ph
  br i1 %.not37, label %.lr.ph.split.split.us, label %.lr.ph.split.split

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split, %45
  %.02641.us42 = phi double [ %.1.us47, %45 ], [ %7, %.lr.ph.split ]
  %.02740.us43 = phi i32 [ %46, %45 ], [ 0, %.lr.ph.split ]
  %.02839.us44 = phi i32 [ %.129.us46, %45 ], [ 0, %.lr.ph.split ]
  %33 = call noundef ptr @_ZNK14R3SceneElement5ShapeEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %.02740.us43)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #4
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 112
  %36 = load ptr, ptr %35, align 8
  call void %36(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(8) %33, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %37 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %38 = fcmp ult double %37, %6
  %39 = fcmp ugt double %37, %.02641.us42
  %or.cond.us45 = select i1 %38, i1 true, i1 %39
  br i1 %or.cond.us45, label %45, label %40

40:                                               ; preds = %.lr.ph.split.split.us
  br i1 %.not, label %42, label %41

41:                                               ; preds = %40
  store ptr %33, ptr %2, align 8, !tbaa !8
  br label %42

42:                                               ; preds = %41, %40
  %43 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %9)
  br i1 %.not38, label %45, label %44

44:                                               ; preds = %42
  store double %37, ptr %5, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %44, %42, %.lr.ph.split.split.us
  %.129.us46 = phi i32 [ %.02839.us44, %.lr.ph.split.split.us ], [ 1, %44 ], [ 1, %42 ]
  %.1.us47 = phi double [ %.02641.us42, %.lr.ph.split.split.us ], [ %37, %44 ], [ %37, %42 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #4
  %46 = add nuw nsw i32 %.02740.us43, 1
  %47 = call noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %.lr.ph.split.split.us, label %.loopexit, !llvm.loop !13

.lr.ph.split.split:                               ; preds = %.lr.ph.split
  br i1 %.not, label %.lr.ph.split.split.split.us, label %.lr.ph.split.split.split

.lr.ph.split.split.split.us:                      ; preds = %.lr.ph.split.split, %60
  %.02641.us50 = phi double [ %.1.us55, %60 ], [ %7, %.lr.ph.split.split ]
  %.02740.us51 = phi i32 [ %61, %60 ], [ 0, %.lr.ph.split.split ]
  %.02839.us52 = phi i32 [ %.129.us54, %60 ], [ 0, %.lr.ph.split.split ]
  %49 = call noundef ptr @_ZNK14R3SceneElement5ShapeEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %.02740.us51)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #4
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 112
  %52 = load ptr, ptr %51, align 8
  call void %52(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(8) %49, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %53 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %54 = fcmp ult double %53, %6
  %55 = fcmp ugt double %53, %.02641.us50
  %or.cond.us53 = select i1 %54, i1 true, i1 %55
  br i1 %or.cond.us53, label %60, label %56

56:                                               ; preds = %.lr.ph.split.split.split.us
  %57 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %9)
  %58 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) @R3null_vector)
  br i1 %.not38, label %60, label %59

59:                                               ; preds = %56
  store double %53, ptr %5, align 8, !tbaa !11
  br label %60

60:                                               ; preds = %59, %56, %.lr.ph.split.split.split.us
  %.129.us54 = phi i32 [ %.02839.us52, %.lr.ph.split.split.split.us ], [ 1, %59 ], [ 1, %56 ]
  %.1.us55 = phi double [ %.02641.us50, %.lr.ph.split.split.split.us ], [ %53, %59 ], [ %53, %56 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #4
  %61 = add nuw nsw i32 %.02740.us51, 1
  %62 = call noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %.lr.ph.split.split.split.us, label %.loopexit, !llvm.loop !13

.lr.ph.split.split.split:                         ; preds = %.lr.ph.split.split, %75
  %.02641 = phi double [ %.1, %75 ], [ %7, %.lr.ph.split.split ]
  %.02740 = phi i32 [ %76, %75 ], [ 0, %.lr.ph.split.split ]
  %.02839 = phi i32 [ %.129, %75 ], [ 0, %.lr.ph.split.split ]
  %64 = call noundef ptr @_ZNK14R3SceneElement5ShapeEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %.02740)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #4
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i64 112
  %67 = load ptr, ptr %66, align 8
  call void %67(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(8) %64, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %68 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %69 = fcmp ult double %68, %6
  %70 = fcmp ugt double %68, %.02641
  %or.cond = select i1 %69, i1 true, i1 %70
  br i1 %or.cond, label %75, label %71

71:                                               ; preds = %.lr.ph.split.split.split
  store ptr %64, ptr %2, align 8, !tbaa !8
  %72 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %9)
  %73 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN8R3VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) @R3null_vector)
  br i1 %.not38, label %75, label %74

74:                                               ; preds = %71
  store double %68, ptr %5, align 8, !tbaa !11
  br label %75

75:                                               ; preds = %71, %74, %.lr.ph.split.split.split
  %.129 = phi i32 [ %.02839, %.lr.ph.split.split.split ], [ 1, %74 ], [ 1, %71 ]
  %.1 = phi double [ %.02641, %.lr.ph.split.split.split ], [ %68, %74 ], [ %68, %71 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #4
  %76 = add nuw nsw i32 %.02740, 1
  %77 = call noundef i32 @_ZNK14R3SceneElement7NShapesEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %78 = icmp slt i32 %76, %77
  br i1 %78, label %.lr.ph.split.split.split, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %75, %60, %45, %29, %.preheader, %8
  %.0 = phi i32 [ 0, %8 ], [ 0, %.preheader ], [ %.129.us, %29 ], [ %.129.us46, %45 ], [ %.129.us54, %60 ], [ %.129, %75 ]
  ret i32 %.0
}

declare noundef double @_Z10R3DistanceRK7R3PointRK5R3Box(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #3

declare noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

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 #3

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 #3

attributes #0 = { 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 #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 = { "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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass