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

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

37:                                               ; preds = %5
  %38 = load double, ptr %8, align 8, !tbaa !9
  %39 = getelementptr inbounds %class.R3Grid, ptr %34, i32 0, i32 5
  %40 = getelementptr inbounds [3 x i32], ptr %39, i64 0, i64 0
  %41 = load i32, ptr %40, align 8, !tbaa !11
  %42 = sub nsw i32 %41, 1
  %43 = sitofp i32 %42 to double
  %44 = fcmp ogt double %38, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %37, %5
  store double 0.000000e+00, ptr %6, align 8
  br label %242

46:                                               ; preds = %37
  %47 = load double, ptr %9, align 8, !tbaa !9
  %48 = fcmp olt double %47, 0.000000e+00
  br i1 %48, label %57, label %49

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

57:                                               ; preds = %49, %46
  store double 0.000000e+00, ptr %6, align 8
  br label %242

58:                                               ; preds = %49
  %59 = load double, ptr %10, align 8, !tbaa !9
  %60 = fcmp olt double %59, 0.000000e+00
  br i1 %60, label %69, label %61

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

69:                                               ; preds = %61, %58
  store double 0.000000e+00, ptr %6, align 8
  br label %242

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

112:                                              ; preds = %70
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %113

113:                                              ; preds = %112, %70
  %114 = load i32, ptr %14, align 4, !tbaa !11
  %115 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %34)
  %116 = sub nsw i32 %115, 1
  %117 = icmp sgt i32 %114, %116
  br i1 %117, label %118, label %121

118:                                              ; preds = %113
  %119 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %34)
  %120 = sub nsw i32 %119, 1
  store i32 %120, ptr %14, align 4, !tbaa !11
  br label %121

121:                                              ; preds = %118, %113
  %122 = load i32, ptr %15, align 4, !tbaa !11
  %123 = icmp slt i32 %122, 0
  br i1 %123, label %124, label %125

124:                                              ; preds = %121
  store i32 0, ptr %15, align 4, !tbaa !11
  br label %125

125:                                              ; preds = %124, %121
  %126 = load i32, ptr %16, align 4, !tbaa !11
  %127 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %34)
  %128 = sub nsw i32 %127, 1
  %129 = icmp sgt i32 %126, %128
  br i1 %129, label %130, label %133

130:                                              ; preds = %125
  %131 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %34)
  %132 = sub nsw i32 %131, 1
  store i32 %132, ptr %16, align 4, !tbaa !11
  br label %133

133:                                              ; preds = %130, %125
  %134 = load i32, ptr %17, align 4, !tbaa !11
  %135 = icmp slt i32 %134, 0
  br i1 %135, label %136, label %137

136:                                              ; preds = %133
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %137

137:                                              ; preds = %136, %133
  %138 = load i32, ptr %18, align 4, !tbaa !11
  %139 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %34)
  %140 = sub nsw i32 %139, 1
  %141 = icmp sgt i32 %138, %140
  br i1 %141, label %142, label %145

142:                                              ; preds = %137
  %143 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %34)
  %144 = sub nsw i32 %143, 1
  store i32 %144, ptr %18, align 4, !tbaa !11
  br label %145

145:                                              ; preds = %142, %137
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %146 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %147 = call double @sqrt(double noundef %146) #6
  store double %147, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %148 = load double, ptr %19, align 8, !tbaa !9
  %149 = load double, ptr %11, align 8, !tbaa !9
  %150 = fmul double %148, %149
  store double %150, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %151 = load double, ptr %20, align 8, !tbaa !9
  %152 = load double, ptr %20, align 8, !tbaa !9
  %153 = fmul double %151, %152
  %154 = load double, ptr %20, align 8, !tbaa !9
  %155 = fmul double %153, %154
  %156 = fdiv double 1.000000e+00, %155
  store double %156, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %157 = load double, ptr %11, align 8, !tbaa !9
  %158 = fmul double 2.000000e+00, %157
  %159 = load double, ptr %11, align 8, !tbaa !9
  %160 = fmul double %158, %159
  store double %160, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  store double 0.000000e+00, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  store double 0.000000e+00, ptr %24, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  %161 = load i32, ptr %17, align 4, !tbaa !11
  store i32 %161, ptr %25, align 4, !tbaa !11
  br label %162

162:                                              ; preds = %228, %145
  %163 = load i32, ptr %25, align 4, !tbaa !11
  %164 = load i32, ptr %18, align 4, !tbaa !11
  %165 = icmp sle i32 %163, %164
  br i1 %165, label %167, label %166

166:                                              ; preds = %162
  store i32 2, ptr %26, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  br label %231

167:                                              ; preds = %162
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #6
  %168 = load i32, ptr %15, align 4, !tbaa !11
  store i32 %168, ptr %27, align 4, !tbaa !11
  br label %169

169:                                              ; preds = %224, %167
  %170 = load i32, ptr %27, align 4, !tbaa !11
  %171 = load i32, ptr %16, align 4, !tbaa !11
  %172 = icmp sle i32 %170, %171
  br i1 %172, label %174, label %173

173:                                              ; preds = %169
  store i32 5, ptr %26, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  br label %227

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

176:                                              ; preds = %220, %174
  %177 = load i32, ptr %28, align 4, !tbaa !11
  %178 = load i32, ptr %14, align 4, !tbaa !11
  %179 = icmp sle i32 %177, %178
  br i1 %179, label %181, label %180

180:                                              ; preds = %176
  store i32 8, ptr %26, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  br label %223

181:                                              ; preds = %176
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #6
  %182 = load double, ptr %8, align 8, !tbaa !9
  %183 = load i32, ptr %28, align 4, !tbaa !11
  %184 = sitofp i32 %183 to double
  %185 = fsub double %182, %184
  store double %185, ptr %29, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #6
  %186 = load double, ptr %9, align 8, !tbaa !9
  %187 = load i32, ptr %27, align 4, !tbaa !11
  %188 = sitofp i32 %187 to double
  %189 = fsub double %186, %188
  store double %189, ptr %30, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #6
  %190 = load double, ptr %10, align 8, !tbaa !9
  %191 = load i32, ptr %25, align 4, !tbaa !11
  %192 = sitofp i32 %191 to double
  %193 = fsub double %190, %192
  store double %193, ptr %31, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #6
  %194 = load double, ptr %29, align 8, !tbaa !9
  %195 = load double, ptr %29, align 8, !tbaa !9
  %196 = load double, ptr %30, align 8, !tbaa !9
  %197 = load double, ptr %30, align 8, !tbaa !9
  %198 = fmul double %196, %197
  %199 = call double @llvm.fmuladd.f64(double %194, double %195, double %198)
  %200 = load double, ptr %31, align 8, !tbaa !9
  %201 = load double, ptr %31, align 8, !tbaa !9
  %202 = call double @llvm.fmuladd.f64(double %200, double %201, double %199)
  store double %202, ptr %32, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #6
  %203 = load double, ptr %21, align 8, !tbaa !9
  %204 = load double, ptr %32, align 8, !tbaa !9
  %205 = fneg double %204
  %206 = load double, ptr %22, align 8, !tbaa !9
  %207 = fdiv double %205, %206
  %208 = call double @exp(double noundef %207) #6
  %209 = fmul double %203, %208
  store double %209, ptr %33, align 8, !tbaa !9
  %210 = load double, ptr %33, align 8, !tbaa !9
  %211 = load i32, ptr %28, align 4, !tbaa !11
  %212 = load i32, ptr %27, align 4, !tbaa !11
  %213 = load i32, ptr %25, align 4, !tbaa !11
  %214 = call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %34, i32 noundef %211, i32 noundef %212, i32 noundef %213)
  %215 = load double, ptr %23, align 8, !tbaa !9
  %216 = call double @llvm.fmuladd.f64(double %210, double %214, double %215)
  store double %216, ptr %23, align 8, !tbaa !9
  %217 = load double, ptr %33, align 8, !tbaa !9
  %218 = load double, ptr %24, align 8, !tbaa !9
  %219 = fadd double %218, %217
  store double %219, ptr %24, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #6
  br label %220

220:                                              ; preds = %181
  %221 = load i32, ptr %28, align 4, !tbaa !11
  %222 = add nsw i32 %221, 1
  store i32 %222, ptr %28, align 4, !tbaa !11
  br label %176, !llvm.loop !13

223:                                              ; preds = %180
  br label %224

224:                                              ; preds = %223
  %225 = load i32, ptr %27, align 4, !tbaa !11
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %27, align 4, !tbaa !11
  br label %169, !llvm.loop !15

227:                                              ; preds = %173
  br label %228

228:                                              ; preds = %227
  %229 = load i32, ptr %25, align 4, !tbaa !11
  %230 = add nsw i32 %229, 1
  store i32 %230, ptr %25, align 4, !tbaa !11
  br label %162, !llvm.loop !16

231:                                              ; preds = %166
  %232 = load double, ptr %24, align 8, !tbaa !9
  %233 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %234 = call noundef i32 @_Z11RNIsNotZerodd(double noundef %232, double noundef %233)
  %235 = icmp ne i32 %234, 0
  br i1 %235, label %236, label %240

236:                                              ; preds = %231
  %237 = load double, ptr %24, align 8, !tbaa !9
  %238 = load double, ptr %23, align 8, !tbaa !9
  %239 = fdiv double %238, %237
  store double %239, ptr %23, align 8, !tbaa !9
  br label %240

240:                                              ; preds = %236, %231
  %241 = load double, ptr %23, align 8, !tbaa !9
  store double %241, ptr %6, align 8
  store i32 1, ptr %26, align 4
  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 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %242

242:                                              ; preds = %240, %69, %57, %45
  %243 = load double, ptr %6, align 8
  ret double %243
}

; 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 @sqrt(double noundef) #5

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

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

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 = { 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}


; 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_TWO_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: mustprogress uwtable
define dso_local noundef double @_ZNK6R3Grid9GridValueEdddd(ptr noundef nonnull align 8 dereferenceable(592) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4) local_unnamed_addr #2 align 2 {
  %6 = fcmp olt double %1, 0.000000e+00
  br i1 %6, label %95, label %7

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

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

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

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

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

53:                                               ; preds = %50, %27
  %.073 = phi i32 [ %52, %50 ], [ %36, %27 ]
  %spec.store.select1 = tail call i32 @llvm.smax.i32(i32 %39, i32 0)
  %54 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not89 = icmp sgt i32 %54, %42
  br i1 %.not89, label %58, label %55

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

58:                                               ; preds = %55, %53
  %.074 = phi i32 [ %57, %55 ], [ %42, %53 ]
  %spec.store.select2 = tail call i32 @llvm.smax.i32(i32 %45, i32 0)
  %59 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not90 = icmp sgt i32 %59, %48
  br i1 %.not90, label %63, label %60

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

63:                                               ; preds = %60, %58
  %.082 = phi i32 [ %62, %60 ], [ %48, %58 ]
  %64 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %65 = tail call double @sqrt(double noundef %64) #6
  %66 = fmul double %65, %4
  %67 = fmul double %66, %66
  %68 = fmul double %66, %67
  %69 = fdiv double 1.000000e+00, %68
  %70 = fmul double %4, 2.000000e+00
  %71 = fmul double %70, %4
  %.not91110 = icmp sgt i32 %spec.store.select2, %.082
  %.not93102 = icmp sgt i32 %spec.store.select1, %.074
  %or.cond135 = select i1 %.not91110, i1 true, i1 %.not93102
  %.not9497 = icmp sgt i32 %spec.store.select, %.073
  %or.cond136 = select i1 %or.cond135, i1 true, i1 %.not9497
  br i1 %or.cond136, label %._crit_edge115, label %.preheader96

.preheader96:                                     ; preds = %63, %._crit_edge106.split
  %.077113 = phi i32 [ %80, %._crit_edge106.split ], [ %spec.store.select2, %63 ]
  %.078112 = phi double [ %93, %._crit_edge106.split ], [ 0.000000e+00, %63 ]
  %.079111 = phi double [ %92, %._crit_edge106.split ], [ 0.000000e+00, %63 ]
  %72 = uitofp nneg i32 %.077113 to double
  %73 = fsub double %3, %72
  br label %.preheader

._crit_edge115:                                   ; preds = %._crit_edge106.split, %63
  %.079.lcssa = phi double [ 0.000000e+00, %63 ], [ %92, %._crit_edge106.split ]
  %.078.lcssa = phi double [ 0.000000e+00, %63 ], [ %93, %._crit_edge106.split ]
  %74 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %75 = tail call noundef i32 @_Z11RNIsNotZerodd(double noundef %.078.lcssa, double noundef %74)
  %.not92 = icmp eq i32 %75, 0
  %76 = fdiv double %.079.lcssa, %.078.lcssa
  %.3 = select i1 %.not92, double %.079.lcssa, double %76
  br label %95

.preheader:                                       ; preds = %.preheader96, %._crit_edge
  %.076105 = phi i32 [ %spec.store.select1, %.preheader96 ], [ %81, %._crit_edge ]
  %.1104 = phi double [ %.078112, %.preheader96 ], [ %93, %._crit_edge ]
  %.180103 = phi double [ %.079111, %.preheader96 ], [ %92, %._crit_edge ]
  %77 = uitofp nneg i32 %.076105 to double
  %78 = fsub double %2, %77
  %79 = fmul double %78, %78
  br label %82

._crit_edge106.split:                             ; preds = %._crit_edge
  %80 = add nuw i32 %.077113, 1
  %exitcond133.not = icmp eq i32 %.077113, %.082
  br i1 %exitcond133.not, label %._crit_edge115, label %.preheader96, !llvm.loop !11

._crit_edge:                                      ; preds = %82
  %81 = add nuw i32 %.076105, 1
  %exitcond132.not = icmp eq i32 %.076105, %.074
  br i1 %exitcond132.not, label %._crit_edge106.split, label %.preheader, !llvm.loop !13

82:                                               ; preds = %.preheader, %82
  %.075100 = phi i32 [ %spec.store.select, %.preheader ], [ %94, %82 ]
  %.299 = phi double [ %.1104, %.preheader ], [ %93, %82 ]
  %.28198 = phi double [ %.180103, %.preheader ], [ %92, %82 ]
  %83 = uitofp nneg i32 %.075100 to double
  %84 = fsub double %1, %83
  %85 = tail call double @llvm.fmuladd.f64(double %84, double %84, double %79)
  %86 = tail call double @llvm.fmuladd.f64(double %73, double %73, double %85)
  %87 = fneg double %86
  %88 = fdiv double %87, %71
  %89 = tail call double @exp(double noundef %88) #6
  %90 = fmul double %69, %89
  %91 = tail call noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.075100, i32 noundef %.076105, i32 noundef %.077113)
  %92 = tail call double @llvm.fmuladd.f64(double %90, double %91, double %.28198)
  %93 = fadd double %.299, %90
  %94 = add nuw i32 %.075100, 1
  %exitcond.not = icmp eq i32 %.075100, %.073
  br i1 %exitcond.not, label %._crit_edge, label %82, !llvm.loop !14

95:                                               ; preds = %21, %14, %5, %7, %._crit_edge115
  %.0 = phi double [ %.3, %._crit_edge115 ], [ 0.000000e+00, %7 ], [ 0.000000e+00, %5 ], [ 0.000000e+00, %14 ], [ 0.000000e+00, %21 ]
  ret double %.0
}

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z11RNIsNotZerodd(double noundef, double noundef) local_unnamed_addr #1

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


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