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

; 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.R2Line = type { %class.R2Vector, %class.R2Vector, double }
%class.R2Vector = type { [2 x double] }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R2Point = type { [2 x double] }
%class.R2Diad = type { [2 x %class.R2Vector] }
%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 }

@R2null_line = external global %class.R2Line, align 8

declare i32 @__gxx_personality_v0(...)

; 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 @_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: mustprogress uwtable
define dso_local void @_ZNK10R2Polyline7TangentEid(ptr dead_on_unwind noalias writable sret(%class.R2Line) align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %1, i32 noundef %2, double noundef %3) #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca %class.RNArray, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca %class.R2Point, align 8
  %20 = alloca %class.R2Diad, align 8
  %21 = alloca %class.R2Vector, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = 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
  %25 = load ptr, ptr %6, align 8
  %26 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 8, !tbaa !13
  %28 = icmp slt i32 %27, 3
  br i1 %28, label %29, label %30

29:                                               ; preds = %4
  call void @_ZN6R2LineC1ERKS_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) @R2null_line)
  br label %212

30:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  call void @_ZN7RNArrayIP7R2PointEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9)
  %31 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %class.R2Point, ptr %32, i64 %34
  %36 = invoke noundef ptr @_ZN7RNArrayIP7R2PointE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef %35)
          to label %37 unwind label %50

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %38 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %class.R2Point, ptr %39, i64 %41
  store ptr %42, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 1, ptr %14, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %90, %37
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = sdiv i32 %46, 3
  %48 = icmp slt i32 %44, %47
  br i1 %48, label %54, label %49

49:                                               ; preds = %43
  store i32 2, ptr %15, align 4
  br label %93

50:                                               ; preds = %30
  %51 = landingpad { ptr, i32 }
          cleanup
  %52 = extractvalue { ptr, i32 } %51, 0
  store ptr %52, ptr %10, align 8
  %53 = extractvalue { ptr, i32 } %51, 1
  store i32 %53, ptr %11, align 4
  br label %211

54:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %55 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !20
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = load i32, ptr %14, align 4, !tbaa !9
  %59 = sub nsw i32 %57, %58
  %60 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !13
  %62 = add nsw i32 %59, %61
  %63 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %64 = load i32, ptr %63, align 8, !tbaa !13
  %65 = srem i32 %62, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %class.R2Point, ptr %56, i64 %66
  store ptr %67, ptr %16, align 8, !tbaa !5
  %68 = load ptr, ptr %16, align 8, !tbaa !5
  %69 = invoke noundef ptr @_ZN7RNArrayIP7R2PointE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef %68)
          to label %70 unwind label %81

70:                                               ; preds = %54
  %71 = load ptr, ptr %16, align 8, !tbaa !5
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = invoke noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %71, ptr noundef nonnull align 8 dereferenceable(16) %72)
          to label %74 unwind label %81

74:                                               ; preds = %70
  %75 = load double, ptr %12, align 8, !tbaa !11
  %76 = fadd double %75, %73
  store double %76, ptr %12, align 8, !tbaa !11
  %77 = load double, ptr %12, align 8, !tbaa !11
  %78 = load double, ptr %8, align 8, !tbaa !11
  %79 = fcmp oge double %77, %78
  br i1 %79, label %80, label %85

80:                                               ; preds = %74
  store i32 2, ptr %15, align 4
  br label %87

81:                                               ; preds = %70, %54
  %82 = landingpad { ptr, i32 }
          cleanup
  %83 = extractvalue { ptr, i32 } %82, 0
  store ptr %83, ptr %10, align 8
  %84 = extractvalue { ptr, i32 } %82, 1
  store i32 %84, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %210

85:                                               ; preds = %74
  %86 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %86, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %15, align 4
  br label %87

87:                                               ; preds = %85, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %88 = load i32, ptr %15, align 4
  switch i32 %88, label %93 [
    i32 0, label %89
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %14, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %14, align 4, !tbaa !9
  br label %43, !llvm.loop !21

93:                                               ; preds = %87, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %94

94:                                               ; preds = %93
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  %95 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %96 = load ptr, ptr %95, align 8, !tbaa !20
  %97 = load i32, ptr %7, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %class.R2Point, ptr %96, i64 %98
  store ptr %99, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 1, ptr %17, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %140, %94
  %101 = load i32, ptr %17, align 4, !tbaa !9
  %102 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %103 = load i32, ptr %102, align 8, !tbaa !13
  %104 = sdiv i32 %103, 3
  %105 = icmp slt i32 %101, %104
  br i1 %105, label %107, label %106

106:                                              ; preds = %100
  store i32 5, ptr %15, align 4
  br label %143

107:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %108 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %109 = load ptr, ptr %108, align 8, !tbaa !20
  %110 = load i32, ptr %7, align 4, !tbaa !9
  %111 = load i32, ptr %17, align 4, !tbaa !9
  %112 = add nsw i32 %110, %111
  %113 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %114 = load i32, ptr %113, align 8, !tbaa !13
  %115 = srem i32 %112, %114
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds %class.R2Point, ptr %109, i64 %116
  store ptr %117, ptr %18, align 8, !tbaa !5
  %118 = load ptr, ptr %18, align 8, !tbaa !5
  %119 = invoke noundef ptr @_ZN7RNArrayIP7R2PointE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef %118)
          to label %120 unwind label %131

120:                                              ; preds = %107
  %121 = load ptr, ptr %18, align 8, !tbaa !5
  %122 = load ptr, ptr %13, align 8, !tbaa !5
  %123 = invoke noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %121, ptr noundef nonnull align 8 dereferenceable(16) %122)
          to label %124 unwind label %131

124:                                              ; preds = %120
  %125 = load double, ptr %12, align 8, !tbaa !11
  %126 = fadd double %125, %123
  store double %126, ptr %12, align 8, !tbaa !11
  %127 = load double, ptr %12, align 8, !tbaa !11
  %128 = load double, ptr %8, align 8, !tbaa !11
  %129 = fcmp oge double %127, %128
  br i1 %129, label %130, label %135

130:                                              ; preds = %124
  store i32 5, ptr %15, align 4
  br label %137

131:                                              ; preds = %120, %107
  %132 = landingpad { ptr, i32 }
          cleanup
  %133 = extractvalue { ptr, i32 } %132, 0
  store ptr %133, ptr %10, align 8
  %134 = extractvalue { ptr, i32 } %132, 1
  store i32 %134, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %210

135:                                              ; preds = %124
  %136 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %136, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %15, align 4
  br label %137

137:                                              ; preds = %135, %130
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %138 = load i32, ptr %15, align 4
  switch i32 %138, label %143 [
    i32 0, label %139
  ]

139:                                              ; preds = %137
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %17, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %17, align 4, !tbaa !9
  br label %100, !llvm.loop !23

143:                                              ; preds = %137, %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %144

144:                                              ; preds = %143
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #5
  invoke void @_Z10R2CentroidRK7RNArrayIP7R2PointEPKd(ptr dead_on_unwind writable sret(%class.R2Point) align 8 %19, ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef null)
          to label %145 unwind label %179

145:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #5
  invoke void @_Z15R2PrincipleAxesRK7R2PointRK7RNArrayIPS_EPKdPd(ptr dead_on_unwind writable sret(%class.R2Diad) align 8 %20, ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef null, ptr noundef null)
          to label %146 unwind label %183

146:                                              ; preds = %145
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #5
  %147 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R2Diad4AxisEi(ptr noundef nonnull align 8 dereferenceable(32) %20, i32 noundef 0)
          to label %148 unwind label %187

148:                                              ; preds = %146
  invoke void @_ZN8R2VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(16) %147)
          to label %149 unwind label %187

149:                                              ; preds = %148
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %150 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %151 = load ptr, ptr %150, align 8, !tbaa !20
  %152 = load i32, ptr %7, align 4, !tbaa !9
  %153 = sub nsw i32 %152, 1
  %154 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %155 = load i32, ptr %154, align 8, !tbaa !13
  %156 = add nsw i32 %153, %155
  %157 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %158 = load i32, ptr %157, align 8, !tbaa !13
  %159 = srem i32 %156, %158
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds %class.R2Point, ptr %151, i64 %160
  store ptr %161, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  %162 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %163 = load ptr, ptr %162, align 8, !tbaa !20
  %164 = load i32, ptr %7, align 4, !tbaa !9
  %165 = add nsw i32 %164, 1
  %166 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 2
  %167 = load i32, ptr %166, align 8, !tbaa !13
  %168 = srem i32 %165, %167
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds %class.R2Point, ptr %163, i64 %169
  store ptr %170, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %24) #5
  %171 = load ptr, ptr %23, align 8, !tbaa !5
  %172 = load ptr, ptr %22, align 8, !tbaa !5
  invoke void @_ZmiRK7R2PointS1_(ptr dead_on_unwind writable sret(%class.R2Vector) align 8 %24, ptr noundef nonnull align 8 dereferenceable(16) %171, ptr noundef nonnull align 8 dereferenceable(16) %172)
          to label %173 unwind label %191

173:                                              ; preds = %149
  %174 = invoke noundef double @_ZNK8R2Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(16) %24)
          to label %175 unwind label %191

175:                                              ; preds = %173
  %176 = fcmp olt double %174, 0.000000e+00
  call void @llvm.lifetime.end.p0(i64 16, ptr %24) #5
  br i1 %176, label %177, label %199

177:                                              ; preds = %175
  invoke void @_ZN8R2Vector4FlipEv(ptr noundef nonnull align 8 dereferenceable(16) %21)
          to label %178 unwind label %195

178:                                              ; preds = %177
  br label %199

179:                                              ; preds = %144
  %180 = landingpad { ptr, i32 }
          cleanup
  %181 = extractvalue { ptr, i32 } %180, 0
  store ptr %181, ptr %10, align 8
  %182 = extractvalue { ptr, i32 } %180, 1
  store i32 %182, ptr %11, align 4
  br label %209

183:                                              ; preds = %145
  %184 = landingpad { ptr, i32 }
          cleanup
  %185 = extractvalue { ptr, i32 } %184, 0
  store ptr %185, ptr %10, align 8
  %186 = extractvalue { ptr, i32 } %184, 1
  store i32 %186, ptr %11, align 4
  br label %208

187:                                              ; preds = %148, %146
  %188 = landingpad { ptr, i32 }
          cleanup
  %189 = extractvalue { ptr, i32 } %188, 0
  store ptr %189, ptr %10, align 8
  %190 = extractvalue { ptr, i32 } %188, 1
  store i32 %190, ptr %11, align 4
  br label %207

191:                                              ; preds = %173, %149
  %192 = landingpad { ptr, i32 }
          cleanup
  %193 = extractvalue { ptr, i32 } %192, 0
  store ptr %193, ptr %10, align 8
  %194 = extractvalue { ptr, i32 } %192, 1
  store i32 %194, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %24) #5
  br label %206

195:                                              ; preds = %199, %177
  %196 = landingpad { ptr, i32 }
          cleanup
  %197 = extractvalue { ptr, i32 } %196, 0
  store ptr %197, ptr %10, align 8
  %198 = extractvalue { ptr, i32 } %196, 1
  store i32 %198, ptr %11, align 4
  br label %206

199:                                              ; preds = %178, %175
  %200 = getelementptr inbounds %class.R2Polyline, ptr %25, i32 0, i32 1
  %201 = load ptr, ptr %200, align 8, !tbaa !20
  %202 = load i32, ptr %7, align 4, !tbaa !9
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds %class.R2Point, ptr %201, i64 %203
  invoke void @_ZN6R2LineC1ERK7R2PointRK8R2Vectori(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(16) %204, ptr noundef nonnull align 8 dereferenceable(16) %21, i32 noundef 0)
          to label %205 unwind label %195

205:                                              ; preds = %199
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  br label %212

206:                                              ; preds = %195, %191
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  br label %207

207:                                              ; preds = %206, %187
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #5
  br label %208

208:                                              ; preds = %207, %183
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #5
  br label %209

209:                                              ; preds = %208, %179
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #5
  br label %210

210:                                              ; preds = %209, %131, %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %211

211:                                              ; preds = %210, %50
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  br label %213

212:                                              ; preds = %205, %29
  ret void

213:                                              ; preds = %211
  %214 = load ptr, ptr %10, align 8
  %215 = load i32, ptr %11, align 4
  %216 = insertvalue { ptr, i32 } poison, ptr %214, 0
  %217 = insertvalue { ptr, i32 } %216, i32 %215, 1
  resume { ptr, i32 } %217
}

declare void @_ZN6R2LineC1ERKS_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP7R2PointEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

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

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

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

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

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

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

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

; Function Attrs: nounwind
declare void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #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 = { 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 "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 = !{!"_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.R2Line = type { %class.R2Vector, %class.R2Vector, double }
%class.R2Vector = type { [2 x double] }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R2Point = type { [2 x double] }
%class.R2Diad = type { [2 x %class.R2Vector] }

@R2null_line = external global %class.R2Line, align 8

declare i32 @__gxx_personality_v0(...)

; 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 @_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: mustprogress uwtable
define dso_local void @_ZNK10R2Polyline7TangentEid(ptr dead_on_unwind noalias writable sret(%class.R2Line) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(64) %1, i32 noundef %2, double noundef %3) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.RNArray, align 8
  %6 = alloca %class.R2Point, align 8
  %7 = alloca %class.R2Diad, align 8
  %8 = alloca %class.R2Vector, align 8
  %9 = alloca %class.R2Vector, align 8
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = icmp slt i32 %11, 3
  br i1 %12, label %13, label %14

13:                                               ; preds = %4
  tail call void @_ZN6R2LineC1ERKS_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) @R2null_line)
  br label %106

14:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  call void @_ZN7RNArrayIP7R2PointEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = sext i32 %2 to i64
  %18 = getelementptr inbounds %class.R2Point, ptr %16, i64 %17
  %19 = invoke noundef ptr @_ZN7RNArrayIP7R2PointE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %18)
          to label %20 unwind label %29

20:                                               ; preds = %14
  %21 = load i32, ptr %10, align 8, !tbaa !5
  %22 = icmp sgt i32 %21, 5
  br i1 %22, label %.lr.ph.preheader, label %._crit_edge66

.lr.ph.preheader:                                 ; preds = %20
  %23 = load ptr, ptr %15, align 8, !tbaa !16
  %24 = getelementptr inbounds %class.R2Point, ptr %23, i64 %17
  br label %.lr.ph

25:                                               ; preds = %41
  %26 = add nuw nsw i32 %.05057, 1
  %27 = sdiv i32 %.pre68.pre, 3
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !17

29:                                               ; preds = %14
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %105

.lr.ph:                                           ; preds = %.lr.ph.preheader, %25
  %31 = phi i32 [ %.pre68.pre, %25 ], [ %21, %.lr.ph.preheader ]
  %.04159 = phi double [ %42, %25 ], [ 0.000000e+00, %.lr.ph.preheader ]
  %.04458 = phi ptr [ %37, %25 ], [ %24, %.lr.ph.preheader ]
  %.05057 = phi i32 [ %26, %25 ], [ 1, %.lr.ph.preheader ]
  %32 = load ptr, ptr %15, align 8, !tbaa !16
  %33 = sub i32 %2, %.05057
  %34 = add nsw i32 %33, %31
  %35 = srem i32 %34, %31
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds %class.R2Point, ptr %32, i64 %36
  %38 = invoke noundef ptr @_ZN7RNArrayIP7R2PointE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %37)
          to label %39 unwind label %44

39:                                               ; preds = %.lr.ph
  %40 = invoke noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %37, ptr noundef nonnull align 8 dereferenceable(16) %.04458)
          to label %41 unwind label %44

41:                                               ; preds = %39
  %42 = fadd double %.04159, %40
  %43 = fcmp ult double %42, %3
  %.pre68.pre = load i32, ptr %10, align 8, !tbaa !5
  br i1 %43, label %25, label %._crit_edge

44:                                               ; preds = %39, %.lr.ph
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %105

._crit_edge:                                      ; preds = %41, %25
  %46 = icmp sgt i32 %.pre68.pre, 5
  br i1 %46, label %.lr.ph65.preheader, label %._crit_edge66

.lr.ph65.preheader:                               ; preds = %._crit_edge
  %.pre = load ptr, ptr %15, align 8, !tbaa !16
  %47 = getelementptr inbounds %class.R2Point, ptr %.pre, i64 %17
  br label %.lr.ph65

48:                                               ; preds = %62
  %49 = add nuw nsw i32 %.04362, 1
  %50 = load i32, ptr %10, align 8, !tbaa !5
  %51 = sdiv i32 %50, 3
  %52 = icmp slt i32 %49, %51
  br i1 %52, label %.lr.ph65, label %._crit_edge66, !llvm.loop !19

.lr.ph65:                                         ; preds = %.lr.ph65.preheader, %48
  %53 = phi i32 [ %50, %48 ], [ %.pre68.pre, %.lr.ph65.preheader ]
  %.14263 = phi double [ %63, %48 ], [ 0.000000e+00, %.lr.ph65.preheader ]
  %.04362 = phi i32 [ %49, %48 ], [ 1, %.lr.ph65.preheader ]
  %.24661 = phi ptr [ %58, %48 ], [ %47, %.lr.ph65.preheader ]
  %54 = load ptr, ptr %15, align 8, !tbaa !16
  %55 = add nsw i32 %.04362, %2
  %56 = srem i32 %55, %53
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds %class.R2Point, ptr %54, i64 %57
  %59 = invoke noundef ptr @_ZN7RNArrayIP7R2PointE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %58)
          to label %60 unwind label %65

60:                                               ; preds = %.lr.ph65
  %61 = invoke noundef double @_Z10R2DistanceRK7R2PointS1_(ptr noundef nonnull align 8 dereferenceable(16) %58, ptr noundef nonnull align 8 dereferenceable(16) %.24661)
          to label %62 unwind label %65

62:                                               ; preds = %60
  %63 = fadd double %.14263, %61
  %64 = fcmp ult double %63, %3
  br i1 %64, label %48, label %._crit_edge66

65:                                               ; preds = %60, %.lr.ph65
  %66 = landingpad { ptr, i32 }
          cleanup
  br label %105

._crit_edge66:                                    ; preds = %62, %48, %20, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  invoke void @_Z10R2CentroidRK7RNArrayIP7R2PointEPKd(ptr dead_on_unwind nonnull writable sret(%class.R2Point) align 8 %6, ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef null)
          to label %67 unwind label %88

67:                                               ; preds = %._crit_edge66
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #5
  invoke void @_Z15R2PrincipleAxesRK7R2PointRK7RNArrayIPS_EPKdPd(ptr dead_on_unwind nonnull writable sret(%class.R2Diad) align 8 %7, ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef null, ptr noundef null)
          to label %68 unwind label %90

68:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #5
  %69 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R2Diad4AxisEi(ptr noundef nonnull align 8 dereferenceable(32) %7, i32 noundef 0)
          to label %70 unwind label %92

70:                                               ; preds = %68
  invoke void @_ZN8R2VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %69)
          to label %71 unwind label %92

71:                                               ; preds = %70
  %72 = load ptr, ptr %15, align 8, !tbaa !16
  %73 = add nsw i32 %2, -1
  %74 = load i32, ptr %10, align 8, !tbaa !5
  %75 = add nsw i32 %73, %74
  %76 = srem i32 %75, %74
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %class.R2Point, ptr %72, i64 %77
  %79 = add nsw i32 %2, 1
  %80 = srem i32 %79, %74
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds %class.R2Point, ptr %72, i64 %81
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #5
  invoke void @_ZmiRK7R2PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R2Vector) align 8 %9, ptr noundef nonnull align 8 dereferenceable(16) %82, ptr noundef nonnull align 8 dereferenceable(16) %78)
          to label %83 unwind label %94

83:                                               ; preds = %71
  %84 = invoke noundef double @_ZNK8R2Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %85 unwind label %94

85:                                               ; preds = %83
  %86 = fcmp olt double %84, 0.000000e+00
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #5
  br i1 %86, label %87, label %98

87:                                               ; preds = %85
  invoke void @_ZN8R2Vector4FlipEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %98 unwind label %96

88:                                               ; preds = %._crit_edge66
  %89 = landingpad { ptr, i32 }
          cleanup
  br label %104

90:                                               ; preds = %67
  %91 = landingpad { ptr, i32 }
          cleanup
  br label %103

92:                                               ; preds = %70, %68
  %93 = landingpad { ptr, i32 }
          cleanup
  br label %102

94:                                               ; preds = %83, %71
  %95 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #5
  br label %102

96:                                               ; preds = %98, %87
  %97 = landingpad { ptr, i32 }
          cleanup
  br label %102

98:                                               ; preds = %87, %85
  %99 = load ptr, ptr %15, align 8, !tbaa !16
  %100 = getelementptr inbounds %class.R2Point, ptr %99, i64 %17
  invoke void @_ZN6R2LineC1ERK7R2PointRK8R2Vectori(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(16) %100, ptr noundef nonnull align 8 dereferenceable(16) %8, i32 noundef 0)
          to label %101 unwind label %96

101:                                              ; preds = %98
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  br label %106

102:                                              ; preds = %94, %96, %92
  %.pn.pn = phi { ptr, i32 } [ %93, %92 ], [ %97, %96 ], [ %95, %94 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  br label %103

103:                                              ; preds = %102, %90
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %102 ], [ %91, %90 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  br label %104

104:                                              ; preds = %103, %88
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %103 ], [ %89, %88 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  br label %105

105:                                              ; preds = %44, %65, %104, %29
  %.pn.pn.pn.pn.pn.pn = phi { ptr, i32 } [ %30, %29 ], [ %.pn.pn.pn.pn, %104 ], [ %66, %65 ], [ %45, %44 ]
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  resume { ptr, i32 } %.pn.pn.pn.pn.pn.pn

106:                                              ; preds = %101, %13
  ret void
}

declare void @_ZN6R2LineC1ERKS_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP7R2PointEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

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

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

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

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

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

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

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

; Function Attrs: nounwind
declare void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #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 = { 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 "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 = !{!"_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}


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