; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Grid.ll (ZN6R3Grid24SquaredDistanceTransformEv)

; 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.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.29 = 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) #6 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid24SquaredDistanceTransformEv(ptr noundef nonnull align 8 dereferenceable(592) %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 i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %18 = 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 8, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 8, 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 8, 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %19 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  store i32 %19, ptr %15, align 4, !tbaa !9
  %20 = load i32, ptr %15, align 4, !tbaa !9
  %21 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %25

23:                                               ; preds = %1
  %24 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  store i32 %24, ptr %15, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %23, %1
  %26 = load i32, ptr %15, align 4, !tbaa !9
  %27 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  store i32 %30, ptr %15, align 4, !tbaa !9
  br label %31

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

41:                                               ; preds = %31
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.28, i32 noundef 1593, ptr noundef @.str.2)
  br label %42

42:                                               ; preds = %41, %31
  %43 = load i32, ptr %15, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %44, i64 8)
  %46 = extractvalue { i64, i1 } %45, 1
  %47 = extractvalue { i64, i1 } %45, 0
  %48 = select i1 %46, i64 -1, i64 %47
  %49 = call noalias noundef nonnull ptr @_Znam(i64 noundef %48) #9
  store ptr %49, ptr %12, align 8, !tbaa !5
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %53, label %52

52:                                               ; preds = %42
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.29, i32 noundef 1595, ptr noundef @.str.2)
  br label %53

53:                                               ; preds = %52, %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %54 = load i32, ptr %15, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  %56 = sitofp i32 %55 to double
  %57 = fmul double 3.000000e+00, %56
  %58 = load i32, ptr %15, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  %60 = sitofp i32 %59 to double
  %61 = fmul double %57, %60
  store double %61, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %62 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 4
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  store ptr %63, ptr %17, align 8, !tbaa !5
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %81, %53
  %65 = load i32, ptr %14, align 4, !tbaa !9
  %66 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 8
  %67 = load i32, ptr %66, align 4, !tbaa !20
  %68 = icmp slt i32 %65, %67
  br i1 %68, label %69, label %84

69:                                               ; preds = %64
  %70 = load ptr, ptr %17, align 8, !tbaa !5
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = fcmp oeq double %71, 0.000000e+00
  br i1 %72, label %73, label %76

73:                                               ; preds = %69
  %74 = load double, ptr %16, align 8, !tbaa !11
  %75 = load ptr, ptr %17, align 8, !tbaa !5
  store double %74, ptr %75, align 8, !tbaa !11
  br label %78

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

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

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

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

85:                                               ; preds = %177, %84
  %86 = load i32, ptr %3, align 4, !tbaa !9
  %87 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %89, label %180

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

90:                                               ; preds = %173, %89
  %91 = load i32, ptr %4, align 4, !tbaa !9
  %92 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %94, label %176

94:                                               ; preds = %90
  store i32 1, ptr %13, align 4, !tbaa !9
  store i64 0, ptr %8, align 8, !tbaa !23
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %125, %94
  %96 = load i32, ptr %5, align 4, !tbaa !9
  %97 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %99, label %128

99:                                               ; preds = %95
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = load i32, ptr %4, align 4, !tbaa !9
  %102 = load i32, ptr %5, align 4, !tbaa !9
  %103 = call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %100, i32 noundef %101, i32 noundef %102)
  %104 = fcmp oeq double %103, 0.000000e+00
  br i1 %104, label %105, label %109

105:                                              ; preds = %99
  store i64 0, ptr %8, align 8, !tbaa !23
  store i32 0, ptr %13, align 4, !tbaa !9
  %106 = load i32, ptr %3, align 4, !tbaa !9
  %107 = load i32, ptr %4, align 4, !tbaa !9
  %108 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %106, i32 noundef %107, i32 noundef %108, double noundef 0.000000e+00)
  br label %124

109:                                              ; preds = %99
  %110 = load i32, ptr %13, align 4, !tbaa !9
  %111 = icmp eq i32 %110, 0
  br i1 %111, label %112, label %123

112:                                              ; preds = %109
  %113 = load i64, ptr %8, align 8, !tbaa !23
  %114 = add nsw i64 %113, 1
  store i64 %114, ptr %8, align 8, !tbaa !23
  %115 = load i64, ptr %8, align 8, !tbaa !23
  %116 = load i64, ptr %8, align 8, !tbaa !23
  %117 = mul nsw i64 %115, %116
  store i64 %117, ptr %9, align 8, !tbaa !23
  %118 = load i32, ptr %3, align 4, !tbaa !9
  %119 = load i32, ptr %4, align 4, !tbaa !9
  %120 = load i32, ptr %5, align 4, !tbaa !9
  %121 = load i64, ptr %9, align 8, !tbaa !23
  %122 = sitofp i64 %121 to double
  call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %118, i32 noundef %119, i32 noundef %120, double noundef %122)
  br label %123

123:                                              ; preds = %112, %109
  br label %124

124:                                              ; preds = %123, %105
  br label %125

125:                                              ; preds = %124
  %126 = load i32, ptr %5, align 4, !tbaa !9
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %5, align 4, !tbaa !9
  br label %95, !llvm.loop !25

128:                                              ; preds = %95
  store i64 0, ptr %8, align 8, !tbaa !23
  store i32 1, ptr %13, align 4, !tbaa !9
  %129 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %130 = sub nsw i32 %129, 1
  store i32 %130, ptr %5, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %169, %128
  %132 = load i32, ptr %5, align 4, !tbaa !9
  %133 = icmp sge i32 %132, 0
  br i1 %133, label %134, label %172

134:                                              ; preds = %131
  %135 = load i32, ptr %3, align 4, !tbaa !9
  %136 = load i32, ptr %4, align 4, !tbaa !9
  %137 = load i32, ptr %5, align 4, !tbaa !9
  %138 = call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %135, i32 noundef %136, i32 noundef %137)
  %139 = fcmp oeq double %138, 0.000000e+00
  br i1 %139, label %140, label %144

140:                                              ; preds = %134
  store i64 0, ptr %8, align 8, !tbaa !23
  store i32 0, ptr %13, align 4, !tbaa !9
  %141 = load i32, ptr %3, align 4, !tbaa !9
  %142 = load i32, ptr %4, align 4, !tbaa !9
  %143 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %141, i32 noundef %142, i32 noundef %143, double noundef 0.000000e+00)
  br label %168

144:                                              ; preds = %134
  %145 = load i32, ptr %13, align 4, !tbaa !9
  %146 = icmp eq i32 %145, 0
  br i1 %146, label %147, label %167

147:                                              ; preds = %144
  %148 = load i64, ptr %8, align 8, !tbaa !23
  %149 = add nsw i64 %148, 1
  store i64 %149, ptr %8, align 8, !tbaa !23
  %150 = load i64, ptr %8, align 8, !tbaa !23
  %151 = load i64, ptr %8, align 8, !tbaa !23
  %152 = mul nsw i64 %150, %151
  store i64 %152, ptr %9, align 8, !tbaa !23
  %153 = load i64, ptr %9, align 8, !tbaa !23
  %154 = sitofp i64 %153 to double
  %155 = load i32, ptr %3, align 4, !tbaa !9
  %156 = load i32, ptr %4, align 4, !tbaa !9
  %157 = load i32, ptr %5, align 4, !tbaa !9
  %158 = call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %155, i32 noundef %156, i32 noundef %157)
  %159 = fcmp olt double %154, %158
  br i1 %159, label %160, label %166

160:                                              ; preds = %147
  %161 = load i32, ptr %3, align 4, !tbaa !9
  %162 = load i32, ptr %4, align 4, !tbaa !9
  %163 = load i32, ptr %5, align 4, !tbaa !9
  %164 = load i64, ptr %9, align 8, !tbaa !23
  %165 = sitofp i64 %164 to double
  call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %161, i32 noundef %162, i32 noundef %163, double noundef %165)
  br label %166

166:                                              ; preds = %160, %147
  br label %167

167:                                              ; preds = %166, %144
  br label %168

168:                                              ; preds = %167, %140
  br label %169

169:                                              ; preds = %168
  %170 = load i32, ptr %5, align 4, !tbaa !9
  %171 = add nsw i32 %170, -1
  store i32 %171, ptr %5, align 4, !tbaa !9
  br label %131, !llvm.loop !26

172:                                              ; preds = %131
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %4, align 4, !tbaa !9
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %4, align 4, !tbaa !9
  br label %90, !llvm.loop !27

176:                                              ; preds = %90
  br label %177

177:                                              ; preds = %176
  %178 = load i32, ptr %3, align 4, !tbaa !9
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %3, align 4, !tbaa !9
  br label %85, !llvm.loop !28

180:                                              ; preds = %85
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %181

181:                                              ; preds = %330, %180
  %182 = load i32, ptr %5, align 4, !tbaa !9
  %183 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %184 = icmp slt i32 %182, %183
  br i1 %184, label %185, label %333

185:                                              ; preds = %181
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %186

186:                                              ; preds = %326, %185
  %187 = load i32, ptr %4, align 4, !tbaa !9
  %188 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %189 = icmp slt i32 %187, %188
  br i1 %189, label %190, label %329

190:                                              ; preds = %186
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %191

191:                                              ; preds = %207, %190
  %192 = load i32, ptr %3, align 4, !tbaa !9
  %193 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %194 = icmp slt i32 %192, %193
  br i1 %194, label %195, label %210

195:                                              ; preds = %191
  %196 = load i32, ptr %3, align 4, !tbaa !9
  %197 = load i32, ptr %4, align 4, !tbaa !9
  %198 = load i32, ptr %5, align 4, !tbaa !9
  %199 = call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %196, i32 noundef %197, i32 noundef %198)
  %200 = fadd double %199, 5.000000e-01
  %201 = fptosi double %200 to i32
  %202 = sext i32 %201 to i64
  %203 = load ptr, ptr %11, align 8, !tbaa !5
  %204 = load i32, ptr %3, align 4, !tbaa !9
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds i64, ptr %203, i64 %205
  store i64 %202, ptr %206, align 8, !tbaa !23
  br label %207

207:                                              ; preds = %195
  %208 = load i32, ptr %3, align 4, !tbaa !9
  %209 = add nsw i32 %208, 1
  store i32 %209, ptr %3, align 4, !tbaa !9
  br label %191, !llvm.loop !29

210:                                              ; preds = %191
  store i32 0, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %211

211:                                              ; preds = %263, %210
  %212 = load i32, ptr %3, align 4, !tbaa !9
  %213 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %214 = icmp slt i32 %212, %213
  br i1 %214, label %215, label %266

215:                                              ; preds = %211
  %216 = load ptr, ptr %11, align 8, !tbaa !5
  %217 = load i32, ptr %3, align 4, !tbaa !9
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds i64, ptr %216, i64 %218
  %220 = load i64, ptr %219, align 8, !tbaa !23
  store i64 %220, ptr %8, align 8, !tbaa !23
  %221 = load i64, ptr %8, align 8, !tbaa !23
  %222 = icmp ne i64 %221, 0
  br i1 %222, label %223, label %255

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

225:                                              ; preds = %251, %223
  %226 = load i32, ptr %7, align 4, !tbaa !9
  %227 = load i32, ptr %3, align 4, !tbaa !9
  %228 = icmp sle i32 %226, %227
  br i1 %228, label %229, label %254

229:                                              ; preds = %225
  %230 = load ptr, ptr %11, align 8, !tbaa !5
  %231 = load i32, ptr %7, align 4, !tbaa !9
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds i64, ptr %230, i64 %232
  %234 = load i64, ptr %233, align 8, !tbaa !23
  %235 = load i32, ptr %3, align 4, !tbaa !9
  %236 = load i32, ptr %7, align 4, !tbaa !9
  %237 = sub nsw i32 %235, %236
  %238 = load i32, ptr %3, align 4, !tbaa !9
  %239 = load i32, ptr %7, align 4, !tbaa !9
  %240 = sub nsw i32 %238, %239
  %241 = mul nsw i32 %237, %240
  %242 = sext i32 %241 to i64
  %243 = add nsw i64 %234, %242
  store i64 %243, ptr %10, align 8, !tbaa !23
  %244 = load i64, ptr %10, align 8, !tbaa !23
  %245 = load i64, ptr %8, align 8, !tbaa !23
  %246 = icmp sle i64 %244, %245
  br i1 %246, label %247, label %250

247:                                              ; preds = %229
  %248 = load i64, ptr %10, align 8, !tbaa !23
  store i64 %248, ptr %8, align 8, !tbaa !23
  %249 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %249, ptr %6, align 4, !tbaa !9
  br label %250

250:                                              ; preds = %247, %229
  br label %251

251:                                              ; preds = %250
  %252 = load i32, ptr %7, align 4, !tbaa !9
  %253 = add nsw i32 %252, 1
  store i32 %253, ptr %7, align 4, !tbaa !9
  br label %225, !llvm.loop !30

254:                                              ; preds = %225
  br label %257

255:                                              ; preds = %215
  %256 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %256, ptr %6, align 4, !tbaa !9
  br label %257

257:                                              ; preds = %255, %254
  %258 = load i64, ptr %8, align 8, !tbaa !23
  %259 = load ptr, ptr %12, align 8, !tbaa !5
  %260 = load i32, ptr %3, align 4, !tbaa !9
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds i64, ptr %259, i64 %261
  store i64 %258, ptr %262, align 8, !tbaa !23
  br label %263

263:                                              ; preds = %257
  %264 = load i32, ptr %3, align 4, !tbaa !9
  %265 = add nsw i32 %264, 1
  store i32 %265, ptr %3, align 4, !tbaa !9
  br label %211, !llvm.loop !31

266:                                              ; preds = %211
  %267 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %268 = sub nsw i32 %267, 1
  store i32 %268, ptr %6, align 4, !tbaa !9
  %269 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %270 = sub nsw i32 %269, 1
  store i32 %270, ptr %3, align 4, !tbaa !9
  br label %271

271:                                              ; preds = %322, %266
  %272 = load i32, ptr %3, align 4, !tbaa !9
  %273 = icmp sge i32 %272, 0
  br i1 %273, label %274, label %325

274:                                              ; preds = %271
  %275 = load ptr, ptr %12, align 8, !tbaa !5
  %276 = load i32, ptr %3, align 4, !tbaa !9
  %277 = sext i32 %276 to i64
  %278 = getelementptr inbounds i64, ptr %275, i64 %277
  %279 = load i64, ptr %278, align 8, !tbaa !23
  store i64 %279, ptr %8, align 8, !tbaa !23
  %280 = load i64, ptr %8, align 8, !tbaa !23
  %281 = icmp ne i64 %280, 0
  br i1 %281, label %282, label %319

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

284:                                              ; preds = %310, %282
  %285 = load i32, ptr %7, align 4, !tbaa !9
  %286 = load i32, ptr %3, align 4, !tbaa !9
  %287 = icmp sge i32 %285, %286
  br i1 %287, label %288, label %313

288:                                              ; preds = %284
  %289 = load ptr, ptr %11, align 8, !tbaa !5
  %290 = load i32, ptr %7, align 4, !tbaa !9
  %291 = sext i32 %290 to i64
  %292 = getelementptr inbounds i64, ptr %289, i64 %291
  %293 = load i64, ptr %292, align 8, !tbaa !23
  %294 = load i32, ptr %3, align 4, !tbaa !9
  %295 = load i32, ptr %7, align 4, !tbaa !9
  %296 = sub nsw i32 %294, %295
  %297 = load i32, ptr %3, align 4, !tbaa !9
  %298 = load i32, ptr %7, align 4, !tbaa !9
  %299 = sub nsw i32 %297, %298
  %300 = mul nsw i32 %296, %299
  %301 = sext i32 %300 to i64
  %302 = add nsw i64 %293, %301
  store i64 %302, ptr %10, align 8, !tbaa !23
  %303 = load i64, ptr %10, align 8, !tbaa !23
  %304 = load i64, ptr %8, align 8, !tbaa !23
  %305 = icmp sle i64 %303, %304
  br i1 %305, label %306, label %309

306:                                              ; preds = %288
  %307 = load i64, ptr %10, align 8, !tbaa !23
  store i64 %307, ptr %8, align 8, !tbaa !23
  %308 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %308, ptr %6, align 4, !tbaa !9
  br label %309

309:                                              ; preds = %306, %288
  br label %310

310:                                              ; preds = %309
  %311 = load i32, ptr %7, align 4, !tbaa !9
  %312 = add nsw i32 %311, -1
  store i32 %312, ptr %7, align 4, !tbaa !9
  br label %284, !llvm.loop !32

313:                                              ; preds = %284
  %314 = load i32, ptr %3, align 4, !tbaa !9
  %315 = load i32, ptr %4, align 4, !tbaa !9
  %316 = load i32, ptr %5, align 4, !tbaa !9
  %317 = load i64, ptr %8, align 8, !tbaa !23
  %318 = sitofp i64 %317 to double
  call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %314, i32 noundef %315, i32 noundef %316, double noundef %318)
  br label %321

319:                                              ; preds = %274
  %320 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %320, ptr %6, align 4, !tbaa !9
  br label %321

321:                                              ; preds = %319, %313
  br label %322

322:                                              ; preds = %321
  %323 = load i32, ptr %3, align 4, !tbaa !9
  %324 = add nsw i32 %323, -1
  store i32 %324, ptr %3, align 4, !tbaa !9
  br label %271, !llvm.loop !33

325:                                              ; preds = %271
  br label %326

326:                                              ; preds = %325
  %327 = load i32, ptr %4, align 4, !tbaa !9
  %328 = add nsw i32 %327, 1
  store i32 %328, ptr %4, align 4, !tbaa !9
  br label %186, !llvm.loop !34

329:                                              ; preds = %186
  br label %330

330:                                              ; preds = %329
  %331 = load i32, ptr %5, align 4, !tbaa !9
  %332 = add nsw i32 %331, 1
  store i32 %332, ptr %5, align 4, !tbaa !9
  br label %181, !llvm.loop !35

333:                                              ; preds = %181
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %334

334:                                              ; preds = %483, %333
  %335 = load i32, ptr %5, align 4, !tbaa !9
  %336 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %337 = icmp slt i32 %335, %336
  br i1 %337, label %338, label %486

338:                                              ; preds = %334
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %339

339:                                              ; preds = %479, %338
  %340 = load i32, ptr %3, align 4, !tbaa !9
  %341 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %342 = icmp slt i32 %340, %341
  br i1 %342, label %343, label %482

343:                                              ; preds = %339
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %344

344:                                              ; preds = %360, %343
  %345 = load i32, ptr %4, align 4, !tbaa !9
  %346 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %347 = icmp slt i32 %345, %346
  br i1 %347, label %348, label %363

348:                                              ; preds = %344
  %349 = load i32, ptr %3, align 4, !tbaa !9
  %350 = load i32, ptr %4, align 4, !tbaa !9
  %351 = load i32, ptr %5, align 4, !tbaa !9
  %352 = call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %349, i32 noundef %350, i32 noundef %351)
  %353 = fadd double %352, 5.000000e-01
  %354 = fptosi double %353 to i32
  %355 = sext i32 %354 to i64
  %356 = load ptr, ptr %11, align 8, !tbaa !5
  %357 = load i32, ptr %4, align 4, !tbaa !9
  %358 = sext i32 %357 to i64
  %359 = getelementptr inbounds i64, ptr %356, i64 %358
  store i64 %355, ptr %359, align 8, !tbaa !23
  br label %360

360:                                              ; preds = %348
  %361 = load i32, ptr %4, align 4, !tbaa !9
  %362 = add nsw i32 %361, 1
  store i32 %362, ptr %4, align 4, !tbaa !9
  br label %344, !llvm.loop !36

363:                                              ; preds = %344
  store i32 0, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %364

364:                                              ; preds = %416, %363
  %365 = load i32, ptr %4, align 4, !tbaa !9
  %366 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %367 = icmp slt i32 %365, %366
  br i1 %367, label %368, label %419

368:                                              ; preds = %364
  %369 = load ptr, ptr %11, align 8, !tbaa !5
  %370 = load i32, ptr %4, align 4, !tbaa !9
  %371 = sext i32 %370 to i64
  %372 = getelementptr inbounds i64, ptr %369, i64 %371
  %373 = load i64, ptr %372, align 8, !tbaa !23
  store i64 %373, ptr %8, align 8, !tbaa !23
  %374 = load i64, ptr %8, align 8, !tbaa !23
  %375 = icmp ne i64 %374, 0
  br i1 %375, label %376, label %408

376:                                              ; preds = %368
  %377 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %377, ptr %7, align 4, !tbaa !9
  br label %378

378:                                              ; preds = %404, %376
  %379 = load i32, ptr %7, align 4, !tbaa !9
  %380 = load i32, ptr %4, align 4, !tbaa !9
  %381 = icmp sle i32 %379, %380
  br i1 %381, label %382, label %407

382:                                              ; preds = %378
  %383 = load ptr, ptr %11, align 8, !tbaa !5
  %384 = load i32, ptr %7, align 4, !tbaa !9
  %385 = sext i32 %384 to i64
  %386 = getelementptr inbounds i64, ptr %383, i64 %385
  %387 = load i64, ptr %386, align 8, !tbaa !23
  %388 = load i32, ptr %4, align 4, !tbaa !9
  %389 = load i32, ptr %7, align 4, !tbaa !9
  %390 = sub nsw i32 %388, %389
  %391 = load i32, ptr %4, align 4, !tbaa !9
  %392 = load i32, ptr %7, align 4, !tbaa !9
  %393 = sub nsw i32 %391, %392
  %394 = mul nsw i32 %390, %393
  %395 = sext i32 %394 to i64
  %396 = add nsw i64 %387, %395
  store i64 %396, ptr %10, align 8, !tbaa !23
  %397 = load i64, ptr %10, align 8, !tbaa !23
  %398 = load i64, ptr %8, align 8, !tbaa !23
  %399 = icmp sle i64 %397, %398
  br i1 %399, label %400, label %403

400:                                              ; preds = %382
  %401 = load i64, ptr %10, align 8, !tbaa !23
  store i64 %401, ptr %8, align 8, !tbaa !23
  %402 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %402, ptr %6, align 4, !tbaa !9
  br label %403

403:                                              ; preds = %400, %382
  br label %404

404:                                              ; preds = %403
  %405 = load i32, ptr %7, align 4, !tbaa !9
  %406 = add nsw i32 %405, 1
  store i32 %406, ptr %7, align 4, !tbaa !9
  br label %378, !llvm.loop !37

407:                                              ; preds = %378
  br label %410

408:                                              ; preds = %368
  %409 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %409, ptr %6, align 4, !tbaa !9
  br label %410

410:                                              ; preds = %408, %407
  %411 = load i64, ptr %8, align 8, !tbaa !23
  %412 = load ptr, ptr %12, align 8, !tbaa !5
  %413 = load i32, ptr %4, align 4, !tbaa !9
  %414 = sext i32 %413 to i64
  %415 = getelementptr inbounds i64, ptr %412, i64 %414
  store i64 %411, ptr %415, align 8, !tbaa !23
  br label %416

416:                                              ; preds = %410
  %417 = load i32, ptr %4, align 4, !tbaa !9
  %418 = add nsw i32 %417, 1
  store i32 %418, ptr %4, align 4, !tbaa !9
  br label %364, !llvm.loop !38

419:                                              ; preds = %364
  %420 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %421 = sub nsw i32 %420, 1
  store i32 %421, ptr %6, align 4, !tbaa !9
  %422 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %18)
  %423 = sub nsw i32 %422, 1
  store i32 %423, ptr %4, align 4, !tbaa !9
  br label %424

424:                                              ; preds = %475, %419
  %425 = load i32, ptr %4, align 4, !tbaa !9
  %426 = icmp sge i32 %425, 0
  br i1 %426, label %427, label %478

427:                                              ; preds = %424
  %428 = load ptr, ptr %12, align 8, !tbaa !5
  %429 = load i32, ptr %4, align 4, !tbaa !9
  %430 = sext i32 %429 to i64
  %431 = getelementptr inbounds i64, ptr %428, i64 %430
  %432 = load i64, ptr %431, align 8, !tbaa !23
  store i64 %432, ptr %8, align 8, !tbaa !23
  %433 = load i64, ptr %8, align 8, !tbaa !23
  %434 = icmp ne i64 %433, 0
  br i1 %434, label %435, label %472

435:                                              ; preds = %427
  %436 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %436, ptr %7, align 4, !tbaa !9
  br label %437

437:                                              ; preds = %463, %435
  %438 = load i32, ptr %7, align 4, !tbaa !9
  %439 = load i32, ptr %4, align 4, !tbaa !9
  %440 = icmp sgt i32 %438, %439
  br i1 %440, label %441, label %466

441:                                              ; preds = %437
  %442 = load ptr, ptr %11, align 8, !tbaa !5
  %443 = load i32, ptr %7, align 4, !tbaa !9
  %444 = sext i32 %443 to i64
  %445 = getelementptr inbounds i64, ptr %442, i64 %444
  %446 = load i64, ptr %445, align 8, !tbaa !23
  %447 = load i32, ptr %4, align 4, !tbaa !9
  %448 = load i32, ptr %7, align 4, !tbaa !9
  %449 = sub nsw i32 %447, %448
  %450 = load i32, ptr %4, align 4, !tbaa !9
  %451 = load i32, ptr %7, align 4, !tbaa !9
  %452 = sub nsw i32 %450, %451
  %453 = mul nsw i32 %449, %452
  %454 = sext i32 %453 to i64
  %455 = add nsw i64 %446, %454
  store i64 %455, ptr %10, align 8, !tbaa !23
  %456 = load i64, ptr %10, align 8, !tbaa !23
  %457 = load i64, ptr %8, align 8, !tbaa !23
  %458 = icmp sle i64 %456, %457
  br i1 %458, label %459, label %462

459:                                              ; preds = %441
  %460 = load i64, ptr %10, align 8, !tbaa !23
  store i64 %460, ptr %8, align 8, !tbaa !23
  %461 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %461, ptr %6, align 4, !tbaa !9
  br label %462

462:                                              ; preds = %459, %441
  br label %463

463:                                              ; preds = %462
  %464 = load i32, ptr %7, align 4, !tbaa !9
  %465 = add nsw i32 %464, -1
  store i32 %465, ptr %7, align 4, !tbaa !9
  br label %437, !llvm.loop !39

466:                                              ; preds = %437
  %467 = load i32, ptr %3, align 4, !tbaa !9
  %468 = load i32, ptr %4, align 4, !tbaa !9
  %469 = load i32, ptr %5, align 4, !tbaa !9
  %470 = load i64, ptr %8, align 8, !tbaa !23
  %471 = sitofp i64 %470 to double
  call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %467, i32 noundef %468, i32 noundef %469, double noundef %471)
  br label %474

472:                                              ; preds = %427
  %473 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %473, ptr %6, align 4, !tbaa !9
  br label %474

474:                                              ; preds = %472, %466
  br label %475

475:                                              ; preds = %474
  %476 = load i32, ptr %4, align 4, !tbaa !9
  %477 = add nsw i32 %476, -1
  store i32 %477, ptr %4, align 4, !tbaa !9
  br label %424, !llvm.loop !40

478:                                              ; preds = %424
  br label %479

479:                                              ; preds = %478
  %480 = load i32, ptr %3, align 4, !tbaa !9
  %481 = add nsw i32 %480, 1
  store i32 %481, ptr %3, align 4, !tbaa !9
  br label %339, !llvm.loop !41

482:                                              ; preds = %339
  br label %483

483:                                              ; preds = %482
  %484 = load i32, ptr %5, align 4, !tbaa !9
  %485 = add nsw i32 %484, 1
  store i32 %485, ptr %5, align 4, !tbaa !9
  br label %334, !llvm.loop !42

486:                                              ; preds = %334
  %487 = load ptr, ptr %11, align 8, !tbaa !5
  %488 = icmp eq ptr %487, null
  br i1 %488, label %490, label %489

489:                                              ; preds = %486
  call void @_ZdaPv(ptr noundef %487) #10
  br label %490

490:                                              ; preds = %489, %486
  %491 = load ptr, ptr %12, align 8, !tbaa !5
  %492 = icmp eq ptr %491, null
  br i1 %492, label %494, label %493

493:                                              ; preds = %490
  call void @_ZdaPv(ptr noundef %491) #10
  br label %494

494:                                              ; preds = %493, %490
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, 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 8, 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 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, 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 = { 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 #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 = { 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 #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 560}
!14 = !{!"_ZTS6R3Grid", !15, i64 0, !15, i64 272, !12, i64 544, !12, i64 552, !6, i64 560, !7, i64 568, !10, i64 580, !10, i64 584, !10, i64 588}
!15 = !{!"_ZTS8R3Affine", !16, i64 0, !17, i64 8, !17, i64 136, !18, i64 264}
!16 = !{!"_ZTS16R3Transformation"}
!17 = !{!"_ZTS8R4Matrix", !7, i64 0}
!18 = !{!"_ZTS7RNFlags", !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!14, !10, i64 588}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!24, !24, i64 0}
!24 = !{!"long long", !7, i64 0}
!25 = distinct !{!25, !22}
!26 = distinct !{!26, !22}
!27 = distinct !{!27, !22}
!28 = distinct !{!28, !22}
!29 = distinct !{!29, !22}
!30 = distinct !{!30, !22}
!31 = distinct !{!31, !22}
!32 = distinct !{!32, !22}
!33 = distinct !{!33, !22}
!34 = distinct !{!34, !22}
!35 = distinct !{!35, !22}
!36 = distinct !{!36, !22}
!37 = distinct !{!37, !22}
!38 = distinct !{!38, !22}
!39 = distinct !{!39, !22}
!40 = distinct !{!40, !22}
!41 = distinct !{!41, !22}
!42 = distinct !{!42, !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"

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #3 align 2

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

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

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

7:                                                ; preds = %5, %1
  %.0174 = phi i32 [ %6, %5 ], [ %2, %1 ]
  %8 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %9 = icmp slt i32 %.0174, %8
  br i1 %9, label %10, label %12

10:                                               ; preds = %7
  %11 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  br label %12

12:                                               ; preds = %10, %7
  %.1175 = phi i32 [ %11, %10 ], [ %.0174, %7 ]
  %13 = zext nneg i32 %.1175 to i64
  %14 = icmp slt i32 %.1175, 0
  %15 = shl nuw nsw i64 %13, 3
  %16 = select i1 %14, i64 -1, i64 %15
  %17 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %16) #6
  %18 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %16) #6
  %19 = add nsw i32 %.1175, 1
  %20 = sitofp i32 %19 to double
  %21 = fmul double %20, 3.000000e+00
  %22 = fmul double %21, %20
  %23 = getelementptr inbounds i8, ptr %0, i64 588
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph.preheader, label %.preheader257

.lr.ph.preheader:                                 ; preds = %12
  %26 = getelementptr inbounds i8, ptr %0, i64 560
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = zext nneg i32 %24 to i64
  %min.iters.check = icmp ult i32 %24, 4
  br i1 %min.iters.check, label %.lr.ph.preheader372, label %vector.ph

.lr.ph.preheader372:                              ; preds = %middle.block, %.lr.ph.preheader
  %.0259.ph = phi ptr [ %27, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.0176258.ph = phi i32 [ 0, %.lr.ph.preheader ], [ %ind.end368, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %28, 2147483644
  %29 = shl nuw nsw i64 %n.vec, 3
  %ind.end = getelementptr i8, ptr %27, i64 %29
  %ind.end368 = trunc nuw nsw i64 %n.vec to i32
  %broadcast.splatinsert = insertelement <2 x double> poison, double %22, 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 %27, i64 %offset.idx
  %30 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <2 x double>, ptr %next.gep, align 8, !tbaa !18
  %wide.load371 = load <2 x double>, ptr %30, align 8, !tbaa !18
  %31 = fcmp oeq <2 x double> %wide.load, zeroinitializer
  %32 = fcmp oeq <2 x double> %wide.load371, zeroinitializer
  %33 = select <2 x i1> %31, <2 x double> %broadcast.splat, <2 x double> zeroinitializer
  %34 = select <2 x i1> %32, <2 x double> %broadcast.splat, <2 x double> zeroinitializer
  store <2 x double> %33, ptr %next.gep, align 8, !tbaa !18
  store <2 x double> %34, ptr %30, align 8, !tbaa !18
  %index.next = add nuw i64 %index, 4
  %35 = icmp eq i64 %index.next, %n.vec
  br i1 %35, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %28
  br i1 %cmp.n, label %.preheader257, label %.lr.ph.preheader372

.preheader257:                                    ; preds = %.lr.ph, %middle.block, %12
  %36 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %.preheader256, label %.preheader254

.lr.ph:                                           ; preds = %.lr.ph.preheader372, %.lr.ph
  %.0259 = phi ptr [ %40, %.lr.ph ], [ %.0259.ph, %.lr.ph.preheader372 ]
  %.0176258 = phi i32 [ %41, %.lr.ph ], [ %.0176258.ph, %.lr.ph.preheader372 ]
  %38 = load double, ptr %.0259, align 8, !tbaa !18
  %39 = fcmp oeq double %38, 0.000000e+00
  %. = select i1 %39, double %22, double 0.000000e+00
  store double %., ptr %.0259, align 8, !tbaa !18
  %40 = getelementptr inbounds i8, ptr %.0259, i64 8
  %41 = add nuw nsw i32 %.0176258, 1
  %exitcond.not = icmp eq i32 %41, %24
  br i1 %exitcond.not, label %.preheader257, label %.lr.ph, !llvm.loop !23

.preheader256:                                    ; preds = %.preheader257, %._crit_edge272
  %.0173273 = phi i32 [ %77, %._crit_edge272 ], [ 0, %.preheader257 ]
  %42 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.preheader255, label %._crit_edge272

.preheader254:                                    ; preds = %._crit_edge272, %.preheader257
  %44 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.preheader253, label %.preheader247

.preheader255:                                    ; preds = %.preheader256, %._crit_edge270
  %.0181271 = phi i32 [ %74, %._crit_edge270 ], [ 0, %.preheader256 ]
  %46 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %.lr.ph263, label %._crit_edge

.lr.ph263:                                        ; preds = %.preheader255, %56
  %.0177262 = phi i32 [ %.1178, %56 ], [ 1, %.preheader255 ]
  %.0186261 = phi i32 [ %57, %56 ], [ 0, %.preheader255 ]
  %.0190260 = phi i64 [ %.1191, %56 ], [ 0, %.preheader255 ]
  %48 = tail call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0173273, i32 noundef %.0181271, i32 noundef %.0186261)
  %49 = fcmp oeq double %48, 0.000000e+00
  br i1 %49, label %.sink.split, label %50

50:                                               ; preds = %.lr.ph263
  %51 = icmp eq i32 %.0177262, 0
  br i1 %51, label %52, label %56

52:                                               ; preds = %50
  %53 = add nsw i64 %.0190260, 1
  %54 = mul nsw i64 %53, %53
  %55 = uitofp nneg i64 %54 to double
  br label %.sink.split

.sink.split:                                      ; preds = %.lr.ph263, %52
  %.sink = phi double [ %55, %52 ], [ 0.000000e+00, %.lr.ph263 ]
  %.1191.ph = phi i64 [ %53, %52 ], [ 0, %.lr.ph263 ]
  tail call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0173273, i32 noundef %.0181271, i32 noundef %.0186261, double noundef %.sink)
  br label %56

56:                                               ; preds = %.sink.split, %50
  %.1191 = phi i64 [ %.0190260, %50 ], [ %.1191.ph, %.sink.split ]
  %.1178 = phi i32 [ 1, %50 ], [ 0, %.sink.split ]
  %57 = add nuw nsw i32 %.0186261, 1
  %58 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %.lr.ph263, label %._crit_edge, !llvm.loop !24

._crit_edge:                                      ; preds = %56, %.preheader255
  %60 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %61 = icmp sgt i32 %60, 0
  br i1 %61, label %.lr.ph269, label %._crit_edge270

.lr.ph269:                                        ; preds = %._crit_edge, %72
  %.1187267.in = phi i32 [ %.1187267, %72 ], [ %60, %._crit_edge ]
  %.2179266 = phi i32 [ %.3180, %72 ], [ 1, %._crit_edge ]
  %.2192265 = phi i64 [ %.3193, %72 ], [ 0, %._crit_edge ]
  %.1187267 = add nsw i32 %.1187267.in, -1
  %62 = tail call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0173273, i32 noundef %.0181271, i32 noundef %.1187267)
  %63 = fcmp oeq double %62, 0.000000e+00
  br i1 %63, label %.sink.split366, label %64

64:                                               ; preds = %.lr.ph269
  %65 = icmp eq i32 %.2179266, 0
  br i1 %65, label %66, label %72

66:                                               ; preds = %64
  %67 = add nsw i64 %.2192265, 1
  %68 = mul nsw i64 %67, %67
  %69 = uitofp nneg i64 %68 to double
  %70 = tail call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0173273, i32 noundef %.0181271, i32 noundef %.1187267)
  %71 = fcmp ogt double %70, %69
  br i1 %71, label %.sink.split366, label %72

.sink.split366:                                   ; preds = %66, %.lr.ph269
  %.sink367 = phi double [ 0.000000e+00, %.lr.ph269 ], [ %69, %66 ]
  %.3193.ph = phi i64 [ 0, %.lr.ph269 ], [ %67, %66 ]
  tail call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0173273, i32 noundef %.0181271, i32 noundef %.1187267, double noundef %.sink367)
  br label %72

72:                                               ; preds = %.sink.split366, %66, %64
  %.3193 = phi i64 [ %67, %66 ], [ %.2192265, %64 ], [ %.3193.ph, %.sink.split366 ]
  %.3180 = phi i32 [ 0, %66 ], [ 1, %64 ], [ 0, %.sink.split366 ]
  %73 = icmp ugt i32 %.1187267.in, 1
  br i1 %73, label %.lr.ph269, label %._crit_edge270, !llvm.loop !25

._crit_edge270:                                   ; preds = %72, %._crit_edge
  %74 = add nuw nsw i32 %.0181271, 1
  %75 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %76 = icmp slt i32 %74, %75
  br i1 %76, label %.preheader255, label %._crit_edge272, !llvm.loop !26

._crit_edge272:                                   ; preds = %._crit_edge270, %.preheader256
  %77 = add nuw nsw i32 %.0173273, 1
  %78 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %.preheader256, label %.preheader254, !llvm.loop !27

.preheader253:                                    ; preds = %.preheader254, %._crit_edge302
  %.2188303 = phi i32 [ %152, %._crit_edge302 ], [ 0, %.preheader254 ]
  %80 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %81 = icmp sgt i32 %80, 0
  br i1 %81, label %.preheader252, label %._crit_edge302

.preheader247:                                    ; preds = %._crit_edge302, %.preheader254
  %82 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %83 = icmp sgt i32 %82, 0
  br i1 %83, label %.preheader246, label %._crit_edge336

.preheader252:                                    ; preds = %.preheader253, %._crit_edge300
  %.1182301 = phi i32 [ %149, %._crit_edge300 ], [ 0, %.preheader253 ]
  %84 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %85 = icmp sgt i32 %84, 0
  br i1 %85, label %.lr.ph275, label %.preheader251

.preheader251:                                    ; preds = %.lr.ph275, %.preheader252
  %86 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %87 = icmp sgt i32 %86, 0
  br i1 %87, label %.lr.ph285, label %._crit_edge286

.lr.ph275:                                        ; preds = %.preheader252, %.lr.ph275
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph275 ], [ 0, %.preheader252 ]
  %88 = trunc nuw nsw i64 %indvars.iv to i32
  %89 = tail call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %88, i32 noundef %.1182301, i32 noundef %.2188303)
  %90 = fadd double %89, 5.000000e-01
  %91 = fptosi double %90 to i32
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv
  store i64 %92, ptr %93, align 8, !tbaa !28
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %94 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %95 = sext i32 %94 to i64
  %96 = icmp slt i64 %indvars.iv.next, %95
  br i1 %96, label %.lr.ph275, label %.preheader251, !llvm.loop !30

.lr.ph285:                                        ; preds = %.preheader251, %.loopexit250
  %indvars.iv344 = phi i64 [ %indvars.iv.next345, %.loopexit250 ], [ 0, %.preheader251 ]
  %indvars.iv341 = phi i32 [ %indvars.iv.next342, %.loopexit250 ], [ 1, %.preheader251 ]
  %.0199282 = phi i32 [ %.3202, %.loopexit250 ], [ 0, %.preheader251 ]
  %97 = trunc i64 %indvars.iv344 to i32
  %98 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv344
  %99 = load i64, ptr %98, align 8, !tbaa !28
  %.not233 = icmp eq i64 %99, 0
  %100 = trunc nuw nsw i64 %indvars.iv344 to i32
  br i1 %.not233, label %.loopexit250, label %.preheader249

.preheader249:                                    ; preds = %.lr.ph285
  %101 = sext i32 %.0199282 to i64
  %.not234276 = icmp slt i64 %indvars.iv344, %101
  br i1 %.not234276, label %.loopexit250, label %.lr.ph280.preheader

.lr.ph280.preheader:                              ; preds = %.preheader249
  %102 = sub i32 %indvars.iv341, %.0199282
  %xtraiter = and i32 %102, 1
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph280.prol.loopexit, label %.lr.ph280.prol

.lr.ph280.prol:                                   ; preds = %.lr.ph280.preheader
  %103 = getelementptr inbounds i64, ptr %17, i64 %101
  %104 = load i64, ptr %103, align 8, !tbaa !28
  %105 = sub nsw i64 %indvars.iv344, %101
  %106 = mul i64 %105, %105
  %107 = and i64 %106, 4294967295
  %108 = add nsw i64 %104, %107
  %spec.select236.prol = tail call i64 @llvm.smin.i64(i64 %108, i64 %99)
  %indvars.iv.next339.prol = add nsw i64 %101, 1
  br label %.lr.ph280.prol.loopexit

.lr.ph280.prol.loopexit:                          ; preds = %.lr.ph280.prol, %.lr.ph280.preheader
  %spec.select236.lcssa.unr = phi i64 [ poison, %.lr.ph280.preheader ], [ %spec.select236.prol, %.lr.ph280.prol ]
  %indvars.iv338.unr = phi i64 [ %101, %.lr.ph280.preheader ], [ %indvars.iv.next339.prol, %.lr.ph280.prol ]
  %.4194279.unr = phi i64 [ %99, %.lr.ph280.preheader ], [ %spec.select236.prol, %.lr.ph280.prol ]
  %109 = icmp eq i32 %.0199282, %97
  br i1 %109, label %.loopexit250, label %.lr.ph280

.lr.ph280:                                        ; preds = %.lr.ph280.prol.loopexit, %.lr.ph280
  %indvars.iv338 = phi i64 [ %indvars.iv.next339.1, %.lr.ph280 ], [ %indvars.iv338.unr, %.lr.ph280.prol.loopexit ]
  %.4194279 = phi i64 [ %spec.select236.1, %.lr.ph280 ], [ %.4194279.unr, %.lr.ph280.prol.loopexit ]
  %.1200277 = phi i32 [ %spec.select.1, %.lr.ph280 ], [ %.0199282, %.lr.ph280.prol.loopexit ]
  %110 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv338
  %111 = load i64, ptr %110, align 8, !tbaa !28
  %112 = sub nsw i64 %indvars.iv344, %indvars.iv338
  %113 = mul i64 %112, %112
  %114 = and i64 %113, 4294967295
  %115 = add nsw i64 %111, %114
  %.not235 = icmp sgt i64 %115, %.4194279
  %116 = trunc nsw i64 %indvars.iv338 to i32
  %spec.select = select i1 %.not235, i32 %.1200277, i32 %116
  %spec.select236 = tail call i64 @llvm.smin.i64(i64 %115, i64 %.4194279)
  %indvars.iv.next339 = add nsw i64 %indvars.iv338, 1
  %117 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv.next339
  %118 = load i64, ptr %117, align 8, !tbaa !28
  %119 = sub nsw i64 %indvars.iv344, %indvars.iv.next339
  %120 = mul i64 %119, %119
  %121 = and i64 %120, 4294967295
  %122 = add nsw i64 %118, %121
  %.not235.1 = icmp sgt i64 %122, %spec.select236
  %123 = trunc nsw i64 %indvars.iv.next339 to i32
  %spec.select.1 = select i1 %.not235.1, i32 %spec.select, i32 %123
  %spec.select236.1 = tail call i64 @llvm.smin.i64(i64 %122, i64 %spec.select236)
  %indvars.iv.next339.1 = add nsw i64 %indvars.iv338, 2
  %lftr.wideiv.1 = trunc i64 %indvars.iv.next339.1 to i32
  %exitcond343.not.1 = icmp eq i32 %indvars.iv341, %lftr.wideiv.1
  br i1 %exitcond343.not.1, label %.loopexit250, label %.lr.ph280, !llvm.loop !31

.loopexit250:                                     ; preds = %.lr.ph280.prol.loopexit, %.lr.ph280, %.preheader249, %.lr.ph285
  %.3202 = phi i32 [ %100, %.lr.ph285 ], [ %.0199282, %.preheader249 ], [ %.0199282, %.lr.ph280.prol.loopexit ], [ %spec.select.1, %.lr.ph280 ]
  %.6 = phi i64 [ 0, %.lr.ph285 ], [ %99, %.preheader249 ], [ %spec.select236.lcssa.unr, %.lr.ph280.prol.loopexit ], [ %spec.select236.1, %.lr.ph280 ]
  %124 = getelementptr inbounds i64, ptr %18, i64 %indvars.iv344
  store i64 %.6, ptr %124, align 8, !tbaa !28
  %indvars.iv.next345 = add nuw nsw i64 %indvars.iv344, 1
  %125 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %126 = sext i32 %125 to i64
  %127 = icmp slt i64 %indvars.iv.next345, %126
  %indvars.iv.next342 = add nuw i32 %indvars.iv341, 1
  br i1 %127, label %.lr.ph285, label %._crit_edge286, !llvm.loop !32

._crit_edge286:                                   ; preds = %.loopexit250, %.preheader251
  %128 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %129 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %130 = icmp sgt i32 %129, 0
  br i1 %130, label %.lr.ph299.preheader, label %._crit_edge300

.lr.ph299.preheader:                              ; preds = %._crit_edge286
  %131 = add nsw i32 %128, -1
  %132 = zext nneg i32 %129 to i64
  br label %.lr.ph299

.lr.ph299:                                        ; preds = %.lr.ph299.preheader, %147
  %indvars.iv347 = phi i64 [ %132, %.lr.ph299.preheader ], [ %indvars.iv.next348, %147 ]
  %.4203296 = phi i32 [ %131, %.lr.ph299.preheader ], [ %.7206, %147 ]
  %indvars.iv.next348 = add nsw i64 %indvars.iv347, -1
  %133 = getelementptr inbounds i64, ptr %18, i64 %indvars.iv.next348
  %134 = load i64, ptr %133, align 8, !tbaa !28
  %.not230 = icmp eq i64 %134, 0
  %135 = trunc nuw nsw i64 %indvars.iv.next348 to i32
  br i1 %.not230, label %147, label %.preheader248

.preheader248:                                    ; preds = %.lr.ph299
  %136 = sext i32 %.4203296 to i64
  %.not231287 = icmp sgt i64 %indvars.iv.next348, %136
  br i1 %.not231287, label %._crit_edge292, label %.lr.ph291

.lr.ph291:                                        ; preds = %.preheader248, %.lr.ph291
  %.7290 = phi i64 [ %spec.select238, %.lr.ph291 ], [ %134, %.preheader248 ]
  %.1196289 = phi i32 [ %144, %.lr.ph291 ], [ %.4203296, %.preheader248 ]
  %.5204288 = phi i32 [ %spec.select237, %.lr.ph291 ], [ %.4203296, %.preheader248 ]
  %137 = zext nneg i32 %.1196289 to i64
  %138 = getelementptr inbounds i64, ptr %17, i64 %137
  %139 = load i64, ptr %138, align 8, !tbaa !28
  %140 = sub nsw i32 %135, %.1196289
  %141 = mul nsw i32 %140, %140
  %142 = zext nneg i32 %141 to i64
  %143 = add nsw i64 %139, %142
  %.not232 = icmp sgt i64 %143, %.7290
  %spec.select237 = select i1 %.not232, i32 %.5204288, i32 %.1196289
  %spec.select238 = tail call i64 @llvm.smin.i64(i64 %143, i64 %.7290)
  %144 = add nsw i32 %.1196289, -1
  %145 = sext i32 %.1196289 to i64
  %.not231 = icmp sgt i64 %indvars.iv347, %145
  br i1 %.not231, label %._crit_edge292, label %.lr.ph291, !llvm.loop !33

._crit_edge292:                                   ; preds = %.lr.ph291, %.preheader248
  %.5204.lcssa = phi i32 [ %.4203296, %.preheader248 ], [ %spec.select237, %.lr.ph291 ]
  %.7.lcssa = phi i64 [ %134, %.preheader248 ], [ %spec.select238, %.lr.ph291 ]
  %146 = sitofp i64 %.7.lcssa to double
  tail call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %135, i32 noundef %.1182301, i32 noundef %.2188303, double noundef %146)
  br label %147

147:                                              ; preds = %.lr.ph299, %._crit_edge292
  %.7206 = phi i32 [ %.5204.lcssa, %._crit_edge292 ], [ %135, %.lr.ph299 ]
  %148 = icmp sgt i64 %indvars.iv347, 1
  br i1 %148, label %.lr.ph299, label %._crit_edge300, !llvm.loop !34

._crit_edge300:                                   ; preds = %147, %._crit_edge286
  %149 = add nuw nsw i32 %.1182301, 1
  %150 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %151 = icmp slt i32 %149, %150
  br i1 %151, label %.preheader252, label %._crit_edge302, !llvm.loop !35

._crit_edge302:                                   ; preds = %._crit_edge300, %.preheader253
  %152 = add nuw nsw i32 %.2188303, 1
  %153 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %154 = icmp slt i32 %152, %153
  br i1 %154, label %.preheader253, label %.preheader247, !llvm.loop !36

.preheader246:                                    ; preds = %.preheader247, %._crit_edge334
  %.3189335 = phi i32 [ %225, %._crit_edge334 ], [ 0, %.preheader247 ]
  %155 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %156 = icmp sgt i32 %155, 0
  br i1 %156, label %.preheader245, label %._crit_edge334

.preheader245:                                    ; preds = %.preheader246, %._crit_edge332
  %.4333 = phi i32 [ %222, %._crit_edge332 ], [ 0, %.preheader246 ]
  %157 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %158 = icmp sgt i32 %157, 0
  br i1 %158, label %.lr.ph305, label %.preheader244

.preheader244:                                    ; preds = %.lr.ph305, %.preheader245
  %159 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %160 = icmp sgt i32 %159, 0
  br i1 %160, label %.lr.ph316, label %._crit_edge317

.lr.ph305:                                        ; preds = %.preheader245, %.lr.ph305
  %indvars.iv350 = phi i64 [ %indvars.iv.next351, %.lr.ph305 ], [ 0, %.preheader245 ]
  %161 = trunc nuw nsw i64 %indvars.iv350 to i32
  %162 = tail call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.4333, i32 noundef %161, i32 noundef %.3189335)
  %163 = fadd double %162, 5.000000e-01
  %164 = fptosi double %163 to i32
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv350
  store i64 %165, ptr %166, align 8, !tbaa !28
  %indvars.iv.next351 = add nuw nsw i64 %indvars.iv350, 1
  %167 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %168 = sext i32 %167 to i64
  %169 = icmp slt i64 %indvars.iv.next351, %168
  br i1 %169, label %.lr.ph305, label %.preheader244, !llvm.loop !37

.lr.ph316:                                        ; preds = %.preheader244, %.loopexit
  %indvars.iv360 = phi i64 [ %indvars.iv.next361, %.loopexit ], [ 0, %.preheader244 ]
  %indvars.iv356 = phi i32 [ %indvars.iv.next357, %.loopexit ], [ 1, %.preheader244 ]
  %.8207313 = phi i32 [ %.11210, %.loopexit ], [ 0, %.preheader244 ]
  %170 = trunc i64 %indvars.iv360 to i32
  %171 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv360
  %172 = load i64, ptr %171, align 8, !tbaa !28
  %.not227 = icmp eq i64 %172, 0
  %173 = trunc nuw nsw i64 %indvars.iv360 to i32
  br i1 %.not227, label %.loopexit, label %.preheader243

.preheader243:                                    ; preds = %.lr.ph316
  %174 = sext i32 %.8207313 to i64
  %.not228306 = icmp slt i64 %indvars.iv360, %174
  br i1 %.not228306, label %.loopexit, label %.lr.ph310.preheader

.lr.ph310.preheader:                              ; preds = %.preheader243
  %175 = sub i32 %indvars.iv356, %.8207313
  %xtraiter373 = and i32 %175, 1
  %lcmp.mod374.not = icmp eq i32 %xtraiter373, 0
  br i1 %lcmp.mod374.not, label %.lr.ph310.prol.loopexit, label %.lr.ph310.prol

.lr.ph310.prol:                                   ; preds = %.lr.ph310.preheader
  %176 = getelementptr inbounds i64, ptr %17, i64 %174
  %177 = load i64, ptr %176, align 8, !tbaa !28
  %178 = sub nsw i64 %indvars.iv360, %174
  %179 = mul i64 %178, %178
  %180 = and i64 %179, 4294967295
  %181 = add nsw i64 %177, %180
  %spec.select240.prol = tail call i64 @llvm.smin.i64(i64 %181, i64 %172)
  %indvars.iv.next354.prol = add nsw i64 %174, 1
  br label %.lr.ph310.prol.loopexit

.lr.ph310.prol.loopexit:                          ; preds = %.lr.ph310.prol, %.lr.ph310.preheader
  %spec.select240.lcssa.unr = phi i64 [ poison, %.lr.ph310.preheader ], [ %spec.select240.prol, %.lr.ph310.prol ]
  %indvars.iv353.unr = phi i64 [ %174, %.lr.ph310.preheader ], [ %indvars.iv.next354.prol, %.lr.ph310.prol ]
  %.9309.unr = phi i64 [ %172, %.lr.ph310.preheader ], [ %spec.select240.prol, %.lr.ph310.prol ]
  %182 = icmp eq i32 %.8207313, %170
  br i1 %182, label %.loopexit, label %.lr.ph310

.lr.ph310:                                        ; preds = %.lr.ph310.prol.loopexit, %.lr.ph310
  %indvars.iv353 = phi i64 [ %indvars.iv.next354.1, %.lr.ph310 ], [ %indvars.iv353.unr, %.lr.ph310.prol.loopexit ]
  %.9309 = phi i64 [ %spec.select240.1, %.lr.ph310 ], [ %.9309.unr, %.lr.ph310.prol.loopexit ]
  %.9208307 = phi i32 [ %spec.select239.1, %.lr.ph310 ], [ %.8207313, %.lr.ph310.prol.loopexit ]
  %183 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv353
  %184 = load i64, ptr %183, align 8, !tbaa !28
  %185 = sub nsw i64 %indvars.iv360, %indvars.iv353
  %186 = mul i64 %185, %185
  %187 = and i64 %186, 4294967295
  %188 = add nsw i64 %184, %187
  %.not229 = icmp sgt i64 %188, %.9309
  %189 = trunc nsw i64 %indvars.iv353 to i32
  %spec.select239 = select i1 %.not229, i32 %.9208307, i32 %189
  %spec.select240 = tail call i64 @llvm.smin.i64(i64 %188, i64 %.9309)
  %indvars.iv.next354 = add nsw i64 %indvars.iv353, 1
  %190 = getelementptr inbounds i64, ptr %17, i64 %indvars.iv.next354
  %191 = load i64, ptr %190, align 8, !tbaa !28
  %192 = sub nsw i64 %indvars.iv360, %indvars.iv.next354
  %193 = mul i64 %192, %192
  %194 = and i64 %193, 4294967295
  %195 = add nsw i64 %191, %194
  %.not229.1 = icmp sgt i64 %195, %spec.select240
  %196 = trunc nsw i64 %indvars.iv.next354 to i32
  %spec.select239.1 = select i1 %.not229.1, i32 %spec.select239, i32 %196
  %spec.select240.1 = tail call i64 @llvm.smin.i64(i64 %195, i64 %spec.select240)
  %indvars.iv.next354.1 = add nsw i64 %indvars.iv353, 2
  %lftr.wideiv358.1 = trunc i64 %indvars.iv.next354.1 to i32
  %exitcond359.not.1 = icmp eq i32 %indvars.iv356, %lftr.wideiv358.1
  br i1 %exitcond359.not.1, label %.loopexit, label %.lr.ph310, !llvm.loop !38

.loopexit:                                        ; preds = %.lr.ph310.prol.loopexit, %.lr.ph310, %.preheader243, %.lr.ph316
  %.11210 = phi i32 [ %173, %.lr.ph316 ], [ %.8207313, %.preheader243 ], [ %.8207313, %.lr.ph310.prol.loopexit ], [ %spec.select239.1, %.lr.ph310 ]
  %.11 = phi i64 [ 0, %.lr.ph316 ], [ %172, %.preheader243 ], [ %spec.select240.lcssa.unr, %.lr.ph310.prol.loopexit ], [ %spec.select240.1, %.lr.ph310 ]
  %197 = getelementptr inbounds i64, ptr %18, i64 %indvars.iv360
  store i64 %.11, ptr %197, align 8, !tbaa !28
  %indvars.iv.next361 = add nuw nsw i64 %indvars.iv360, 1
  %198 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %199 = sext i32 %198 to i64
  %200 = icmp slt i64 %indvars.iv.next361, %199
  %indvars.iv.next357 = add nuw i32 %indvars.iv356, 1
  br i1 %200, label %.lr.ph316, label %._crit_edge317, !llvm.loop !39

._crit_edge317:                                   ; preds = %.loopexit, %.preheader244
  %201 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %202 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %203 = icmp sgt i32 %202, 0
  br i1 %203, label %.lr.ph331.preheader, label %._crit_edge332

.lr.ph331.preheader:                              ; preds = %._crit_edge317
  %204 = add nsw i32 %201, -1
  %205 = zext nneg i32 %202 to i64
  br label %.lr.ph331

.lr.ph331:                                        ; preds = %.lr.ph331.preheader, %220
  %indvars.iv363 = phi i64 [ %205, %.lr.ph331.preheader ], [ %indvars.iv.next364, %220 ]
  %.12211327 = phi i32 [ %204, %.lr.ph331.preheader ], [ %.15, %220 ]
  %indvars.iv.next364 = add nsw i64 %indvars.iv363, -1
  %206 = getelementptr inbounds i64, ptr %18, i64 %indvars.iv.next364
  %207 = load i64, ptr %206, align 8, !tbaa !28
  %.not = icmp eq i64 %207, 0
  %208 = trunc nuw nsw i64 %indvars.iv.next364 to i32
  br i1 %.not, label %220, label %.preheader

.preheader:                                       ; preds = %.lr.ph331
  %209 = sext i32 %.12211327 to i64
  %.not225318 = icmp sgt i64 %indvars.iv363, %209
  br i1 %.not225318, label %._crit_edge323, label %.lr.ph322

.lr.ph322:                                        ; preds = %.preheader, %.lr.ph322
  %.12321 = phi i64 [ %spec.select242, %.lr.ph322 ], [ %207, %.preheader ]
  %.3198320 = phi i32 [ %217, %.lr.ph322 ], [ %.12211327, %.preheader ]
  %.13212319 = phi i32 [ %spec.select241, %.lr.ph322 ], [ %.12211327, %.preheader ]
  %210 = zext nneg i32 %.3198320 to i64
  %211 = getelementptr inbounds i64, ptr %17, i64 %210
  %212 = load i64, ptr %211, align 8, !tbaa !28
  %213 = sub nsw i32 %208, %.3198320
  %214 = mul nsw i32 %213, %213
  %215 = zext nneg i32 %214 to i64
  %216 = add nsw i64 %212, %215
  %.not226 = icmp sgt i64 %216, %.12321
  %spec.select241 = select i1 %.not226, i32 %.13212319, i32 %.3198320
  %spec.select242 = tail call i64 @llvm.smin.i64(i64 %216, i64 %.12321)
  %217 = add nsw i32 %.3198320, -1
  %218 = sext i32 %.3198320 to i64
  %.not225.not = icmp slt i64 %indvars.iv363, %218
  br i1 %.not225.not, label %.lr.ph322, label %._crit_edge323, !llvm.loop !40

._crit_edge323:                                   ; preds = %.lr.ph322, %.preheader
  %.13212.lcssa = phi i32 [ %.12211327, %.preheader ], [ %spec.select241, %.lr.ph322 ]
  %.12.lcssa = phi i64 [ %207, %.preheader ], [ %spec.select242, %.lr.ph322 ]
  %219 = sitofp i64 %.12.lcssa to double
  tail call void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.4333, i32 noundef %208, i32 noundef %.3189335, double noundef %219)
  br label %220

220:                                              ; preds = %.lr.ph331, %._crit_edge323
  %.15 = phi i32 [ %.13212.lcssa, %._crit_edge323 ], [ %208, %.lr.ph331 ]
  %221 = icmp sgt i64 %indvars.iv363, 1
  br i1 %221, label %.lr.ph331, label %._crit_edge332, !llvm.loop !41

._crit_edge332:                                   ; preds = %220, %._crit_edge317
  %222 = add nuw nsw i32 %.4333, 1
  %223 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %224 = icmp slt i32 %222, %223
  br i1 %224, label %.preheader245, label %._crit_edge334, !llvm.loop !42

._crit_edge334:                                   ; preds = %._crit_edge332, %.preheader246
  %225 = add nuw nsw i32 %.3189335, 1
  %226 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %227 = icmp slt i32 %225, %226
  br i1 %227, label %.preheader246, label %._crit_edge336, !llvm.loop !43

._crit_edge336:                                   ; preds = %._crit_edge334, %.preheader247
  tail call void @_ZdaPv(ptr noundef nonnull %17) #7
  tail call void @_ZdaPv(ptr noundef nonnull %18) #7
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #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 = { 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 #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 = { 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 #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, !16, i64 588}
!6 = !{!"_ZTS6R3Grid", !7, i64 0, !7, i64 272, !14, i64 544, !14, i64 552, !15, i64 560, !10, i64 568, !16, i64 580, !16, i64 584, !16, i64 588}
!7 = !{!"_ZTS8R3Affine", !8, i64 0, !9, i64 8, !9, i64 136, !12, i64 264}
!8 = !{!"_ZTS16R3Transformation"}
!9 = !{!"_ZTS8R4Matrix", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTS7RNFlags", !13, i64 0}
!13 = !{!"long", !10, i64 0}
!14 = !{!"double", !10, i64 0}
!15 = !{!"any pointer", !10, i64 0}
!16 = !{!"int", !10, i64 0}
!17 = !{!6, !15, i64 560}
!18 = !{!14, !14, i64 0}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !22, !21}
!24 = distinct !{!24, !20}
!25 = distinct !{!25, !20}
!26 = distinct !{!26, !20}
!27 = distinct !{!27, !20}
!28 = !{!29, !29, i64 0}
!29 = !{!"long long", !10, i64 0}
!30 = distinct !{!30, !20}
!31 = distinct !{!31, !20}
!32 = distinct !{!32, !20}
!33 = distinct !{!33, !20}
!34 = distinct !{!34, !20}
!35 = distinct !{!35, !20}
!36 = distinct !{!36, !20}
!37 = distinct !{!37, !20}
!38 = distinct !{!38, !20}
!39 = distinct !{!39, !20}
!40 = distinct !{!40, !20}
!41 = distinct !{!41, !20}
!42 = distinct !{!42, !20}
!43 = distinct !{!43, !20}


; 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