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

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

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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) #1 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid15BilateralFilterEdd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef %1, double noundef %2) #3 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.R2Grid, 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 double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca i32, align 4
  %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 double, align 8
  %32 = alloca double, align 8
  %33 = 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
  %34 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 208, ptr %7) #6
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %7, ptr noundef nonnull align 8 dereferenceable(208) %34)
  %35 = load double, ptr %6, align 8, !tbaa !9
  %36 = fcmp oeq double %35, -1.000000e+00
  br i1 %36, label %37, label %49

37:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  invoke void @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind writable sret(%class.RNInterval) align 8 %8, ptr noundef nonnull align 8 dereferenceable(208) %34)
          to label %38 unwind label %45

38:                                               ; preds = %37
  %39 = invoke noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %40 unwind label %45

40:                                               ; preds = %38
  %41 = invoke noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %42 unwind label %45

42:                                               ; preds = %40
  %43 = fsub double %39, %41
  %44 = fmul double 1.000000e-02, %43
  store double %44, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  br label %49

45:                                               ; preds = %40, %38, %37
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %9, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  br label %254

49:                                               ; preds = %42, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %50 = load double, ptr %5, align 8, !tbaa !9
  %51 = fmul double 2.000000e+00, %50
  %52 = load double, ptr %5, align 8, !tbaa !9
  %53 = fmul double %51, %52
  store double %53, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %54 = load double, ptr %6, align 8, !tbaa !9
  %55 = fmul double 2.000000e+00, %54
  %56 = load double, ptr %6, align 8, !tbaa !9
  %57 = fmul double %55, %56
  store double %57, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %58 = load double, ptr %5, align 8, !tbaa !9
  %59 = fmul double 3.000000e+00, %58
  store double %59, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %60 = load double, ptr %13, align 8, !tbaa !9
  %61 = fadd double %60, 1.000000e+00
  %62 = fptosi double %61 to i32
  store i32 %62, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %63 = load i32, ptr %14, align 4, !tbaa !11
  %64 = load i32, ptr %14, align 4, !tbaa !11
  %65 = mul nsw i32 %63, %64
  store i32 %65, 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 %66

66:                                               ; preds = %249, %49
  %67 = load i32, ptr %16, align 4, !tbaa !11
  %68 = invoke noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %34)
          to label %69 unwind label %72

69:                                               ; preds = %66
  %70 = icmp slt i32 %67, %68
  br i1 %70, label %76, label %71

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

72:                                               ; preds = %66
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %9, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %10, align 4
  br label %252

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

77:                                               ; preds = %243, %76
  %78 = load i32, ptr %18, align 4, !tbaa !11
  %79 = invoke noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %34)
          to label %80 unwind label %83

80:                                               ; preds = %77
  %81 = icmp slt i32 %78, %79
  br i1 %81, label %87, label %82

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

83:                                               ; preds = %77
  %84 = landingpad { ptr, i32 }
          cleanup
  %85 = extractvalue { ptr, i32 } %84, 0
  store ptr %85, ptr %9, align 8
  %86 = extractvalue { ptr, i32 } %84, 1
  store i32 %86, ptr %10, align 4
  br label %247

87:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %88 = load i32, ptr %18, align 4, !tbaa !11
  %89 = load i32, ptr %16, align 4, !tbaa !11
  %90 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %7, i32 noundef %88, i32 noundef %89)
          to label %91 unwind label %104

91:                                               ; preds = %87
  store double %90, ptr %19, align 8, !tbaa !9
  %92 = load double, ptr %19, align 8, !tbaa !9
  %93 = fcmp une double %92, -3.210000e+02
  br i1 %93, label %94, label %242

94:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  store double 0.000000e+00, 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 4, ptr %22) #6
  %95 = load i32, ptr %16, align 4, !tbaa !11
  %96 = load i32, ptr %14, align 4, !tbaa !11
  %97 = sub nsw i32 %95, %96
  store i32 %97, ptr %22, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  %98 = load i32, ptr %16, align 4, !tbaa !11
  %99 = load i32, ptr %14, align 4, !tbaa !11
  %100 = add nsw i32 %98, %99
  store i32 %100, ptr %23, align 4, !tbaa !11
  %101 = load i32, ptr %22, align 4, !tbaa !11
  %102 = icmp slt i32 %101, 0
  br i1 %102, label %103, label %108

103:                                              ; preds = %94
  store i32 0, ptr %22, align 4, !tbaa !11
  br label %108

104:                                              ; preds = %87
  %105 = landingpad { ptr, i32 }
          cleanup
  %106 = extractvalue { ptr, i32 } %105, 0
  store ptr %106, ptr %9, align 8
  %107 = extractvalue { ptr, i32 } %105, 1
  store i32 %107, ptr %10, align 4
  br label %246

108:                                              ; preds = %103, %94
  %109 = load i32, ptr %23, align 4, !tbaa !11
  %110 = invoke noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %34)
          to label %111 unwind label %117

111:                                              ; preds = %108
  %112 = icmp sge i32 %109, %110
  br i1 %112, label %113, label %121

113:                                              ; preds = %111
  %114 = invoke noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %34)
          to label %115 unwind label %117

115:                                              ; preds = %113
  %116 = sub nsw i32 %114, 1
  store i32 %116, ptr %23, align 4, !tbaa !11
  br label %121

117:                                              ; preds = %233, %229, %113, %108
  %118 = landingpad { ptr, i32 }
          cleanup
  %119 = extractvalue { ptr, i32 } %118, 0
  store ptr %119, ptr %9, align 8
  %120 = extractvalue { ptr, i32 } %118, 1
  store i32 %120, ptr %10, align 4
  br label %241

121:                                              ; preds = %115, %111
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  %122 = load i32, ptr %22, align 4, !tbaa !11
  store i32 %122, ptr %24, align 4, !tbaa !11
  br label %123

123:                                              ; preds = %222, %121
  %124 = load i32, ptr %24, align 4, !tbaa !11
  %125 = load i32, ptr %23, align 4, !tbaa !11
  %126 = icmp sle i32 %124, %125
  br i1 %126, label %128, label %127

127:                                              ; preds = %123
  store i32 8, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  br label %226

128:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  %129 = load i32, ptr %18, align 4, !tbaa !11
  %130 = load i32, ptr %14, align 4, !tbaa !11
  %131 = sub nsw i32 %129, %130
  store i32 %131, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  %132 = load i32, ptr %18, align 4, !tbaa !11
  %133 = load i32, ptr %14, align 4, !tbaa !11
  %134 = add nsw i32 %132, %133
  store i32 %134, ptr %26, align 4, !tbaa !11
  %135 = load i32, ptr %25, align 4, !tbaa !11
  %136 = icmp slt i32 %135, 0
  br i1 %136, label %137, label %138

137:                                              ; preds = %128
  store i32 0, ptr %25, align 4, !tbaa !11
  br label %138

138:                                              ; preds = %137, %128
  %139 = load i32, ptr %26, align 4, !tbaa !11
  %140 = invoke noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %34)
          to label %141 unwind label %147

141:                                              ; preds = %138
  %142 = icmp sge i32 %139, %140
  br i1 %142, label %143, label %151

143:                                              ; preds = %141
  %144 = invoke noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %34)
          to label %145 unwind label %147

145:                                              ; preds = %143
  %146 = sub nsw i32 %144, 1
  store i32 %146, ptr %26, align 4, !tbaa !11
  br label %151

147:                                              ; preds = %143, %138
  %148 = landingpad { ptr, i32 }
          cleanup
  %149 = extractvalue { ptr, i32 } %148, 0
  store ptr %149, ptr %9, align 8
  %150 = extractvalue { ptr, i32 } %148, 1
  store i32 %150, ptr %10, align 4
  br label %225

151:                                              ; preds = %145, %141
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #6
  %152 = load i32, ptr %24, align 4, !tbaa !11
  %153 = load i32, ptr %16, align 4, !tbaa !11
  %154 = sub nsw i32 %152, %153
  store i32 %154, ptr %27, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #6
  %155 = load i32, ptr %25, align 4, !tbaa !11
  store i32 %155, ptr %28, align 4, !tbaa !11
  br label %156

156:                                              ; preds = %218, %151
  %157 = load i32, ptr %28, align 4, !tbaa !11
  %158 = load i32, ptr %26, align 4, !tbaa !11
  %159 = icmp sle i32 %157, %158
  br i1 %159, label %161, label %160

160:                                              ; preds = %156
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  br label %221

161:                                              ; preds = %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #6
  %162 = load i32, ptr %28, align 4, !tbaa !11
  %163 = load i32, ptr %18, align 4, !tbaa !11
  %164 = sub nsw i32 %162, %163
  store i32 %164, ptr %29, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #6
  %165 = load i32, ptr %29, align 4, !tbaa !11
  %166 = load i32, ptr %29, align 4, !tbaa !11
  %167 = mul nsw i32 %165, %166
  %168 = load i32, ptr %27, align 4, !tbaa !11
  %169 = load i32, ptr %27, align 4, !tbaa !11
  %170 = mul nsw i32 %168, %169
  %171 = add nsw i32 %167, %170
  store i32 %171, ptr %30, align 4, !tbaa !11
  %172 = load i32, ptr %30, align 4, !tbaa !11
  %173 = load i32, ptr %15, align 4, !tbaa !11
  %174 = icmp sgt i32 %172, %173
  br i1 %174, label %175, label %176

175:                                              ; preds = %161
  store i32 13, ptr %17, align 4
  br label %215

176:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #6
  %177 = load i32, ptr %28, align 4, !tbaa !11
  %178 = load i32, ptr %24, align 4, !tbaa !11
  %179 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %7, i32 noundef %177, i32 noundef %178)
          to label %180 unwind label %184

180:                                              ; preds = %176
  store double %179, ptr %31, align 8, !tbaa !9
  %181 = load double, ptr %31, align 8, !tbaa !9
  %182 = fcmp oeq double %181, -3.210000e+02
  br i1 %182, label %183, label %188

183:                                              ; preds = %180
  store i32 13, ptr %17, align 4
  br label %214

184:                                              ; preds = %176
  %185 = landingpad { ptr, i32 }
          cleanup
  %186 = extractvalue { ptr, i32 } %185, 0
  store ptr %186, ptr %9, align 8
  %187 = extractvalue { ptr, i32 } %185, 1
  store i32 %187, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  br label %225

188:                                              ; preds = %180
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #6
  %189 = load double, ptr %19, align 8, !tbaa !9
  %190 = load double, ptr %31, align 8, !tbaa !9
  %191 = fsub double %189, %190
  store double %191, ptr %32, align 8, !tbaa !9
  %192 = load double, ptr %32, align 8, !tbaa !9
  %193 = load double, ptr %32, align 8, !tbaa !9
  %194 = fmul double %193, %192
  store double %194, ptr %32, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #6
  %195 = load i32, ptr %30, align 4, !tbaa !11
  %196 = sub nsw i32 0, %195
  %197 = sitofp i32 %196 to double
  %198 = load double, ptr %11, align 8, !tbaa !9
  %199 = fdiv double %197, %198
  %200 = call double @exp(double noundef %199) #6
  %201 = load double, ptr %32, align 8, !tbaa !9
  %202 = fneg double %201
  %203 = load double, ptr %12, align 8, !tbaa !9
  %204 = fdiv double %202, %203
  %205 = call double @exp(double noundef %204) #6
  %206 = fmul double %200, %205
  store double %206, ptr %33, align 8, !tbaa !9
  %207 = load double, ptr %33, align 8, !tbaa !9
  %208 = load double, ptr %31, align 8, !tbaa !9
  %209 = load double, ptr %20, align 8, !tbaa !9
  %210 = call double @llvm.fmuladd.f64(double %207, double %208, double %209)
  store double %210, ptr %20, align 8, !tbaa !9
  %211 = load double, ptr %33, align 8, !tbaa !9
  %212 = load double, ptr %21, align 8, !tbaa !9
  %213 = fadd double %212, %211
  store double %213, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %32) #6
  store i32 0, ptr %17, align 4
  br label %214

214:                                              ; preds = %188, %183
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #6
  br label %215

215:                                              ; preds = %214, %175
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #6
  %216 = load i32, ptr %17, align 4
  switch i32 %216, label %260 [
    i32 0, label %217
    i32 13, label %218
  ]

217:                                              ; preds = %215
  br label %218

218:                                              ; preds = %217, %215
  %219 = load i32, ptr %28, align 4, !tbaa !11
  %220 = add nsw i32 %219, 1
  store i32 %220, ptr %28, align 4, !tbaa !11
  br label %156, !llvm.loop !13

221:                                              ; preds = %160
  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 %222

222:                                              ; preds = %221
  %223 = load i32, ptr %24, align 4, !tbaa !11
  %224 = add nsw i32 %223, 1
  store i32 %224, ptr %24, align 4, !tbaa !11
  br label %123, !llvm.loop !15

225:                                              ; preds = %184, %147
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  br label %241

226:                                              ; preds = %127
  %227 = load double, ptr %21, align 8, !tbaa !9
  %228 = fcmp oeq double %227, 0.000000e+00
  br i1 %228, label %229, label %233

229:                                              ; preds = %226
  %230 = load i32, ptr %18, align 4, !tbaa !11
  %231 = load i32, ptr %16, align 4, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %34, i32 noundef %230, i32 noundef %231, double noundef -3.210000e+02)
          to label %232 unwind label %117

232:                                              ; preds = %229
  br label %240

233:                                              ; preds = %226
  %234 = load i32, ptr %18, align 4, !tbaa !11
  %235 = load i32, ptr %16, align 4, !tbaa !11
  %236 = load double, ptr %20, align 8, !tbaa !9
  %237 = load double, ptr %21, align 8, !tbaa !9
  %238 = fdiv double %236, %237
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %34, i32 noundef %234, i32 noundef %235, double noundef %238)
          to label %239 unwind label %117

239:                                              ; preds = %233
  br label %240

240:                                              ; preds = %239, %232
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, 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 %242

241:                                              ; preds = %225, %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, 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 %246

242:                                              ; preds = %240, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %243

243:                                              ; preds = %242
  %244 = load i32, ptr %18, align 4, !tbaa !11
  %245 = add nsw i32 %244, 1
  store i32 %245, ptr %18, align 4, !tbaa !11
  br label %77, !llvm.loop !16

246:                                              ; preds = %241, %104
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %247

247:                                              ; preds = %246, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %252

248:                                              ; preds = %82
  br label %249

249:                                              ; preds = %248
  %250 = load i32, ptr %16, align 4, !tbaa !11
  %251 = add nsw i32 %250, 1
  store i32 %251, ptr %16, align 4, !tbaa !11
  br label %66, !llvm.loop !17

252:                                              ; preds = %247, %72
  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 %254

253:                                              ; preds = %71
  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 @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %7) #6
  call void @llvm.lifetime.end.p0(i64 208, ptr %7) #6
  ret void

254:                                              ; preds = %252, %45
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %7) #6
  call void @llvm.lifetime.end.p0(i64 208, ptr %7) #6
  br label %255

255:                                              ; preds = %254
  %256 = load ptr, ptr %9, align 8
  %257 = load i32, ptr %10, align 4
  %258 = insertvalue { ptr, i32 } poison, ptr %256, 0
  %259 = insertvalue { ptr, i32 } %258, i32 %257, 1
  resume { ptr, i32 } %259

260:                                              ; preds = %215
  unreachable
}

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

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

declare void @_ZN6R2GridC1ERKS_(ptr, ptr)

declare void @_ZN6R2GridD1Ev(ptr)

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


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

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid15BilateralFilterEdd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef %1, double noundef %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.R2Grid, align 8
  %5 = alloca %class.RNInterval, align 8
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %4) #7
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %4, ptr noundef nonnull align 8 dereferenceable(208) %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 @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind nonnull writable sret(%class.RNInterval) align 8 %5, ptr noundef nonnull align 8 dereferenceable(208) %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 %92

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 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.preheader, label %._crit_edge123

.preheader:                                       ; preds = %15, %._crit_edge121
  %.076122 = phi i32 [ %30, %._crit_edge121 ], [ 0, %15 ]
  %26 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph120, label %._crit_edge121

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

._crit_edge123:                                   ; preds = %._crit_edge121, %15
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #7
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %4) #7
  ret void

._crit_edge121:                                   ; preds = %88, %.preheader
  %30 = add nuw nsw i32 %.076122, 1
  %31 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %.preheader, label %._crit_edge123, !llvm.loop !5

33:                                               ; preds = %.lr.ph120, %88
  %.078119 = phi i32 [ 0, %.lr.ph120 ], [ %89, %88 ]
  %34 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %.078119, i32 noundef %.076122)
          to label %35 unwind label %39

35:                                               ; preds = %33
  %36 = fcmp une double %34, -3.210000e+02
  br i1 %36, label %37, label %88

37:                                               ; preds = %35
  %38 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %.not = icmp slt i32 %29, %38
  br i1 %.not, label %46, label %41

39:                                               ; preds = %33
  %40 = landingpad { ptr, i32 }
          cleanup
  br label %92

41:                                               ; preds = %37
  %42 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %43 = add nsw i32 %42, -1
  br label %46

44:                                               ; preds = %.invoke
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %92

46:                                               ; preds = %41, %37
  %.081 = phi i32 [ %43, %41 ], [ %29, %37 ]
  %.not95110 = icmp sgt i32 %spec.store.select, %.081
  br i1 %.not95110, label %.invoke, label %.lr.ph115

.lr.ph115:                                        ; preds = %46
  %47 = sub nsw i32 %.078119, %22
  %48 = add nsw i32 %.078119, %22
  %spec.store.select1 = call i32 @llvm.smax.i32(i32 %47, i32 0)
  br label %50

._crit_edge116:                                   ; preds = %._crit_edge
  %49 = fcmp oeq double %.183.lcssa, 0.000000e+00
  br i1 %49, label %.invoke, label %85

50:                                               ; preds = %.lr.ph115, %._crit_edge
  %.080113 = phi i32 [ %spec.store.select, %.lr.ph115 ], [ %58, %._crit_edge ]
  %.082112 = phi double [ 0.000000e+00, %.lr.ph115 ], [ %.183.lcssa, %._crit_edge ]
  %.085111 = phi double [ 0.000000e+00, %.lr.ph115 ], [ %.186.lcssa, %._crit_edge ]
  %51 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %.not96 = icmp slt i32 %48, %51
  br i1 %.not96, label %55, label %52

52:                                               ; preds = %50
  %53 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %54 = add nsw i32 %53, -1
  br label %55

55:                                               ; preds = %52, %50
  %.079 = phi i32 [ %54, %52 ], [ %48, %50 ]
  %.not97105 = icmp sgt i32 %spec.store.select1, %.079
  br i1 %.not97105, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %55
  %56 = sub nsw i32 %.080113, %.076122
  %57 = mul nsw i32 %56, %56
  br label %59

._crit_edge:                                      ; preds = %83, %55
  %.186.lcssa = phi double [ %.085111, %55 ], [ %.388, %83 ]
  %.183.lcssa = phi double [ %.082112, %55 ], [ %.3, %83 ]
  %58 = add nuw nsw i32 %.080113, 1
  %.not95.not = icmp slt i32 %.080113, %.081
  br i1 %.not95.not, label %50, label %._crit_edge116, !llvm.loop !7

59:                                               ; preds = %.lr.ph, %83
  %.077108 = phi i32 [ %spec.store.select1, %.lr.ph ], [ %84, %83 ]
  %.183107 = phi double [ %.082112, %.lr.ph ], [ %.3, %83 ]
  %.186106 = phi double [ %.085111, %.lr.ph ], [ %.388, %83 ]
  %60 = sub nsw i32 %.077108, %.078119
  %61 = mul nsw i32 %60, %60
  %62 = add nuw nsw i32 %61, %57
  %63 = icmp ugt i32 %62, %23
  br i1 %63, label %83, label %64

64:                                               ; preds = %59
  %65 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %.077108, i32 noundef %.080113)
          to label %66 unwind label %68

66:                                               ; preds = %64
  %67 = fcmp oeq double %65, -3.210000e+02
  br i1 %67, label %83, label %70

68:                                               ; preds = %64
  %69 = landingpad { ptr, i32 }
          cleanup
  br label %92

70:                                               ; preds = %66
  %71 = fsub double %34, %65
  %72 = sub nsw i32 0, %62
  %73 = sitofp i32 %72 to double
  %74 = fdiv double %73, %17
  %75 = call double @exp(double noundef %74) #7
  %76 = fneg double %71
  %77 = fmul double %71, %76
  %78 = fdiv double %77, %19
  %79 = call double @exp(double noundef %78) #7
  %80 = fmul double %75, %79
  %81 = call double @llvm.fmuladd.f64(double %80, double %65, double %.186106)
  %82 = fadd double %.183107, %80
  br label %83

83:                                               ; preds = %70, %66, %59
  %.388 = phi double [ %.186106, %59 ], [ %81, %70 ], [ %.186106, %66 ]
  %.3 = phi double [ %.183107, %59 ], [ %82, %70 ], [ %.183107, %66 ]
  %84 = add nuw nsw i32 %.077108, 1
  %.not97.not = icmp slt i32 %.077108, %.079
  br i1 %.not97.not, label %59, label %._crit_edge, !llvm.loop !8

85:                                               ; preds = %._crit_edge116
  %86 = fdiv double %.186.lcssa, %.183.lcssa
  br label %.invoke

.invoke:                                          ; preds = %._crit_edge116, %46, %85
  %87 = phi double [ %86, %85 ], [ -3.210000e+02, %46 ], [ -3.210000e+02, %._crit_edge116 ]
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.078119, i32 noundef %.076122, double noundef %87)
          to label %88 unwind label %44

88:                                               ; preds = %.invoke, %35
  %89 = add nuw nsw i32 %.078119, 1
  %90 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %33, label %._crit_edge121, !llvm.loop !9

92:                                               ; preds = %39, %68, %44, %13
  %.pn.pn.pn = phi { ptr, i32 } [ %14, %13 ], [ %40, %39 ], [ %69, %68 ], [ %45, %44 ]
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #7
  call void @llvm.lifetime.end.p0(i64 208, 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 #1 align 2

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

declare void @_ZN6R2GridC1ERKS_(ptr, ptr) local_unnamed_addr

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


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