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

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

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

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

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

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)) #2

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK9R2Polygon13InteriorAngleEid(ptr noundef nonnull align 8 dereferenceable(68) %0, i32 noundef %1, double noundef %2) #4 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.R2Polygon, 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 %214

28:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %29 = getelementptr inbounds %class.R2Polygon, ptr %23, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !19
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = sub nsw i32 %31, 1
  %33 = getelementptr inbounds %class.R2Polygon, 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.R2Polygon, 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.R2Polygon, ptr %23, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  %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.R2Polygon, 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.R2Polygon, ptr %23, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %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.R2Polygon, 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.R2Polygon, 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 !20

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.R2Polygon, ptr %23, i32 0, i32 1
  %96 = load ptr, ptr %95, align 8, !tbaa !19
  %97 = load i32, ptr %6, align 4, !tbaa !9
  %98 = add nsw i32 %97, 1
  %99 = getelementptr inbounds %class.R2Polygon, 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.R2Polygon, ptr %23, i32 0, i32 1
  %110 = load ptr, ptr %109, align 8, !tbaa !19
  %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.R2Polygon, 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.R2Polygon, ptr %23, i32 0, i32 1
  %128 = load ptr, ptr %127, align 8, !tbaa !19
  %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.R2Polygon, 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 !22

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.R2Polygon, ptr %23, i32 0, i32 1
  %157 = load ptr, ptr %156, align 8, !tbaa !19
  %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.R2Polygon, ptr %23, i32 0, i32 1
  %163 = load ptr, ptr %162, align 8, !tbaa !19
  %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 %213

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 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %17, i32 noundef 0)
  %182 = load double, ptr %181, align 8, !tbaa !11
  %183 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %18, i32 noundef 1)
  %184 = load double, ptr %183, align 8, !tbaa !11
  %185 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %17, i32 noundef 1)
  %186 = load double, ptr %185, align 8, !tbaa !11
  %187 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %18, i32 noundef 0)
  %188 = load double, ptr %187, align 8, !tbaa !11
  %189 = fmul double %186, %188
  %190 = fneg double %189
  %191 = call double @llvm.fmuladd.f64(double %182, double %184, double %190)
  store double %191, ptr %22, align 8, !tbaa !11
  %192 = getelementptr inbounds %class.R2Polygon, ptr %23, i32 0, i32 5
  %193 = load i32, ptr %192, align 8, !tbaa !23
  %194 = icmp ne i32 %193, 0
  br i1 %194, label %195, label %203

195:                                              ; preds = %179
  %196 = load double, ptr %22, align 8, !tbaa !11
  %197 = fcmp olt double %196, 0.000000e+00
  br i1 %197, label %198, label %202

198:                                              ; preds = %195
  %199 = load double, ptr @RN_TWO_PI, align 8, !tbaa !11
  %200 = load double, ptr %21, align 8, !tbaa !11
  %201 = fsub double %199, %200
  store double %201, ptr %21, align 8, !tbaa !11
  br label %202

202:                                              ; preds = %198, %195
  br label %211

203:                                              ; preds = %179
  %204 = load double, ptr %22, align 8, !tbaa !11
  %205 = fcmp ogt double %204, 0.000000e+00
  br i1 %205, label %206, label %210

206:                                              ; preds = %203
  %207 = load double, ptr @RN_TWO_PI, align 8, !tbaa !11
  %208 = load double, ptr %21, align 8, !tbaa !11
  %209 = fsub double %207, %208
  store double %209, ptr %21, align 8, !tbaa !11
  br label %210

210:                                              ; preds = %206, %203
  br label %211

211:                                              ; preds = %210, %202
  %212 = load double, ptr %21, align 8, !tbaa !11
  store double %212, 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 %213

213:                                              ; preds = %211, %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 %214

214:                                              ; preds = %213, %27
  %215 = load double, ptr %4, align 8
  ret double %215
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"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] }

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

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

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

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

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK9R2Polygon13InteriorAngleEid(ptr nocapture noundef nonnull readonly align 8 dereferenceable(68) %0, i32 noundef %1, double noundef %2) local_unnamed_addr #4 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 %108, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %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 %.thread71

.thread71:                                        ; 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 %.preheader73, label %.thread

.preheader73:                                     ; 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 %.05775, 1
  %34 = sdiv i32 %.pre.pre, 3
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !16

.lr.ph:                                           ; preds = %.preheader73, %32
  %36 = phi i32 [ %.pre.pre, %32 ], [ %27, %.preheader73 ]
  %.04776 = phi ptr [ %42, %32 ], [ %16, %.preheader73 ]
  %.05775 = phi i32 [ %33, %32 ], [ 2, %.preheader73 ]
  %.05874 = phi double [ %44, %32 ], [ %25, %.preheader73 ]
  %37 = load ptr, ptr %10, align 8, !tbaa !15
  %38 = sub i32 %1, %.05775
  %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) %.04776)
  %44 = fadd double %.05874, %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, %.preheader73
  %46 = phi i32 [ %27, %.preheader73 ], [ %.pre.pre, %.lr.ph ], [ %.pre.pre, %32 ]
  %.3 = phi ptr [ %16, %.preheader73 ], [ %42, %.lr.ph ], [ %42, %32 ]
  %47 = add nsw i32 %1, 1
  %48 = srem i32 %47, %46
  br label %49

49:                                               ; preds = %._crit_edge, %.thread
  %.sink89 = phi i32 [ %48, %._crit_edge ], [ %31, %.thread ]
  %.370 = phi ptr [ %.3, %._crit_edge ], [ %16, %.thread ]
  %.sink = load ptr, ptr %10, align 8, !tbaa !15
  %50 = sext i32 %.sink89 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.ph82, label %.loopexit

57:                                               ; preds = %.lr.ph82
  %58 = add nuw nsw i32 %.05081, 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.ph82, label %.loopexit, !llvm.loop !18

.lr.ph82:                                         ; preds = %49, %57
  %62 = phi i32 [ %59, %57 ], [ %55, %49 ]
  %.05081 = phi i32 [ %58, %57 ], [ 2, %49 ]
  %.05180 = phi double [ %69, %57 ], [ %53, %49 ]
  %.05279 = phi ptr [ %67, %57 ], [ %51, %49 ]
  %63 = load ptr, ptr %10, align 8, !tbaa !15
  %64 = add nsw i32 %.05081, %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) %.05279)
  %69 = fadd double %.05180, %68
  %70 = fcmp ult double %69, %2
  br i1 %70, label %57, label %.loopexit

.loopexit:                                        ; preds = %57, %.lr.ph82, %.thread71, %49
  %.pre-phi = phi i64 [ %.pre, %.thread71 ], [ %23, %49 ], [ %23, %.lr.ph82 ], [ %23, %57 ]
  %.369 = phi ptr [ %16, %.thread71 ], [ %.370, %49 ], [ %.370, %.lr.ph82 ], [ %.370, %57 ]
  %.356 = phi ptr [ %21, %.thread71 ], [ %51, %49 ], [ %67, %.lr.ph82 ], [ %67, %57 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %71 = load ptr, ptr %10, align 8, !tbaa !15
  %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) %.369, 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 !15
  %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) %.356, 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 !19
  %78 = call noundef i32 @_Z8RNIsZerodd(double noundef %75, double noundef %77)
  %.not = icmp eq i32 %78, 0
  br i1 %.not, label %79, label %107

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

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 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef 0)
  %85 = load double, ptr %84, align 8, !tbaa !19
  %86 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 1)
  %87 = load double, ptr %86, align 8, !tbaa !19
  %88 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef 1)
  %89 = load double, ptr %88, align 8, !tbaa !19
  %90 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8R2VectorixEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 0)
  %91 = load double, ptr %90, align 8, !tbaa !19
  %92 = fneg double %89
  %93 = fmul double %91, %92
  %94 = call double @llvm.fmuladd.f64(double %85, double %87, double %93)
  %95 = getelementptr inbounds i8, ptr %0, i64 64
  %96 = load i32, ptr %95, align 8, !tbaa !21
  %.not67 = icmp eq i32 %96, 0
  br i1 %.not67, label %102, label %97

97:                                               ; preds = %82
  %98 = fcmp olt double %94, 0.000000e+00
  br i1 %98, label %99, label %107

99:                                               ; preds = %97
  %100 = load double, ptr @RN_TWO_PI, align 8, !tbaa !19
  %101 = fsub double %100, %83
  br label %107

102:                                              ; preds = %82
  %103 = fcmp ogt double %94, 0.000000e+00
  br i1 %103, label %104, label %107

104:                                              ; preds = %102
  %105 = load double, ptr @RN_TWO_PI, align 8, !tbaa !19
  %106 = fsub double %105, %83
  br label %107

107:                                              ; preds = %99, %97, %104, %102, %.loopexit, %79
  %.0 = phi double [ -1.000000e+00, %79 ], [ -1.000000e+00, %.loopexit ], [ %101, %99 ], [ %83, %97 ], [ %106, %104 ], [ %83, %102 ]
  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 %108

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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