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

; 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.R2Polygon = type <{ %class.R2Solid, ptr, i32, [4 x i8], %class.R2Box, i32, [4 x i8] }>
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Point = type { [2 x double] }
%struct.ScanLineCrossing = type { double, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

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

; Function Attrs: nounwind
declare void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #6

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid20RasterizeGridPolygonERK9R2Polygondi(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(68) %1, double noundef %2, i32 noundef %3) #7 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca %class.R2Polygon, align 8
  %10 = alloca %class.R2Box, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca double, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca i32, align 4
  %26 = alloca ptr, align 8
  %27 = alloca ptr, align 8
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  %31 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr %9) #9
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN9R2PolygonC1ERKS_(ptr noundef nonnull align 8 dereferenceable(68) %9, ptr noundef nonnull align 8 dereferenceable(68) %32)
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #9
  invoke void @_ZNK6R2Grid7GridBoxEv(ptr dead_on_unwind writable sret(%class.R2Box) align 8 %10, ptr noundef nonnull align 8 dereferenceable(208) %31)
          to label %33 unwind label %39

33:                                               ; preds = %4
  invoke void @_ZN9R2Polygon4ClipERK5R2Box(ptr noundef nonnull align 8 dereferenceable(68) %9, ptr noundef nonnull align 8 dereferenceable(40) %10)
          to label %34 unwind label %43

34:                                               ; preds = %33
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %10) #9
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #9
  %35 = invoke noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %9)
          to label %36 unwind label %48

36:                                               ; preds = %34
  %37 = icmp eq i32 %35, 0
  br i1 %37, label %38, label %52

38:                                               ; preds = %36
  store i32 1, ptr %13, align 4
  br label %353

39:                                               ; preds = %4
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %11, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %12, align 4
  br label %47

43:                                               ; preds = %33
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %11, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %12, align 4
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %10) #9
  br label %47

47:                                               ; preds = %43, %39
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #9
  br label %358

48:                                               ; preds = %70, %68, %66, %62, %58, %56, %52, %34
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %11, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %12, align 4
  br label %358

52:                                               ; preds = %36
  %53 = invoke noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %9)
          to label %54 unwind label %48

54:                                               ; preds = %52
  %55 = icmp eq i32 %53, 1
  br i1 %55, label %56, label %62

56:                                               ; preds = %54
  %57 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %9, i32 noundef 0)
          to label %58 unwind label %48

58:                                               ; preds = %56
  %59 = load double, ptr %7, align 8, !tbaa !9
  %60 = load i32, ptr %8, align 4, !tbaa !11
  invoke void @_ZN6R2Grid18RasterizeGridPointERK7R2Pointdi(ptr noundef nonnull align 8 dereferenceable(208) %31, ptr noundef nonnull align 8 dereferenceable(16) %57, double noundef %59, i32 noundef %60)
          to label %61 unwind label %48

61:                                               ; preds = %58
  store i32 1, ptr %13, align 4
  br label %353

62:                                               ; preds = %54
  %63 = invoke noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %9)
          to label %64 unwind label %48

64:                                               ; preds = %62
  %65 = icmp eq i32 %63, 2
  br i1 %65, label %66, label %74

66:                                               ; preds = %64
  %67 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %9, i32 noundef 0)
          to label %68 unwind label %48

68:                                               ; preds = %66
  %69 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %9, i32 noundef 1)
          to label %70 unwind label %48

70:                                               ; preds = %68
  %71 = load double, ptr %7, align 8, !tbaa !9
  %72 = load i32, ptr %8, align 4, !tbaa !11
  invoke void @_ZN6R2Grid17RasterizeGridSpanERK7R2PointS2_di(ptr noundef nonnull align 8 dereferenceable(208) %31, ptr noundef nonnull align 8 dereferenceable(16) %67, ptr noundef nonnull align 8 dereferenceable(16) %69, double noundef %71, i32 noundef %72)
          to label %73 unwind label %48

73:                                               ; preds = %70
  store i32 1, ptr %13, align 4
  br label %353

74:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  %75 = invoke noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %31)
          to label %76 unwind label %95

76:                                               ; preds = %74
  %77 = mul nsw i32 2, %75
  %78 = invoke noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %9)
          to label %79 unwind label %95

79:                                               ; preds = %76
  %80 = mul nsw i32 %77, %78
  store i32 %80, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #9
  %81 = load i32, ptr %14, align 4, !tbaa !11
  %82 = sext i32 %81 to i64
  %83 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %82, i64 16)
  %84 = extractvalue { i64, i1 } %83, 1
  %85 = extractvalue { i64, i1 } %83, 0
  %86 = select i1 %84, i64 -1, i64 %85
  %87 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %86) #10
          to label %88 unwind label %99

88:                                               ; preds = %79
  store ptr %87, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  store i32 0, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %89

89:                                               ; preds = %342, %88
  %90 = load i32, ptr %17, align 4, !tbaa !11
  %91 = invoke noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %31)
          to label %92 unwind label %103

92:                                               ; preds = %89
  %93 = icmp slt i32 %90, %91
  br i1 %93, label %107, label %94

94:                                               ; preds = %92
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  br label %348

95:                                               ; preds = %76, %74
  %96 = landingpad { ptr, i32 }
          cleanup
  %97 = extractvalue { ptr, i32 } %96, 0
  store ptr %97, ptr %11, align 8
  %98 = extractvalue { ptr, i32 } %96, 1
  store i32 %98, ptr %12, align 4
  br label %357

99:                                               ; preds = %79
  %100 = landingpad { ptr, i32 }
          cleanup
  %101 = extractvalue { ptr, i32 } %100, 0
  store ptr %101, ptr %11, align 8
  %102 = extractvalue { ptr, i32 } %100, 1
  store i32 %102, ptr %12, align 4
  br label %356

103:                                              ; preds = %89
  %104 = landingpad { ptr, i32 }
          cleanup
  %105 = extractvalue { ptr, i32 } %104, 0
  store ptr %105, ptr %11, align 8
  %106 = extractvalue { ptr, i32 } %104, 1
  store i32 %106, ptr %12, align 4
  br label %347

107:                                              ; preds = %92
  store i32 0, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #9
  %108 = invoke noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %9)
          to label %109 unwind label %125

109:                                              ; preds = %107
  %110 = sub nsw i32 %108, 1
  %111 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %9, i32 noundef %110)
          to label %112 unwind label %125

112:                                              ; preds = %109
  store ptr %111, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #9
  %113 = load ptr, ptr %18, align 8, !tbaa !5
  %114 = invoke noundef double @_ZNK7R2Point1YEv(ptr noundef nonnull align 8 dereferenceable(16) %113)
          to label %115 unwind label %129

115:                                              ; preds = %112
  %116 = load i32, ptr %17, align 4, !tbaa !11
  %117 = sitofp i32 %116 to double
  %118 = fsub double %114, %117
  store double %118, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #9
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %119

119:                                              ; preds = %243, %115
  %120 = load i32, ptr %20, align 4, !tbaa !11
  %121 = invoke noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %9)
          to label %122 unwind label %133

122:                                              ; preds = %119
  %123 = icmp slt i32 %120, %121
  br i1 %123, label %137, label %124

124:                                              ; preds = %122
  store i32 5, ptr %13, align 4
  br label %248

125:                                              ; preds = %109, %107
  %126 = landingpad { ptr, i32 }
          cleanup
  %127 = extractvalue { ptr, i32 } %126, 0
  store ptr %127, ptr %11, align 8
  %128 = extractvalue { ptr, i32 } %126, 1
  store i32 %128, ptr %12, align 4
  br label %346

129:                                              ; preds = %254, %112
  %130 = landingpad { ptr, i32 }
          cleanup
  %131 = extractvalue { ptr, i32 } %130, 0
  store ptr %131, ptr %11, align 8
  %132 = extractvalue { ptr, i32 } %130, 1
  store i32 %132, ptr %12, align 4
  br label %345

133:                                              ; preds = %119
  %134 = landingpad { ptr, i32 }
          cleanup
  %135 = extractvalue { ptr, i32 } %134, 0
  store ptr %135, ptr %11, align 8
  %136 = extractvalue { ptr, i32 } %134, 1
  store i32 %136, ptr %12, align 4
  br label %249

137:                                              ; preds = %122
  %138 = load i32, ptr %16, align 4, !tbaa !11
  %139 = load i32, ptr %14, align 4, !tbaa !11
  %140 = icmp sge i32 %138, %139
  br i1 %140, label %141, label %142

141:                                              ; preds = %137
  store i32 5, ptr %13, align 4
  br label %248

142:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #9
  %143 = load i32, ptr %20, align 4, !tbaa !11
  %144 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %9, i32 noundef %143)
          to label %145 unwind label %187

145:                                              ; preds = %142
  store ptr %144, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #9
  %146 = load ptr, ptr %21, align 8, !tbaa !5
  %147 = invoke noundef double @_ZNK7R2Point1YEv(ptr noundef nonnull align 8 dereferenceable(16) %146)
          to label %148 unwind label %191

148:                                              ; preds = %145
  %149 = load i32, ptr %17, align 4, !tbaa !11
  %150 = sitofp i32 %149 to double
  %151 = fsub double %147, %150
  store double %151, ptr %22, align 8, !tbaa !9
  %152 = load double, ptr %19, align 8, !tbaa !9
  %153 = fcmp olt double %152, 0.000000e+00
  br i1 %153, label %154, label %199

154:                                              ; preds = %148
  %155 = load double, ptr %22, align 8, !tbaa !9
  %156 = fcmp oge double %155, 0.000000e+00
  br i1 %156, label %157, label %199

157:                                              ; preds = %154
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #9
  %158 = load double, ptr %22, align 8, !tbaa !9
  %159 = load double, ptr %22, align 8, !tbaa !9
  %160 = load double, ptr %19, align 8, !tbaa !9
  %161 = fsub double %159, %160
  %162 = fdiv double %158, %161
  store double %162, ptr %23, align 8, !tbaa !9
  %163 = load ptr, ptr %21, align 8, !tbaa !5
  %164 = invoke noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %163)
          to label %165 unwind label %195

165:                                              ; preds = %157
  %166 = load double, ptr %23, align 8, !tbaa !9
  %167 = load ptr, ptr %18, align 8, !tbaa !5
  %168 = invoke noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %167)
          to label %169 unwind label %195

169:                                              ; preds = %165
  %170 = load ptr, ptr %21, align 8, !tbaa !5
  %171 = invoke noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %170)
          to label %172 unwind label %195

172:                                              ; preds = %169
  %173 = fsub double %168, %171
  %174 = call double @llvm.fmuladd.f64(double %166, double %173, double %164)
  %175 = load ptr, ptr %15, align 8, !tbaa !5
  %176 = load i32, ptr %16, align 4, !tbaa !11
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds %struct.ScanLineCrossing, ptr %175, i64 %177
  %179 = getelementptr inbounds %struct.ScanLineCrossing, ptr %178, i32 0, i32 0
  store double %174, ptr %179, align 8, !tbaa !13
  %180 = load ptr, ptr %15, align 8, !tbaa !5
  %181 = load i32, ptr %16, align 4, !tbaa !11
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds %struct.ScanLineCrossing, ptr %180, i64 %182
  %184 = getelementptr inbounds %struct.ScanLineCrossing, ptr %183, i32 0, i32 1
  store i32 -1, ptr %184, align 8, !tbaa !15
  %185 = load i32, ptr %16, align 4, !tbaa !11
  %186 = add nsw i32 %185, 1
  store i32 %186, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #9
  br label %240

187:                                              ; preds = %142
  %188 = landingpad { ptr, i32 }
          cleanup
  %189 = extractvalue { ptr, i32 } %188, 0
  store ptr %189, ptr %11, align 8
  %190 = extractvalue { ptr, i32 } %188, 1
  store i32 %190, ptr %12, align 4
  br label %247

191:                                              ; preds = %145
  %192 = landingpad { ptr, i32 }
          cleanup
  %193 = extractvalue { ptr, i32 } %192, 0
  store ptr %193, ptr %11, align 8
  %194 = extractvalue { ptr, i32 } %192, 1
  store i32 %194, ptr %12, align 4
  br label %246

195:                                              ; preds = %169, %165, %157
  %196 = landingpad { ptr, i32 }
          cleanup
  %197 = extractvalue { ptr, i32 } %196, 0
  store ptr %197, ptr %11, align 8
  %198 = extractvalue { ptr, i32 } %196, 1
  store i32 %198, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #9
  br label %246

199:                                              ; preds = %154, %148
  %200 = load double, ptr %22, align 8, !tbaa !9
  %201 = fcmp olt double %200, 0.000000e+00
  br i1 %201, label %202, label %239

202:                                              ; preds = %199
  %203 = load double, ptr %19, align 8, !tbaa !9
  %204 = fcmp oge double %203, 0.000000e+00
  br i1 %204, label %205, label %239

205:                                              ; preds = %202
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #9
  %206 = load double, ptr %19, align 8, !tbaa !9
  %207 = load double, ptr %19, align 8, !tbaa !9
  %208 = load double, ptr %22, align 8, !tbaa !9
  %209 = fsub double %207, %208
  %210 = fdiv double %206, %209
  store double %210, ptr %24, align 8, !tbaa !9
  %211 = load ptr, ptr %18, align 8, !tbaa !5
  %212 = invoke noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %211)
          to label %213 unwind label %235

213:                                              ; preds = %205
  %214 = load double, ptr %24, align 8, !tbaa !9
  %215 = load ptr, ptr %21, align 8, !tbaa !5
  %216 = invoke noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %215)
          to label %217 unwind label %235

217:                                              ; preds = %213
  %218 = load ptr, ptr %18, align 8, !tbaa !5
  %219 = invoke noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %218)
          to label %220 unwind label %235

220:                                              ; preds = %217
  %221 = fsub double %216, %219
  %222 = call double @llvm.fmuladd.f64(double %214, double %221, double %212)
  %223 = load ptr, ptr %15, align 8, !tbaa !5
  %224 = load i32, ptr %16, align 4, !tbaa !11
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds %struct.ScanLineCrossing, ptr %223, i64 %225
  %227 = getelementptr inbounds %struct.ScanLineCrossing, ptr %226, i32 0, i32 0
  store double %222, ptr %227, align 8, !tbaa !13
  %228 = load ptr, ptr %15, align 8, !tbaa !5
  %229 = load i32, ptr %16, align 4, !tbaa !11
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds %struct.ScanLineCrossing, ptr %228, i64 %230
  %232 = getelementptr inbounds %struct.ScanLineCrossing, ptr %231, i32 0, i32 1
  store i32 1, ptr %232, align 8, !tbaa !15
  %233 = load i32, ptr %16, align 4, !tbaa !11
  %234 = add nsw i32 %233, 1
  store i32 %234, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #9
  br label %239

235:                                              ; preds = %217, %213, %205
  %236 = landingpad { ptr, i32 }
          cleanup
  %237 = extractvalue { ptr, i32 } %236, 0
  store ptr %237, ptr %11, align 8
  %238 = extractvalue { ptr, i32 } %236, 1
  store i32 %238, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #9
  br label %246

239:                                              ; preds = %220, %202, %199
  br label %240

240:                                              ; preds = %239, %172
  %241 = load ptr, ptr %21, align 8, !tbaa !5
  store ptr %241, ptr %18, align 8, !tbaa !5
  %242 = load double, ptr %22, align 8, !tbaa !9
  store double %242, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #9
  br label %243

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

246:                                              ; preds = %235, %195, %191
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #9
  br label %247

247:                                              ; preds = %246, %187
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #9
  br label %249

248:                                              ; preds = %141, %124
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #9
  br label %250

249:                                              ; preds = %247, %133
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #9
  br label %345

250:                                              ; preds = %248
  %251 = load i32, ptr %16, align 4, !tbaa !11
  %252 = icmp slt i32 %251, 2
  br i1 %252, label %253, label %254

253:                                              ; preds = %250
  store i32 4, ptr %13, align 4
  br label %339

254:                                              ; preds = %250
  %255 = load ptr, ptr %15, align 8, !tbaa !5
  %256 = load i32, ptr %16, align 4, !tbaa !11
  %257 = sext i32 %256 to i64
  invoke void @qsort(ptr noundef %255, i64 noundef %257, i64 noundef 16, ptr noundef @_ZL24CompareScanLineCrossingsPKvS0_)
          to label %258 unwind label %129

258:                                              ; preds = %254
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #9
  store i32 0, ptr %25, align 4, !tbaa !11
  br label %259

259:                                              ; preds = %337, %258
  %260 = load i32, ptr %25, align 4, !tbaa !11
  %261 = load i32, ptr %16, align 4, !tbaa !11
  %262 = sub nsw i32 %261, 1
  %263 = icmp slt i32 %260, %262
  br i1 %263, label %264, label %338

264:                                              ; preds = %259
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #9
  %265 = load ptr, ptr %15, align 8, !tbaa !5
  %266 = load i32, ptr %25, align 4, !tbaa !11
  %267 = add nsw i32 %266, 1
  store i32 %267, ptr %25, align 4, !tbaa !11
  %268 = sext i32 %266 to i64
  %269 = getelementptr inbounds %struct.ScanLineCrossing, ptr %265, i64 %268
  store ptr %269, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #9
  %270 = load ptr, ptr %15, align 8, !tbaa !5
  %271 = load i32, ptr %25, align 4, !tbaa !11
  %272 = add nsw i32 %271, 1
  store i32 %272, ptr %25, align 4, !tbaa !11
  %273 = sext i32 %271 to i64
  %274 = getelementptr inbounds %struct.ScanLineCrossing, ptr %270, i64 %273
  store ptr %274, ptr %27, align 8, !tbaa !5
  br label %275

275:                                              ; preds = %289, %264
  %276 = load i32, ptr %25, align 4, !tbaa !11
  %277 = load i32, ptr %16, align 4, !tbaa !11
  %278 = icmp slt i32 %276, %277
  br i1 %278, label %279, label %287

279:                                              ; preds = %275
  %280 = load ptr, ptr %27, align 8, !tbaa !5
  %281 = getelementptr inbounds %struct.ScanLineCrossing, ptr %280, i32 0, i32 1
  %282 = load i32, ptr %281, align 8, !tbaa !15
  %283 = load ptr, ptr %26, align 8, !tbaa !5
  %284 = getelementptr inbounds %struct.ScanLineCrossing, ptr %283, i32 0, i32 1
  %285 = load i32, ptr %284, align 8, !tbaa !15
  %286 = icmp eq i32 %282, %285
  br label %287

287:                                              ; preds = %279, %275
  %288 = phi i1 [ false, %275 ], [ %286, %279 ]
  br i1 %288, label %289, label %295

289:                                              ; preds = %287
  %290 = load ptr, ptr %15, align 8, !tbaa !5
  %291 = load i32, ptr %25, align 4, !tbaa !11
  %292 = add nsw i32 %291, 1
  store i32 %292, ptr %25, align 4, !tbaa !11
  %293 = sext i32 %291 to i64
  %294 = getelementptr inbounds %struct.ScanLineCrossing, ptr %290, i64 %293
  store ptr %294, ptr %27, align 8, !tbaa !5
  br label %275, !llvm.loop !18

295:                                              ; preds = %287
  %296 = load ptr, ptr %26, align 8, !tbaa !5
  %297 = getelementptr inbounds %struct.ScanLineCrossing, ptr %296, i32 0, i32 1
  %298 = load i32, ptr %297, align 8, !tbaa !15
  %299 = load ptr, ptr %27, align 8, !tbaa !5
  %300 = getelementptr inbounds %struct.ScanLineCrossing, ptr %299, i32 0, i32 1
  %301 = load i32, ptr %300, align 8, !tbaa !15
  %302 = icmp eq i32 %298, %301
  br i1 %302, label %303, label %304

303:                                              ; preds = %295
  store i32 9, ptr %13, align 4
  br label %335

304:                                              ; preds = %295
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #9
  %305 = load ptr, ptr %26, align 8, !tbaa !5
  %306 = getelementptr inbounds %struct.ScanLineCrossing, ptr %305, i32 0, i32 0
  %307 = load double, ptr %306, align 8, !tbaa !13
  %308 = fadd double %307, 5.000000e-01
  %309 = fptosi double %308 to i32
  store i32 %309, ptr %28, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #9
  %310 = load ptr, ptr %27, align 8, !tbaa !5
  %311 = getelementptr inbounds %struct.ScanLineCrossing, ptr %310, i32 0, i32 0
  %312 = load double, ptr %311, align 8, !tbaa !13
  %313 = fadd double %312, 5.000000e-01
  %314 = fptosi double %313 to i32
  store i32 %314, ptr %29, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #9
  %315 = load i32, ptr %28, align 4, !tbaa !11
  store i32 %315, ptr %30, align 4, !tbaa !11
  br label %316

316:                                              ; preds = %327, %304
  %317 = load i32, ptr %30, align 4, !tbaa !11
  %318 = load i32, ptr %29, align 4, !tbaa !11
  %319 = icmp sle i32 %317, %318
  br i1 %319, label %321, label %320

320:                                              ; preds = %316
  store i32 12, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #9
  br label %334

321:                                              ; preds = %316
  %322 = load i32, ptr %30, align 4, !tbaa !11
  %323 = load i32, ptr %17, align 4, !tbaa !11
  %324 = load double, ptr %7, align 8, !tbaa !9
  %325 = load i32, ptr %8, align 4, !tbaa !11
  invoke void @_ZN6R2Grid18RasterizeGridValueEiidi(ptr noundef nonnull align 8 dereferenceable(208) %31, i32 noundef %322, i32 noundef %323, double noundef %324, i32 noundef %325)
          to label %326 unwind label %330

326:                                              ; preds = %321
  br label %327

327:                                              ; preds = %326
  %328 = load i32, ptr %30, align 4, !tbaa !11
  %329 = add nsw i32 %328, 1
  store i32 %329, ptr %30, align 4, !tbaa !11
  br label %316, !llvm.loop !19

330:                                              ; preds = %321
  %331 = landingpad { ptr, i32 }
          cleanup
  %332 = extractvalue { ptr, i32 } %331, 0
  store ptr %332, ptr %11, align 8
  %333 = extractvalue { ptr, i32 } %331, 1
  store i32 %333, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #9
  br label %345

334:                                              ; preds = %320
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #9
  store i32 0, ptr %13, align 4
  br label %335

335:                                              ; preds = %334, %303
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #9
  %336 = load i32, ptr %13, align 4
  switch i32 %336, label %364 [
    i32 0, label %337
    i32 9, label %338
  ]

337:                                              ; preds = %335
  br label %259, !llvm.loop !20

338:                                              ; preds = %335, %259
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #9
  store i32 0, ptr %13, align 4
  br label %339

339:                                              ; preds = %338, %253
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #9
  %340 = load i32, ptr %13, align 4
  switch i32 %340, label %364 [
    i32 0, label %341
    i32 4, label %342
  ]

341:                                              ; preds = %339
  br label %342

342:                                              ; preds = %341, %339
  %343 = load i32, ptr %17, align 4, !tbaa !11
  %344 = add nsw i32 %343, 1
  store i32 %344, ptr %17, align 4, !tbaa !11
  br label %89, !llvm.loop !21

345:                                              ; preds = %330, %249, %129
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #9
  br label %346

346:                                              ; preds = %345, %125
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #9
  br label %347

347:                                              ; preds = %346, %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  br label %356

348:                                              ; preds = %94
  %349 = load ptr, ptr %15, align 8, !tbaa !5
  %350 = icmp eq ptr %349, null
  br i1 %350, label %352, label %351

351:                                              ; preds = %348
  call void @_ZdaPv(ptr noundef %349) #11
  br label %352

352:                                              ; preds = %351, %348
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  store i32 0, ptr %13, align 4
  br label %353

353:                                              ; preds = %352, %73, %61, %38
  call void @_ZN9R2PolygonD1Ev(ptr noundef nonnull align 8 dereferenceable(68) %9) #9
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #9
  %354 = load i32, ptr %13, align 4
  switch i32 %354, label %364 [
    i32 0, label %355
    i32 1, label %355
  ]

355:                                              ; preds = %353, %353
  ret void

356:                                              ; preds = %347, %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  br label %357

357:                                              ; preds = %356, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  br label %358

358:                                              ; preds = %357, %48, %47
  call void @_ZN9R2PolygonD1Ev(ptr noundef nonnull align 8 dereferenceable(68) %9) #9
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #9
  br label %359

359:                                              ; preds = %358
  %360 = load ptr, ptr %11, align 8
  %361 = load i32, ptr %12, align 4
  %362 = insertvalue { ptr, i32 } poison, ptr %360, 0
  %363 = insertvalue { ptr, i32 } %362, i32 %361, 1
  resume { ptr, i32 } %363

364:                                              ; preds = %353, %339, %335
  unreachable
}

declare void @_ZN9R2PolygonC1ERKS_(ptr noundef nonnull align 8 dereferenceable(68), ptr noundef nonnull align 8 dereferenceable(68)) unnamed_addr #5

declare void @_ZN9R2Polygon4ClipERK5R2Box(ptr noundef nonnull align 8 dereferenceable(68), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #5

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68), i32 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL24CompareScanLineCrossingsPKvS0_(ptr noundef, ptr noundef) #7

; Function Attrs: nounwind
declare void @_ZN9R2PolygonD1Ev(ptr noundef nonnull align 8 dereferenceable(68)) unnamed_addr #6

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nobuiltin allocsize(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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin 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 = { "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 "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 #7 = { 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 #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin 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 = !{!14, !10, i64 0}
!14 = !{!"_ZTS16ScanLineCrossing", !10, i64 0, !12, i64 8}
!15 = !{!14, !12, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !17}
!21 = distinct !{!21, !17}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.R2Polygon = type <{ %class.R2Solid, ptr, i32, [4 x i8], %class.R2Box, i32, [4 x i8] }>
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Point = type { [2 x double] }
%struct.ScanLineCrossing = type { double, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind
declare void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #6

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid20RasterizeGridPolygonERK9R2Polygondi(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(68) %1, double noundef %2, i32 noundef %3) local_unnamed_addr #7 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.R2Polygon, align 8
  %6 = alloca %class.R2Box, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %5) #10
  call void @_ZN9R2PolygonC1ERKS_(ptr noundef nonnull align 8 dereferenceable(68) %5, ptr noundef nonnull align 8 dereferenceable(68) %1)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #10
  invoke void @_ZNK6R2Grid7GridBoxEv(ptr dead_on_unwind nonnull writable sret(%class.R2Box) align 8 %6, ptr noundef nonnull align 8 dereferenceable(208) %0)
          to label %7 unwind label %11

7:                                                ; preds = %4
  invoke void @_ZN9R2Polygon4ClipERK5R2Box(ptr noundef nonnull align 8 dereferenceable(68) %5, ptr noundef nonnull align 8 dereferenceable(40) %6)
          to label %8 unwind label %13

8:                                                ; preds = %7
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #10
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #10
  %9 = call noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %5)
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %121, label %18

11:                                               ; preds = %4
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %15

13:                                               ; preds = %7
  %14 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #10
  br label %15

15:                                               ; preds = %13, %11
  %.pn = phi { ptr, i32 } [ %14, %13 ], [ %12, %11 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #10
  br label %122

16:                                               ; preds = %26, %21
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %122

18:                                               ; preds = %8
  %19 = call noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %5)
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %5, i32 noundef 0)
  invoke void @_ZN6R2Grid18RasterizeGridPointERK7R2Pointdi(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(16) %22, double noundef %2, i32 noundef %3)
          to label %121 unwind label %16

23:                                               ; preds = %18
  %24 = call noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %5)
  %25 = icmp eq i32 %24, 2
  br i1 %25, label %26, label %29

26:                                               ; preds = %23
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %5, i32 noundef 0)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %5, i32 noundef 1)
  invoke void @_ZN6R2Grid17RasterizeGridSpanERK7R2PointS2_di(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 8 dereferenceable(16) %28, double noundef %2, i32 noundef %3)
          to label %121 unwind label %16

29:                                               ; preds = %23
  %30 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %31 = shl nsw i32 %30, 1
  %32 = call noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %5)
  %33 = mul nsw i32 %31, %32
  %34 = zext nneg i32 %33 to i64
  %35 = icmp slt i32 %33, 0
  %36 = shl nuw nsw i64 %34, 4
  %37 = select i1 %35, i64 -1, i64 %36
  %38 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %37) #11
          to label %.preheader108 unwind label %41

.preheader108:                                    ; preds = %29
  %39 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %.lr.ph131, label %._crit_edge132

.lr.ph131:                                        ; preds = %.preheader108
  %.not109 = icmp sgt i32 %33, 0
  br label %43

41:                                               ; preds = %29
  %42 = landingpad { ptr, i32 }
          cleanup
  br label %122

43:                                               ; preds = %.lr.ph131, %.thread
  %.092130 = phi i32 [ 0, %.lr.ph131 ], [ %118, %.thread ]
  %44 = call noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %5)
  %45 = add nsw i32 %44, -1
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %5, i32 noundef %45)
  %47 = call noundef double @_ZNK7R2Point1YEv(ptr noundef nonnull align 8 dereferenceable(16) %46)
  %48 = uitofp nneg i32 %.092130 to double
  %49 = call noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %5)
  %50 = icmp sgt i32 %49, 0
  %or.cond105110 = and i1 %50, %.not109
  br i1 %or.cond105110, label %.lr.ph.preheader, label %.thread

.lr.ph.preheader:                                 ; preds = %43
  %51 = fsub double %47, %48
  br label %.lr.ph

52:                                               ; preds = %82
  %53 = landingpad { ptr, i32 }
          cleanup
  br label %122

.lr.ph:                                           ; preds = %.lr.ph.preheader, %77
  %.090114 = phi i32 [ %.191, %77 ], [ 0, %.lr.ph.preheader ]
  %.093113 = phi ptr [ %54, %77 ], [ %46, %.lr.ph.preheader ]
  %.094112 = phi double [ %56, %77 ], [ %51, %.lr.ph.preheader ]
  %.095111 = phi i32 [ %78, %77 ], [ 0, %.lr.ph.preheader ]
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68) %5, i32 noundef %.095111)
  %55 = call noundef double @_ZNK7R2Point1YEv(ptr noundef nonnull align 8 dereferenceable(16) %54)
  %56 = fsub double %55, %48
  %57 = fcmp olt double %.094112, 0.000000e+00
  %58 = fcmp oge double %56, 0.000000e+00
  %or.cond = select i1 %57, i1 %58, i1 false
  br i1 %or.cond, label %59, label %62

59:                                               ; preds = %.lr.ph
  %60 = fsub double %56, %.094112
  %61 = fdiv double %56, %60
  br label %.sink.split

62:                                               ; preds = %.lr.ph
  %63 = fcmp olt double %56, 0.000000e+00
  %64 = fcmp oge double %.094112, 0.000000e+00
  %or.cond3 = select i1 %63, i1 %64, i1 false
  br i1 %or.cond3, label %65, label %77

65:                                               ; preds = %62
  %66 = fsub double %.094112, %56
  %67 = fdiv double %.094112, %66
  br label %.sink.split

.sink.split:                                      ; preds = %59, %65
  %.093113.sink150 = phi ptr [ %.093113, %65 ], [ %54, %59 ]
  %.sink149 = phi ptr [ %54, %65 ], [ %.093113, %59 ]
  %.sink144 = phi double [ %67, %65 ], [ %61, %59 ]
  %.sink = phi i32 [ 1, %65 ], [ -1, %59 ]
  %68 = call noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %.093113.sink150)
  %69 = call noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %.sink149)
  %70 = call noundef double @_ZNK7R2Point1XEv(ptr noundef nonnull align 8 dereferenceable(16) %.093113.sink150)
  %71 = fsub double %69, %70
  %72 = call double @llvm.fmuladd.f64(double %.sink144, double %71, double %68)
  %73 = sext i32 %.090114 to i64
  %74 = getelementptr inbounds %struct.ScanLineCrossing, ptr %38, i64 %73
  store double %72, ptr %74, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i64 8
  store i32 %.sink, ptr %75, align 8, !tbaa !11
  %76 = add nsw i32 %.090114, 1
  br label %77

77:                                               ; preds = %.sink.split, %62
  %.191 = phi i32 [ %.090114, %62 ], [ %76, %.sink.split ]
  %78 = add nuw nsw i32 %.095111, 1
  %79 = call noundef i32 @_ZNK9R2Polygon7NPointsEv(ptr noundef nonnull align 8 dereferenceable(68) %5)
  %80 = icmp slt i32 %78, %79
  %.not = icmp slt i32 %.191, %33
  %or.cond105 = select i1 %80, i1 %.not, i1 false
  br i1 %or.cond105, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %77
  %81 = icmp slt i32 %.191, 2
  br i1 %81, label %.thread, label %82

82:                                               ; preds = %._crit_edge
  %83 = zext nneg i32 %.191 to i64
  invoke void @qsort(ptr noundef nonnull %38, i64 noundef %83, i64 noundef 16, ptr noundef nonnull @_ZL24CompareScanLineCrossingsPKvS0_)
          to label %.lr.ph129.preheader unwind label %52

.lr.ph129.preheader:                              ; preds = %82
  %84 = add nsw i32 %.191, -1
  %85 = zext nneg i32 %.191 to i64
  br label %.lr.ph129

.loopexit:                                        ; preds = %114, %105
  %86 = icmp slt i32 %.189.lcssa, %84
  br i1 %86, label %.lr.ph129, label %.thread

.lr.ph129:                                        ; preds = %.lr.ph129.preheader, %.loopexit
  %.088128 = phi i32 [ %.189.lcssa, %.loopexit ], [ 0, %.lr.ph129.preheader ]
  %87 = sext i32 %.088128 to i64
  %88 = getelementptr %struct.ScanLineCrossing, ptr %38, i64 %87
  %89 = add nsw i32 %.088128, 2
  %90 = getelementptr i8, ptr %88, i64 16
  %91 = icmp slt i32 %89, %.191
  %92 = getelementptr inbounds i8, ptr %88, i64 8
  %93 = load i32, ptr %92, align 8, !tbaa !11
  br i1 %91, label %.lr.ph118, label %.critedge

.lr.ph118:                                        ; preds = %.lr.ph129
  %94 = add nsw i64 %87, 2
  br label %95

95:                                               ; preds = %.lr.ph118, %99
  %indvars.iv = phi i64 [ %94, %.lr.ph118 ], [ %indvars.iv.next, %99 ]
  %.086116 = phi ptr [ %90, %.lr.ph118 ], [ %100, %99 ]
  %96 = getelementptr inbounds i8, ptr %.086116, i64 8
  %97 = load i32, ptr %96, align 8, !tbaa !11
  %98 = icmp eq i32 %97, %93
  br i1 %98, label %99, label %.critedge.loopexit.split.loop.exit136

99:                                               ; preds = %95
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %100 = getelementptr inbounds %struct.ScanLineCrossing, ptr %38, i64 %indvars.iv
  %exitcond.not = icmp eq i64 %indvars.iv.next, %85
  br i1 %exitcond.not, label %.critedge, label %95, !llvm.loop !14

.critedge.loopexit.split.loop.exit136:            ; preds = %95
  %101 = trunc nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge:                                        ; preds = %99, %.critedge.loopexit.split.loop.exit136, %.lr.ph129
  %.189.lcssa = phi i32 [ %89, %.lr.ph129 ], [ %101, %.critedge.loopexit.split.loop.exit136 ], [ %.191, %99 ]
  %.086.lcssa = phi ptr [ %90, %.lr.ph129 ], [ %.086116, %.critedge.loopexit.split.loop.exit136 ], [ %100, %99 ]
  %102 = getelementptr inbounds i8, ptr %.086.lcssa, i64 8
  %103 = load i32, ptr %102, align 8, !tbaa !11
  %104 = icmp eq i32 %93, %103
  br i1 %104, label %.thread, label %105

105:                                              ; preds = %.critedge
  %106 = load double, ptr %88, align 8, !tbaa !5
  %107 = load double, ptr %.086.lcssa, align 8, !tbaa !5
  %108 = insertelement <2 x double> poison, double %106, i64 0
  %109 = insertelement <2 x double> %108, double %107, i64 1
  %110 = fadd <2 x double> %109, <double 5.000000e-01, double 5.000000e-01>
  %111 = fptosi <2 x double> %110 to <2 x i32>
  %112 = extractelement <2 x i32> %111, i64 0
  %113 = extractelement <2 x i32> %111, i64 1
  %.not99124 = icmp sgt i32 %112, %113
  br i1 %.not99124, label %.loopexit, label %.lr.ph127

.lr.ph127:                                        ; preds = %105, %114
  %.0125 = phi i32 [ %115, %114 ], [ %112, %105 ]
  invoke void @_ZN6R2Grid18RasterizeGridValueEiidi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.0125, i32 noundef %.092130, double noundef %2, i32 noundef %3)
          to label %114 unwind label %116

114:                                              ; preds = %.lr.ph127
  %115 = add i32 %.0125, 1
  %exitcond134.not = icmp eq i32 %.0125, %113
  br i1 %exitcond134.not, label %.loopexit, label %.lr.ph127, !llvm.loop !15

116:                                              ; preds = %.lr.ph127
  %117 = landingpad { ptr, i32 }
          cleanup
  br label %122

.thread:                                          ; preds = %.loopexit, %.critedge, %43, %._crit_edge
  %118 = add nuw nsw i32 %.092130, 1
  %119 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %120 = icmp slt i32 %118, %119
  br i1 %120, label %43, label %._crit_edge132, !llvm.loop !16

._crit_edge132:                                   ; preds = %.thread, %.preheader108
  call void @_ZdaPv(ptr noundef nonnull %38) #12
  br label %121

121:                                              ; preds = %26, %21, %8, %._crit_edge132
  call void @_ZN9R2PolygonD1Ev(ptr noundef nonnull align 8 dereferenceable(68) %5) #10
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #10
  ret void

122:                                              ; preds = %41, %116, %52, %16, %15
  %.pn103 = phi { ptr, i32 } [ %17, %16 ], [ %.pn, %15 ], [ %42, %41 ], [ %117, %116 ], [ %53, %52 ]
  call void @_ZN9R2PolygonD1Ev(ptr noundef nonnull align 8 dereferenceable(68) %5) #10
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #10
  resume { ptr, i32 } %.pn103
}

declare void @_ZN9R2PolygonC1ERKS_(ptr noundef nonnull align 8 dereferenceable(68), ptr noundef nonnull align 8 dereferenceable(68)) unnamed_addr #8

declare void @_ZN9R2Polygon4ClipERK5R2Box(ptr noundef nonnull align 8 dereferenceable(68), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #8

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9R2Polygon5PointEi(ptr noundef nonnull align 8 dereferenceable(68), i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL24CompareScanLineCrossingsPKvS0_(ptr noundef, ptr noundef) #7

; Function Attrs: nounwind
declare void @_ZN9R2PolygonD1Ev(ptr noundef nonnull align 8 dereferenceable(68)) unnamed_addr #6

attributes #0 = { nobuiltin allocsize(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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin 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 #4 = { nofree "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { 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 #8 = { "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 #9 = { 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 #10 = { nounwind }
attributes #11 = { builtin allocsize(0) }
attributes #12 = { builtin 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, !7, i64 0}
!6 = !{!"_ZTS16ScanLineCrossing", !7, i64 0, !10, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass