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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }

@RN_EPSILON = external global double, align 8
@RN_PI = external constant 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

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

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

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

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid18RasterizeGridPointEdddddi(ptr noundef nonnull align 8 dereferenceable(592) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, i32 noundef %6) #5 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %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 i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca double, align 8
  %31 = alloca double, align 8
  %32 = alloca double, align 8
  %33 = alloca double, align 8
  %34 = alloca double, align 8
  %35 = alloca i32, align 4
  %36 = alloca i32, align 4
  %37 = alloca i32, align 4
  %38 = alloca double, align 8
  %39 = alloca double, align 8
  %40 = alloca double, align 8
  %41 = alloca double, align 8
  %42 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !9
  store double %2, ptr %10, align 8, !tbaa !9
  store double %3, ptr %11, align 8, !tbaa !9
  store double %4, ptr %12, align 8, !tbaa !9
  store double %5, ptr %13, align 8, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !11
  %43 = load ptr, ptr %8, align 8
  %44 = load double, ptr %9, align 8, !tbaa !9
  %45 = fcmp olt double %44, 0.000000e+00
  br i1 %45, label %54, label %46

46:                                               ; preds = %7
  %47 = load double, ptr %9, align 8, !tbaa !9
  %48 = getelementptr inbounds %class.R3Grid, ptr %43, i32 0, i32 5
  %49 = getelementptr inbounds [3 x i32], ptr %48, i64 0, i64 0
  %50 = load i32, ptr %49, align 8, !tbaa !11
  %51 = sub nsw i32 %50, 1
  %52 = sitofp i32 %51 to double
  %53 = fcmp ogt double %47, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %46, %7
  br label %323

55:                                               ; preds = %46
  %56 = load double, ptr %10, align 8, !tbaa !9
  %57 = fcmp olt double %56, 0.000000e+00
  br i1 %57, label %66, label %58

58:                                               ; preds = %55
  %59 = load double, ptr %10, align 8, !tbaa !9
  %60 = getelementptr inbounds %class.R3Grid, ptr %43, i32 0, i32 5
  %61 = getelementptr inbounds [3 x i32], ptr %60, i64 0, i64 1
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = sub nsw i32 %62, 1
  %64 = sitofp i32 %63 to double
  %65 = fcmp ogt double %59, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %58, %55
  br label %323

67:                                               ; preds = %58
  %68 = load double, ptr %11, align 8, !tbaa !9
  %69 = fcmp olt double %68, 0.000000e+00
  br i1 %69, label %78, label %70

70:                                               ; preds = %67
  %71 = load double, ptr %11, align 8, !tbaa !9
  %72 = getelementptr inbounds %class.R3Grid, ptr %43, i32 0, i32 5
  %73 = getelementptr inbounds [3 x i32], ptr %72, i64 0, i64 2
  %74 = load i32, ptr %73, align 8, !tbaa !11
  %75 = sub nsw i32 %74, 1
  %76 = sitofp i32 %75 to double
  %77 = fcmp ogt double %71, %76
  br i1 %77, label %78, label %79

78:                                               ; preds = %70, %67
  br label %323

79:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %80 = load double, ptr %13, align 8, !tbaa !9
  %81 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %80, double 5.000000e-01)
  %82 = fptosi double %81 to i32
  store i32 %82, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %83 = load double, ptr %9, align 8, !tbaa !9
  %84 = load i32, ptr %15, align 4, !tbaa !11
  %85 = sitofp i32 %84 to double
  %86 = fsub double %83, %85
  %87 = fadd double %86, 5.000000e-01
  %88 = fptosi double %87 to i32
  store i32 %88, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %89 = load double, ptr %9, align 8, !tbaa !9
  %90 = load i32, ptr %15, align 4, !tbaa !11
  %91 = sitofp i32 %90 to double
  %92 = fadd double %89, %91
  %93 = fadd double %92, 5.000000e-01
  %94 = fptosi double %93 to i32
  store i32 %94, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %95 = load double, ptr %10, align 8, !tbaa !9
  %96 = load i32, ptr %15, align 4, !tbaa !11
  %97 = sitofp i32 %96 to double
  %98 = fsub double %95, %97
  %99 = fadd double %98, 5.000000e-01
  %100 = fptosi double %99 to i32
  store i32 %100, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %101 = load double, ptr %10, align 8, !tbaa !9
  %102 = load i32, ptr %15, align 4, !tbaa !11
  %103 = sitofp i32 %102 to double
  %104 = fadd double %101, %103
  %105 = fadd double %104, 5.000000e-01
  %106 = fptosi double %105 to i32
  store i32 %106, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %107 = load double, ptr %11, align 8, !tbaa !9
  %108 = load i32, ptr %15, align 4, !tbaa !11
  %109 = sitofp i32 %108 to double
  %110 = fsub double %107, %109
  %111 = fadd double %110, 5.000000e-01
  %112 = fptosi double %111 to i32
  store i32 %112, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %113 = load double, ptr %11, align 8, !tbaa !9
  %114 = load i32, ptr %15, align 4, !tbaa !11
  %115 = sitofp i32 %114 to double
  %116 = fadd double %113, %115
  %117 = fadd double %116, 5.000000e-01
  %118 = fptosi double %117 to i32
  store i32 %118, ptr %21, align 4, !tbaa !11
  %119 = load i32, ptr %16, align 4, !tbaa !11
  %120 = icmp slt i32 %119, 0
  br i1 %120, label %121, label %122

121:                                              ; preds = %79
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %122

122:                                              ; preds = %121, %79
  %123 = load i32, ptr %17, align 4, !tbaa !11
  %124 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %43)
  %125 = sub nsw i32 %124, 1
  %126 = icmp sgt i32 %123, %125
  br i1 %126, label %127, label %130

127:                                              ; preds = %122
  %128 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %43)
  %129 = sub nsw i32 %128, 1
  store i32 %129, ptr %17, align 4, !tbaa !11
  br label %130

130:                                              ; preds = %127, %122
  %131 = load i32, ptr %18, align 4, !tbaa !11
  %132 = icmp slt i32 %131, 0
  br i1 %132, label %133, label %134

133:                                              ; preds = %130
  store i32 0, ptr %18, align 4, !tbaa !11
  br label %134

134:                                              ; preds = %133, %130
  %135 = load i32, ptr %19, align 4, !tbaa !11
  %136 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %43)
  %137 = sub nsw i32 %136, 1
  %138 = icmp sgt i32 %135, %137
  br i1 %138, label %139, label %142

139:                                              ; preds = %134
  %140 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %43)
  %141 = sub nsw i32 %140, 1
  store i32 %141, ptr %19, align 4, !tbaa !11
  br label %142

142:                                              ; preds = %139, %134
  %143 = load i32, ptr %20, align 4, !tbaa !11
  %144 = icmp slt i32 %143, 0
  br i1 %144, label %145, label %146

145:                                              ; preds = %142
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %146

146:                                              ; preds = %145, %142
  %147 = load i32, ptr %21, align 4, !tbaa !11
  %148 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %43)
  %149 = sub nsw i32 %148, 1
  %150 = icmp sgt i32 %147, %149
  br i1 %150, label %151, label %154

151:                                              ; preds = %146
  %152 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %43)
  %153 = sub nsw i32 %152, 1
  store i32 %153, ptr %21, align 4, !tbaa !11
  br label %154

154:                                              ; preds = %151, %146
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %155 = load double, ptr @RN_PI, align 8, !tbaa !9
  %156 = fmul double 2.000000e+00, %155
  %157 = call double @sqrt(double noundef %156) #6
  %158 = load double, ptr %13, align 8, !tbaa !9
  %159 = fmul double %157, %158
  store double %159, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %160 = load double, ptr %22, align 8, !tbaa !9
  %161 = load double, ptr %22, align 8, !tbaa !9
  %162 = fmul double %160, %161
  %163 = load double, ptr %22, align 8, !tbaa !9
  %164 = fmul double %162, %163
  %165 = fdiv double 1.000000e+00, %164
  store double %165, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  %166 = load double, ptr %13, align 8, !tbaa !9
  %167 = fmul double 2.000000e+00, %166
  %168 = load double, ptr %13, align 8, !tbaa !9
  %169 = fmul double %167, %168
  store double %169, ptr %24, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  store double 0.000000e+00, ptr %25, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  %170 = load i32, ptr %20, align 4, !tbaa !11
  store i32 %170, ptr %26, align 4, !tbaa !11
  br label %171

171:                                              ; preds = %240, %154
  %172 = load i32, ptr %26, align 4, !tbaa !11
  %173 = load i32, ptr %21, align 4, !tbaa !11
  %174 = icmp sle i32 %172, %173
  br i1 %174, label %176, label %175

175:                                              ; preds = %171
  store i32 2, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  br label %243

176:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #6
  %177 = load i32, ptr %18, align 4, !tbaa !11
  store i32 %177, ptr %28, align 4, !tbaa !11
  br label %178

178:                                              ; preds = %236, %176
  %179 = load i32, ptr %28, align 4, !tbaa !11
  %180 = load i32, ptr %19, align 4, !tbaa !11
  %181 = icmp sle i32 %179, %180
  br i1 %181, label %183, label %182

182:                                              ; preds = %178
  store i32 5, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  br label %239

183:                                              ; preds = %178
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #6
  %184 = load i32, ptr %16, align 4, !tbaa !11
  store i32 %184, ptr %29, align 4, !tbaa !11
  br label %185

185:                                              ; preds = %232, %183
  %186 = load i32, ptr %29, align 4, !tbaa !11
  %187 = load i32, ptr %17, align 4, !tbaa !11
  %188 = icmp sle i32 %186, %187
  br i1 %188, label %190, label %189

189:                                              ; preds = %185
  store i32 8, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #6
  br label %235

190:                                              ; preds = %185
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #6
  %191 = load double, ptr %9, align 8, !tbaa !9
  %192 = load i32, ptr %29, align 4, !tbaa !11
  %193 = sitofp i32 %192 to double
  %194 = fsub double %191, %193
  store double %194, ptr %30, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #6
  %195 = load double, ptr %10, align 8, !tbaa !9
  %196 = load i32, ptr %28, align 4, !tbaa !11
  %197 = sitofp i32 %196 to double
  %198 = fsub double %195, %197
  store double %198, ptr %31, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #6
  %199 = load double, ptr %11, align 8, !tbaa !9
  %200 = load i32, ptr %26, align 4, !tbaa !11
  %201 = sitofp i32 %200 to double
  %202 = fsub double %199, %201
  store double %202, ptr %32, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #6
  %203 = load double, ptr %30, align 8, !tbaa !9
  %204 = load double, ptr %30, align 8, !tbaa !9
  %205 = load double, ptr %31, align 8, !tbaa !9
  %206 = load double, ptr %31, align 8, !tbaa !9
  %207 = fmul double %205, %206
  %208 = call double @llvm.fmuladd.f64(double %203, double %204, double %207)
  %209 = load double, ptr %32, align 8, !tbaa !9
  %210 = load double, ptr %32, align 8, !tbaa !9
  %211 = call double @llvm.fmuladd.f64(double %209, double %210, double %208)
  %212 = call double @sqrt(double noundef %211) #6
  store double %212, ptr %33, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %34) #6
  %213 = load double, ptr %23, align 8, !tbaa !9
  %214 = load double, ptr %33, align 8, !tbaa !9
  %215 = fneg double %214
  %216 = load double, ptr %33, align 8, !tbaa !9
  %217 = fmul double %215, %216
  %218 = load double, ptr %24, align 8, !tbaa !9
  %219 = fdiv double %217, %218
  %220 = call double @exp(double noundef %219) #6
  %221 = fmul double %213, %220
  store double %221, ptr %34, align 8, !tbaa !9
  %222 = load double, ptr %34, align 8, !tbaa !9
  %223 = load i32, ptr %29, align 4, !tbaa !11
  %224 = load i32, ptr %28, align 4, !tbaa !11
  %225 = load i32, ptr %26, align 4, !tbaa !11
  %226 = call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %43, i32 noundef %223, i32 noundef %224, i32 noundef %225)
  %227 = load double, ptr %12, align 8, !tbaa !9
  %228 = call double @llvm.fmuladd.f64(double %222, double %226, double %227)
  store double %228, ptr %12, align 8, !tbaa !9
  %229 = load double, ptr %34, align 8, !tbaa !9
  %230 = load double, ptr %25, align 8, !tbaa !9
  %231 = fadd double %230, %229
  store double %231, ptr %25, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %34) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %32) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #6
  br label %232

232:                                              ; preds = %190
  %233 = load i32, ptr %29, align 4, !tbaa !11
  %234 = add nsw i32 %233, 1
  store i32 %234, ptr %29, align 4, !tbaa !11
  br label %185, !llvm.loop !13

235:                                              ; preds = %189
  br label %236

236:                                              ; preds = %235
  %237 = load i32, ptr %28, align 4, !tbaa !11
  %238 = add nsw i32 %237, 1
  store i32 %238, ptr %28, align 4, !tbaa !11
  br label %178, !llvm.loop !15

239:                                              ; preds = %182
  br label %240

240:                                              ; preds = %239
  %241 = load i32, ptr %26, align 4, !tbaa !11
  %242 = add nsw i32 %241, 1
  store i32 %242, ptr %26, align 4, !tbaa !11
  br label %171, !llvm.loop !16

243:                                              ; preds = %175
  %244 = load double, ptr %25, align 8, !tbaa !9
  %245 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %246 = call noundef i32 @_Z12RNIsPositivedd(double noundef %244, double noundef %245)
  %247 = icmp ne i32 %246, 0
  br i1 %247, label %248, label %322

248:                                              ; preds = %243
  call void @llvm.lifetime.start.p0(i64 4, ptr %35) #6
  %249 = load i32, ptr %20, align 4, !tbaa !11
  store i32 %249, ptr %35, align 4, !tbaa !11
  br label %250

250:                                              ; preds = %318, %248
  %251 = load i32, ptr %35, align 4, !tbaa !11
  %252 = load i32, ptr %21, align 4, !tbaa !11
  %253 = icmp sle i32 %251, %252
  br i1 %253, label %255, label %254

254:                                              ; preds = %250
  store i32 11, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %35) #6
  br label %321

255:                                              ; preds = %250
  call void @llvm.lifetime.start.p0(i64 4, ptr %36) #6
  %256 = load i32, ptr %18, align 4, !tbaa !11
  store i32 %256, ptr %36, align 4, !tbaa !11
  br label %257

257:                                              ; preds = %314, %255
  %258 = load i32, ptr %36, align 4, !tbaa !11
  %259 = load i32, ptr %19, align 4, !tbaa !11
  %260 = icmp sle i32 %258, %259
  br i1 %260, label %262, label %261

261:                                              ; preds = %257
  store i32 14, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %36) #6
  br label %317

262:                                              ; preds = %257
  call void @llvm.lifetime.start.p0(i64 4, ptr %37) #6
  %263 = load i32, ptr %16, align 4, !tbaa !11
  store i32 %263, ptr %37, align 4, !tbaa !11
  br label %264

264:                                              ; preds = %310, %262
  %265 = load i32, ptr %37, align 4, !tbaa !11
  %266 = load i32, ptr %17, align 4, !tbaa !11
  %267 = icmp sle i32 %265, %266
  br i1 %267, label %269, label %268

268:                                              ; preds = %264
  store i32 17, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %37) #6
  br label %313

269:                                              ; preds = %264
  call void @llvm.lifetime.start.p0(i64 8, ptr %38) #6
  %270 = load double, ptr %9, align 8, !tbaa !9
  %271 = load i32, ptr %37, align 4, !tbaa !11
  %272 = sitofp i32 %271 to double
  %273 = fsub double %270, %272
  store double %273, ptr %38, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %39) #6
  %274 = load double, ptr %10, align 8, !tbaa !9
  %275 = load i32, ptr %36, align 4, !tbaa !11
  %276 = sitofp i32 %275 to double
  %277 = fsub double %274, %276
  store double %277, ptr %39, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %40) #6
  %278 = load double, ptr %11, align 8, !tbaa !9
  %279 = load i32, ptr %35, align 4, !tbaa !11
  %280 = sitofp i32 %279 to double
  %281 = fsub double %278, %280
  store double %281, ptr %40, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %41) #6
  %282 = load double, ptr %38, align 8, !tbaa !9
  %283 = load double, ptr %38, align 8, !tbaa !9
  %284 = load double, ptr %39, align 8, !tbaa !9
  %285 = load double, ptr %39, align 8, !tbaa !9
  %286 = fmul double %284, %285
  %287 = call double @llvm.fmuladd.f64(double %282, double %283, double %286)
  %288 = load double, ptr %40, align 8, !tbaa !9
  %289 = load double, ptr %40, align 8, !tbaa !9
  %290 = call double @llvm.fmuladd.f64(double %288, double %289, double %287)
  %291 = call double @sqrt(double noundef %290) #6
  store double %291, ptr %41, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %42) #6
  %292 = load double, ptr %23, align 8, !tbaa !9
  %293 = load double, ptr %41, align 8, !tbaa !9
  %294 = fneg double %293
  %295 = load double, ptr %41, align 8, !tbaa !9
  %296 = fmul double %294, %295
  %297 = load double, ptr %24, align 8, !tbaa !9
  %298 = fdiv double %296, %297
  %299 = call double @exp(double noundef %298) #6
  %300 = fmul double %292, %299
  store double %300, ptr %42, align 8, !tbaa !9
  %301 = load i32, ptr %37, align 4, !tbaa !11
  %302 = load i32, ptr %36, align 4, !tbaa !11
  %303 = load i32, ptr %35, align 4, !tbaa !11
  %304 = load double, ptr %42, align 8, !tbaa !9
  %305 = load double, ptr %12, align 8, !tbaa !9
  %306 = fmul double %304, %305
  %307 = load double, ptr %25, align 8, !tbaa !9
  %308 = fdiv double %306, %307
  %309 = load i32, ptr %14, align 4, !tbaa !11
  call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %43, i32 noundef %301, i32 noundef %302, i32 noundef %303, double noundef %308, i32 noundef %309)
  call void @llvm.lifetime.end.p0(i64 8, ptr %42) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %41) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %40) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %39) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %38) #6
  br label %310

310:                                              ; preds = %269
  %311 = load i32, ptr %37, align 4, !tbaa !11
  %312 = add nsw i32 %311, 1
  store i32 %312, ptr %37, align 4, !tbaa !11
  br label %264, !llvm.loop !17

313:                                              ; preds = %268
  br label %314

314:                                              ; preds = %313
  %315 = load i32, ptr %36, align 4, !tbaa !11
  %316 = add nsw i32 %315, 1
  store i32 %316, ptr %36, align 4, !tbaa !11
  br label %257, !llvm.loop !18

317:                                              ; preds = %261
  br label %318

318:                                              ; preds = %317
  %319 = load i32, ptr %35, align 4, !tbaa !11
  %320 = add nsw i32 %319, 1
  store i32 %320, ptr %35, align 4, !tbaa !11
  br label %250, !llvm.loop !19

321:                                              ; preds = %254
  br label %322

322:                                              ; preds = %321, %243
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %323

323:                                              ; preds = %322, %78, %66, %54
  ret void
}

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

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


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

@RN_EPSILON = external local_unnamed_addr global double, align 8
@RN_PI = external local_unnamed_addr constant double, align 8

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid18RasterizeGridPointEdddddi(ptr noundef nonnull align 8 dereferenceable(592) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, i32 noundef %6) local_unnamed_addr #4 align 2 {
  %8 = fcmp olt double %1, 0.000000e+00
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 568
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = add nsw i32 %11, -1
  %13 = sitofp i32 %12 to double
  %14 = fcmp olt double %13, %1
  %15 = fcmp olt double %2, 0.000000e+00
  %or.cond = or i1 %15, %14
  br i1 %or.cond, label %.loopexit, label %16

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %0, i64 572
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %18, -1
  %20 = sitofp i32 %19 to double
  %21 = fcmp olt double %20, %2
  %22 = fcmp olt double %3, 0.000000e+00
  %or.cond5 = or i1 %22, %21
  br i1 %or.cond5, label %.loopexit, label %23

23:                                               ; preds = %16
  %24 = getelementptr inbounds i8, ptr %0, i64 576
  %25 = load i32, ptr %24, align 8, !tbaa !5
  %26 = add nsw i32 %25, -1
  %27 = sitofp i32 %26 to double
  %28 = fcmp olt double %27, %3
  br i1 %28, label %.loopexit, label %29

29:                                               ; preds = %23
  %30 = tail call double @llvm.fmuladd.f64(double %5, double 3.000000e+00, double 5.000000e-01)
  %31 = fptosi double %30 to i32
  %32 = sitofp i32 %31 to double
  %33 = fsub double %1, %32
  %34 = fadd double %33, 5.000000e-01
  %35 = fptosi double %34 to i32
  %36 = fadd double %32, %1
  %37 = fadd double %36, 5.000000e-01
  %38 = fptosi double %37 to i32
  %39 = fsub double %2, %32
  %40 = fadd double %39, 5.000000e-01
  %41 = fptosi double %40 to i32
  %42 = fadd double %32, %2
  %43 = fadd double %42, 5.000000e-01
  %44 = fptosi double %43 to i32
  %45 = fsub double %3, %32
  %46 = fadd double %45, 5.000000e-01
  %47 = fptosi double %46 to i32
  %48 = fadd double %32, %3
  %49 = fadd double %48, 5.000000e-01
  %50 = fptosi double %49 to i32
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %35, i32 0)
  %51 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not = icmp sgt i32 %51, %38
  br i1 %.not, label %55, label %52

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

55:                                               ; preds = %52, %29
  %.0107 = phi i32 [ %54, %52 ], [ %38, %29 ]
  %spec.store.select1 = tail call i32 @llvm.smax.i32(i32 %41, i32 0)
  %56 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not125 = icmp sgt i32 %56, %44
  br i1 %.not125, label %60, label %57

57:                                               ; preds = %55
  %58 = tail 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
  %.0108 = phi i32 [ %59, %57 ], [ %44, %55 ]
  %spec.store.select2 = tail call i32 @llvm.smax.i32(i32 %47, i32 0)
  %61 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not126 = icmp sgt i32 %61, %50
  br i1 %.not126, label %65, label %62

62:                                               ; preds = %60
  %63 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %64 = add nsw i32 %63, -1
  br label %65

65:                                               ; preds = %62, %60
  %.0112 = phi i32 [ %64, %62 ], [ %50, %60 ]
  %66 = load double, ptr @RN_PI, align 8, !tbaa !9
  %67 = fmul double %66, 2.000000e+00
  %68 = tail call double @sqrt(double noundef %67) #6
  %69 = fmul double %68, %5
  %70 = fmul double %69, %69
  %71 = fmul double %69, %70
  %72 = fdiv double 1.000000e+00, %71
  %73 = fmul double %5, 2.000000e+00
  %74 = fmul double %73, %5
  %.not127152 = icmp sgt i32 %spec.store.select2, %.0112
  %.not132144 = icmp sgt i32 %spec.store.select1, %.0108
  %or.cond195 = select i1 %.not127152, i1 true, i1 %.not132144
  %.not133139 = icmp sgt i32 %spec.store.select, %.0107
  %or.cond196 = select i1 %or.cond195, i1 true, i1 %.not133139
  br i1 %or.cond196, label %._crit_edge157, label %.preheader138

.preheader138:                                    ; preds = %65, %._crit_edge148.split
  %.0156 = phi double [ %95, %._crit_edge148.split ], [ %4, %65 ]
  %.0113155 = phi double [ %96, %._crit_edge148.split ], [ 0.000000e+00, %65 ]
  %.0116153 = phi i32 [ %82, %._crit_edge148.split ], [ %spec.store.select2, %65 ]
  %75 = uitofp nneg i32 %.0116153 to double
  %76 = fsub double %3, %75
  br label %.preheader137

._crit_edge157:                                   ; preds = %._crit_edge148.split, %65
  %.0113.lcssa = phi double [ 0.000000e+00, %65 ], [ %96, %._crit_edge148.split ]
  %.0.lcssa = phi double [ %4, %65 ], [ %95, %._crit_edge148.split ]
  %77 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %78 = tail call noundef i32 @_Z12RNIsPositivedd(double noundef %.0113.lcssa, double noundef %77)
  %.not128 = icmp eq i32 %78, 0
  %or.cond183 = or i1 %.not128, %.not127152
  %.not130174 = icmp sgt i32 %spec.store.select1, %.0108
  %or.cond197 = select i1 %or.cond183, i1 true, i1 %.not130174
  %.not131171 = icmp sgt i32 %spec.store.select, %.0107
  %or.cond198 = select i1 %or.cond197, i1 true, i1 %.not131171
  br i1 %or.cond198, label %.loopexit, label %.preheader135

.preheader137:                                    ; preds = %.preheader138, %._crit_edge
  %.1147 = phi double [ %.0156, %.preheader138 ], [ %95, %._crit_edge ]
  %.1114146 = phi double [ %.0113155, %.preheader138 ], [ %96, %._crit_edge ]
  %.0118145 = phi i32 [ %spec.store.select1, %.preheader138 ], [ %83, %._crit_edge ]
  %79 = uitofp nneg i32 %.0118145 to double
  %80 = fsub double %2, %79
  %81 = fmul double %80, %80
  br label %84

._crit_edge148.split:                             ; preds = %._crit_edge
  %82 = add nuw i32 %.0116153, 1
  %exitcond190.not = icmp eq i32 %.0116153, %.0112
  br i1 %exitcond190.not, label %._crit_edge157, label %.preheader138, !llvm.loop !11

._crit_edge:                                      ; preds = %84
  %83 = add nuw i32 %.0118145, 1
  %exitcond189.not = icmp eq i32 %.0118145, %.0108
  br i1 %exitcond189.not, label %._crit_edge148.split, label %.preheader137, !llvm.loop !13

84:                                               ; preds = %.preheader137, %84
  %.2142 = phi double [ %.1147, %.preheader137 ], [ %95, %84 ]
  %.2115141 = phi double [ %.1114146, %.preheader137 ], [ %96, %84 ]
  %.0117140 = phi i32 [ %spec.store.select, %.preheader137 ], [ %97, %84 ]
  %85 = uitofp nneg i32 %.0117140 to double
  %86 = fsub double %1, %85
  %87 = tail call double @llvm.fmuladd.f64(double %86, double %86, double %81)
  %88 = tail call double @llvm.fmuladd.f64(double %76, double %76, double %87)
  %sqrt = tail call double @llvm.sqrt.f64(double %88)
  %89 = fneg double %sqrt
  %90 = fmul double %sqrt, %89
  %91 = fdiv double %90, %74
  %92 = tail call double @exp(double noundef %91) #6
  %93 = fmul double %72, %92
  %94 = tail call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0117140, i32 noundef %.0118145, i32 noundef %.0116153)
  %95 = tail call double @llvm.fmuladd.f64(double %93, double %94, double %.2142)
  %96 = fadd double %.2115141, %93
  %97 = add nuw i32 %.0117140, 1
  %exitcond.not = icmp eq i32 %.0117140, %.0107
  br i1 %exitcond.not, label %._crit_edge, label %84, !llvm.loop !14

.preheader135:                                    ; preds = %._crit_edge157, %._crit_edge176.split
  %.0111178 = phi i32 [ %103, %._crit_edge176.split ], [ %spec.store.select2, %._crit_edge157 ]
  %98 = uitofp nneg i32 %.0111178 to double
  %99 = fsub double %3, %98
  br label %.preheader

.preheader:                                       ; preds = %.preheader135, %._crit_edge173
  %.0110175 = phi i32 [ %spec.store.select1, %.preheader135 ], [ %104, %._crit_edge173 ]
  %100 = uitofp nneg i32 %.0110175 to double
  %101 = fsub double %2, %100
  %102 = fmul double %101, %101
  br label %105

._crit_edge176.split:                             ; preds = %._crit_edge173
  %103 = add nuw i32 %.0111178, 1
  %exitcond193.not = icmp eq i32 %.0111178, %.0112
  br i1 %exitcond193.not, label %.loopexit, label %.preheader135, !llvm.loop !15

._crit_edge173:                                   ; preds = %105
  %104 = add nuw i32 %.0110175, 1
  %exitcond192.not = icmp eq i32 %.0110175, %.0108
  br i1 %exitcond192.not, label %._crit_edge176.split, label %.preheader, !llvm.loop !16

105:                                              ; preds = %.preheader, %105
  %.0109172 = phi i32 [ %spec.store.select, %.preheader ], [ %117, %105 ]
  %106 = uitofp nneg i32 %.0109172 to double
  %107 = fsub double %1, %106
  %108 = tail call double @llvm.fmuladd.f64(double %107, double %107, double %102)
  %109 = tail call double @llvm.fmuladd.f64(double %99, double %99, double %108)
  %sqrt134 = tail call double @llvm.sqrt.f64(double %109)
  %110 = fneg double %sqrt134
  %111 = fmul double %sqrt134, %110
  %112 = fdiv double %111, %74
  %113 = tail call double @exp(double noundef %112) #6
  %114 = fmul double %72, %113
  %115 = fmul double %.0.lcssa, %114
  %116 = fdiv double %115, %.0113.lcssa
  tail call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0109172, i32 noundef %.0110175, i32 noundef %.0111178, double noundef %116, i32 noundef %6)
  %117 = add nuw i32 %.0109172, 1
  %exitcond191.not = icmp eq i32 %.0109172, %.0107
  br i1 %exitcond191.not, label %._crit_edge173, label %105, !llvm.loop !17

.loopexit:                                        ; preds = %._crit_edge176.split, %._crit_edge157, %23, %16, %7, %9
  ret void
}

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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