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

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

@RN_EPSILON = external global double, align 8
@RN_PI = external constant double, 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

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

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

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

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

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

27:                                               ; preds = %3
  store double 0.000000e+00, ptr %4, align 8
  br label %191

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

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

55:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 2, ptr %11, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %88, %55
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = getelementptr inbounds %class.R2Polyline, ptr %23, i32 0, i32 2
  %59 = load i32, ptr %58, align 8, !tbaa !13
  %60 = sdiv i32 %59, 3
  %61 = icmp slt i32 %57, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %56
  store i32 2, ptr %12, align 4
  br label %91

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

85:                                               ; preds = %63
  store i32 2, ptr %12, align 4
  br label %91

86:                                               ; preds = %63
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %87, ptr %9, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %86
  %89 = load i32, ptr %11, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %11, align 4, !tbaa !9
  br label %56, !llvm.loop !21

91:                                               ; preds = %85, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %92

92:                                               ; preds = %91
  br label %93

93:                                               ; preds = %92, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %94

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

106:                                              ; preds = %94
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %107 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %107, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %108 = load ptr, ptr %13, align 8, !tbaa !5
  %109 = getelementptr inbounds %class.R2Polyline, ptr %23, i32 0, i32 1
  %110 = load ptr, ptr %109, align 8, !tbaa !20
  %111 = load i32, ptr %6, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds %class.R2Point, ptr %110, i64 %112
  %114 = call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %108, ptr noundef nonnull align 8 dereferenceable(16) %113)
  store double %114, ptr %15, align 8, !tbaa !11
  %115 = load double, ptr %15, align 8, !tbaa !11
  %116 = load double, ptr %7, align 8, !tbaa !11
  %117 = fcmp olt double %115, %116
  br i1 %117, label %118, label %153

118:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 2, ptr %16, align 4, !tbaa !9
  br label %119

119:                                              ; preds = %148, %118
  %120 = load i32, ptr %16, align 4, !tbaa !9
  %121 = getelementptr inbounds %class.R2Polyline, ptr %23, i32 0, i32 2
  %122 = load i32, ptr %121, align 8, !tbaa !13
  %123 = sdiv i32 %122, 3
  %124 = icmp slt i32 %120, %123
  br i1 %124, label %126, label %125

125:                                              ; preds = %119
  store i32 5, ptr %12, align 4
  br label %151

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

145:                                              ; preds = %126
  store i32 5, ptr %12, align 4
  br label %151

146:                                              ; preds = %126
  %147 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %147, ptr %14, align 8, !tbaa !5
  br label %148

148:                                              ; preds = %146
  %149 = load i32, ptr %16, align 4, !tbaa !9
  %150 = add nsw i32 %149, 1
  store i32 %150, ptr %16, align 4, !tbaa !9
  br label %119, !llvm.loop !23

151:                                              ; preds = %145, %125
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %152

152:                                              ; preds = %151
  br label %153

153:                                              ; preds = %152, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %154

154:                                              ; preds = %153, %94
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #5
  %155 = load ptr, ptr %8, align 8, !tbaa !5
  %156 = getelementptr inbounds %class.R2Polyline, ptr %23, i32 0, i32 1
  %157 = load ptr, ptr %156, align 8, !tbaa !20
  %158 = load i32, ptr %6, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds %class.R2Point, ptr %157, i64 %159
  call void @_ZmiRK7R2PointS1_(ptr dead_on_unwind writable sret(%class.R2Vector) align 8 %17, ptr noundef nonnull align 8 dereferenceable(16) %155, ptr noundef nonnull align 8 dereferenceable(16) %160)
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #5
  %161 = load ptr, ptr %13, align 8, !tbaa !5
  %162 = getelementptr inbounds %class.R2Polyline, ptr %23, i32 0, i32 1
  %163 = load ptr, ptr %162, align 8, !tbaa !20
  %164 = load i32, ptr %6, align 4, !tbaa !9
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds %class.R2Point, ptr %163, i64 %165
  call void @_ZmiRK7R2PointS1_(ptr dead_on_unwind writable sret(%class.R2Vector) align 8 %18, ptr noundef nonnull align 8 dereferenceable(16) %161, ptr noundef nonnull align 8 dereferenceable(16) %166)
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %167 = call noundef double @_ZNK8R2Vector6LengthEv(ptr noundef nonnull align 8 dereferenceable(16) %17)
  store double %167, ptr %19, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %168 = call noundef double @_ZNK8R2Vector6LengthEv(ptr noundef nonnull align 8 dereferenceable(16) %18)
  store double %168, ptr %20, align 8, !tbaa !11
  %169 = load double, ptr %19, align 8, !tbaa !11
  %170 = load double, ptr @RN_EPSILON, align 8, !tbaa !11
  %171 = call noundef i32 @_Z8RNIsZerodd(double noundef %169, double noundef %170)
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %178, label %173

173:                                              ; preds = %154
  %174 = load double, ptr %20, align 8, !tbaa !11
  %175 = load double, ptr @RN_EPSILON, align 8, !tbaa !11
  %176 = call noundef i32 @_Z8RNIsZerodd(double noundef %174, double noundef %175)
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %178, label %179

178:                                              ; preds = %173, %154
  store double -1.000000e+00, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %190

179:                                              ; preds = %173
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %180 = call noundef double @_Z15R2InteriorAngleRK8R2VectorS1_(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(16) %18)
  store double %180, ptr %21, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %181 = load double, ptr @RN_PI, align 8, !tbaa !11
  %182 = load double, ptr %21, align 8, !tbaa !11
  %183 = fsub double %181, %182
  %184 = load double, ptr %19, align 8, !tbaa !11
  %185 = load double, ptr %20, align 8, !tbaa !11
  %186 = fadd double %184, %185
  %187 = fdiv double %183, %186
  %188 = call double @llvm.fabs.f64(double %187)
  store double %188, ptr %22, align 8, !tbaa !11
  %189 = load double, ptr %22, align 8, !tbaa !11
  store double %189, ptr %4, align 8
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  br label %190

190:                                              ; preds = %179, %178
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %191

191:                                              ; preds = %190, %27
  %192 = load double, ptr %4, align 8
  ret double %192
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #4

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


; 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] }

@RN_EPSILON = external local_unnamed_addr global double, align 8
@RN_PI = external local_unnamed_addr constant double, 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

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

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

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

declare noundef double @_Z15R2InteriorAngleRK8R2VectorS1_(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 noundef double @_ZNK10R2Polyline9CurvatureEid(ptr nocapture noundef nonnull readonly align 8 dereferenceable(64) %0, i32 noundef %1, double noundef %2) local_unnamed_addr #3 align 2 {
  %4 = alloca %class.R2Vector, align 8
  %5 = alloca %class.R2Vector, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp slt i32 %7, 3
  br i1 %8, label %90, label %9

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

.thread68:                                        ; preds = %9
  %18 = add nsw i32 %1, 1
  %19 = srem i32 %18, %7
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds %class.R2Point, ptr %11, i64 %20
  %.pre = sext i32 %1 to i64
  br label %.loopexit

22:                                               ; preds = %9
  %23 = sext i32 %1 to i64
  %24 = getelementptr inbounds %class.R2Point, ptr %11, i64 %23
  %25 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 8 dereferenceable(16) %24)
  %26 = fcmp olt double %25, %2
  br i1 %26, label %.preheader70, label %.thread

.preheader70:                                     ; preds = %22
  %27 = load i32, ptr %6, align 8, !tbaa !5
  %28 = icmp sgt i32 %27, 8
  br i1 %28, label %.lr.ph, label %._crit_edge

.thread:                                          ; preds = %22
  %29 = add nsw i32 %1, 1
  %30 = load i32, ptr %6, align 8, !tbaa !5
  %31 = srem i32 %29, %30
  br label %49

32:                                               ; preds = %.lr.ph
  %33 = add nuw nsw i32 %.05671, 1
  %34 = sdiv i32 %.pre.pre, 3
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !17

.lr.ph:                                           ; preds = %.preheader70, %32
  %36 = phi i32 [ %.pre.pre, %32 ], [ %27, %.preheader70 ]
  %.04573 = phi ptr [ %42, %32 ], [ %16, %.preheader70 ]
  %.04872 = phi double [ %44, %32 ], [ %25, %.preheader70 ]
  %.05671 = phi i32 [ %33, %32 ], [ 2, %.preheader70 ]
  %37 = load ptr, ptr %10, align 8, !tbaa !16
  %38 = sub i32 %1, %.05671
  %39 = add nsw i32 %38, %36
  %40 = srem i32 %39, %36
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %class.R2Point, ptr %37, i64 %41
  %43 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef nonnull align 8 dereferenceable(16) %.04573)
  %44 = fadd double %.04872, %43
  %45 = fcmp ult double %44, %2
  %.pre.pre = load i32, ptr %6, align 8, !tbaa !5
  br i1 %45, label %32, label %._crit_edge

._crit_edge:                                      ; preds = %32, %.lr.ph, %.preheader70
  %46 = phi i32 [ %27, %.preheader70 ], [ %.pre.pre, %.lr.ph ], [ %.pre.pre, %32 ]
  %.3 = phi ptr [ %16, %.preheader70 ], [ %42, %.lr.ph ], [ %42, %32 ]
  %47 = add nsw i32 %1, 1
  %48 = srem i32 %47, %46
  br label %49

49:                                               ; preds = %._crit_edge, %.thread
  %.sink86 = phi i32 [ %48, %._crit_edge ], [ %31, %.thread ]
  %.367 = phi ptr [ %.3, %._crit_edge ], [ %16, %.thread ]
  %.sink = load ptr, ptr %10, align 8, !tbaa !16
  %50 = sext i32 %.sink86 to i64
  %51 = getelementptr inbounds %class.R2Point, ptr %.sink, i64 %50
  %52 = getelementptr inbounds %class.R2Point, ptr %.sink, i64 %23
  %53 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %51, ptr noundef nonnull align 8 dereferenceable(16) %52)
  %54 = fcmp olt double %53, %2
  %55 = load i32, ptr %6, align 8
  %56 = icmp sgt i32 %55, 8
  %or.cond = select i1 %54, i1 %56, i1 false
  br i1 %or.cond, label %.lr.ph79, label %.loopexit

57:                                               ; preds = %.lr.ph79
  %58 = add nuw nsw i32 %.04978, 1
  %59 = load i32, ptr %6, align 8, !tbaa !5
  %60 = sdiv i32 %59, 3
  %61 = icmp slt i32 %58, %60
  br i1 %61, label %.lr.ph79, label %.loopexit, !llvm.loop !19

.lr.ph79:                                         ; preds = %49, %57
  %62 = phi i32 [ %59, %57 ], [ %55, %49 ]
  %.04978 = phi i32 [ %58, %57 ], [ 2, %49 ]
  %.05077 = phi double [ %69, %57 ], [ %53, %49 ]
  %.05176 = phi ptr [ %67, %57 ], [ %51, %49 ]
  %63 = load ptr, ptr %10, align 8, !tbaa !16
  %64 = add nsw i32 %.04978, %1
  %65 = srem i32 %64, %62
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %class.R2Point, ptr %63, i64 %66
  %68 = tail call noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %67, ptr noundef nonnull align 8 dereferenceable(16) %.05176)
  %69 = fadd double %.05077, %68
  %70 = fcmp ult double %69, %2
  br i1 %70, label %57, label %.loopexit

.loopexit:                                        ; preds = %57, %.lr.ph79, %.thread68, %49
  %.pre-phi = phi i64 [ %.pre, %.thread68 ], [ %23, %49 ], [ %23, %.lr.ph79 ], [ %23, %57 ]
  %.366 = phi ptr [ %16, %.thread68 ], [ %.367, %49 ], [ %.367, %.lr.ph79 ], [ %.367, %57 ]
  %.355 = phi ptr [ %21, %.thread68 ], [ %51, %49 ], [ %67, %.lr.ph79 ], [ %67, %57 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %71 = load ptr, ptr %10, align 8, !tbaa !16
  %72 = getelementptr inbounds %class.R2Point, ptr %71, i64 %.pre-phi
  call void @_ZmiRK7R2PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R2Vector) align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %.366, ptr noundef nonnull align 8 dereferenceable(16) %72)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  %73 = load ptr, ptr %10, align 8, !tbaa !16
  %74 = getelementptr inbounds %class.R2Point, ptr %73, i64 %.pre-phi
  call void @_ZmiRK7R2PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R2Vector) align 8 %5, ptr noundef nonnull align 8 dereferenceable(16) %.355, ptr noundef nonnull align 8 dereferenceable(16) %74)
  %75 = call noundef double @_ZNK8R2Vector6LengthEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %76 = call noundef double @_ZNK8R2Vector6LengthEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %77 = load double, ptr @RN_EPSILON, align 8, !tbaa !20
  %78 = call noundef i32 @_Z8RNIsZerodd(double noundef %75, double noundef %77)
  %.not = icmp eq i32 %78, 0
  br i1 %.not, label %79, label %89

79:                                               ; preds = %.loopexit
  %80 = load double, ptr @RN_EPSILON, align 8, !tbaa !20
  %81 = call noundef i32 @_Z8RNIsZerodd(double noundef %76, double noundef %80)
  %.not64 = icmp eq i32 %81, 0
  br i1 %.not64, label %82, label %89

82:                                               ; preds = %79
  %83 = call noundef double @_Z15R2InteriorAngleRK8R2VectorS1_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %84 = load double, ptr @RN_PI, align 8, !tbaa !20
  %85 = fsub double %84, %83
  %86 = fadd double %75, %76
  %87 = fdiv double %85, %86
  %88 = call double @llvm.fabs.f64(double %87)
  br label %89

89:                                               ; preds = %.loopexit, %79, %82
  %.0 = phi double [ %88, %82 ], [ -1.000000e+00, %79 ], [ -1.000000e+00, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  br label %90

90:                                               ; preds = %3, %89
  %.1 = phi double [ %.0, %89 ], [ 0.000000e+00, %3 ]
  ret double %.1
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #4

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 = { 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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !12, i64 16}
!6 = !{!"_ZTS10R2Polyline", !7, i64 0, !9, i64 8, !12, i64 16, !13, i64 24}
!7 = !{!"_ZTS7R2Curve", !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", !14, i64 0, !15, i64 8, !15, i64 24}
!14 = !{!"_ZTS7R2Solid", !8, i64 0}
!15 = !{!"_ZTS7R2Point", !10, i64 0}
!16 = !{!6, !9, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !10, i64 0}


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