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

; 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.R2Grid = type { %class.R2Affine, %class.R2Affine, double, ptr, [2 x i32], i32, i32 }
%class.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, double noundef) #5 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #6

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid24SquaredDistanceTransformEv(ptr noundef nonnull align 8 dereferenceable(208) %0) #7 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %18 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  store i32 %18, ptr %14, align 4, !tbaa !9
  %19 = load i32, ptr %14, align 4, !tbaa !9
  %20 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %24

22:                                               ; preds = %1
  %23 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  store i32 %23, ptr %14, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %22, %1
  %25 = load i32, ptr %14, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %26, i64 4)
  %28 = extractvalue { i64, i1 } %27, 1
  %29 = extractvalue { i64, i1 } %27, 0
  %30 = select i1 %28, i64 -1, i64 %29
  %31 = call noalias noundef nonnull ptr @_Znam(i64 noundef %30) #9
  store ptr %31, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %24
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.18, i32 noundef 1763, ptr noundef @.str.2)
  br label %35

35:                                               ; preds = %34, %24
  %36 = load i32, ptr %14, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %37, i64 4)
  %39 = extractvalue { i64, i1 } %38, 1
  %40 = extractvalue { i64, i1 } %38, 0
  %41 = select i1 %39, i64 -1, i64 %40
  %42 = call noalias noundef nonnull ptr @_Znam(i64 noundef %41) #9
  store ptr %42, ptr %11, align 8, !tbaa !5
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %35
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.19, i32 noundef 1765, ptr noundef @.str.2)
  br label %46

46:                                               ; preds = %45, %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %47 = load i32, ptr %14, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  %49 = mul nsw i32 2, %48
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  %52 = mul nsw i32 %49, %51
  %53 = sitofp i32 %52 to double
  store double %53, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %54 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  store ptr %55, ptr %16, align 8, !tbaa !5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %81, %46
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 6
  %59 = load i32, ptr %58, align 4, !tbaa !18
  %60 = icmp slt i32 %57, %59
  br i1 %60, label %61, label %84

61:                                               ; preds = %56
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = fcmp oeq double %63, 0.000000e+00
  br i1 %64, label %65, label %68

65:                                               ; preds = %61
  %66 = load double, ptr %15, align 8, !tbaa !11
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  store double %66, ptr %67, align 8, !tbaa !11
  br label %78

68:                                               ; preds = %61
  %69 = load ptr, ptr %16, align 8, !tbaa !5
  %70 = load double, ptr %69, align 8, !tbaa !11
  %71 = fcmp oeq double %70, -3.210000e+02
  br i1 %71, label %72, label %75

72:                                               ; preds = %68
  %73 = load double, ptr %15, align 8, !tbaa !11
  %74 = load ptr, ptr %16, align 8, !tbaa !5
  store double %73, ptr %74, align 8, !tbaa !11
  br label %77

75:                                               ; preds = %68
  %76 = load ptr, ptr %16, align 8, !tbaa !5
  store double 0.000000e+00, ptr %76, align 8, !tbaa !11
  br label %77

77:                                               ; preds = %75, %72
  br label %78

78:                                               ; preds = %77, %65
  %79 = load ptr, ptr %16, align 8, !tbaa !5
  %80 = getelementptr inbounds double, ptr %79, i32 1
  store ptr %80, ptr %16, align 8, !tbaa !5
  br label %81

81:                                               ; preds = %78
  %82 = load i32, ptr %13, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %13, align 4, !tbaa !9
  br label %56, !llvm.loop !19

84:                                               ; preds = %56
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %85

85:                                               ; preds = %161, %84
  %86 = load i32, ptr %4, align 4, !tbaa !9
  %87 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %89, label %164

89:                                               ; preds = %85
  store i32 1, ptr %12, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %117, %89
  %91 = load i32, ptr %3, align 4, !tbaa !9
  %92 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %94, label %120

94:                                               ; preds = %90
  %95 = load i32, ptr %3, align 4, !tbaa !9
  %96 = load i32, ptr %4, align 4, !tbaa !9
  %97 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %95, i32 noundef %96)
  %98 = fcmp oeq double %97, 0.000000e+00
  br i1 %98, label %99, label %102

99:                                               ; preds = %94
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !9
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %100, i32 noundef %101, double noundef 0.000000e+00)
  br label %116

102:                                              ; preds = %94
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = icmp eq i32 %103, 0
  br i1 %104, label %105, label %115

105:                                              ; preds = %102
  %106 = load i32, ptr %7, align 4, !tbaa !9
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %7, align 4, !tbaa !9
  %108 = load i32, ptr %7, align 4, !tbaa !9
  %109 = load i32, ptr %7, align 4, !tbaa !9
  %110 = mul nsw i32 %108, %109
  store i32 %110, ptr %8, align 4, !tbaa !9
  %111 = load i32, ptr %3, align 4, !tbaa !9
  %112 = load i32, ptr %4, align 4, !tbaa !9
  %113 = load i32, ptr %8, align 4, !tbaa !9
  %114 = sitofp i32 %113 to double
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %111, i32 noundef %112, double noundef %114)
  br label %115

