; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Polygon.ll (ZNK9R2Polygon6NormalEid)

; 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.R2Vector = type { [2 x double] }
%class.R2Polygon = type <{ %class.R2Solid, ptr, i32, [4 x i8], %class.R2Box, i32, [4 x i8] }>
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Point = type { [2 x double] }

@R2null_vector = external global %class.R2Vector, align 8

; 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

declare noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK9R2Polygon6NormalEid(ptr dead_on_unwind noalias writable sret(%class.R2Vector) align 8 %0, ptr noundef nonnull align 8 dereferenceable(68) %1, i32 noundef %2, double noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  %18 = alloca %class.R2Vector, align 8
  %19 = alloca %class.R2Vector, align 8
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !11
  %20 = load ptr, ptr %6, align 8
  %21 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = icmp slt i32 %22, 3
  br i1 %23, label %24, label %25

24:                                               ; preds = %4
  call void @_ZN8R2VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) @R2null_vector)
  br label %165

25:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %26 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !19
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = sub nsw i32 %28, 1
  %30 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = add nsw i32 %29, %31
  %33 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !13
  %35 = srem i32 %32, %34
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds %class.R2Point, ptr %27, i64 %36
  store ptr %37, ptr %9, align 8, !tbaa !5
  %38 = load double, ptr %8, align 8, !tbaa !11
  %39 = fcmp ogt double %38, 0.000000e+00
  br i1 %39, label %40, label %91

40:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %41, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %class.R2Point, ptr %44, i64 %46
  %48 = call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef nonnull align 8 dereferenceable(16) %47)
  store double %48, ptr %11, align 8, !tbaa !11
  %49 = load double, ptr %11, align 8, !tbaa !11
  %50 = load double, ptr %8, align 8, !tbaa !11
  %51 = fcmp olt double %49, %50
  br i1 %51, label %52, label %90

52:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 2, ptr %12, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %85, %52
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !13
  %57 = sdiv i32 %56, 3
  %58 = icmp slt i32 %54, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %53
  store i32 2, ptr %13, align 4
  br label %88

60:                                               ; preds = %53
  %61 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = sub nsw i32 %63, %64
  %66 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %67 = load i32, ptr %66, align 8, !tbaa !13
  %68 = add nsw i32 %65, %67
  %69 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !13
  %71 = srem i32 %68, %70
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %class.R2Point, ptr %62, i64 %72
  store ptr %73, ptr %9, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %74, ptr noundef nonnull align 8 dereferenceable(16) %75)
  %77 = load double, ptr %11, align 8, !tbaa !11
  %78 = fadd double %77, %76
  store double %78, ptr %11, align 8, !tbaa !11
  %79 = load double, ptr %11, align 8, !tbaa !11
  %80 = load double, ptr %8, align 8, !tbaa !11
  %81 = fcmp oge double %79, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %60
  store i32 2, ptr %13, align 4
  br label %88

83:                                               ; preds = %60
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %84, ptr %10, align 8, !tbaa !5
  br label %85

85:                                               ; preds = %83
  %86 = load i32, ptr %12, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %12, align 4, !tbaa !9
  br label %53, !llvm.loop !20

88:                                               ; preds = %82, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %91

91:                                               ; preds = %90, %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %92 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 1
  %93 = load ptr, ptr %92, align 8, !tbaa !19
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  %96 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %97 = load i32, ptr %96, align 8, !tbaa !13
  %98 = srem i32 %95, %97
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds %class.R2Point, ptr %93, i64 %99
  store ptr %100, ptr %14, align 8, !tbaa !5
  %101 = load double, ptr %8, align 8, !tbaa !11
  %102 = fcmp ogt double %101, 0.000000e+00
  br i1 %102, label %103, label %151

103:                                              ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %104 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %104, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %105 = load ptr, ptr %14, align 8, !tbaa !5
  %106 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 1
  %107 = load ptr, ptr %106, align 8, !tbaa !19
  %108 = load i32, ptr %7, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds %class.R2Point, ptr %107, i64 %109
  %111 = call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %105, ptr noundef nonnull align 8 dereferenceable(16) %110)
  store double %111, ptr %16, align 8, !tbaa !11
  %112 = load double, ptr %16, align 8, !tbaa !11
  %113 = load double, ptr %8, align 8, !tbaa !11
  %114 = fcmp olt double %112, %113
  br i1 %114, label %115, label %150

115:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 2, ptr %17, align 4, !tbaa !9
  br label %116

116:                                              ; preds = %145, %115
  %117 = load i32, ptr %17, align 4, !tbaa !9
  %118 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %119 = load i32, ptr %118, align 8, !tbaa !13
  %120 = sdiv i32 %119, 3
  %121 = icmp slt i32 %117, %120
  br i1 %121, label %123, label %122

122:                                              ; preds = %116
  store i32 5, ptr %13, align 4
  br label %148

123:                                              ; preds = %116
  %124 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 1
  %125 = load ptr, ptr %124, align 8, !tbaa !19
  %126 = load i32, ptr %7, align 4, !tbaa !9
  %127 = load i32, ptr %17, align 4, !tbaa !9
  %128 = add nsw i32 %126, %127
  %129 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 2
  %130 = load i32, ptr %129, align 8, !tbaa !13
  %131 = srem i32 %128, %130
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds %class.R2Point, ptr %125, i64 %132
  store ptr %133, ptr %14, align 8, !tbaa !5
  %134 = load ptr, ptr %14, align 8, !tbaa !5
  %135 = load ptr, ptr %15, align 8, !tbaa !5
  %136 = call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %134, ptr noundef nonnull align 8 dereferenceable(16) %135)
  %137 = load double, ptr %16, align 8, !tbaa !11
  %138 = fadd double %137, %136
  store double %138, ptr %16, align 8, !tbaa !11
  %139 = load double, ptr %16, align 8, !tbaa !11
  %140 = load double, ptr %8, align 8, !tbaa !11
  %141 = fcmp oge double %139, %140
  br i1 %141, label %142, label %143

142:                                              ; preds = %123
  store i32 5, ptr %13, align 4
  br label %148

143:                                              ; preds = %123
  %144 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %144, ptr %15, align 8, !tbaa !5
  br label %145

145:                                              ; preds = %143
  %146 = load i32, ptr %17, align 4, !tbaa !9
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %17, align 4, !tbaa !9
  br label %116, !llvm.loop !22

148:                                              ; preds = %142, %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %149

149:                                              ; preds = %148
  br label %150

150:                                              ; preds = %149, %103
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %151

151:                                              ; preds = %150, %91
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #4
  %152 = load ptr, ptr %14, align 8, !tbaa !5
  %153 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZmiRK7R2PointS1_(ptr dead_on_unwind writable sret(%class.R2Vector) align 8 %18, ptr noundef nonnull align 8 dereferenceable(16) %152, ptr noundef nonnull align 8 dereferenceable(16) %153)
  %154 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %18, i32 noundef 1)
  %155 = load double, ptr %154, align 8, !tbaa !11
  %156 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %18, i32 noundef 0)
  %157 = load double, ptr %156, align 8, !tbaa !11
  %158 = fneg double %157
  call void @_ZN8R2VectorC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %0, double noundef %155, double noundef %158)
  call void @_ZN8R2Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %159 = getelementptr inbounds %class.R2Polygon, ptr %20, i32 0, i32 5
  %160 = load i32, ptr %159, align 8, !tbaa !23
  %161 = icmp ne i32 %160, 0
  br i1 %161, label %162, label %164

162:                                              ; preds = %151
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #4
  call void @_ZngRK8R2Vector(ptr dead_on_unwind writable sret(%class.R2Vector) align 8 %19, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %163 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8R2VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %19)
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #4
  br label %164

164:                                              ; preds = %162, %151
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %165

165:                                              ; preds = %164, %24
  ret void
}

declare void @_ZN8R2VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare void @_ZmiRK7R2PointS1_(ptr dead_on_unwind writable sret(%class.R2Vector) align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1

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

declare void @_ZN8R2VectorC1Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1

declare void @_ZN8R2Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #1

declare void @_ZngRK8R2Vector(ptr dead_on_unwind writable sret(%class.R2Vector) align 8, ptr noundef nonnull align 8 dereferenceable(16)) #1

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZN8R2VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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"="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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTS9R2Polygon", !15, i64 0, !6, i64 8, !10, i64 16, !17, i64 24, !10, i64 64}
!15 = !{!"_ZTS7R2Solid", !16, i64 0}
!16 = !{!"_ZTS7R2Shape"}
!17 = !{!"_ZTS5R2Box", !15, i64 0, !18, i64 8, !18, i64 24}
!18 = !{!"_ZTS7R2Point", !7, i64 0}
!19 = !{!14, !6, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = !{!14, !10, i64 64}


; 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.R2Vector = type { [2 x double] }
%class.R2Point = type { [2 x double] }

@R2null_vector = external global %class.R2Vector, align 8

; 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

declare noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK9R2Polygon6NormalEid(ptr dead_on_unwind noalias writable sret(%class.R2Vector) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(68) %1, i32 noundef %2, double noundef %3) local_unnamed_addr #2 align 2 {
  %5 = alloca %class.R2Vector, align 8
  %6 = alloca %class.R2Vector, align 8
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = icmp slt i32 %8, 3
  br i1 %9, label %10, label %11

10:                                               ; preds = %4
  tail call void @_ZN8R2VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) @R2null_vector)
  br label %83

11:                                               ; preds = %4
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = add nsw i32 %2, -1
  %15 = add nsw i32 %14, %8
  %16 = srem i32 %15, %8
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds %class.R2Point, ptr %13, i64 %17
  %19 = fcmp ogt double %3, 0.000000e+00
  br i1 %19, label %24, label %.thread56

.thread56:                                        ; preds = %11
  %20 = add nsw i32 %2, 1
  %21 = srem i32 %20, %8
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %class.R2Point, ptr %13, i64 %22
  br label %.loopexit

24:                                               ; preds = %11
  %25 = sext i32 %2 to i64
  %26 = getelementptr inbounds %class.R2Point, ptr %13, i64 %25
  %27 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 8 dereferenceable(16) %26)
  %28 = fcmp olt double %27, %3
  br i1 %28, label %.preheader58, label %.thread

.preheader58:                                     ; preds = %24
  %29 = load i32, ptr %7, align 8, !tbaa !5
  %30 = icmp sgt i32 %29, 8
  br i1 %30, label %.lr.ph, label %._crit_edge

.thread:                                          ; preds = %24
  %31 = add nsw i32 %2, 1
  %32 = load i32, ptr %7, align 8, !tbaa !5
  %33 = srem i32 %31, %32
  br label %51

34:                                               ; preds = %.lr.ph
  %35 = add nuw nsw i32 %.03961, 1
  %36 = sdiv i32 %.pre.pre, 3
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %.lr.ph, label %._crit_edge, !llvm.loop !16

.lr.ph:                                           ; preds = %.preheader58, %34
  %38 = phi i32 [ %.pre.pre, %34 ], [ %29, %.preheader58 ]
  %.03961 = phi i32 [ %35, %34 ], [ 2, %.preheader58 ]
  %.04060 = phi double [ %46, %34 ], [ %27, %.preheader58 ]
  %.04159 = phi ptr [ %44, %34 ], [ %18, %.preheader58 ]
  %39 = load ptr, ptr %12, align 8, !tbaa !15
  %40 = sub i32 %2, %.03961
  %41 = add nsw i32 %40, %38
  %42 = srem i32 %41, %38
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %class.R2Point, ptr %39, i64 %43
  %45 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 8 dereferenceable(16) %.04159)
  %46 = fadd double %.04060, %45
  %47 = fcmp ult double %46, %3
  %.pre.pre = load i32, ptr %7, align 8, !tbaa !5
  br i1 %47, label %34, label %._crit_edge

._crit_edge:                                      ; preds = %34, %.lr.ph, %.preheader58
  %48 = phi i32 [ %29, %.preheader58 ], [ %.pre.pre, %.lr.ph ], [ %.pre.pre, %34 ]
  %.345 = phi ptr [ %18, %.preheader58 ], [ %44, %.lr.ph ], [ %44, %34 ]
  %49 = add nsw i32 %2, 1
  %50 = srem i32 %49, %48
  br label %51

51:                                               ; preds = %._crit_edge, %.thread
  %.sink74 = phi i32 [ %50, %._crit_edge ], [ %33, %.thread ]
  %.34555 = phi ptr [ %.345, %._crit_edge ], [ %18, %.thread ]
  %.sink = load ptr, ptr %12, align 8, !tbaa !15
  %52 = sext i32 %.sink74 to i64
  %53 = getelementptr inbounds %class.R2Point, ptr %.sink, i64 %52
  %54 = getelementptr inbounds %class.R2Point, ptr %.sink, i64 %25
  %55 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %53, ptr noundef nonnull align 8 dereferenceable(16) %54)
  %56 = fcmp olt double %55, %3
  %57 = load i32, ptr %7, align 8
  %58 = icmp sgt i32 %57, 8
  %or.cond = select i1 %56, i1 %58, i1 false
  br i1 %or.cond, label %.lr.ph67, label %.loopexit

59:                                               ; preds = %.lr.ph67
  %60 = add nuw nsw i32 %.066, 1
  %61 = load i32, ptr %7, align 8, !tbaa !5
  %62 = sdiv i32 %61, 3
  %63 = icmp slt i32 %60, %62
  br i1 %63, label %.lr.ph67, label %.loopexit, !llvm.loop !18

.lr.ph67:                                         ; preds = %51, %59
  %64 = phi i32 [ %61, %59 ], [ %57, %51 ]
  %.066 = phi i32 [ %60, %59 ], [ 2, %51 ]
  %.03665 = phi double [ %71, %59 ], [ %55, %51 ]
  %.03764 = phi ptr [ %69, %59 ], [ %53, %51 ]
  %65 = load ptr, ptr %12, align 8, !tbaa !15
  %66 = add nsw i32 %.066, %2
  %67 = srem i32 %66, %64
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds %class.R2Point, ptr %65, i64 %68
  %70 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %69, ptr noundef nonnull align 8 dereferenceable(16) %.03764)
  %71 = fadd double %.03665, %70
  %72 = fcmp ult double %71, %3
  br i1 %72, label %59, label %.loopexit

.loopexit:                                        ; preds = %59, %.lr.ph67, %.thread56, %51
  %.34554 = phi ptr [ %.34555, %51 ], [ %18, %.thread56 ], [ %.34555, %.lr.ph67 ], [ %.34555, %59 ]
  %.3 = phi ptr [ %53, %51 ], [ %23, %.thread56 ], [ %69, %.lr.ph67 ], [ %69, %59 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZmiRK7R2PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R2Vector) align 8 %5, ptr noundef nonnull align 8 dereferenceable(16) %.3, ptr noundef nonnull align 8 dereferenceable(16) %.34554)
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 1)
  %74 = load double, ptr %73, align 8, !tbaa !19
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 0)
  %76 = load double, ptr %75, align 8, !tbaa !19
  %77 = fneg double %76
  call void @_ZN8R2VectorC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %0, double noundef %74, double noundef %77)
  call void @_ZN8R2Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %78 = getelementptr inbounds i8, ptr %1, i64 64
  %79 = load i32, ptr %78, align 8, !tbaa !21
  %.not = icmp eq i32 %79, 0
  br i1 %.not, label %82, label %80

80:                                               ; preds = %.loopexit
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @_ZngRK8R2Vector(ptr dead_on_unwind nonnull writable sret(%class.R2Vector) align 8 %6, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %81 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8R2VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %6)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  br label %82

82:                                               ; preds = %80, %.loopexit
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  br label %83

83:                                               ; preds = %82, %10
  ret void
}

declare void @_ZN8R2VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare void @_ZmiRK7R2PointS1_(ptr dead_on_unwind writable sret(%class.R2Vector) align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

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

declare void @_ZN8R2VectorC1Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1

declare void @_ZN8R2Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

declare void @_ZngRK8R2Vector(ptr dead_on_unwind writable sret(%class.R2Vector) align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZN8R2VectoraSERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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"="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, !12, i64 16}
!6 = !{!"_ZTS9R2Polygon", !7, i64 0, !9, i64 8, !12, i64 16, !13, i64 24, !12, i64 64}
!7 = !{!"_ZTS7R2Solid", !8, i64 0}
!8 = !{!"_ZTS7R2Shape"}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"_ZTS5R2Box", !7, i64 0, !14, i64 8, !14, i64 24}
!14 = !{!"_ZTS7R2Point", !10, i64 0}
!15 = !{!6, !9, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !10, i64 0}
!21 = !{!6, !12, i64 64}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass