; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RGBD/RGBDUtil.ll (Z25RGBDCreateBoundaryChannelRK6R2GridRS_d)

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

@RN_EPSILON = external global double, align 8

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z25RGBDCreateBoundaryChannelRK6R2GridRS_d(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(208) %1, double noundef %2) #2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %class.R2Grid, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca double, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  %26 = alloca double, align 8
  %27 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call noundef nonnull align 8 dereferenceable(208) ptr @_ZN6R2GridaSERKS_(ptr noundef nonnull align 8 dereferenceable(208) %29, ptr noundef nonnull align 8 dereferenceable(208) %28)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208) %31, double noundef -3.210000e+02)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %32

32:                                               ; preds = %88, %3
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %34)
  %36 = icmp slt i32 %33, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %32
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %91

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %58, %38
  %40 = load i32, ptr %9, align 4, !tbaa !11
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %41)
  %43 = icmp slt i32 %40, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %39
  store i32 5, ptr %8, align 4
  br label %61

45:                                               ; preds = %39
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i32, ptr %7, align 4, !tbaa !11
  %48 = load i32, ptr %9, align 4, !tbaa !11
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %46, i32 noundef %47, i32 noundef %48, double noundef 1.000000e+00)
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load i32, ptr %7, align 4, !tbaa !11
  %51 = load i32, ptr %9, align 4, !tbaa !11
  %52 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %49, i32 noundef %50, i32 noundef %51)
  %53 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %54 = call noundef i32 @_Z12RNIsPositivedd(double noundef %52, double noundef %53)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %45
  store i32 5, ptr %8, align 4
  br label %61

57:                                               ; preds = %45
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %9, align 4, !tbaa !11
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %9, align 4, !tbaa !11
  br label %39, !llvm.loop !13

61:                                               ; preds = %56, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %63)
  %65 = sub nsw i32 %64, 1
  store i32 %65, ptr %10, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %83, %62
  %67 = load i32, ptr %10, align 4, !tbaa !11
  %68 = icmp sge i32 %67, 0
  br i1 %68, label %70, label %69

69:                                               ; preds = %66
  store i32 8, ptr %8, align 4
  br label %86

70:                                               ; preds = %66
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !11
  %73 = load i32, ptr %10, align 4, !tbaa !11
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %71, i32 noundef %72, i32 noundef %73, double noundef 1.000000e+00)
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !11
  %76 = load i32, ptr %10, align 4, !tbaa !11
  %77 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %74, i32 noundef %75, i32 noundef %76)
  %78 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %79 = call noundef i32 @_Z12RNIsPositivedd(double noundef %77, double noundef %78)
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %70
  store i32 8, ptr %8, align 4
  br label %86

82:                                               ; preds = %70
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %10, align 4, !tbaa !11
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr %10, align 4, !tbaa !11
  br label %66, !llvm.loop !15

86:                                               ; preds = %81, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %7, align 4, !tbaa !11
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %7, align 4, !tbaa !11
  br label %32, !llvm.loop !16

91:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %92

92:                                               ; preds = %148, %91
  %93 = load i32, ptr %11, align 4, !tbaa !11
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %94)
  %96 = icmp slt i32 %93, %95
  br i1 %96, label %98, label %97

97:                                               ; preds = %92
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %151

98:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %99

99:                                               ; preds = %118, %98
  %100 = load i32, ptr %12, align 4, !tbaa !11
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %101)
  %103 = icmp slt i32 %100, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %99
  store i32 14, ptr %8, align 4
  br label %121

105:                                              ; preds = %99
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = load i32, ptr %12, align 4, !tbaa !11
  %108 = load i32, ptr %11, align 4, !tbaa !11
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %106, i32 noundef %107, i32 noundef %108, double noundef 1.000000e+00)
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = load i32, ptr %12, align 4, !tbaa !11
  %111 = load i32, ptr %11, align 4, !tbaa !11
  %112 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %109, i32 noundef %110, i32 noundef %111)
  %113 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %114 = call noundef i32 @_Z12RNIsPositivedd(double noundef %112, double noundef %113)
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %117

116:                                              ; preds = %105
  store i32 14, ptr %8, align 4
  br label %121

117:                                              ; preds = %105
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %12, align 4, !tbaa !11
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %12, align 4, !tbaa !11
  br label %99, !llvm.loop !17

121:                                              ; preds = %116, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %122

122:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %123)
  %125 = sub nsw i32 %124, 1
  store i32 %125, ptr %13, align 4, !tbaa !11
  br label %126

126:                                              ; preds = %143, %122
  %127 = load i32, ptr %13, align 4, !tbaa !11
  %128 = icmp sge i32 %127, 0
  br i1 %128, label %130, label %129

129:                                              ; preds = %126
  store i32 17, ptr %8, align 4
  br label %146

130:                                              ; preds = %126
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = load i32, ptr %13, align 4, !tbaa !11
  %133 = load i32, ptr %11, align 4, !tbaa !11
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %131, i32 noundef %132, i32 noundef %133, double noundef 1.000000e+00)
  %134 = load ptr, ptr %4, align 8, !tbaa !5
  %135 = load i32, ptr %13, align 4, !tbaa !11
  %136 = load i32, ptr %11, align 4, !tbaa !11
  %137 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %134, i32 noundef %135, i32 noundef %136)
  %138 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %139 = call noundef i32 @_Z12RNIsPositivedd(double noundef %137, double noundef %138)
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %141, label %142

141:                                              ; preds = %130
  store i32 17, ptr %8, align 4
  br label %146

142:                                              ; preds = %130
  br label %143

143:                                              ; preds = %142
  %144 = load i32, ptr %13, align 4, !tbaa !11
  %145 = add nsw i32 %144, -1
  store i32 %145, ptr %13, align 4, !tbaa !11
  br label %126, !llvm.loop !18

146:                                              ; preds = %141, %129
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %147

147:                                              ; preds = %146
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %11, align 4, !tbaa !11
  %150 = add nsw i32 %149, 1
  store i32 %150, ptr %11, align 4, !tbaa !11
  br label %92, !llvm.loop !19

151:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 208, ptr %14) #6
  %152 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %14, ptr noundef nonnull align 8 dereferenceable(208) %152)
  invoke void @_ZN6R2Grid10SubstituteEdd(ptr noundef nonnull align 8 dereferenceable(208) %14, double noundef 0.000000e+00, double noundef -3.210000e+02)
          to label %153 unwind label %163

153:                                              ; preds = %151
  invoke void @_ZN6R2Grid9FillHolesEv(ptr noundef nonnull align 8 dereferenceable(208) %14)
          to label %154 unwind label %163

154:                                              ; preds = %153
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 1, ptr %17, align 4, !tbaa !11
  br label %155

155:                                              ; preds = %412, %154
  %156 = load i32, ptr %17, align 4, !tbaa !11
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  %158 = invoke noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %157)
          to label %159 unwind label %167

159:                                              ; preds = %155
  %160 = sub nsw i32 %158, 1
  %161 = icmp slt i32 %156, %160
  br i1 %161, label %171, label %162

162:                                              ; preds = %159
  store i32 20, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %416

163:                                              ; preds = %153, %151
  %164 = landingpad { ptr, i32 }
          cleanup
  %165 = extractvalue { ptr, i32 } %164, 0
  store ptr %165, ptr %15, align 8
  %166 = extractvalue { ptr, i32 } %164, 1
  store i32 %166, ptr %16, align 4
  br label %417

167:                                              ; preds = %155
  %168 = landingpad { ptr, i32 }
          cleanup
  %169 = extractvalue { ptr, i32 } %168, 0
  store ptr %169, ptr %15, align 8
  %170 = extractvalue { ptr, i32 } %168, 1
  store i32 %170, ptr %16, align 4
  br label %415

171:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 1, ptr %18, align 4, !tbaa !11
  br label %172

172:                                              ; preds = %406, %171
  %173 = load i32, ptr %18, align 4, !tbaa !11
  %174 = load ptr, ptr %5, align 8, !tbaa !5
  %175 = invoke noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %174)
          to label %176 unwind label %180

176:                                              ; preds = %172
  %177 = sub nsw i32 %175, 1
  %178 = icmp slt i32 %173, %177
  br i1 %178, label %184, label %179

179:                                              ; preds = %176
  store i32 23, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %411

180:                                              ; preds = %172
  %181 = landingpad { ptr, i32 }
          cleanup
  %182 = extractvalue { ptr, i32 } %181, 0
  store ptr %182, ptr %15, align 8
  %183 = extractvalue { ptr, i32 } %181, 1
  store i32 %183, ptr %16, align 4
  br label %410

184:                                              ; preds = %176
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %185 = load ptr, ptr %4, align 8, !tbaa !5
  %186 = load i32, ptr %17, align 4, !tbaa !11
  %187 = load i32, ptr %18, align 4, !tbaa !11
  %188 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %185, i32 noundef %186, i32 noundef %187)
          to label %189 unwind label %200

189:                                              ; preds = %184
  store double %188, ptr %19, align 8, !tbaa !9
  %190 = load double, ptr %19, align 8, !tbaa !9
  %191 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %192 = invoke noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %190, double noundef %191)
          to label %193 unwind label %200

193:                                              ; preds = %189
  %194 = icmp ne i32 %192, 0
  br i1 %194, label %195, label %204

195:                                              ; preds = %193
  %196 = load ptr, ptr %5, align 8, !tbaa !5
  %197 = load i32, ptr %17, align 4, !tbaa !11
  %198 = load i32, ptr %18, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %196, i32 noundef %197, i32 noundef %198, double noundef 1.000000e+00)
          to label %199 unwind label %200

199:                                              ; preds = %195
  store i32 25, ptr %8, align 4
  br label %403

200:                                              ; preds = %208, %204, %195, %189, %184
  %201 = landingpad { ptr, i32 }
          cleanup
  %202 = extractvalue { ptr, i32 } %201, 0
  store ptr %202, ptr %15, align 8
  %203 = extractvalue { ptr, i32 } %201, 1
  store i32 %203, ptr %16, align 4
  br label %409

204:                                              ; preds = %193
  %205 = load i32, ptr %17, align 4, !tbaa !11
  %206 = load i32, ptr %18, align 4, !tbaa !11
  %207 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %14, i32 noundef %205, i32 noundef %206)
          to label %208 unwind label %200

208:                                              ; preds = %204
  store double %207, ptr %19, align 8, !tbaa !9
  %209 = load double, ptr %19, align 8, !tbaa !9
  %210 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %211 = invoke noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %209, double noundef %210)
          to label %212 unwind label %200

212:                                              ; preds = %208
  %213 = icmp ne i32 %211, 0
  br i1 %213, label %214, label %215

214:                                              ; preds = %212
  store i32 25, ptr %8, align 4
  br label %403

215:                                              ; preds = %212
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %216

216:                                              ; preds = %396, %215
  %217 = load i32, ptr %20, align 4, !tbaa !11
  %218 = icmp slt i32 %217, 4
  br i1 %218, label %220, label %219

219:                                              ; preds = %216
  store i32 26, ptr %8, align 4
  br label %401

220:                                              ; preds = %216
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %221 = load i32, ptr %20, align 4, !tbaa !11
  %222 = icmp slt i32 %221, 3
  %223 = zext i1 %222 to i64
  %224 = select i1 %222, i32 -1, i32 0
  store i32 %224, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %225 = load i32, ptr %20, align 4, !tbaa !11
  %226 = icmp slt i32 %225, 3
  br i1 %226, label %227, label %230

227:                                              ; preds = %220
  %228 = load i32, ptr %20, align 4, !tbaa !11
  %229 = sub nsw i32 %228, 1
  br label %231

230:                                              ; preds = %220
  br label %231

231:                                              ; preds = %230, %227
  %232 = phi i32 [ %229, %227 ], [ -1, %230 ]
  store i32 %232, ptr %22, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %233 = load i32, ptr %17, align 4, !tbaa !11
  %234 = load i32, ptr %21, align 4, !tbaa !11
  %235 = sub nsw i32 %233, %234
  %236 = load i32, ptr %18, align 4, !tbaa !11
  %237 = load i32, ptr %22, align 4, !tbaa !11
  %238 = sub nsw i32 %236, %237
  %239 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %14, i32 noundef %235, i32 noundef %238)
          to label %240 unwind label %251

240:                                              ; preds = %231
  store double %239, ptr %23, align 8, !tbaa !9
  %241 = load double, ptr %23, align 8, !tbaa !9
  %242 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %243 = invoke noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %241, double noundef %242)
          to label %244 unwind label %251

244:                                              ; preds = %240
  %245 = icmp ne i32 %243, 0
  br i1 %245, label %246, label %255

246:                                              ; preds = %244
  %247 = load ptr, ptr %5, align 8, !tbaa !5
  %248 = load i32, ptr %17, align 4, !tbaa !11
  %249 = load i32, ptr %18, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %247, i32 noundef %248, i32 noundef %249, double noundef 1.000000e+00)
          to label %250 unwind label %251

250:                                              ; preds = %246
  store i32 26, ptr %8, align 4
  br label %393

251:                                              ; preds = %246, %240, %231
  %252 = landingpad { ptr, i32 }
          cleanup
  %253 = extractvalue { ptr, i32 } %252, 0
  store ptr %253, ptr %15, align 8
  %254 = extractvalue { ptr, i32 } %252, 1
  store i32 %254, ptr %16, align 4
  br label %400

255:                                              ; preds = %244
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  %256 = load i32, ptr %17, align 4, !tbaa !11
  %257 = load i32, ptr %21, align 4, !tbaa !11
  %258 = add nsw i32 %256, %257
  %259 = load i32, ptr %18, align 4, !tbaa !11
  %260 = load i32, ptr %22, align 4, !tbaa !11
  %261 = add nsw i32 %259, %260
  %262 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %14, i32 noundef %258, i32 noundef %261)
          to label %263 unwind label %274

263:                                              ; preds = %255
  store double %262, ptr %24, align 8, !tbaa !9
  %264 = load double, ptr %24, align 8, !tbaa !9
  %265 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %266 = invoke noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %264, double noundef %265)
          to label %267 unwind label %274

267:                                              ; preds = %263
  %268 = icmp ne i32 %266, 0
  br i1 %268, label %269, label %278

269:                                              ; preds = %267
  %270 = load ptr, ptr %5, align 8, !tbaa !5
  %271 = load i32, ptr %17, align 4, !tbaa !11
  %272 = load i32, ptr %18, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %270, i32 noundef %271, i32 noundef %272, double noundef 1.000000e+00)
          to label %273 unwind label %274

273:                                              ; preds = %269
  store i32 26, ptr %8, align 4
  br label %392

274:                                              ; preds = %269, %263, %255
  %275 = landingpad { ptr, i32 }
          cleanup
  %276 = extractvalue { ptr, i32 } %275, 0
  store ptr %276, ptr %15, align 8
  %277 = extractvalue { ptr, i32 } %275, 1
  store i32 %277, ptr %16, align 4
  br label %399

278:                                              ; preds = %267
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  %279 = load double, ptr %19, align 8, !tbaa !9
  %280 = load double, ptr %23, align 8, !tbaa !9
  %281 = fsub double %279, %280
  store double %281, ptr %25, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #6
  %282 = load double, ptr %24, align 8, !tbaa !9
  %283 = load double, ptr %19, align 8, !tbaa !9
  %284 = fsub double %282, %283
  store double %284, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #6
  %285 = load double, ptr %19, align 8, !tbaa !9
  %286 = load double, ptr %6, align 8, !tbaa !9
  %287 = fmul double %285, %286
  store double %287, ptr %27, align 8, !tbaa !9
  %288 = load double, ptr %27, align 8, !tbaa !9
  %289 = fcmp olt double %288, 1.000000e-01
  br i1 %289, label %290, label %291

290:                                              ; preds = %278
  store double 1.000000e-01, ptr %27, align 8, !tbaa !9
  br label %291

291:                                              ; preds = %290, %278
  %292 = load double, ptr %25, align 8, !tbaa !9
  %293 = load double, ptr %27, align 8, !tbaa !9
  %294 = fneg double %293
  %295 = fcmp olt double %292, %294
  br i1 %295, label %296, label %319

296:                                              ; preds = %291
  %297 = load double, ptr %25, align 8, !tbaa !9
  %298 = load double, ptr %26, align 8, !tbaa !9
  %299 = fmul double 4.000000e+00, %298
  %300 = fcmp olt double %297, %299
  br i1 %300, label %301, label %318

301:                                              ; preds = %296
  %302 = load ptr, ptr %5, align 8, !tbaa !5
  %303 = load i32, ptr %17, align 4, !tbaa !11
  %304 = load i32, ptr %21, align 4, !tbaa !11
  %305 = sub nsw i32 %303, %304
  %306 = load i32, ptr %18, align 4, !tbaa !11
  %307 = load i32, ptr %22, align 4, !tbaa !11
  %308 = sub nsw i32 %306, %307
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %302, i32 noundef %305, i32 noundef %308, double noundef 4.000000e+00)
          to label %309 unwind label %314

309:                                              ; preds = %301
  %310 = load ptr, ptr %5, align 8, !tbaa !5
  %311 = load i32, ptr %17, align 4, !tbaa !11
  %312 = load i32, ptr %18, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %310, i32 noundef %311, i32 noundef %312, double noundef 2.000000e+00)
          to label %313 unwind label %314

313:                                              ; preds = %309
  br label %318

314:                                              ; preds = %384, %376, %361, %353, %336, %328, %309, %301
  %315 = landingpad { ptr, i32 }
          cleanup
  %316 = extractvalue { ptr, i32 } %315, 0
  store ptr %316, ptr %15, align 8
  %317 = extractvalue { ptr, i32 } %315, 1
  store i32 %317, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  br label %399

318:                                              ; preds = %313, %296
  br label %343

319:                                              ; preds = %291
  %320 = load double, ptr %25, align 8, !tbaa !9
  %321 = load double, ptr %27, align 8, !tbaa !9
  %322 = fcmp ogt double %320, %321
  br i1 %322, label %323, label %342

323:                                              ; preds = %319
  %324 = load double, ptr %25, align 8, !tbaa !9
  %325 = load double, ptr %26, align 8, !tbaa !9
  %326 = fmul double 4.000000e+00, %325
  %327 = fcmp ogt double %324, %326
  br i1 %327, label %328, label %341

328:                                              ; preds = %323
  %329 = load ptr, ptr %5, align 8, !tbaa !5
  %330 = load i32, ptr %17, align 4, !tbaa !11
  %331 = load i32, ptr %21, align 4, !tbaa !11
  %332 = sub nsw i32 %330, %331
  %333 = load i32, ptr %18, align 4, !tbaa !11
  %334 = load i32, ptr %22, align 4, !tbaa !11
  %335 = sub nsw i32 %333, %334
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %329, i32 noundef %332, i32 noundef %335, double noundef 2.000000e+00)
          to label %336 unwind label %314

336:                                              ; preds = %328
  %337 = load ptr, ptr %5, align 8, !tbaa !5
  %338 = load i32, ptr %17, align 4, !tbaa !11
  %339 = load i32, ptr %18, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %337, i32 noundef %338, i32 noundef %339, double noundef 4.000000e+00)
          to label %340 unwind label %314

340:                                              ; preds = %336
  br label %341

341:                                              ; preds = %340, %323
  br label %342

342:                                              ; preds = %341, %319
  br label %343

343:                                              ; preds = %342, %318
  %344 = load double, ptr %26, align 8, !tbaa !9
  %345 = load double, ptr %27, align 8, !tbaa !9
  %346 = fneg double %345
  %347 = fcmp olt double %344, %346
  br i1 %347, label %348, label %367

348:                                              ; preds = %343
  %349 = load double, ptr %26, align 8, !tbaa !9
  %350 = load double, ptr %25, align 8, !tbaa !9
  %351 = fmul double 4.000000e+00, %350
  %352 = fcmp olt double %349, %351
  br i1 %352, label %353, label %366

353:                                              ; preds = %348
  %354 = load ptr, ptr %5, align 8, !tbaa !5
  %355 = load i32, ptr %17, align 4, !tbaa !11
  %356 = load i32, ptr %21, align 4, !tbaa !11
  %357 = add nsw i32 %355, %356
  %358 = load i32, ptr %18, align 4, !tbaa !11
  %359 = load i32, ptr %22, align 4, !tbaa !11
  %360 = add nsw i32 %358, %359
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %354, i32 noundef %357, i32 noundef %360, double noundef 2.000000e+00)
          to label %361 unwind label %314

361:                                              ; preds = %353
  %362 = load ptr, ptr %5, align 8, !tbaa !5
  %363 = load i32, ptr %17, align 4, !tbaa !11
  %364 = load i32, ptr %18, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %362, i32 noundef %363, i32 noundef %364, double noundef 4.000000e+00)
          to label %365 unwind label %314

365:                                              ; preds = %361
  br label %366

366:                                              ; preds = %365, %348
  br label %391

367:                                              ; preds = %343
  %368 = load double, ptr %26, align 8, !tbaa !9
  %369 = load double, ptr %27, align 8, !tbaa !9
  %370 = fcmp ogt double %368, %369
  br i1 %370, label %371, label %390

371:                                              ; preds = %367
  %372 = load double, ptr %26, align 8, !tbaa !9
  %373 = load double, ptr %25, align 8, !tbaa !9
  %374 = fmul double 4.000000e+00, %373
  %375 = fcmp ogt double %372, %374
  br i1 %375, label %376, label %389

376:                                              ; preds = %371
  %377 = load ptr, ptr %5, align 8, !tbaa !5
  %378 = load i32, ptr %17, align 4, !tbaa !11
  %379 = load i32, ptr %21, align 4, !tbaa !11
  %380 = add nsw i32 %378, %379
  %381 = load i32, ptr %18, align 4, !tbaa !11
  %382 = load i32, ptr %22, align 4, !tbaa !11
  %383 = add nsw i32 %381, %382
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %377, i32 noundef %380, i32 noundef %383, double noundef 4.000000e+00)
          to label %384 unwind label %314

384:                                              ; preds = %376
  %385 = load ptr, ptr %5, align 8, !tbaa !5
  %386 = load i32, ptr %17, align 4, !tbaa !11
  %387 = load i32, ptr %18, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %385, i32 noundef %386, i32 noundef %387, double noundef 2.000000e+00)
          to label %388 unwind label %314

388:                                              ; preds = %384
  br label %389

389:                                              ; preds = %388, %371
  br label %390

390:                                              ; preds = %389, %367
  br label %391

391:                                              ; preds = %390, %366
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  store i32 0, ptr %8, align 4
  br label %392

392:                                              ; preds = %391, %273
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  br label %393

393:                                              ; preds = %392, %250
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  %394 = load i32, ptr %8, align 4
  switch i32 %394, label %401 [
    i32 0, label %395
  ]

395:                                              ; preds = %393
  br label %396

396:                                              ; preds = %395
  %397 = load i32, ptr %20, align 4, !tbaa !11
  %398 = add nsw i32 %397, 1
  store i32 %398, ptr %20, align 4, !tbaa !11
  br label %216, !llvm.loop !20

399:                                              ; preds = %314, %274
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  br label %400

400:                                              ; preds = %399, %251
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %409

401:                                              ; preds = %393, %219
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %402

402:                                              ; preds = %401
  store i32 0, ptr %8, align 4
  br label %403

403:                                              ; preds = %402, %214, %199
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  %404 = load i32, ptr %8, align 4
  switch i32 %404, label %423 [
    i32 0, label %405
    i32 25, label %406
  ]

405:                                              ; preds = %403
  br label %406

406:                                              ; preds = %405, %403
  %407 = load i32, ptr %18, align 4, !tbaa !11
  %408 = add nsw i32 %407, 1
  store i32 %408, ptr %18, align 4, !tbaa !11
  br label %172, !llvm.loop !21

409:                                              ; preds = %400, %200
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %410

410:                                              ; preds = %409, %180
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %415

411:                                              ; preds = %179
  br label %412

412:                                              ; preds = %411
  %413 = load i32, ptr %17, align 4, !tbaa !11
  %414 = add nsw i32 %413, 1
  store i32 %414, ptr %17, align 4, !tbaa !11
  br label %155, !llvm.loop !22

415:                                              ; preds = %410, %167
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %417

416:                                              ; preds = %162
  store i32 1, ptr %8, align 4
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %14) #6
  call void @llvm.lifetime.end.p0(i64 208, ptr %14) #6
  ret i32 1

417:                                              ; preds = %415, %163
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %14) #6
  call void @llvm.lifetime.end.p0(i64 208, ptr %14) #6
  br label %418

418:                                              ; preds = %417
  %419 = load ptr, ptr %15, align 8
  %420 = load i32, ptr %16, align 4
  %421 = insertvalue { ptr, i32 } poison, ptr %419, 0
  %422 = insertvalue { ptr, i32 } %421, i32 %420, 1
  resume { ptr, i32 } %422

423:                                              ; preds = %403
  unreachable
}

declare noundef nonnull align 8 dereferenceable(208) ptr @_ZN6R2GridaSERKS_(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(208)) #3

declare void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208), double noundef) #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 nounwind uwtable
declare dso_local noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef, double noundef) #4

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z12RNIsPositivedd(double noundef, double noundef) #4

declare void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(208)) unnamed_addr #3

declare void @_ZN6R2Grid10SubstituteEdd(ptr noundef nonnull align 8 dereferenceable(208), double noundef, double noundef) #3

declare void @_ZN6R2Grid9FillHolesEv(ptr noundef nonnull align 8 dereferenceable(208)) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = { "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 = { 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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.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]] }

@RN_EPSILON = external local_unnamed_addr global double, align 8

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z25RGBDCreateBoundaryChannelRK6R2GridRS_d(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(208) %1, double noundef %2) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.R2Grid, align 8
  %5 = tail call noundef nonnull align 8 dereferenceable(208) ptr @_ZN6R2GridaSERKS_(ptr noundef nonnull align 8 dereferenceable(208) %1, ptr noundef nonnull align 8 dereferenceable(208) %0)
  tail call void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208) %1, double noundef -3.210000e+02)
  %6 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader190, label %.preheader189

.preheader190:                                    ; preds = %3, %26
  %.0140193 = phi i32 [ %27, %26 ], [ 0, %3 ]
  %8 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.preheader189:                                    ; preds = %26, %3
  %10 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.preheader188, label %._crit_edge199

12:                                               ; preds = %.lr.ph
  %13 = add nuw nsw i32 %.0142191, 1
  %14 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %.lr.ph, label %._crit_edge, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader190, %12
  %.0142191 = phi i32 [ %13, %12 ], [ 0, %.preheader190 ]
  tail call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0140193, i32 noundef %.0142191, double noundef 1.000000e+00)
  %16 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0140193, i32 noundef %.0142191)
  %17 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %18 = tail call noundef i32 @_Z12RNIsPositivedd(double noundef %16, double noundef %17)
  %.not173 = icmp eq i32 %18, 0
  br i1 %.not173, label %12, label %._crit_edge

._crit_edge:                                      ; preds = %12, %.lr.ph, %.preheader190
  %19 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  br label %20

20:                                               ; preds = %22, %._crit_edge
  %.0143.in = phi i32 [ %19, %._crit_edge ], [ %.0143, %22 ]
  %21 = icmp sgt i32 %.0143.in, 0
  br i1 %21, label %22, label %26

22:                                               ; preds = %20
  %.0143 = add nsw i32 %.0143.in, -1
  tail call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0140193, i32 noundef %.0143, double noundef 1.000000e+00)
  %23 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0140193, i32 noundef %.0143)
  %24 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %25 = tail call noundef i32 @_Z12RNIsPositivedd(double noundef %23, double noundef %24)
  %.not174 = icmp eq i32 %25, 0
  br i1 %.not174, label %20, label %26, !llvm.loop !11

26:                                               ; preds = %22, %20
  %27 = add nuw nsw i32 %.0140193, 1
  %28 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %.preheader190, label %.preheader189, !llvm.loop !12

.preheader188:                                    ; preds = %.preheader189, %46
  %.0144198 = phi i32 [ %47, %46 ], [ 0, %.preheader189 ]
  %30 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph195, label %._crit_edge196

._crit_edge199:                                   ; preds = %46, %.preheader189
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %4) #6
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %4, ptr noundef nonnull align 8 dereferenceable(208) %0)
  invoke void @_ZN6R2Grid10SubstituteEdd(ptr noundef nonnull align 8 dereferenceable(208) %4, double noundef 0.000000e+00, double noundef -3.210000e+02)
          to label %50 unwind label %55

32:                                               ; preds = %.lr.ph195
  %33 = add nuw nsw i32 %.0145194, 1
  %34 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %.lr.ph195, label %._crit_edge196, !llvm.loop !13

.lr.ph195:                                        ; preds = %.preheader188, %32
  %.0145194 = phi i32 [ %33, %32 ], [ 0, %.preheader188 ]
  tail call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0145194, i32 noundef %.0144198, double noundef 1.000000e+00)
  %36 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0145194, i32 noundef %.0144198)
  %37 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %38 = tail call noundef i32 @_Z12RNIsPositivedd(double noundef %36, double noundef %37)
  %.not171 = icmp eq i32 %38, 0
  br i1 %.not171, label %32, label %._crit_edge196

._crit_edge196:                                   ; preds = %32, %.lr.ph195, %.preheader188
  %39 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  br label %40

40:                                               ; preds = %42, %._crit_edge196
  %.0155.in = phi i32 [ %39, %._crit_edge196 ], [ %.0155, %42 ]
  %41 = icmp sgt i32 %.0155.in, 0
  br i1 %41, label %42, label %46

42:                                               ; preds = %40
  %.0155 = add nsw i32 %.0155.in, -1
  tail call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0155, i32 noundef %.0144198, double noundef 1.000000e+00)
  %43 = tail call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0155, i32 noundef %.0144198)
  %44 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %45 = tail call noundef i32 @_Z12RNIsPositivedd(double noundef %43, double noundef %44)
  %.not172 = icmp eq i32 %45, 0
  br i1 %.not172, label %40, label %46, !llvm.loop !14

46:                                               ; preds = %42, %40
  %47 = add nuw nsw i32 %.0144198, 1
  %48 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %.preheader188, label %._crit_edge199, !llvm.loop !15

50:                                               ; preds = %._crit_edge199
  invoke void @_ZN6R2Grid9FillHolesEv(ptr noundef nonnull align 8 dereferenceable(208) %4)
          to label %.preheader187 unwind label %55

.preheader187:                                    ; preds = %50
  %51 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %52 = icmp sgt i32 %51, 2
  br i1 %52, label %.preheader186, label %._crit_edge205

.preheader186:                                    ; preds = %.preheader187, %._crit_edge203
  %.0148204 = phi i32 [ %57, %._crit_edge203 ], [ 1, %.preheader187 ]
  %53 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %54 = icmp sgt i32 %53, 2
  br i1 %54, label %.lr.ph202, label %._crit_edge203

._crit_edge205:                                   ; preds = %._crit_edge203, %.preheader187
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #6
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %4) #6
  ret i32 1

55:                                               ; preds = %50, %._crit_edge199
  %56 = landingpad { ptr, i32 }
          cleanup
  br label %129

._crit_edge203:                                   ; preds = %.loopexit, %.preheader186
  %57 = add nuw nsw i32 %.0148204, 1
  %58 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %59 = add nsw i32 %58, -1
  %60 = icmp slt i32 %57, %59
  br i1 %60, label %.preheader186, label %._crit_edge205, !llvm.loop !16

.lr.ph202:                                        ; preds = %.preheader186, %.loopexit
  %.0147201 = phi i32 [ %125, %.loopexit ], [ 1, %.preheader186 ]
  %61 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0148204, i32 noundef %.0147201)
          to label %62 unwind label %66

62:                                               ; preds = %.lr.ph202
  %63 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %64 = call noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %61, double noundef %63)
  %.not = icmp eq i32 %64, 0
  br i1 %.not, label %68, label %65

65:                                               ; preds = %62
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0148204, i32 noundef %.0147201, double noundef 1.000000e+00)
          to label %.loopexit unwind label %66

66:                                               ; preds = %68, %65, %.lr.ph202
  %67 = landingpad { ptr, i32 }
          cleanup
  br label %129

68:                                               ; preds = %62
  %69 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %.0148204, i32 noundef %.0147201)
          to label %70 unwind label %66

70:                                               ; preds = %68
  %71 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %72 = call noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %69, double noundef %71)
  %.not161 = icmp eq i32 %72, 0
  br i1 %.not161, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %70
  %73 = fmul double %69, %2
  %74 = fcmp olt double %73, 1.000000e-01
  %.0 = select i1 %74, double 1.000000e-01, double %73
  %75 = fneg double %.0
  br label %76

76:                                               ; preds = %.preheader, %123
  %.0146200 = phi i32 [ 0, %.preheader ], [ %124, %123 ]
  %.not162 = icmp ne i32 %.0146200, 3
  %77 = sext i1 %.not162 to i32
  %78 = add nsw i32 %.0146200, -1
  %79 = select i1 %.not162, i32 %78, i32 -1
  %80 = sub nsw i32 %.0148204, %77
  %81 = sub nsw i32 %.0147201, %79
  %82 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %80, i32 noundef %81)
          to label %83 unwind label %.loopexit180

83:                                               ; preds = %76
  %84 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %85 = call noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %82, double noundef %84)
  %.not163 = icmp eq i32 %85, 0
  br i1 %.not163, label %87, label %86

86:                                               ; preds = %83
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0148204, i32 noundef %.0147201, double noundef 1.000000e+00)
          to label %.loopexit unwind label %.loopexit.split-lp

.loopexit180:                                     ; preds = %76
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %129

.loopexit.split-lp:                               ; preds = %86
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %129

87:                                               ; preds = %83
  %88 = add nsw i32 %.0148204, %77
  %89 = add nsw i32 %79, %.0147201
  %90 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %88, i32 noundef %89)
          to label %91 unwind label %.loopexit181

91:                                               ; preds = %87
  %92 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %93 = call noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %90, double noundef %92)
  %.not164 = icmp eq i32 %93, 0
  br i1 %.not164, label %95, label %94

94:                                               ; preds = %91
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0148204, i32 noundef %.0147201, double noundef 1.000000e+00)
          to label %.loopexit unwind label %.loopexit.split-lp182

.loopexit181:                                     ; preds = %87
  %lpad.loopexit183 = landingpad { ptr, i32 }
          cleanup
  br label %129

.loopexit.split-lp182:                            ; preds = %94
  %lpad.loopexit.split-lp184 = landingpad { ptr, i32 }
          cleanup
  br label %129

95:                                               ; preds = %91
  %96 = fsub double %69, %82
  %97 = fsub double %90, %69
  %98 = fcmp olt double %96, %75
  br i1 %98, label %99, label %105

99:                                               ; preds = %95
  %100 = fmul double %97, 4.000000e+00
  %101 = fcmp olt double %96, %100
  br i1 %101, label %102, label %111

102:                                              ; preds = %99
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %80, i32 noundef %81, double noundef 4.000000e+00)
          to label %.invoke206 unwind label %103

103:                                              ; preds = %.invoke206, %.invoke, %121, %116, %109, %102
  %104 = landingpad { ptr, i32 }
          cleanup
  br label %129

105:                                              ; preds = %95
  %106 = fcmp ogt double %96, %.0
  %107 = fmul double %97, 4.000000e+00
  %108 = fcmp ogt double %96, %107
  %or.cond = and i1 %106, %108
  br i1 %or.cond, label %109, label %111

109:                                              ; preds = %105
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %80, i32 noundef %81, double noundef 2.000000e+00)
          to label %.invoke206 unwind label %103

.invoke206:                                       ; preds = %102, %109
  %110 = phi double [ 4.000000e+00, %109 ], [ 2.000000e+00, %102 ]
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0148204, i32 noundef %.0147201, double noundef %110)
          to label %111 unwind label %103

111:                                              ; preds = %.invoke206, %105, %99
  %112 = fcmp olt double %97, %75
  br i1 %112, label %113, label %117

113:                                              ; preds = %111
  %114 = fmul double %96, 4.000000e+00
  %115 = fcmp olt double %97, %114
  br i1 %115, label %116, label %123

116:                                              ; preds = %113
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %88, i32 noundef %89, double noundef 2.000000e+00)
          to label %.invoke unwind label %103

117:                                              ; preds = %111
  %118 = fcmp ogt double %97, %.0
  %119 = fmul double %96, 4.000000e+00
  %120 = fcmp ogt double %97, %119
  %or.cond177 = and i1 %118, %120
  br i1 %or.cond177, label %121, label %123

121:                                              ; preds = %117
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %88, i32 noundef %89, double noundef 4.000000e+00)
          to label %.invoke unwind label %103

.invoke:                                          ; preds = %121, %116
  %122 = phi double [ 4.000000e+00, %116 ], [ 2.000000e+00, %121 ]
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %.0148204, i32 noundef %.0147201, double noundef %122)
          to label %123 unwind label %103

123:                                              ; preds = %.invoke, %117, %113
  %124 = add nuw nsw i32 %.0146200, 1
  %exitcond.not = icmp eq i32 %124, 4
  br i1 %exitcond.not, label %.loopexit, label %76, !llvm.loop !17

.loopexit:                                        ; preds = %123, %86, %94, %70, %65
  %125 = add nuw nsw i32 %.0147201, 1
  %126 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %127 = add nsw i32 %126, -1
  %128 = icmp slt i32 %125, %127
  br i1 %128, label %.lr.ph202, label %._crit_edge203, !llvm.loop !18

129:                                              ; preds = %.loopexit181, %.loopexit.split-lp182, %.loopexit180, %.loopexit.split-lp, %66, %103, %55
  %.pn168.pn = phi { ptr, i32 } [ %56, %55 ], [ %67, %66 ], [ %104, %103 ], [ %lpad.loopexit, %.loopexit180 ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ], [ %lpad.loopexit183, %.loopexit181 ], [ %lpad.loopexit.split-lp184, %.loopexit.split-lp182 ]
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #6
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %4) #6
  resume { ptr, i32 } %.pn168.pn
}

declare noundef nonnull align 8 dereferenceable(208) ptr @_ZN6R2GridaSERKS_(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #3

declare void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208), double noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #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) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef, double noundef) local_unnamed_addr #4

; 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 #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z12RNIsPositivedd(double noundef, double noundef) local_unnamed_addr #4

declare void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(208)) unnamed_addr #3

declare void @_ZN6R2Grid10SubstituteEdd(ptr noundef nonnull align 8 dereferenceable(208), double noundef, double noundef) local_unnamed_addr #3

declare void @_ZN6R2Grid9FillHolesEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = { "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 = { 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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}
!12 = distinct !{!12, !6}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}
!15 = distinct !{!15, !6}
!16 = distinct !{!16, !6}
!17 = distinct !{!17, !6}
!18 = distinct !{!18, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass