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

; 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.RNInterval = type { double, double }
%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 }

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6R3Grid5RangeEv(ptr dead_on_unwind noalias writable sret(%class.RNInterval) align 8, ptr noundef nonnull align 8 dereferenceable(592)) #2 align 2

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

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

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

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

; Function Attrs: nounwind
declare double @exp(double noundef) #5

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid15BilateralFilterEdd(ptr noundef nonnull align 8 dereferenceable(592) %0, double noundef %1, double noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca %class.R3Grid, align 8
  %8 = alloca %class.RNInterval, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca i32, align 4
  %32 = alloca i32, align 4
  %33 = alloca i32, align 4
  %34 = alloca i32, align 4
  %35 = alloca i32, align 4
  %36 = alloca double, align 8
  %37 = alloca double, align 8
  %38 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %39 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 592, ptr %7) #6
  call void @_ZN6R3GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(592) %7, ptr noundef nonnull align 8 dereferenceable(592) %39)
  %40 = load double, ptr %6, align 8, !tbaa !9
  %41 = fcmp oeq double %40, -1.000000e+00
  br i1 %41, label %42, label %54

42:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  invoke void @_ZNK6R3Grid5RangeEv(ptr dead_on_unwind writable sret(%class.RNInterval) align 8 %8, ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %43 unwind label %50

43:                                               ; preds = %42
  %44 = invoke noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %45 unwind label %50

45:                                               ; preds = %43
  %46 = invoke noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %47 unwind label %50

47:                                               ; preds = %45
  %48 = fsub double %44, %46
  %49 = fmul double 1.000000e-02, %48
  store double %49, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  br label %54

50:                                               ; preds = %45, %43, %42
  %51 = landingpad { ptr, i32 }
          cleanup
  %52 = extractvalue { ptr, i32 } %51, 0
  store ptr %52, ptr %9, align 8
  %53 = extractvalue { ptr, i32 } %51, 1
  store i32 %53, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  br label %305

54:                                               ; preds = %47, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %55 = load double, ptr %5, align 8, !tbaa !9
  %56 = fmul double -2.000000e+00, %55
  %57 = load double, ptr %5, align 8, !tbaa !9
  %58 = fmul double %56, %57
  store double %58, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %59 = load double, ptr %6, align 8, !tbaa !9
  %60 = fmul double -2.000000e+00, %59
  %61 = load double, ptr %6, align 8, !tbaa !9
  %62 = fmul double %60, %61
  store double %62, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %63 = load double, ptr %5, align 8, !tbaa !9
  %64 = fmul double 3.000000e+00, %63
  store double %64, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %65 = load double, ptr %13, align 8, !tbaa !9
  %66 = fadd double %65, 1.000000e+00
  %67 = fptosi double %66 to i32
  store i32 %67, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %68 = load i32, ptr %14, align 4, !tbaa !11
  %69 = load i32, ptr %14, align 4, !tbaa !11
  %70 = mul nsw i32 %68, %69
  store i32 %70, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %71

71:                                               ; preds = %300, %54
  %72 = load i32, ptr %16, align 4, !tbaa !11
  %73 = invoke noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %74 unwind label %77

74:                                               ; preds = %71
  %75 = icmp slt i32 %72, %73
  br i1 %75, label %81, label %76

76:                                               ; preds = %74
  store i32 2, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %304

77:                                               ; preds = %71
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %9, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %10, align 4
  br label %303

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

82:                                               ; preds = %295, %81
  %83 = load i32, ptr %18, align 4, !tbaa !11
  %84 = invoke noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %85 unwind label %88

85:                                               ; preds = %82
  %86 = icmp slt i32 %83, %84
  br i1 %86, label %92, label %87

87:                                               ; preds = %85
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %299

88:                                               ; preds = %82
  %89 = landingpad { ptr, i32 }
          cleanup
  %90 = extractvalue { ptr, i32 } %89, 0
  store ptr %90, ptr %9, align 8
  %91 = extractvalue { ptr, i32 } %89, 1
  store i32 %91, ptr %10, align 4
  br label %298

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

93:                                               ; preds = %288, %92
  %94 = load i32, ptr %19, align 4, !tbaa !11
  %95 = invoke noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %96 unwind label %99

96:                                               ; preds = %93
  %97 = icmp slt i32 %94, %95
  br i1 %97, label %103, label %98

98:                                               ; preds = %96
  store i32 8, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %294

99:                                               ; preds = %93
  %100 = landingpad { ptr, i32 }
          cleanup
  %101 = extractvalue { ptr, i32 } %100, 0
  store ptr %101, ptr %9, align 8
  %102 = extractvalue { ptr, i32 } %100, 1
  store i32 %102, ptr %10, align 4
  br label %293

103:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %104 = load i32, ptr %19, align 4, !tbaa !11
  %105 = load i32, ptr %18, align 4, !tbaa !11
  %106 = load i32, ptr %16, align 4, !tbaa !11
  %107 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %7, i32 noundef %104, i32 noundef %105, i32 noundef %106)
          to label %108 unwind label %118

108:                                              ; preds = %103
  store double %107, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  store double 0.000000e+00, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  store double 0.000000e+00, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  %109 = load i32, ptr %16, align 4, !tbaa !11
  %110 = load i32, ptr %14, align 4, !tbaa !11
  %111 = sub nsw i32 %109, %110
  store i32 %111, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  %112 = load i32, ptr %16, align 4, !tbaa !11
  %113 = load i32, ptr %14, align 4, !tbaa !11
  %114 = add nsw i32 %112, %113
  store i32 %114, ptr %24, align 4, !tbaa !11
  %115 = load i32, ptr %23, align 4, !tbaa !11
  %116 = icmp slt i32 %115, 0
  br i1 %116, label %117, label %122

117:                                              ; preds = %108
  store i32 0, ptr %23, align 4, !tbaa !11
  br label %122

118:                                              ; preds = %103
  %119 = landingpad { ptr, i32 }
          cleanup
  %120 = extractvalue { ptr, i32 } %119, 0
  store ptr %120, ptr %9, align 8
  %121 = extractvalue { ptr, i32 } %119, 1
  store i32 %121, ptr %10, align 4
  br label %292

122:                                              ; preds = %117, %108
  %123 = load i32, ptr %24, align 4, !tbaa !11
  %124 = invoke noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %125 unwind label %131

125:                                              ; preds = %122
  %126 = icmp sge i32 %123, %124
  br i1 %126, label %127, label %135

127:                                              ; preds = %125
  %128 = invoke noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %129 unwind label %131

129:                                              ; preds = %127
  %130 = sub nsw i32 %128, 1
  store i32 %130, ptr %24, align 4, !tbaa !11
  br label %135

131:                                              ; preds = %279, %127, %122
  %132 = landingpad { ptr, i32 }
          cleanup
  %133 = extractvalue { ptr, i32 } %132, 0
  store ptr %133, ptr %9, align 8
  %134 = extractvalue { ptr, i32 } %132, 1
  store i32 %134, ptr %10, align 4
  br label %291

135:                                              ; preds = %129, %125
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  %136 = load i32, ptr %23, align 4, !tbaa !11
  store i32 %136, ptr %25, align 4, !tbaa !11
  br label %137

137:                                              ; preds = %272, %135
  %138 = load i32, ptr %25, align 4, !tbaa !11
  %139 = load i32, ptr %24, align 4, !tbaa !11
  %140 = icmp sle i32 %138, %139
  br i1 %140, label %142, label %141

141:                                              ; preds = %137
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  br label %276

142:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  %143 = load i32, ptr %18, align 4, !tbaa !11
  %144 = load i32, ptr %14, align 4, !tbaa !11
  %145 = sub nsw i32 %143, %144
  store i32 %145, ptr %26, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #6
  %146 = load i32, ptr %18, align 4, !tbaa !11
  %147 = load i32, ptr %14, align 4, !tbaa !11
  %148 = add nsw i32 %146, %147
  store i32 %148, ptr %27, align 4, !tbaa !11
  %149 = load i32, ptr %26, align 4, !tbaa !11
  %150 = icmp slt i32 %149, 0
  br i1 %150, label %151, label %152

151:                                              ; preds = %142
  store i32 0, ptr %26, align 4, !tbaa !11
  br label %152

152:                                              ; preds = %151, %142
  %153 = load i32, ptr %27, align 4, !tbaa !11
  %154 = invoke noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %155 unwind label %161

155:                                              ; preds = %152
  %156 = icmp sge i32 %153, %154
  br i1 %156, label %157, label %165

157:                                              ; preds = %155
  %158 = invoke noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %159 unwind label %161

159:                                              ; preds = %157
  %160 = sub nsw i32 %158, 1
  store i32 %160, ptr %27, align 4, !tbaa !11
  br label %165

161:                                              ; preds = %157, %152
  %162 = landingpad { ptr, i32 }
          cleanup
  %163 = extractvalue { ptr, i32 } %162, 0
  store ptr %163, ptr %9, align 8
  %164 = extractvalue { ptr, i32 } %162, 1
  store i32 %164, ptr %10, align 4
  br label %275

165:                                              ; preds = %159, %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #6
  %166 = load i32, ptr %25, align 4, !tbaa !11
  %167 = load i32, ptr %16, align 4, !tbaa !11
  %168 = sub nsw i32 %166, %167
  store i32 %168, ptr %28, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #6
  %169 = load i32, ptr %26, align 4, !tbaa !11
  store i32 %169, ptr %29, align 4, !tbaa !11
  br label %170

170:                                              ; preds = %267, %165
  %171 = load i32, ptr %29, align 4, !tbaa !11
  %172 = load i32, ptr %27, align 4, !tbaa !11
  %173 = icmp sle i32 %171, %172
  br i1 %173, label %175, label %174

174:                                              ; preds = %170
  store i32 14, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #6
  br label %271

175:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #6
  %176 = load i32, ptr %19, align 4, !tbaa !11
  %177 = load i32, ptr %14, align 4, !tbaa !11
  %178 = sub nsw i32 %176, %177
  store i32 %178, ptr %30, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #6
  %179 = load i32, ptr %19, align 4, !tbaa !11
  %180 = load i32, ptr %14, align 4, !tbaa !11
  %181 = add nsw i32 %179, %180
  store i32 %181, ptr %31, align 4, !tbaa !11
  %182 = load i32, ptr %30, align 4, !tbaa !11
  %183 = icmp slt i32 %182, 0
  br i1 %183, label %184, label %185

184:                                              ; preds = %175
  store i32 0, ptr %30, align 4, !tbaa !11
  br label %185

185:                                              ; preds = %184, %175
  %186 = load i32, ptr %31, align 4, !tbaa !11
  %187 = invoke noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %188 unwind label %194

188:                                              ; preds = %185
  %189 = icmp sge i32 %186, %187
  br i1 %189, label %190, label %198

190:                                              ; preds = %188
  %191 = invoke noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %39)
          to label %192 unwind label %194

192:                                              ; preds = %190
  %193 = sub nsw i32 %191, 1
  store i32 %193, ptr %31, align 4, !tbaa !11
  br label %198

194:                                              ; preds = %190, %185
  %195 = landingpad { ptr, i32 }
          cleanup
  %196 = extractvalue { ptr, i32 } %195, 0
  store ptr %196, ptr %9, align 8
  %197 = extractvalue { ptr, i32 } %195, 1
  store i32 %197, ptr %10, align 4
  br label %270

198:                                              ; preds = %192, %188
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #6
  %199 = load i32, ptr %29, align 4, !tbaa !11
  %200 = load i32, ptr %18, align 4, !tbaa !11
  %201 = sub nsw i32 %199, %200
  store i32 %201, ptr %32, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #6
  %202 = load i32, ptr %30, align 4, !tbaa !11
  store i32 %202, ptr %33, align 4, !tbaa !11
  br label %203

203:                                              ; preds = %259, %198
  %204 = load i32, ptr %33, align 4, !tbaa !11
  %205 = load i32, ptr %31, align 4, !tbaa !11
  %206 = icmp sle i32 %204, %205
  br i1 %206, label %208, label %207

207:                                              ; preds = %203
  store i32 17, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #6
  br label %266

208:                                              ; preds = %203
  call void @llvm.lifetime.start.p0(i64 4, ptr %34) #6
  %209 = load i32, ptr %33, align 4, !tbaa !11
  %210 = load i32, ptr %19, align 4, !tbaa !11
  %211 = sub nsw i32 %209, %210
  store i32 %211, ptr %34, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %35) #6
  %212 = load i32, ptr %34, align 4, !tbaa !11
  %213 = load i32, ptr %34, align 4, !tbaa !11
  %214 = mul nsw i32 %212, %213
  %215 = load i32, ptr %32, align 4, !tbaa !11
  %216 = load i32, ptr %32, align 4, !tbaa !11
  %217 = mul nsw i32 %215, %216
  %218 = add nsw i32 %214, %217
  %219 = load i32, ptr %28, align 4, !tbaa !11
  %220 = load i32, ptr %28, align 4, !tbaa !11
  %221 = mul nsw i32 %219, %220
  %222 = add nsw i32 %218, %221
  store i32 %222, ptr %35, align 4, !tbaa !11
  %223 = load i32, ptr %35, align 4, !tbaa !11
  %224 = load i32, ptr %15, align 4, !tbaa !11
  %225 = icmp sgt i32 %223, %224
  br i1 %225, label %226, label %227

226:                                              ; preds = %208
  store i32 19, ptr %17, align 4
  br label %256

227:                                              ; preds = %208
  call void @llvm.lifetime.start.p0(i64 8, ptr %36) #6
  %228 = load i32, ptr %33, align 4, !tbaa !11
  %229 = load i32, ptr %29, align 4, !tbaa !11
  %230 = load i32, ptr %25, align 4, !tbaa !11
  %231 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %7, i32 noundef %228, i32 noundef %229, i32 noundef %230)
          to label %232 unwind label %262

232:                                              ; preds = %227
  store double %231, ptr %36, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %37) #6
  %233 = load double, ptr %20, align 8, !tbaa !9
  %234 = load double, ptr %36, align 8, !tbaa !9
  %235 = fsub double %233, %234
  store double %235, ptr %37, align 8, !tbaa !9
  %236 = load double, ptr %37, align 8, !tbaa !9
  %237 = load double, ptr %37, align 8, !tbaa !9
  %238 = fmul double %237, %236
  store double %238, ptr %37, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %38) #6
  %239 = load i32, ptr %35, align 4, !tbaa !11
  %240 = sitofp i32 %239 to double
  %241 = load double, ptr %11, align 8, !tbaa !9
  %242 = fdiv double %240, %241
  %243 = call double @exp(double noundef %242) #6
  %244 = load double, ptr %37, align 8, !tbaa !9
  %245 = load double, ptr %12, align 8, !tbaa !9
  %246 = fdiv double %244, %245
  %247 = call double @exp(double noundef %246) #6
  %248 = fmul double %243, %247
  store double %248, ptr %38, align 8, !tbaa !9
  %249 = load double, ptr %38, align 8, !tbaa !9
  %250 = load double, ptr %36, align 8, !tbaa !9
  %251 = load double, ptr %21, align 8, !tbaa !9
  %252 = call double @llvm.fmuladd.f64(double %249, double %250, double %251)
  store double %252, ptr %21, align 8, !tbaa !9
  %253 = load double, ptr %38, align 8, !tbaa !9
  %254 = load double, ptr %22, align 8, !tbaa !9
  %255 = fadd double %254, %253
  store double %255, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %38) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %37) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %36) #6
  store i32 0, ptr %17, align 4
  br label %256

256:                                              ; preds = %232, %226
  call void @llvm.lifetime.end.p0(i64 4, ptr %35) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #6
  %257 = load i32, ptr %17, align 4
  switch i32 %257, label %311 [
    i32 0, label %258
    i32 19, label %259
  ]

258:                                              ; preds = %256
  br label %259

259:                                              ; preds = %258, %256
  %260 = load i32, ptr %33, align 4, !tbaa !11
  %261 = add nsw i32 %260, 1
  store i32 %261, ptr %33, align 4, !tbaa !11
  br label %203, !llvm.loop !13

262:                                              ; preds = %227
  %263 = landingpad { ptr, i32 }
          cleanup
  %264 = extractvalue { ptr, i32 } %263, 0
  store ptr %264, ptr %9, align 8
  %265 = extractvalue { ptr, i32 } %263, 1
  store i32 %265, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %36) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %35) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #6
  br label %270

266:                                              ; preds = %207
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #6
  br label %267

267:                                              ; preds = %266
  %268 = load i32, ptr %29, align 4, !tbaa !11
  %269 = add nsw i32 %268, 1
  store i32 %269, ptr %29, align 4, !tbaa !11
  br label %170, !llvm.loop !15

270:                                              ; preds = %262, %194
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  br label %275

271:                                              ; preds = %174
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  br label %272

272:                                              ; preds = %271
  %273 = load i32, ptr %25, align 4, !tbaa !11
  %274 = add nsw i32 %273, 1
  store i32 %274, ptr %25, align 4, !tbaa !11
  br label %137, !llvm.loop !16

275:                                              ; preds = %270, %161
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  br label %291

276:                                              ; preds = %141
  %277 = load double, ptr %22, align 8, !tbaa !9
  %278 = fcmp ogt double %277, 0.000000e+00
  br i1 %278, label %279, label %287

279:                                              ; preds = %276
  %280 = load i32, ptr %19, align 4, !tbaa !11
  %281 = load i32, ptr %18, align 4, !tbaa !11
  %282 = load i32, ptr %16, align 4, !tbaa !11
  %283 = load double, ptr %21, align 8, !tbaa !9
  %284 = load double, ptr %22, align 8, !tbaa !9
  %285 = fdiv double %283, %284
  invoke void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %39, i32 noundef %280, i32 noundef %281, i32 noundef %282, double noundef %285)
          to label %286 unwind label %131

286:                                              ; preds = %279
  br label %287

287:                                              ; preds = %286, %276
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  br label %288

288:                                              ; preds = %287
  %289 = load i32, ptr %19, align 4, !tbaa !11
  %290 = add nsw i32 %289, 1
  store i32 %290, ptr %19, align 4, !tbaa !11
  br label %93, !llvm.loop !17

291:                                              ; preds = %275, %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  br label %292

292:                                              ; preds = %291, %118
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  br label %293

293:                                              ; preds = %292, %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %298

294:                                              ; preds = %98
  br label %295

295:                                              ; preds = %294
  %296 = load i32, ptr %18, align 4, !tbaa !11
  %297 = add nsw i32 %296, 1
  store i32 %297, ptr %18, align 4, !tbaa !11
  br label %82, !llvm.loop !18

298:                                              ; preds = %293, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %303

299:                                              ; preds = %87
  br label %300

300:                                              ; preds = %299
  %301 = load i32, ptr %16, align 4, !tbaa !11
  %302 = add nsw i32 %301, 1
  store i32 %302, ptr %16, align 4, !tbaa !11
  br label %71, !llvm.loop !19

303:                                              ; preds = %298, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %305

304:                                              ; preds = %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %7) #6
  call void @llvm.lifetime.end.p0(i64 592, ptr %7) #6
  ret void

305:                                              ; preds = %303, %50
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %7) #6
  call void @llvm.lifetime.end.p0(i64 592, ptr %7) #6
  br label %306

306:                                              ; preds = %305
  %307 = load ptr, ptr %9, align 8
  %308 = load i32, ptr %10, align 4
  %309 = insertvalue { ptr, i32 } poison, ptr %307, 0
  %310 = insertvalue { ptr, i32 } %309, i32 %308, 1
  resume { ptr, i32 } %310

311:                                              ; preds = %256
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16)) #4 align 2

declare void @_ZN6R3GridC1ERKS_(ptr, ptr)

declare void @_ZN6R3GridD1Ev(ptr)

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


; 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.RNInterval = type { double, double }
%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 }

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6R3Grid5RangeEv(ptr dead_on_unwind noalias writable sret(%class.RNInterval) align 8, ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #2 align 2

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

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #5

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid15BilateralFilterEdd(ptr noundef nonnull align 8 dereferenceable(592) %0, double noundef %1, double noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.R3Grid, align 8
  %5 = alloca %class.RNInterval, align 8
  call void @llvm.lifetime.start.p0(i64 592, ptr nonnull %4) #7
  call void @_ZN6R3GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(592) %4, ptr noundef nonnull align 8 dereferenceable(592) %0)
  %6 = fcmp oeq double %2, -1.000000e+00
  br i1 %6, label %7, label %15

7:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #7
  invoke void @_ZNK6R3Grid5RangeEv(ptr dead_on_unwind nonnull writable sret(%class.RNInterval) align 8 %5, ptr noundef nonnull align 8 dereferenceable(592) %0)
          to label %8 unwind label %13

8:                                                ; preds = %7
  %9 = call noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %10 = call noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %11 = fsub double %9, %10
  %12 = fmul double %11, 1.000000e-02
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #7
  br label %15

13:                                               ; preds = %7
  %14 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #7
  br label %101

15:                                               ; preds = %8, %3
  %.0 = phi double [ %12, %8 ], [ %2, %3 ]
  %16 = fmul double %1, -2.000000e+00
  %17 = fmul double %16, %1
  %18 = fmul double %.0, -2.000000e+00
  %19 = fmul double %.0, %18
  %20 = fmul double %1, 3.000000e+00
  %21 = fadd double %20, 1.000000e+00
  %22 = fptosi double %21 to i32
  %23 = mul nsw i32 %22, %22
  %24 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.preheader121, label %._crit_edge157

.preheader121:                                    ; preds = %15, %._crit_edge155
  %.092156 = phi i32 [ %34, %._crit_edge155 ], [ 0, %15 ]
  %26 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.preheader.lr.ph, label %._crit_edge155

.preheader.lr.ph:                                 ; preds = %.preheader121
  %28 = sub nsw i32 %.092156, %22
  %29 = add nsw i32 %.092156, %22
  %spec.store.select = call i32 @llvm.smax.i32(i32 %28, i32 0)
  br label %.preheader

._crit_edge157:                                   ; preds = %._crit_edge155, %15
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %4) #7
  call void @llvm.lifetime.end.p0(i64 592, ptr nonnull %4) #7
  ret void

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge153
  %.094154 = phi i32 [ 0, %.preheader.lr.ph ], [ %37, %._crit_edge153 ]
  %30 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph152, label %._crit_edge153

.lr.ph152:                                        ; preds = %.preheader
  %32 = sub nsw i32 %.094154, %22
  %33 = add nsw i32 %.094154, %22
  %spec.store.select1 = call i32 @llvm.smax.i32(i32 %32, i32 0)
  br label %40

._crit_edge155:                                   ; preds = %._crit_edge153, %.preheader121
  %34 = add nuw nsw i32 %.092156, 1
  %35 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %.preheader121, label %._crit_edge157, !llvm.loop !5

._crit_edge153:                                   ; preds = %._crit_edge148.thread, %.preheader
  %37 = add nuw nsw i32 %.094154, 1
  %38 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %.preheader, label %._crit_edge155, !llvm.loop !7

40:                                               ; preds = %.lr.ph152, %._crit_edge148.thread
  %.097151 = phi i32 [ 0, %.lr.ph152 ], [ %98, %._crit_edge148.thread ]
  %41 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %4, i32 noundef %.097151, i32 noundef %.094154, i32 noundef %.092156)
          to label %42 unwind label %44

42:                                               ; preds = %40
  %43 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not = icmp slt i32 %29, %43
  br i1 %.not, label %51, label %46

44:                                               ; preds = %40
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %101

46:                                               ; preds = %42
  %47 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %48 = add nsw i32 %47, -1
  br label %51

49:                                               ; preds = %96
  %50 = landingpad { ptr, i32 }
          cleanup
  br label %101

51:                                               ; preds = %46, %42
  %.0100 = phi i32 [ %48, %46 ], [ %29, %42 ]
  %.not113142 = icmp sgt i32 %spec.store.select, %.0100
  br i1 %.not113142, label %._crit_edge148.thread, label %.lr.ph147

.lr.ph147:                                        ; preds = %51
  %52 = sub nsw i32 %.097151, %22
  %53 = add nsw i32 %.097151, %22
  %spec.store.select2 = call i32 @llvm.smax.i32(i32 %52, i32 0)
  br label %55

._crit_edge148:                                   ; preds = %._crit_edge139
  %54 = fcmp ogt double %.1102.lcssa, 0.000000e+00
  br i1 %54, label %96, label %._crit_edge148.thread

55:                                               ; preds = %.lr.ph147, %._crit_edge139
  %.099145 = phi i32 [ %spec.store.select, %.lr.ph147 ], [ %63, %._crit_edge139 ]
  %.0101144 = phi double [ 0.000000e+00, %.lr.ph147 ], [ %.1102.lcssa, %._crit_edge139 ]
  %.0104143 = phi double [ 0.000000e+00, %.lr.ph147 ], [ %.1105.lcssa, %._crit_edge139 ]
  %56 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not114 = icmp slt i32 %33, %56
  br i1 %.not114, label %60, label %57

57:                                               ; preds = %55
  %58 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %59 = add nsw i32 %58, -1
  br label %60

60:                                               ; preds = %57, %55
  %.098 = phi i32 [ %59, %57 ], [ %33, %55 ]
  %.not115133 = icmp sgt i32 %spec.store.select1, %.098
  br i1 %.not115133, label %._crit_edge139, label %.lr.ph138

.lr.ph138:                                        ; preds = %60
  %61 = sub nsw i32 %.099145, %.092156
  %62 = mul nsw i32 %61, %61
  br label %64

._crit_edge139:                                   ; preds = %._crit_edge, %60
  %.1105.lcssa = phi double [ %.0104143, %60 ], [ %.2106.lcssa, %._crit_edge ]
  %.1102.lcssa = phi double [ %.0101144, %60 ], [ %.2103.lcssa, %._crit_edge ]
  %63 = add nuw nsw i32 %.099145, 1
  %.not113.not = icmp slt i32 %.099145, %.0100
  br i1 %.not113.not, label %55, label %._crit_edge148, !llvm.loop !8

64:                                               ; preds = %.lr.ph138, %._crit_edge
  %.096136 = phi i32 [ %spec.store.select1, %.lr.ph138 ], [ %73, %._crit_edge ]
  %.1102135 = phi double [ %.0101144, %.lr.ph138 ], [ %.2103.lcssa, %._crit_edge ]
  %.1105134 = phi double [ %.0104143, %.lr.ph138 ], [ %.2106.lcssa, %._crit_edge ]
  %65 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not116 = icmp slt i32 %53, %65
  br i1 %.not116, label %69, label %66

66:                                               ; preds = %64
  %67 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %68 = add nsw i32 %67, -1
  br label %69

69:                                               ; preds = %66, %64
  %.095 = phi i32 [ %68, %66 ], [ %53, %64 ]
  %.not117128 = icmp sgt i32 %spec.store.select2, %.095
  br i1 %.not117128, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %69
  %70 = sub nsw i32 %.096136, %.094154
  %71 = mul nsw i32 %70, %70
  %72 = add nuw nsw i32 %71, %62
  br label %74

._crit_edge:                                      ; preds = %92, %69
  %.2106.lcssa = phi double [ %.1105134, %69 ], [ %.3107, %92 ]
  %.2103.lcssa = phi double [ %.1102135, %69 ], [ %.3, %92 ]
  %73 = add nuw nsw i32 %.096136, 1
  %.not115.not = icmp slt i32 %.096136, %.098
  br i1 %.not115.not, label %64, label %._crit_edge139, !llvm.loop !9

74:                                               ; preds = %.lr.ph, %92
  %.093131 = phi i32 [ %spec.store.select2, %.lr.ph ], [ %93, %92 ]
  %.2103130 = phi double [ %.1102135, %.lr.ph ], [ %.3, %92 ]
  %.2106129 = phi double [ %.1105134, %.lr.ph ], [ %.3107, %92 ]
  %75 = sub nsw i32 %.093131, %.097151
  %76 = mul nsw i32 %75, %75
  %77 = add nuw nsw i32 %72, %76
  %78 = icmp ugt i32 %77, %23
  br i1 %78, label %92, label %79

79:                                               ; preds = %74
  %80 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %4, i32 noundef %.093131, i32 noundef %.096136, i32 noundef %.099145)
          to label %81 unwind label %94

81:                                               ; preds = %79
  %82 = fsub double %41, %80
  %83 = fmul double %82, %82
  %84 = uitofp nneg i32 %77 to double
  %85 = fdiv double %84, %17
  %86 = call double @exp(double noundef %85) #7
  %87 = fdiv double %83, %19
  %88 = call double @exp(double noundef %87) #7
  %89 = fmul double %86, %88
  %90 = call double @llvm.fmuladd.f64(double %89, double %80, double %.2106129)
  %91 = fadd double %.2103130, %89
  br label %92

92:                                               ; preds = %74, %81
  %.3107 = phi double [ %90, %81 ], [ %.2106129, %74 ]
  %.3 = phi double [ %91, %81 ], [ %.2103130, %74 ]
  %93 = add nuw nsw i32 %.093131, 1
  %.not117.not = icmp slt i32 %.093131, %.095
  br i1 %.not117.not, label %74, label %._crit_edge, !llvm.loop !10

94:                                               ; preds = %79
  %95 = landingpad { ptr, i32 }
          cleanup
  br label %101

96:                                               ; preds = %._crit_edge148
  %97 = fdiv double %.1105.lcssa, %.1102.lcssa
  invoke void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.097151, i32 noundef %.094154, i32 noundef %.092156, double noundef %97)
          to label %._crit_edge148.thread unwind label %49

._crit_edge148.thread:                            ; preds = %51, %96, %._crit_edge148
  %98 = add nuw nsw i32 %.097151, 1
  %99 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %40, label %._crit_edge153, !llvm.loop !11

101:                                              ; preds = %44, %94, %49, %13
  %.pn.pn.pn = phi { ptr, i32 } [ %14, %13 ], [ %45, %44 ], [ %95, %94 ], [ %50, %49 ]
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %4) #7
  call void @llvm.lifetime.end.p0(i64 592, ptr nonnull %4) #7
  resume { ptr, i32 } %.pn.pn.pn
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

declare void @_ZN6R3GridC1ERKS_(ptr, ptr) local_unnamed_addr

declare void @_ZN6R3GridD1Ev(ptr) local_unnamed_addr

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

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


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