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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid19RasterizeGridCircleERK7R2Pointddi(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, double noundef %2, double noundef %3, i32 noundef %4) #3 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca [2 x i32], align 4
  %12 = alloca [2 x 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 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
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !11
  %26 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %93, %5
  %28 = load i32, ptr %13, align 4, !tbaa !11
  %29 = icmp slt i32 %28, 2
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  store i32 2, ptr %14, align 4
  br label %96

31:                                               ; preds = %27
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load i32, ptr %13, align 4, !tbaa !11
  %34 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %32, i32 noundef %33)
  %35 = load double, ptr %8, align 8, !tbaa !9
  %36 = fadd double %34, %35
  %37 = fptosi double %36 to i32
  %38 = load i32, ptr %13, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 %39
  store i32 %37, ptr %40, align 4, !tbaa !11
  %41 = load i32, ptr %13, align 4, !tbaa !11
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %31
  store i32 1, ptr %14, align 4
  br label %96

47:                                               ; preds = %31
  %48 = load i32, ptr %13, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = load i32, ptr %13, align 4, !tbaa !11
  %53 = call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %26, i32 noundef %52)
  %54 = sub nsw i32 %53, 1
  %55 = icmp sgt i32 %51, %54
  br i1 %55, label %56, label %63

56:                                               ; preds = %47
  %57 = load i32, ptr %13, align 4, !tbaa !11
  %58 = call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %26, i32 noundef %57)
  %59 = sub nsw i32 %58, 1
  %60 = load i32, ptr %13, align 4, !tbaa !11
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 %61
  store i32 %59, ptr %62, align 4, !tbaa !11
  br label %63

63:                                               ; preds = %56, %47
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i32, ptr %13, align 4, !tbaa !11
  %66 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %64, i32 noundef %65)
  %67 = load double, ptr %8, align 8, !tbaa !9
  %68 = fsub double %66, %67
  %69 = fptosi double %68 to i32
  %70 = load i32, ptr %13, align 4, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 %71
  store i32 %69, ptr %72, align 4, !tbaa !11
  %73 = load i32, ptr %13, align 4, !tbaa !11
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !11
  %77 = load i32, ptr %13, align 4, !tbaa !11
  %78 = call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %26, i32 noundef %77)
  %79 = sub nsw i32 %78, 1
  %80 = icmp sgt i32 %76, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %63
  store i32 1, ptr %14, align 4
  br label %96

82:                                               ; preds = %63
  %83 = load i32, ptr %13, align 4, !tbaa !11
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !11
  %87 = icmp slt i32 %86, 0
  br i1 %87, label %88, label %92

88:                                               ; preds = %82
  %89 = load i32, ptr %13, align 4, !tbaa !11
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 %90
  store i32 0, ptr %91, align 4, !tbaa !11
  br label %92

92:                                               ; preds = %88, %82
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %13, align 4, !tbaa !11
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %13, align 4, !tbaa !11
  br label %27, !llvm.loop !13

96:                                               ; preds = %81, %46, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  %97 = load i32, ptr %14, align 4
  switch i32 %97, label %197 [
    i32 2, label %98
  ]

98:                                               ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %99, i32 noundef 1)
  %101 = load double, ptr %8, align 8, !tbaa !9
  %102 = fsub double %100, %101
  %103 = fadd double %102, 5.000000e-01
  %104 = fptosi double %103 to i32
  store i32 %104, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %105, i32 noundef 1)
  %107 = load double, ptr %8, align 8, !tbaa !9
  %108 = fadd double %106, %107
  %109 = fadd double %108, 5.000000e-01
  %110 = fptosi double %109 to i32
  store i32 %110, ptr %16, align 4, !tbaa !11
  %111 = load i32, ptr %15, align 4, !tbaa !11
  %112 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 1
  %113 = load i32, ptr %112, align 4, !tbaa !11
  %114 = icmp slt i32 %111, %113
  br i1 %114, label %115, label %118

115:                                              ; preds = %98
  %116 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 1
  %117 = load i32, ptr %116, align 4, !tbaa !11
  store i32 %117, ptr %15, align 4, !tbaa !11
  br label %118

118:                                              ; preds = %115, %98
  %119 = load i32, ptr %16, align 4, !tbaa !11
  %120 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 1
  %121 = load i32, ptr %120, align 4, !tbaa !11
  %122 = icmp sgt i32 %119, %121
  br i1 %122, label %123, label %126

123:                                              ; preds = %118
  %124 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 1
  %125 = load i32, ptr %124, align 4, !tbaa !11
  store i32 %125, ptr %16, align 4, !tbaa !11
  br label %126

126:                                              ; preds = %123, %118
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %127 = load double, ptr %8, align 8, !tbaa !9
  %128 = load double, ptr %8, align 8, !tbaa !9
  %129 = fmul double %127, %128
  store double %129, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %130 = load i32, ptr %15, align 4, !tbaa !11
  store i32 %130, ptr %18, align 4, !tbaa !11
  br label %131

131:                                              ; preds = %193, %126
  %132 = load i32, ptr %18, align 4, !tbaa !11
  %133 = load i32, ptr %16, align 4, !tbaa !11
  %134 = icmp sle i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %196

136:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %137 = load i32, ptr %18, align 4, !tbaa !11
  %138 = sitofp i32 %137 to double
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %139, i32 noundef 1)
  %141 = fsub double %138, %140
  store double %141, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %142 = load double, ptr %19, align 8, !tbaa !9
  %143 = load double, ptr %19, align 8, !tbaa !9
  %144 = fmul double %142, %143
  store double %144, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %145 = load double, ptr %17, align 8, !tbaa !9
  %146 = load double, ptr %20, align 8, !tbaa !9
  %147 = fsub double %145, %146
  store double %147, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %148 = load double, ptr %21, align 8, !tbaa !9
  %149 = call double @sqrt(double noundef %148) #4
  store double %149, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  %151 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %150, i32 noundef 0)
  %152 = load double, ptr %22, align 8, !tbaa !9
  %153 = fsub double %151, %152
  %154 = fadd double %153, 5.000000e-01
  %155 = fptosi double %154 to i32
  store i32 %155, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %156 = load ptr, ptr %7, align 8, !tbaa !5
  %157 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %156, i32 noundef 0)
  %158 = load double, ptr %22, align 8, !tbaa !9
  %159 = fadd double %157, %158
  %160 = fadd double %159, 5.000000e-01
  %161 = fptosi double %160 to i32
  store i32 %161, ptr %24, align 4, !tbaa !11
  %162 = load i32, ptr %23, align 4, !tbaa !11
  %163 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 0
  %164 = load i32, ptr %163, align 4, !tbaa !11
  %165 = icmp slt i32 %162, %164
  br i1 %165, label %166, label %169

166:                                              ; preds = %136
  %167 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 0
  %168 = load i32, ptr %167, align 4, !tbaa !11
  store i32 %168, ptr %23, align 4, !tbaa !11
  br label %169

169:                                              ; preds = %166, %136
  %170 = load i32, ptr %24, align 4, !tbaa !11
  %171 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 0
  %172 = load i32, ptr %171, align 4, !tbaa !11
  %173 = icmp sgt i32 %170, %172
  br i1 %173, label %174, label %177

174:                                              ; preds = %169
  %175 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 0
  %176 = load i32, ptr %175, align 4, !tbaa !11
  store i32 %176, ptr %24, align 4, !tbaa !11
  br label %177

177:                                              ; preds = %174, %169
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  %178 = load i32, ptr %23, align 4, !tbaa !11
  store i32 %178, ptr %25, align 4, !tbaa !11
  br label %179

179:                                              ; preds = %189, %177
  %180 = load i32, ptr %25, align 4, !tbaa !11
  %181 = load i32, ptr %24, align 4, !tbaa !11
  %182 = icmp sle i32 %180, %181
  br i1 %182, label %184, label %183

183:                                              ; preds = %179
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  br label %192

184:                                              ; preds = %179
  %185 = load i32, ptr %25, align 4, !tbaa !11
  %186 = load i32, ptr %18, align 4, !tbaa !11
  %187 = load double, ptr %9, align 8, !tbaa !9
  %188 = load i32, ptr %10, align 4, !tbaa !11
  call void @_ZN6R2Grid18RasterizeGridValueEiidi(ptr noundef nonnull align 8 dereferenceable(208) %26, i32 noundef %185, i32 noundef %186, double noundef %187, i32 noundef %188)
  br label %189

189:                                              ; preds = %184
  %190 = load i32, ptr %25, align 4, !tbaa !11
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %25, align 4, !tbaa !11
  br label %179, !llvm.loop !15

192:                                              ; preds = %183
  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 %193

193:                                              ; preds = %192
  %194 = load i32, ptr %18, align 4, !tbaa !11
  %195 = add nsw i32 %194, 1
  store i32 %195, ptr %18, align 4, !tbaa !11
  br label %131, !llvm.loop !16

196:                                              ; preds = %135
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  store i32 0, ptr %14, align 4
  br label %197

197:                                              ; preds = %196, %96
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %198 = load i32, ptr %14, align 4
  switch i32 %198, label %200 [
    i32 0, label %199
    i32 1, label %199
  ]

199:                                              ; preds = %197, %197
  ret void

200:                                              ; preds = %197
  unreachable
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #2 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 = { 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 = { 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"

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid19RasterizeGridCircleERK7R2Pointddi(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, double noundef %2, double noundef %3, i32 noundef %4) local_unnamed_addr #2 align 2 {
  %6 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 0)
  %7 = fadd double %6, %2
  %8 = fptosi double %7 to i32
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %.loopexit, label %10

10:                                               ; preds = %5
  %11 = tail call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef 0)
  %.not = icmp sgt i32 %11, %8
  br i1 %.not, label %15, label %12

12:                                               ; preds = %10
  %13 = tail call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef 0)
  %14 = add nsw i32 %13, -1
  br label %15

15:                                               ; preds = %12, %10
  %.sroa.0.0 = phi i32 [ %8, %10 ], [ %14, %12 ]
  %16 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 0)
  %17 = fsub double %16, %2
  %18 = fptosi double %17 to i32
  %19 = tail call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef 0)
  %.not69 = icmp sgt i32 %19, %18
  br i1 %.not69, label %20, label %.loopexit

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

25:                                               ; preds = %20
  %26 = tail call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef 1)
  %.not.1 = icmp sgt i32 %26, %23
  br i1 %.not.1, label %30, label %27

27:                                               ; preds = %25
  %28 = tail call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef 1)
  %29 = add nsw i32 %28, -1
  br label %30

30:                                               ; preds = %27, %25
  %.sroa.5.0 = phi i32 [ %23, %25 ], [ %29, %27 ]
  %31 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 1)
  %32 = fsub double %31, %2
  %33 = fptosi double %32 to i32
  %34 = tail call noundef i32 @_ZNK6R2Grid10ResolutionEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef 1)
  %.not69.1 = icmp sgt i32 %34, %33
  br i1 %.not69.1, label %.critedge, label %.loopexit

.critedge:                                        ; preds = %30
  %35 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 1)
  %36 = fsub double %35, %2
  %37 = fadd double %36, 5.000000e-01
  %38 = fptosi double %37 to i32
  %39 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 1)
  %40 = fadd double %39, %2
  %41 = fadd double %40, 5.000000e-01
  %42 = fptosi double %41 to i32
  %spec.store.select.1 = tail call i32 @llvm.smax.i32(i32 %33, i32 %38)
  %spec.select = tail call i32 @llvm.smax.i32(i32 %spec.store.select.1, i32 0)
  %.058 = tail call i32 @llvm.smin.i32(i32 %.sroa.5.0, i32 %42)
  %43 = fmul double %2, %2
  %.not7077 = icmp sgt i32 %spec.select, %.058
  br i1 %.not7077, label %.loopexit, label %.lr.ph79

.lr.ph79:                                         ; preds = %.critedge, %._crit_edge
  %.05978 = phi i32 [ %58, %._crit_edge ], [ %spec.select, %.critedge ]
  %44 = sitofp i32 %.05978 to double
  %45 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 1)
  %46 = fsub double %44, %45
  %47 = fmul double %46, %46
  %48 = fsub double %43, %47
  %49 = tail call double @sqrt(double noundef %48) #4
  %50 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 0)
  %51 = fsub double %50, %49
  %52 = fadd double %51, 5.000000e-01
  %53 = fptosi double %52 to i32
  %54 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 0)
  %55 = fadd double %49, %54
  %56 = fadd double %55, 5.000000e-01
  %57 = fptosi double %56 to i32
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %18, i32 %53)
  %spec.select72 = tail call i32 @llvm.smax.i32(i32 %spec.store.select, i32 0)
  %.053 = tail call i32 @llvm.smin.i32(i32 %.sroa.0.0, i32 %57)
  %.not7175 = icmp sgt i32 %spec.select72, %.053
  br i1 %.not7175, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph79
  %58 = add i32 %.05978, 1
  %exitcond83.not = icmp eq i32 %.05978, %.058
  br i1 %exitcond83.not, label %.loopexit, label %.lr.ph79, !llvm.loop !5

.lr.ph:                                           ; preds = %.lr.ph79, %.lr.ph
  %.076 = phi i32 [ %59, %.lr.ph ], [ %spec.select72, %.lr.ph79 ]
  tail call void @_ZN6R2Grid18RasterizeGridValueEiidi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.076, i32 noundef %.05978, double noundef %3, i32 noundef %4)
  %59 = add i32 %.076, 1
  %exitcond.not = icmp eq i32 %.076, %.053
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !7

.loopexit:                                        ; preds = %._crit_edge, %5, %15, %20, %30, %.critedge
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1 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 = { 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 = { 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}


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