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

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

; 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: nounwind
declare double @sqrt(double noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid19RasterizeGridSphereERK7R3Pointddii(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, double noundef %2, double noundef %3, i32 noundef %4, i32 noundef %5) #2 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [3 x i32], align 4
  %14 = alloca [3 x i32], align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %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 i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca double, align 8
  %27 = alloca double, align 8
  %28 = alloca double, align 8
  %29 = alloca double, align 8
  %30 = alloca i32, align 4
  %31 = alloca i32, align 4
  %32 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  store i32 %5, ptr %12, align 4, !tbaa !11
  %33 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !11
  br label %34

34:                                               ; preds = %100, %6
  %35 = load i32, ptr %15, align 4, !tbaa !11
  %36 = icmp slt i32 %35, 3
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  store i32 2, ptr %16, align 4
  br label %103

38:                                               ; preds = %34
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load i32, ptr %15, align 4, !tbaa !11
  %41 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %39, i32 noundef %40)
  %42 = load double, ptr %9, align 8, !tbaa !9
  %43 = fadd double %41, %42
  %44 = fptosi double %43 to i32
  %45 = load i32, ptr %15, align 4, !tbaa !11
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 %46
  store i32 %44, ptr %47, align 4, !tbaa !11
  %48 = load i32, ptr %15, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %38
  store i32 1, ptr %16, align 4
  br label %103

54:                                               ; preds = %38
  %55 = load i32, ptr %15, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = load i32, ptr %15, align 4, !tbaa !11
  %60 = call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %33, i32 noundef %59)
  %61 = sub nsw i32 %60, 1
  %62 = icmp sgt i32 %58, %61
  br i1 %62, label %63, label %70

63:                                               ; preds = %54
  %64 = load i32, ptr %15, align 4, !tbaa !11
  %65 = call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %33, i32 noundef %64)
  %66 = sub nsw i32 %65, 1
  %67 = load i32, ptr %15, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 %68
  store i32 %66, ptr %69, align 4, !tbaa !11
  br label %70

70:                                               ; preds = %63, %54
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = load i32, ptr %15, align 4, !tbaa !11
  %73 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %71, i32 noundef %72)
  %74 = load double, ptr %9, align 8, !tbaa !9
  %75 = fsub double %73, %74
  %76 = fptosi double %75 to i32
  %77 = load i32, ptr %15, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 %78
  store i32 %76, ptr %79, align 4, !tbaa !11
  %80 = load i32, ptr %15, align 4, !tbaa !11
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !11
  %84 = load i32, ptr %15, align 4, !tbaa !11
  %85 = call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %33, i32 noundef %84)
  %86 = sub nsw i32 %85, 1
  %87 = icmp sgt i32 %83, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %70
  store i32 1, ptr %16, align 4
  br label %103

89:                                               ; preds = %70
  %90 = load i32, ptr %15, align 4, !tbaa !11
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !11
  %94 = icmp slt i32 %93, 0
  br i1 %94, label %95, label %99

95:                                               ; preds = %89
  %96 = load i32, ptr %15, align 4, !tbaa !11
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 %97
  store i32 0, ptr %98, align 4, !tbaa !11
  br label %99

99:                                               ; preds = %95, %89
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %15, align 4, !tbaa !11
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %15, align 4, !tbaa !11
  br label %34, !llvm.loop !13

103:                                              ; preds = %88, %53, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  %104 = load i32, ptr %16, align 4
  switch i32 %104, label %258 [
    i32 2, label %105
  ]

105:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %106 = load double, ptr %9, align 8, !tbaa !9
  %107 = load double, ptr %9, align 8, !tbaa !9
  %108 = fmul double %106, %107
  store double %108, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %109 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 2
  %110 = load i32, ptr %109, align 4, !tbaa !11
  store i32 %110, ptr %18, align 4, !tbaa !11
  br label %111

111:                                              ; preds = %254, %105
  %112 = load i32, ptr %18, align 4, !tbaa !11
  %113 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 2
  %114 = load i32, ptr %113, align 4, !tbaa !11
  %115 = icmp sle i32 %112, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %111
  store i32 5, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %257

117:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %118 = load i32, ptr %18, align 4, !tbaa !11
  %119 = sitofp i32 %118 to double
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %120, i32 noundef 2)
  %122 = fsub double %119, %121
  %123 = fptosi double %122 to i32
  %124 = sitofp i32 %123 to double
  store double %124, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %125 = load double, ptr %19, align 8, !tbaa !9
  %126 = load double, ptr %19, align 8, !tbaa !9
  %127 = fmul double %125, %126
  store double %127, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %128 = load double, ptr %17, align 8, !tbaa !9
  %129 = load double, ptr %20, align 8, !tbaa !9
  %130 = fsub double %128, %129
  store double %130, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %131 = load double, ptr %21, align 8, !tbaa !9
  %132 = call double @sqrt(double noundef %131) #4
  store double %132, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %133 = load ptr, ptr %8, align 8, !tbaa !5
  %134 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %133, i32 noundef 1)
  %135 = load double, ptr %22, align 8, !tbaa !9
  %136 = fsub double %134, %135
  %137 = fadd double %136, 5.000000e-01
  %138 = fptosi double %137 to i32
  store i32 %138, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %139 = load ptr, ptr %8, align 8, !tbaa !5
  %140 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %139, i32 noundef 1)
  %141 = load double, ptr %22, align 8, !tbaa !9
  %142 = fadd double %140, %141
  %143 = fadd double %142, 5.000000e-01
  %144 = fptosi double %143 to i32
  store i32 %144, ptr %24, align 4, !tbaa !11
  %145 = load i32, ptr %23, align 4, !tbaa !11
  %146 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 1
  %147 = load i32, ptr %146, align 4, !tbaa !11
  %148 = icmp slt i32 %145, %147
  br i1 %148, label %149, label %152

149:                                              ; preds = %117
  %150 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 1
  %151 = load i32, ptr %150, align 4, !tbaa !11
  store i32 %151, ptr %23, align 4, !tbaa !11
  br label %152

152:                                              ; preds = %149, %117
  %153 = load i32, ptr %24, align 4, !tbaa !11
  %154 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 1
  %155 = load i32, ptr %154, align 4, !tbaa !11
  %156 = icmp sgt i32 %153, %155
  br i1 %156, label %157, label %160

157:                                              ; preds = %152
  %158 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 1
  %159 = load i32, ptr %158, align 4, !tbaa !11
  store i32 %159, ptr %24, align 4, !tbaa !11
  br label %160

160:                                              ; preds = %157, %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  %161 = load i32, ptr %23, align 4, !tbaa !11
  store i32 %161, ptr %25, align 4, !tbaa !11
  br label %162

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

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

167:                                              ; preds = %162
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %168 = load i32, ptr %25, align 4, !tbaa !11
  %169 = sitofp i32 %168 to double
  %170 = load ptr, ptr %8, align 8, !tbaa !5
  %171 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %170, i32 noundef 1)
  %172 = fsub double %169, %171
  %173 = fptosi double %172 to i32
  %174 = sitofp i32 %173 to double
  store double %174, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #4
  %175 = load double, ptr %26, align 8, !tbaa !9
  %176 = load double, ptr %26, align 8, !tbaa !9
  %177 = fmul double %175, %176
  store double %177, ptr %27, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  %178 = load double, ptr %21, align 8, !tbaa !9
  %179 = load double, ptr %27, align 8, !tbaa !9
  %180 = fsub double %178, %179
  store double %180, ptr %28, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #4
  %181 = load double, ptr %28, align 8, !tbaa !9
  %182 = call double @sqrt(double noundef %181) #4
  store double %182, ptr %29, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #4
  %183 = load ptr, ptr %8, align 8, !tbaa !5
  %184 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %183, i32 noundef 0)
  %185 = load double, ptr %29, align 8, !tbaa !9
  %186 = fsub double %184, %185
  %187 = fadd double %186, 5.000000e-01
  %188 = fptosi double %187 to i32
  store i32 %188, ptr %30, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #4
  %189 = load ptr, ptr %8, align 8, !tbaa !5
  %190 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %189, i32 noundef 0)
  %191 = load double, ptr %29, align 8, !tbaa !9
  %192 = fadd double %190, %191
  %193 = fadd double %192, 5.000000e-01
  %194 = fptosi double %193 to i32
  store i32 %194, ptr %31, align 4, !tbaa !11
  %195 = load i32, ptr %30, align 4, !tbaa !11
  %196 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 0
  %197 = load i32, ptr %196, align 4, !tbaa !11
  %198 = icmp slt i32 %195, %197
  br i1 %198, label %199, label %202

199:                                              ; preds = %167
  %200 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 0
  %201 = load i32, ptr %200, align 4, !tbaa !11
  store i32 %201, ptr %30, align 4, !tbaa !11
  br label %202

202:                                              ; preds = %199, %167
  %203 = load i32, ptr %31, align 4, !tbaa !11
  %204 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  %205 = load i32, ptr %204, align 4, !tbaa !11
  %206 = icmp sgt i32 %203, %205
  br i1 %206, label %207, label %210

207:                                              ; preds = %202
  %208 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  %209 = load i32, ptr %208, align 4, !tbaa !11
  store i32 %209, ptr %31, align 4, !tbaa !11
  br label %210

210:                                              ; preds = %207, %202
  %211 = load i32, ptr %11, align 4, !tbaa !11
  %212 = icmp ne i32 %211, 0
  br i1 %212, label %221, label %213

213:                                              ; preds = %210
  %214 = load i32, ptr %25, align 4, !tbaa !11
  %215 = load i32, ptr %23, align 4, !tbaa !11
  %216 = icmp eq i32 %214, %215
  br i1 %216, label %221, label %217

217:                                              ; preds = %213
  %218 = load i32, ptr %25, align 4, !tbaa !11
  %219 = load i32, ptr %24, align 4, !tbaa !11
  %220 = icmp eq i32 %218, %219
  br i1 %220, label %221, label %238

221:                                              ; preds = %217, %213, %210
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #4
  %222 = load i32, ptr %30, align 4, !tbaa !11
  store i32 %222, ptr %32, align 4, !tbaa !11
  br label %223

223:                                              ; preds = %234, %221
  %224 = load i32, ptr %32, align 4, !tbaa !11
  %225 = load i32, ptr %31, align 4, !tbaa !11
  %226 = icmp sle i32 %224, %225
  br i1 %226, label %228, label %227

227:                                              ; preds = %223
  store i32 11, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #4
  br label %237

228:                                              ; preds = %223
  %229 = load i32, ptr %32, align 4, !tbaa !11
  %230 = load i32, ptr %25, align 4, !tbaa !11
  %231 = load i32, ptr %18, align 4, !tbaa !11
  %232 = load double, ptr %10, align 8, !tbaa !9
  %233 = load i32, ptr %12, align 4, !tbaa !11
  call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %33, i32 noundef %229, i32 noundef %230, i32 noundef %231, double noundef %232, i32 noundef %233)
  br label %234

234:                                              ; preds = %228
  %235 = load i32, ptr %32, align 4, !tbaa !11
  %236 = add nsw i32 %235, 1
  store i32 %236, ptr %32, align 4, !tbaa !11
  br label %223, !llvm.loop !15

237:                                              ; preds = %227
  br label %249

238:                                              ; preds = %217
  %239 = load i32, ptr %30, align 4, !tbaa !11
  %240 = load i32, ptr %25, align 4, !tbaa !11
  %241 = load i32, ptr %18, align 4, !tbaa !11
  %242 = load double, ptr %10, align 8, !tbaa !9
  %243 = load i32, ptr %12, align 4, !tbaa !11
  call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %33, i32 noundef %239, i32 noundef %240, i32 noundef %241, double noundef %242, i32 noundef %243)
  %244 = load i32, ptr %31, align 4, !tbaa !11
  %245 = load i32, ptr %25, align 4, !tbaa !11
  %246 = load i32, ptr %18, align 4, !tbaa !11
  %247 = load double, ptr %10, align 8, !tbaa !9
  %248 = load i32, ptr %12, align 4, !tbaa !11
  call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %33, i32 noundef %244, i32 noundef %245, i32 noundef %246, double noundef %247, i32 noundef %248)
  br label %249

249:                                              ; preds = %238, %237
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  br label %250

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

253:                                              ; preds = %166
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  br label %254

254:                                              ; preds = %253
  %255 = load i32, ptr %18, align 4, !tbaa !11
  %256 = add nsw i32 %255, 1
  store i32 %256, ptr %18, align 4, !tbaa !11
  br label %111, !llvm.loop !17

257:                                              ; preds = %116
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  store i32 0, ptr %16, align 4
  br label %258

258:                                              ; preds = %257, %103
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #4
  %259 = load i32, ptr %16, align 4
  switch i32 %259, label %261 [
    i32 0, label %260
    i32 1, label %260
  ]

260:                                              ; preds = %258, %258
  ret void

261:                                              ; preds = %258
  unreachable
}

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid19RasterizeGridSphereERK7R3Pointddii(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, double noundef %2, double noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 align 2 {
  %7 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 0)
  %8 = fadd double %7, %2
  %9 = fptosi double %8 to i32
  %10 = icmp slt i32 %9, 0
  br i1 %10, label %.loopexit102, label %11

11:                                               ; preds = %6
  %12 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 0)
  %.not = icmp sgt i32 %12, %9
  br i1 %.not, label %16, label %13

13:                                               ; preds = %11
  %14 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 0)
  %15 = add nsw i32 %14, -1
  br label %16

16:                                               ; preds = %13, %11
  %.sroa.0.0 = phi i32 [ %9, %11 ], [ %15, %13 ]
  %17 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 0)
  %18 = fsub double %17, %2
  %19 = fptosi double %18 to i32
  %20 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 0)
  %.not95 = icmp sgt i32 %20, %19
  br i1 %.not95, label %21, label %.loopexit102

21:                                               ; preds = %16
  %22 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 1)
  %23 = fadd double %22, %2
  %24 = fptosi double %23 to i32
  %25 = icmp slt i32 %24, 0
  br i1 %25, label %.loopexit102, label %26

26:                                               ; preds = %21
  %27 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 1)
  %.not.1 = icmp sgt i32 %27, %24
  br i1 %.not.1, label %31, label %28

28:                                               ; preds = %26
  %29 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 1)
  %30 = add nsw i32 %29, -1
  br label %31

31:                                               ; preds = %28, %26
  %.sroa.5.0 = phi i32 [ %24, %26 ], [ %30, %28 ]
  %32 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 1)
  %33 = fsub double %32, %2
  %34 = fptosi double %33 to i32
  %35 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 1)
  %.not95.1 = icmp sgt i32 %35, %34
  br i1 %.not95.1, label %36, label %.loopexit102

36:                                               ; preds = %31
  %37 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 2)
  %38 = fadd double %37, %2
  %39 = fptosi double %38 to i32
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %.loopexit102, label %41

41:                                               ; preds = %36
  %42 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 2)
  %.not.2 = icmp sgt i32 %42, %39
  br i1 %.not.2, label %46, label %43

43:                                               ; preds = %41
  %44 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 2)
  %45 = add nsw i32 %44, -1
  br label %46

46:                                               ; preds = %43, %41
  %.sroa.8.0 = phi i32 [ %39, %41 ], [ %45, %43 ]
  %47 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 2)
  %48 = fsub double %47, %2
  %49 = fptosi double %48 to i32
  %50 = tail call noundef i32 @_ZNK6R3Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef 2)
  %.not95.2 = icmp sgt i32 %50, %49
  br i1 %.not95.2, label %.critedge, label %.loopexit102

.critedge:                                        ; preds = %46
  %spec.store.select.2 = tail call i32 @llvm.smax.i32(i32 %49, i32 0)
  %51 = fmul double %2, %2
  %.not96111 = icmp sgt i32 %spec.store.select.2, %.sroa.8.0
  br i1 %.not96111, label %.loopexit102, label %.lr.ph113

.lr.ph113:                                        ; preds = %.critedge
  %.not98 = icmp ne i32 %4, 0
  br label %52

52:                                               ; preds = %.lr.ph113, %._crit_edge
  %.082112 = phi i32 [ %spec.store.select.2, %.lr.ph113 ], [ %69, %._crit_edge ]
  %53 = sitofp i32 %.082112 to double
  %54 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 2)
  %55 = fsub double %53, %54
  %56 = fptosi double %55 to i32
  %57 = sitofp i32 %56 to double
  %58 = fmul double %57, %57
  %59 = fsub double %51, %58
  %60 = tail call double @sqrt(double noundef %59) #4
  %61 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 1)
  %62 = fsub double %61, %60
  %63 = fadd double %62, 5.000000e-01
  %64 = fptosi double %63 to i32
  %65 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 1)
  %66 = fadd double %60, %65
  %67 = fadd double %66, 5.000000e-01
  %68 = fptosi double %67 to i32
  %spec.store.select.1 = tail call i32 @llvm.smax.i32(i32 %34, i32 %64)
  %spec.select = tail call i32 @llvm.smax.i32(i32 %spec.store.select.1, i32 0)
  %.085 = tail call i32 @llvm.smin.i32(i32 %.sroa.5.0, i32 %68)
  %.not97107 = icmp sgt i32 %spec.select, %.085
  br i1 %.not97107, label %._crit_edge, label %.lr.ph110

._crit_edge:                                      ; preds = %.loopexit, %52
  %69 = add i32 %.082112, 1
  %exitcond117.not = icmp eq i32 %.082112, %.sroa.8.0
  br i1 %exitcond117.not, label %.loopexit102, label %52, !llvm.loop !5

.lr.ph110:                                        ; preds = %52, %.loopexit
  %.084108 = phi i32 [ %90, %.loopexit ], [ %spec.select, %52 ]
  %70 = sitofp i32 %.084108 to double
  %71 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 1)
  %72 = fsub double %70, %71
  %73 = fptosi double %72 to i32
  %74 = sitofp i32 %73 to double
  %75 = fmul double %74, %74
  %76 = fsub double %59, %75
  %77 = tail call double @sqrt(double noundef %76) #4
  %78 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 0)
  %79 = fsub double %78, %77
  %80 = fadd double %79, 5.000000e-01
  %81 = fptosi double %80 to i32
  %82 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef 0)
  %83 = fadd double %77, %82
  %84 = fadd double %83, 5.000000e-01
  %85 = fptosi double %84 to i32
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %19, i32 %81)
  %spec.select100 = tail call i32 @llvm.smax.i32(i32 %spec.store.select, i32 0)
  %.078 = tail call i32 @llvm.smin.i32(i32 %.sroa.0.0, i32 %85)
  %86 = icmp eq i32 %.084108, %spec.select
  %or.cond = or i1 %.not98, %86
  %87 = icmp eq i32 %.084108, %.085
  %or.cond101 = or i1 %87, %or.cond
  br i1 %or.cond101, label %.preheader, label %89

.preheader:                                       ; preds = %.lr.ph110
  %.not99105 = icmp sgt i32 %spec.select100, %.078
  br i1 %.not99105, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.0106 = phi i32 [ %88, %.lr.ph ], [ %spec.select100, %.preheader ]
  tail call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.0106, i32 noundef %.084108, i32 noundef %.082112, double noundef %3, i32 noundef %5)
  %88 = add i32 %.0106, 1
  %exitcond.not = icmp eq i32 %.0106, %.078
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !7

89:                                               ; preds = %.lr.ph110
  tail call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %spec.select100, i32 noundef %.084108, i32 noundef %.082112, double noundef %3, i32 noundef %5)
  tail call void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.078, i32 noundef %.084108, i32 noundef %.082112, double noundef %3, i32 noundef %5)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %89
  %90 = add i32 %.084108, 1
  %exitcond116.not = icmp eq i32 %.084108, %.085
  br i1 %exitcond116.not, label %._crit_edge, label %.lr.ph110, !llvm.loop !8

.loopexit102:                                     ; preds = %._crit_edge, %6, %16, %21, %31, %36, %46, %.critedge
  ret void
}

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

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

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

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

attributes #0 = { 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 #1 = { 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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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}


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