115:                                              ; preds = %105, %102
  br label %116

116:                                              ; preds = %115, %99
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %3, align 4, !tbaa !9
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %3, align 4, !tbaa !9
  br label %90, !llvm.loop !21

120:                                              ; preds = %90
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 1, ptr %12, align 4, !tbaa !9
  %121 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %122 = sub nsw i32 %121, 1
  store i32 %122, ptr %3, align 4, !tbaa !9
  br label %123

123:                                              ; preds = %157, %120
  %124 = load i32, ptr %3, align 4, !tbaa !9
  %125 = icmp sge i32 %124, 0
  br i1 %125, label %126, label %160

126:                                              ; preds = %123
  %127 = load i32, ptr %3, align 4, !tbaa !9
  %128 = load i32, ptr %4, align 4, !tbaa !9
  %129 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %127, i32 noundef %128)
  %130 = fcmp oeq double %129, 0.000000e+00
  br i1 %130, label %131, label %134

131:                                              ; preds = %126
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !9
  %132 = load i32, ptr %3, align 4, !tbaa !9
  %133 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %132, i32 noundef %133, double noundef 0.000000e+00)
  br label %156

134:                                              ; preds = %126
  %135 = load i32, ptr %12, align 4, !tbaa !9
  %136 = icmp eq i32 %135, 0
  br i1 %136, label %137, label %155

137:                                              ; preds = %134
  %138 = load i32, ptr %7, align 4, !tbaa !9
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %7, align 4, !tbaa !9
  %140 = load i32, ptr %7, align 4, !tbaa !9
  %141 = load i32, ptr %7, align 4, !tbaa !9
  %142 = mul nsw i32 %140, %141
  store i32 %142, ptr %8, align 4, !tbaa !9
  %143 = load i32, ptr %8, align 4, !tbaa !9
  %144 = sitofp i32 %143 to double
  %145 = load i32, ptr %3, align 4, !tbaa !9
  %146 = load i32, ptr %4, align 4, !tbaa !9
  %147 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %145, i32 noundef %146)
  %148 = fcmp olt double %144, %147
  br i1 %148, label %149, label %154

149:                                              ; preds = %137
  %150 = load i32, ptr %3, align 4, !tbaa !9
  %151 = load i32, ptr %4, align 4, !tbaa !9
  %152 = load i32, ptr %8, align 4, !tbaa !9
  %153 = sitofp i32 %152 to double
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %150, i32 noundef %151, double noundef %153)
  br label %154

154:                                              ; preds = %149, %137
  br label %155

155:                                              ; preds = %154, %134
  br label %156

156:                                              ; preds = %155, %131
  br label %157

157:                                              ; preds = %156
  %158 = load i32, ptr %3, align 4, !tbaa !9
  %159 = add nsw i32 %158, -1
  store i32 %159, ptr %3, align 4, !tbaa !9
  br label %123, !llvm.loop !22

160:                                              ; preds = %123
  br label %161

161:                                              ; preds = %160
  %162 = load i32, ptr %4, align 4, !tbaa !9
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %4, align 4, !tbaa !9
  br label %85, !llvm.loop !23

164:                                              ; preds = %85
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %165

165:                                              ; preds = %300, %164
  %166 = load i32, ptr %3, align 4, !tbaa !9
  %167 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %168 = icmp slt i32 %166, %167
  br i1 %168, label %169, label %303

169:                                              ; preds = %165
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %170

170:                                              ; preds = %184, %169
  %171 = load i32, ptr %4, align 4, !tbaa !9
  %172 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %173 = icmp slt i32 %171, %172
  br i1 %173, label %174, label %187

174:                                              ; preds = %170
  %175 = load i32, ptr %3, align 4, !tbaa !9
  %176 = load i32, ptr %4, align 4, !tbaa !9
  %177 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %175, i32 noundef %176)
  %178 = fadd double %177, 5.000000e-01
  %179 = fptosi double %178 to i32
  %180 = load ptr, ptr %10, align 8, !tbaa !5
  %181 = load i32, ptr %4, align 4, !tbaa !9
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds i32, ptr %180, i64 %182
  store i32 %179, ptr %183, align 4, !tbaa !9
  br label %184

184:                                              ; preds = %174
  %185 = load i32, ptr %4, align 4, !tbaa !9
  %186 = add nsw i32 %185, 1
  store i32 %186, ptr %4, align 4, !tbaa !9
  br label %170, !llvm.loop !24

187:                                              ; preds = %170
  store i32 0, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %188

188:                                              ; preds = %239, %187
  %189 = load i32, ptr %4, align 4, !tbaa !9
  %190 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %191 = icmp slt i32 %189, %190
  br i1 %191, label %192, label %242

192:                                              ; preds = %188
  %193 = load ptr, ptr %10, align 8, !tbaa !5
  %194 = load i32, ptr %4, align 4, !tbaa !9
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds i32, ptr %193, i64 %195
  %197 = load i32, ptr %196, align 4, !tbaa !9
  store i32 %197, ptr %7, align 4, !tbaa !9
  %198 = load i32, ptr %7, align 4, !tbaa !9
  %199 = icmp ne i32 %198, 0
  br i1 %199, label %200, label %231

200:                                              ; preds = %192
  %201 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %201, ptr %6, align 4, !tbaa !9
  br label %202

202:                                              ; preds = %227, %200
  %203 = load i32, ptr %6, align 4, !tbaa !9
  %204 = load i32, ptr %4, align 4, !tbaa !9
  %205 = icmp sle i32 %203, %204
  br i1 %205, label %206, label %230

206:                                              ; preds = %202
  %207 = load ptr, ptr %10, align 8, !tbaa !5
  %208 = load i32, ptr %6, align 4, !tbaa !9
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds i32, ptr %207, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !9
  %212 = load i32, ptr %4, align 4, !tbaa !9
  %213 = load i32, ptr %6, align 4, !tbaa !9
  %214 = sub nsw i32 %212, %213
  %215 = load i32, ptr %4, align 4, !tbaa !9
  %216 = load i32, ptr %6, align 4, !tbaa !9
  %217 = sub nsw i32 %215, %216
  %218 = mul nsw i32 %214, %217
  %219 = add nsw i32 %211, %218
  store i32 %219, ptr %9, align 4, !tbaa !9
  %220 = load i32, ptr %9, align 4, !tbaa !9
  %221 = load i32, ptr %7, align 4, !tbaa !9
  %222 = icmp sle i32 %220, %221
  br i1 %222, label %223, label %226

223:                                              ; preds = %206
  %224 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %224, ptr %7, align 4, !tbaa !9
  %225 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %225, ptr %5, align 4, !tbaa !9
  br label %226

226:                                              ; preds = %223, %206
  br label %227

227:                                              ; preds = %226
  %228 = load i32, ptr %6, align 4, !tbaa !9
  %229 = add nsw i32 %228, 1
  store i32 %229, ptr %6, align 4, !tbaa !9
  br label %202, !llvm.loop !25

230:                                              ; preds = %202
  br label %233

231:                                              ; preds = %192
  %232 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %232, ptr %5, align 4, !tbaa !9
  br label %233

233:                                              ; preds = %231, %230
  %234 = load i32, ptr %7, align 4, !tbaa !9
  %235 = load ptr, ptr %11, align 8, !tbaa !5
  %236 = load i32, ptr %4, align 4, !tbaa !9
  %237 = sext i32 %236 to i64
  %238 = getelementptr inbounds i32, ptr %235, i64 %237
  store i32 %234, ptr %238, align 4, !tbaa !9
  br label %239

239:                                              ; preds = %233
  %240 = load i32, ptr %4, align 4, !tbaa !9
  %241 = add nsw i32 %240, 1
  store i32 %241, ptr %4, align 4, !tbaa !9
  br label %188, !llvm.loop !26

242:                                              ; preds = %188
  %243 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %244 = sub nsw i32 %243, 1
  store i32 %244, ptr %5, align 4, !tbaa !9
  %245 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  %246 = sub nsw i32 %245, 1
  store i32 %246, ptr %4, align 4, !tbaa !9
  br label %247

247:                                              ; preds = %296, %242
  %248 = load i32, ptr %4, align 4, !tbaa !9
  %249 = icmp sge i32 %248, 0
  br i1 %249, label %250, label %299

250:                                              ; preds = %247
  %251 = load ptr, ptr %11, align 8, !tbaa !5
  %252 = load i32, ptr %4, align 4, !tbaa !9
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds i32, ptr %251, i64 %253
  %255 = load i32, ptr %254, align 4, !tbaa !9
  store i32 %255, ptr %7, align 4, !tbaa !9
  %256 = load i32, ptr %7, align 4, !tbaa !9
  %257 = icmp ne i32 %256, 0
  br i1 %257, label %258, label %293

258:                                              ; preds = %250
  %259 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %259, ptr %6, align 4, !tbaa !9
  br label %260

260:                                              ; preds = %285, %258
  %261 = load i32, ptr %6, align 4, !tbaa !9
  %262 = load i32, ptr %4, align 4, !tbaa !9
  %263 = icmp sgt i32 %261, %262
  br i1 %263, label %264, label %288

264:                                              ; preds = %260
  %265 = load ptr, ptr %10, align 8, !tbaa !5
  %266 = load i32, ptr %6, align 4, !tbaa !9
  %267 = sext i32 %266 to i64
  %268 = getelementptr inbounds i32, ptr %265, i64 %267
  %269 = load i32, ptr %268, align 4, !tbaa !9
  %270 = load i32, ptr %4, align 4, !tbaa !9
  %271 = load i32, ptr %6, align 4, !tbaa !9
  %272 = sub nsw i32 %270, %271
  %273 = load i32, ptr %4, align 4, !tbaa !9
  %274 = load i32, ptr %6, align 4, !tbaa !9
  %275 = sub nsw i32 %273, %274
  %276 = mul nsw i32 %272, %275
  %277 = add nsw i32 %269, %276
  store i32 %277, ptr %9, align 4, !tbaa !9
  %278 = load i32, ptr %9, align 4, !tbaa !9
  %279 = load i32, ptr %7, align 4, !tbaa !9
  %280 = icmp sle i32 %278, %279
  br i1 %280, label %281, label %284

281:                                              ; preds = %264
  %282 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %282, ptr %7, align 4, !tbaa !9
  %283 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %283, ptr %5, align 4, !tbaa !9
  br label %284

284:                                              ; preds = %281, %264
  br label %285

285:                                              ; preds = %284
  %286 = load i32, ptr %6, align 4, !tbaa !9
  %287 = add nsw i32 %286, -1
  store i32 %287, ptr %6, align 4, !tbaa !9
  br label %260, !llvm.loop !27

288:                                              ; preds = %260
  %289 = load i32, ptr %3, align 4, !tbaa !9
  %290 = load i32, ptr %4, align 4, !tbaa !9
  %291 = load i32, ptr %7, align 4, !tbaa !9
  %292 = sitofp i32 %291 to double
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %17, i32 noundef %289, i32 noundef %290, double noundef %292)
  br label %295

293:                                              ; preds = %250
  %294 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %294, ptr %5, align 4, !tbaa !9
  br label %295

295:                                              ; preds = %293, %288
  br label %296

296:                                              ; preds = %295
  %297 = load i32, ptr %4, align 4, !tbaa !9
  %298 = add nsw i32 %297, -1
  store i32 %298, ptr %4, align 4, !tbaa !9
  br label %247, !llvm.loop !28

299:                                              ; preds = %247
  br label %300

300:                                              ; preds = %299
  %301 = load i32, ptr %3, align 4, !tbaa !9
  %302 = add nsw i32 %301, 1
  store i32 %302, ptr %3, align 4, !tbaa !9
  br label %165, !llvm.loop !29

303:                                              ; preds = %165
  %304 = load ptr, ptr %10, align 8, !tbaa !5
  %305 = icmp eq ptr %304, null
  br i1 %305, label %307, label %306

306:                                              ; preds = %303
  call void @_ZdaPv(ptr noundef %304) #10
  br label %307

307:                                              ; preds = %306, %303
  %308 = load ptr, ptr %11, align 8, !tbaa !5
  %309 = icmp eq ptr %308, null
  br i1 %309, label %311, label %310

310:                                              ; preds = %307
  call void @_ZdaPv(ptr noundef %308) #10
  br label %311

311:                                              ; preds = %310, %307
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nobuiltin allocsize(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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress nounwind 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 = { 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 #6 = { nobuiltin 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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, !6, i64 184}
!14 = !{!"_ZTS6R2Grid", !15, i64 0, !15, i64 88, !12, i64 176, !6, i64 184, !7, i64 192, !10, i64 200, !10, i64 204}
!15 = !{!"_ZTS8R2Affine", !16, i64 0, !17, i64 8, !10, i64 80}
!16 = !{!"_ZTS16R2Transformation"}
!17 = !{!"_ZTS8R3Matrix", !7, i64 0}
!18 = !{!14, !10, i64 204}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !20}
!24 = distinct !{!24, !20}
!25 = distinct !{!25, !20}
!26 = distinct !{!26, !20}
!27 = distinct !{!27, !20}
!28 = distinct !{!28, !20}
!29 = distinct !{!29, !20}


; 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"

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, double noundef) local_unnamed_addr #2 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid24SquaredDistanceTransformEv(ptr noundef nonnull align 8 dereferenceable(208) %0) local_unnamed_addr #4 align 2 {
  %2 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %3 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %4 = icmp slt i32 %2, %3
  br i1 %4, label %5, label %7

5:                                                ; preds = %1
  %6 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  br label %7

7:                                                ; preds = %5, %1
  %.0105 = phi i32 [ %6, %5 ], [ %2, %1 ]
  %8 = zext nneg i32 %.0105 to i64
  %9 = icmp slt i32 %.0105, 0
  %10 = shl nuw nsw i64 %8, 2
  %11 = select i1 %9, i64 -1, i64 %10
  %12 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %11) #6
  %13 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %11) #6
  %14 = add nsw i32 %.0105, 1
  %15 = shl nsw i32 %14, 1
  %16 = mul nsw i32 %15, %14
  %17 = sitofp i32 %16 to double
  %18 = getelementptr inbounds i8, ptr %0, i64 204
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph.preheader, label %.preheader149

.lr.ph.preheader:                                 ; preds = %7
  %21 = getelementptr inbounds i8, ptr %0, i64 184
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = zext nneg i32 %19 to i64
  %min.iters.check = icmp ult i32 %19, 4
  br i1 %min.iters.check, label %.lr.ph.preheader214, label %vector.ph

.lr.ph.preheader214:                              ; preds = %middle.block, %.lr.ph.preheader
  %.0151.ph = phi ptr [ %22, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.0106150.ph = phi i32 [ 0, %.lr.ph.preheader ], [ %ind.end210, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %23, 2147483644
  %24 = shl nuw nsw i64 %n.vec, 3
  %ind.end = getelementptr i8, ptr %22, i64 %24
  %ind.end210 = trunc nuw nsw i64 %n.vec to i32
  %broadcast.splatinsert = insertelement <2 x double> poison, double %17, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 3
  %next.gep = getelementptr i8, ptr %22, i64 %offset.idx
  %25 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <2 x double>, ptr %next.gep, align 8, !tbaa !16
  %wide.load213 = load <2 x double>, ptr %25, align 8, !tbaa !16
  %26 = fcmp oeq <2 x double> %wide.load, zeroinitializer
  %27 = fcmp oeq <2 x double> %wide.load213, zeroinitializer
  %28 = fcmp oeq <2 x double> %wide.load, <double -3.210000e+02, double -3.210000e+02>
  %29 = fcmp oeq <2 x double> %wide.load213, <double -3.210000e+02, double -3.210000e+02>
  %30 = or <2 x i1> %26, %28
  %31 = or <2 x i1> %27, %29
  %32 = select <2 x i1> %30, <2 x double> %broadcast.splat, <2 x double> zeroinitializer
  %33 = select <2 x i1> %31, <2 x double> %broadcast.splat, <2 x double> zeroinitializer
  store <2 x double> %32, ptr %next.gep, align 8, !tbaa !16
  store <2 x double> %33, ptr %25, align 8, !tbaa !16
  %index.next = add nuw i64 %index, 4
  %34 = icmp eq i64 %index.next, %n.vec
  br i1 %34, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %23
  br i1 %cmp.n, label %.preheader149, label %.lr.ph.preheader214

.preheader149:                                    ; preds = %.lr.ph, %middle.block, %7
  %35 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.preheader148, label %.preheader147

.lr.ph:                                           ; preds = %.lr.ph.preheader214, %.lr.ph
  %.0151 = phi ptr [ %41, %.lr.ph ], [ %.0151.ph, %.lr.ph.preheader214 ]
  %.0106150 = phi i32 [ %42, %.lr.ph ], [ %.0106150.ph, %.lr.ph.preheader214 ]
  %37 = load double, ptr %.0151, align 8, !tbaa !16
  %38 = fcmp oeq double %37, 0.000000e+00
  %39 = fcmp oeq double %37, -3.210000e+02
  %40 = or i1 %38, %39
  %.sink = select i1 %40, double %17, double 0.000000e+00
  store double %.sink, ptr %.0151, align 8, !tbaa !16
  %41 = getelementptr inbounds i8, ptr %.0151, i64 8
  %42 = add nuw nsw i32 %.0106150, 1
  %exitcond.not = icmp eq i32 %42, %19
  br i1 %exitcond.not, label %.preheader149, label %.lr.ph, !llvm.loop !21

.preheader148:                                    ; preds = %.preheader149, %._crit_edge162
  %.0110163 = phi i32 [ %73, %._crit_edge162 ], [ 0, %.preheader149 ]
  %43 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.lr.ph155, label %._crit_edge

.preheader147:                                    ; preds = %._crit_edge162, %.preheader149
  %45 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %.preheader146, label %._crit_edge193

.lr.ph155:                                        ; preds = %.preheader148, %55
  %.0104154 = phi i32 [ %56, %55 ], [ 0, %.preheader148 ]
  %.0107153 = phi i32 [ %.1108, %55 ], [ 1, %.preheader148 ]
  %.0118152 = phi i32 [ %.1119, %55 ], [ 0, %.preheader148 ]
  %47 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0104154, i32 noundef %.0110163)
  %48 = fcmp oeq double %47, 0.000000e+00
  br i1 %48, label %.sink.split, label %49

49:                                               ; preds = %.lr.ph155
  %50 = icmp eq i32 %.0107153, 0
  br i1 %50, label %51, label %55

51:                                               ; preds = %49
  %52 = add nsw i32 %.0118152, 1
  %53 = mul nsw i32 %52, %52
  %54 = uitofp nneg i32 %53 to double
  br label %.sink.split

.sink.split:                                      ; preds = %.lr.ph155, %51
  %.sink207 = phi double [ %54, %51 ], [ 0.000000e+00, %.lr.ph155 ]
  %.1119.ph = phi i32 [ %52, %51 ], [ 0, %.lr.ph155 ]
  tail call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0104154, i32 noundef %.0110163, double noundef %.sink207)
  br label %55

55:                                               ; preds = %.sink.split, %49
  %.1119 = phi i32 [ %.0118152, %49 ], [ %.1119.ph, %.sink.split ]
  %.1108 = phi i32 [ 1, %49 ], [ 0, %.sink.split ]
  %56 = add nuw nsw i32 %.0104154, 1
  %57 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %.lr.ph155, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %55, %.preheader148
  %59 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %60 = icmp sgt i32 %59, 0
  br i1 %60, label %.lr.ph161, label %._crit_edge162

.lr.ph161:                                        ; preds = %._crit_edge, %71
  %.1159.in = phi i32 [ %.1159, %71 ], [ %59, %._crit_edge ]
  %.2109158 = phi i32 [ %.3, %71 ], [ 1, %._crit_edge ]
  %.2120157 = phi i32 [ %.3121, %71 ], [ 0, %._crit_edge ]
  %.1159 = add nsw i32 %.1159.in, -1
  %61 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.1159, i32 noundef %.0110163)
  %62 = fcmp oeq double %61, 0.000000e+00
  br i1 %62, label %.sink.split208, label %63

63:                                               ; preds = %.lr.ph161
  %64 = icmp eq i32 %.2109158, 0
  br i1 %64, label %65, label %71

65:                                               ; preds = %63
  %66 = add nsw i32 %.2120157, 1
  %67 = mul nsw i32 %66, %66
  %68 = uitofp nneg i32 %67 to double
  %69 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.1159, i32 noundef %.0110163)
  %70 = fcmp ogt double %69, %68
  br i1 %70, label %.sink.split208, label %71

.sink.split208:                                   ; preds = %65, %.lr.ph161
  %.sink209 = phi double [ 0.000000e+00, %.lr.ph161 ], [ %68, %65 ]
  %.3121.ph = phi i32 [ 0, %.lr.ph161 ], [ %66, %65 ]
  tail call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.1159, i32 noundef %.0110163, double noundef %.sink209)
  br label %71

71:                                               ; preds = %.sink.split208, %65, %63
  %.3121 = phi i32 [ %66, %65 ], [ %.2120157, %63 ], [ %.3121.ph, %.sink.split208 ]
  %.3 = phi i32 [ 0, %65 ], [ 1, %63 ], [ 0, %.sink.split208 ]
  %72 = icmp ugt i32 %.1159.in, 1
  br i1 %72, label %.lr.ph161, label %._crit_edge162, !llvm.loop !23

._crit_edge162:                                   ; preds = %71, %._crit_edge
  %73 = add nuw nsw i32 %.0110163, 1
  %74 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %.preheader148, label %.preheader147, !llvm.loop !24

.preheader146:                                    ; preds = %.preheader147, %._crit_edge191
  %.2192 = phi i32 [ %139, %._crit_edge191 ], [ 0, %.preheader147 ]
  %76 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %77 = icmp sgt i32 %76, 0
  br i1 %77, label %.lr.ph165, label %.preheader145

.preheader145:                                    ; preds = %.lr.ph165, %.preheader146
  %78 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %79 = icmp sgt i32 %78, 0
  br i1 %79, label %.lr.ph175, label %._crit_edge176

.lr.ph165:                                        ; preds = %.preheader146, %.lr.ph165
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph165 ], [ 0, %.preheader146 ]
  %80 = trunc nuw nsw i64 %indvars.iv to i32
  %81 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.2192, i32 noundef %80)
  %82 = fadd double %81, 5.000000e-01
  %83 = fptosi double %82 to i32
  %84 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv
  store i32 %83, ptr %84, align 4, !tbaa !25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %85 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %86 = sext i32 %85 to i64
  %87 = icmp slt i64 %indvars.iv.next, %86
  br i1 %87, label %.lr.ph165, label %.preheader145, !llvm.loop !26

.lr.ph175:                                        ; preds = %.preheader145, %.loopexit
  %indvars.iv201 = phi i64 [ %indvars.iv.next202, %.loopexit ], [ 0, %.preheader145 ]
  %indvars.iv198 = phi i32 [ %indvars.iv.next199, %.loopexit ], [ 1, %.preheader145 ]
  %.0114172 = phi i32 [ %.3117, %.loopexit ], [ 0, %.preheader145 ]
  %88 = trunc i64 %indvars.iv201 to i32
  %89 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv201
  %90 = load i32, ptr %89, align 4, !tbaa !25
  %.not138 = icmp eq i32 %90, 0
  %91 = trunc nuw nsw i64 %indvars.iv201 to i32
  br i1 %.not138, label %.loopexit, label %.preheader144

.preheader144:                                    ; preds = %.lr.ph175
  %92 = sext i32 %.0114172 to i64
  %.not139166 = icmp slt i64 %indvars.iv201, %92
  br i1 %.not139166, label %.loopexit, label %.lr.ph170.preheader

.lr.ph170.preheader:                              ; preds = %.preheader144
  %93 = sub i32 %indvars.iv198, %.0114172
  %xtraiter = and i32 %93, 1
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph170.prol.loopexit, label %.lr.ph170.prol

.lr.ph170.prol:                                   ; preds = %.lr.ph170.preheader
  %94 = getelementptr inbounds i32, ptr %12, i64 %92
  %95 = load i32, ptr %94, align 4, !tbaa !25
  %96 = trunc i64 %indvars.iv201 to i32
  %97 = sub i32 %96, %.0114172
  %98 = mul nsw i32 %97, %97
  %99 = add nsw i32 %95, %98
  %spec.select.prol = tail call i32 @llvm.smin.i32(i32 %99, i32 %90)
  %indvars.iv.next196.prol = add nsw i64 %92, 1
  br label %.lr.ph170.prol.loopexit

.lr.ph170.prol.loopexit:                          ; preds = %.lr.ph170.prol, %.lr.ph170.preheader
  %spec.select.lcssa.unr = phi i32 [ poison, %.lr.ph170.preheader ], [ %spec.select.prol, %.lr.ph170.prol ]
  %indvars.iv195.unr = phi i64 [ %92, %.lr.ph170.preheader ], [ %indvars.iv.next196.prol, %.lr.ph170.prol ]
  %.4122168.unr = phi i32 [ %90, %.lr.ph170.preheader ], [ %spec.select.prol, %.lr.ph170.prol ]
  %100 = icmp eq i32 %.0114172, %88
  br i1 %100, label %.loopexit, label %.lr.ph170

.lr.ph170:                                        ; preds = %.lr.ph170.prol.loopexit, %.lr.ph170
  %indvars.iv195 = phi i64 [ %indvars.iv.next196.1, %.lr.ph170 ], [ %indvars.iv195.unr, %.lr.ph170.prol.loopexit ]
  %.1115169 = phi i32 [ %spec.select141.1, %.lr.ph170 ], [ %.0114172, %.lr.ph170.prol.loopexit ]
  %.4122168 = phi i32 [ %spec.select.1, %.lr.ph170 ], [ %.4122168.unr, %.lr.ph170.prol.loopexit ]
  %101 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv195
  %102 = load i32, ptr %101, align 4, !tbaa !25
  %103 = sub nsw i64 %indvars.iv201, %indvars.iv195
  %104 = trunc nsw i64 %103 to i32
  %105 = mul nsw i32 %104, %104
  %106 = add nsw i32 %102, %105
  %.not140 = icmp sgt i32 %106, %.4122168
  %spec.select = tail call i32 @llvm.smin.i32(i32 %106, i32 %.4122168)
  %107 = trunc nsw i64 %indvars.iv195 to i32
  %spec.select141 = select i1 %.not140, i32 %.1115169, i32 %107
  %indvars.iv.next196 = add nsw i64 %indvars.iv195, 1
  %108 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv.next196
  %109 = load i32, ptr %108, align 4, !tbaa !25
  %110 = sub nsw i64 %indvars.iv201, %indvars.iv.next196
  %111 = trunc nsw i64 %110 to i32
  %112 = mul nsw i32 %111, %111
  %113 = add nsw i32 %109, %112
  %.not140.1 = icmp sgt i32 %113, %spec.select
  %spec.select.1 = tail call i32 @llvm.smin.i32(i32 %113, i32 %spec.select)
  %114 = trunc nsw i64 %indvars.iv.next196 to i32
  %spec.select141.1 = select i1 %.not140.1, i32 %spec.select141, i32 %114
  %indvars.iv.next196.1 = add nsw i64 %indvars.iv195, 2
  %lftr.wideiv.1 = trunc i64 %indvars.iv.next196.1 to i32
  %exitcond200.not.1 = icmp eq i32 %indvars.iv198, %lftr.wideiv.1
  br i1 %exitcond200.not.1, label %.loopexit, label %.lr.ph170, !llvm.loop !27

.loopexit:                                        ; preds = %.lr.ph170.prol.loopexit, %.lr.ph170, %.preheader144, %.lr.ph175
  %.6124 = phi i32 [ 0, %.lr.ph175 ], [ %90, %.preheader144 ], [ %spec.select.lcssa.unr, %.lr.ph170.prol.loopexit ], [ %spec.select.1, %.lr.ph170 ]
  %.3117 = phi i32 [ %91, %.lr.ph175 ], [ %.0114172, %.preheader144 ], [ %.0114172, %.lr.ph170.prol.loopexit ], [ %spec.select141.1, %.lr.ph170 ]
  %115 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv201
  store i32 %.6124, ptr %115, align 4, !tbaa !25
  %indvars.iv.next202 = add nuw nsw i64 %indvars.iv201, 1
  %116 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %117 = sext i32 %116 to i64
  %118 = icmp slt i64 %indvars.iv.next202, %117
  %indvars.iv.next199 = add nuw i32 %indvars.iv198, 1
  br i1 %118, label %.lr.ph175, label %._crit_edge176, !llvm.loop !28

._crit_edge176:                                   ; preds = %.loopexit, %.preheader145
  %119 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %120 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %121 = icmp sgt i32 %120, 0
  br i1 %121, label %.lr.ph190.preheader, label %._crit_edge191

.lr.ph190.preheader:                              ; preds = %._crit_edge176
  %122 = add nsw i32 %119, -1
  %123 = zext nneg i32 %120 to i64
  br label %.lr.ph190

.lr.ph190:                                        ; preds = %.lr.ph190.preheader, %137
  %indvars.iv204 = phi i64 [ %123, %.lr.ph190.preheader ], [ %indvars.iv.next205, %137 ]
  %.4186 = phi i32 [ %122, %.lr.ph190.preheader ], [ %.7, %137 ]
  %indvars.iv.next205 = add nsw i64 %indvars.iv204, -1
  %124 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv.next205
  %125 = load i32, ptr %124, align 4, !tbaa !25
  %.not = icmp eq i32 %125, 0
  %126 = trunc nuw nsw i64 %indvars.iv.next205 to i32
  br i1 %.not, label %137, label %.preheader

.preheader:                                       ; preds = %.lr.ph190
  %127 = sext i32 %.4186 to i64
  %.not136177 = icmp sgt i64 %indvars.iv204, %127
  br i1 %.not136177, label %._crit_edge182, label %.lr.ph181

.lr.ph181:                                        ; preds = %.preheader, %.lr.ph181
  %.5180 = phi i32 [ %spec.select143, %.lr.ph181 ], [ %.4186, %.preheader ]
  %.7125179 = phi i32 [ %spec.select142, %.lr.ph181 ], [ %125, %.preheader ]
  %.1127178 = phi i32 [ %134, %.lr.ph181 ], [ %.4186, %.preheader ]
  %128 = zext nneg i32 %.1127178 to i64
  %129 = getelementptr inbounds i32, ptr %12, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !25
  %131 = sub nsw i32 %126, %.1127178
  %132 = mul nsw i32 %131, %131
  %133 = add nsw i32 %130, %132
  %.not137 = icmp sgt i32 %133, %.7125179
  %spec.select142 = tail call i32 @llvm.smin.i32(i32 %133, i32 %.7125179)
  %spec.select143 = select i1 %.not137, i32 %.5180, i32 %.1127178
  %134 = add nsw i32 %.1127178, -1
  %135 = sext i32 %.1127178 to i64
  %.not136.not = icmp slt i64 %indvars.iv204, %135
  br i1 %.not136.not, label %.lr.ph181, label %._crit_edge182, !llvm.loop !29

._crit_edge182:                                   ; preds = %.lr.ph181, %.preheader
  %.7125.lcssa = phi i32 [ %125, %.preheader ], [ %spec.select142, %.lr.ph181 ]
  %.5.lcssa = phi i32 [ %.4186, %.preheader ], [ %spec.select143, %.lr.ph181 ]
  %136 = sitofp i32 %.7125.lcssa to double
  tail call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.2192, i32 noundef %126, double noundef %136)
  br label %137

137:                                              ; preds = %.lr.ph190, %._crit_edge182
  %.7 = phi i32 [ %.5.lcssa, %._crit_edge182 ], [ %126, %.lr.ph190 ]
  %138 = icmp sgt i64 %indvars.iv204, 1
  br i1 %138, label %.lr.ph190, label %._crit_edge191, !llvm.loop !30

._crit_edge191:                                   ; preds = %137, %._crit_edge176
  %139 = add nuw nsw i32 %.2192, 1
  %140 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %141 = icmp slt i32 %139, %140
  br i1 %141, label %.preheader146, label %._crit_edge193, !llvm.loop !31

._crit_edge193:                                   ; preds = %._crit_edge191, %.preheader147
  tail call void @_ZdaPv(ptr noundef nonnull %12) #7
  tail call void @_ZdaPv(ptr noundef nonnull %13) #7
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5

attributes #0 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint mustprogress nounwind 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 #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 = { nobuiltin 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 204}
!6 = !{!"_ZTS6R2Grid", !7, i64 0, !7, i64 88, !13, i64 176, !14, i64 184, !10, i64 192, !12, i64 200, !12, i64 204}
!7 = !{!"_ZTS8R2Affine", !8, i64 0, !9, i64 8, !12, i64 80}
!8 = !{!"_ZTS16R2Transformation"}
!9 = !{!"_ZTS8R3Matrix", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"double", !10, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!6, !14, i64 184}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !20, !19}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}
!24 = distinct !{!24, !18}
!25 = !{!12, !12, i64 0}
!26 = distinct !{!26, !18}
!27 = distinct !{!27, !18}
!28 = distinct !{!28, !18}
!29 = distinct !{!29, !18}
!30 = distinct !{!30, !18}
!31 = distinct !{!31, !18}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass