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

; 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.R3Point = type { [3 x double] }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid18RasterizeGridPlaneERK7R3Planedi(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %2, i32 noundef %3) #3 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 [8 x %class.R3Point], align 16
  %10 = alloca [8 x double], align 16
  %11 = alloca [24 x %class.R3Point], align 16
  %12 = alloca %class.R3Box, align 8
  %13 = alloca i32, align 4
  %14 = alloca %class.R3Point, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %class.R3Grid, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = 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
  %24 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 192, ptr %9) #5
  %25 = getelementptr inbounds [8 x %class.R3Point], ptr %9, i32 0, i32 0
  %26 = getelementptr inbounds %class.R3Point, ptr %25, i64 8
  br label %27

27:                                               ; preds = %27, %4
  %28 = phi ptr [ %25, %4 ], [ %29, %27 ]
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %28)
  %29 = getelementptr inbounds %class.R3Point, ptr %28, i64 1
  %30 = icmp eq ptr %29, %26
  br i1 %30, label %31, label %27

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 576, ptr %11) #5
  %32 = getelementptr inbounds [24 x %class.R3Point], ptr %11, i32 0, i32 0
  %33 = getelementptr inbounds %class.R3Point, ptr %32, i64 24
  br label %34

34:                                               ; preds = %34, %31
  %35 = phi ptr [ %32, %31 ], [ %36, %34 ]
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %35)
  %36 = getelementptr inbounds %class.R3Point, ptr %35, i64 1
  %37 = icmp eq ptr %36, %33
  br i1 %37, label %38, label %34

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 56, ptr %12) #5
  call void @_ZNK6R3Grid7GridBoxEv(ptr dead_on_unwind writable sret(%class.R3Box) align 8 %12, ptr noundef nonnull align 8 dereferenceable(592) %24)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %60, %38
  %40 = load i32, ptr %13, align 4, !tbaa !11
  %41 = icmp slt i32 %40, 8
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %72

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #5
  %44 = load i32, ptr %13, align 4, !tbaa !11
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind writable sret(%class.R3Point) align 8 %14, ptr noundef nonnull align 8 dereferenceable(56) %12, i32 noundef %44)
          to label %45 unwind label %63

45:                                               ; preds = %43
  %46 = load i32, ptr %13, align 4, !tbaa !11
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [8 x %class.R3Point], ptr %9, i64 0, i64 %47
  %49 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %48, ptr noundef nonnull align 8 dereferenceable(24) %14)
          to label %50 unwind label %63

50:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %13, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [8 x %class.R3Point], ptr %9, i64 0, i64 %53
  %55 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %51, ptr noundef nonnull align 8 dereferenceable(24) %54)
          to label %56 unwind label %67

56:                                               ; preds = %50
  %57 = load i32, ptr %13, align 4, !tbaa !11
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [8 x double], ptr %10, i64 0, i64 %58
  store double %55, ptr %59, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %56
  %61 = load i32, ptr %13, align 4, !tbaa !11
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %13, align 4, !tbaa !11
  br label %39, !llvm.loop !13

63:                                               ; preds = %45, %43
  %64 = landingpad { ptr, i32 }
          cleanup
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %15, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #5
  br label %71

67:                                               ; preds = %50
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %15, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %16, align 4
  br label %71

71:                                               ; preds = %67, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %179

72:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %73 = getelementptr inbounds [8 x %class.R3Point], ptr %9, i64 0, i64 0
  %74 = getelementptr inbounds [8 x double], ptr %10, i64 0, i64 0
  %75 = getelementptr inbounds [24 x %class.R3Point], ptr %11, i64 0, i64 0
  %76 = invoke noundef i32 @_ZL13MarchingCubesP7R3PointPddS0_(ptr noundef %73, ptr noundef %74, double noundef 0.000000e+00, ptr noundef %75)
          to label %77 unwind label %93

77:                                               ; preds = %72
  store i32 %76, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 592, ptr %18) #5
  %78 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %79 = getelementptr inbounds [3 x i32], ptr %78, i64 0, i64 0
  %80 = load i32, ptr %79, align 8, !tbaa !11
  %81 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %82 = getelementptr inbounds [3 x i32], ptr %81, i64 0, i64 1
  %83 = load i32, ptr %82, align 4, !tbaa !11
  %84 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %85 = getelementptr inbounds [3 x i32], ptr %84, i64 0, i64 2
  %86 = load i32, ptr %85, align 8, !tbaa !11
  invoke void @_ZN6R3GridC1Eiii(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %80, i32 noundef %83, i32 noundef %86)
          to label %87 unwind label %97

87:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %88

88:                                               ; preds = %114, %87
  %89 = load i32, ptr %19, align 4, !tbaa !11
  %90 = load i32, ptr %17, align 4, !tbaa !11
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %101, label %92

92:                                               ; preds = %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %121

93:                                               ; preds = %72
  %94 = landingpad { ptr, i32 }
          cleanup
  %95 = extractvalue { ptr, i32 } %94, 0
  store ptr %95, ptr %15, align 8
  %96 = extractvalue { ptr, i32 } %94, 1
  store i32 %96, ptr %16, align 4
  br label %178

97:                                               ; preds = %77
  %98 = landingpad { ptr, i32 }
          cleanup
  %99 = extractvalue { ptr, i32 } %98, 0
  store ptr %99, ptr %15, align 8
  %100 = extractvalue { ptr, i32 } %98, 1
  store i32 %100, ptr %16, align 4
  br label %177

101:                                              ; preds = %88
  %102 = load i32, ptr %19, align 4, !tbaa !11
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [24 x %class.R3Point], ptr %11, i64 0, i64 %103
  %105 = load i32, ptr %19, align 4, !tbaa !11
  %106 = add nsw i32 %105, 1
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [24 x %class.R3Point], ptr %11, i64 0, i64 %107
  %109 = load i32, ptr %19, align 4, !tbaa !11
  %110 = add nsw i32 %109, 2
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [24 x %class.R3Point], ptr %11, i64 0, i64 %111
  invoke void @_ZN6R3Grid21RasterizeGridTriangleERK7R3PointS2_S2_di(ptr noundef nonnull align 8 dereferenceable(592) %18, ptr noundef nonnull align 8 dereferenceable(24) %104, ptr noundef nonnull align 8 dereferenceable(24) %108, ptr noundef nonnull align 8 dereferenceable(24) %112, double noundef 1.000000e+00, i32 noundef 0)
          to label %113 unwind label %117

113:                                              ; preds = %101
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %19, align 4, !tbaa !11
  %116 = add nsw i32 %115, 3
  store i32 %116, ptr %19, align 4, !tbaa !11
  br label %88, !llvm.loop !15

117:                                              ; preds = %101
  %118 = landingpad { ptr, i32 }
          cleanup
  %119 = extractvalue { ptr, i32 } %118, 0
  store ptr %119, ptr %15, align 8
  %120 = extractvalue { ptr, i32 } %118, 1
  store i32 %120, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %176

121:                                              ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %122

122:                                              ; preds = %172, %121
  %123 = load i32, ptr %20, align 4, !tbaa !11
  %124 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %125 = getelementptr inbounds [3 x i32], ptr %124, i64 0, i64 2
  %126 = load i32, ptr %125, align 8, !tbaa !11
  %127 = icmp slt i32 %123, %126
  br i1 %127, label %129, label %128

128:                                              ; preds = %122
  store i32 8, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %175

129:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  store i32 0, ptr %22, align 4, !tbaa !11
  br label %130

130:                                              ; preds = %168, %129
  %131 = load i32, ptr %22, align 4, !tbaa !11
  %132 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %133 = getelementptr inbounds [3 x i32], ptr %132, i64 0, i64 1
  %134 = load i32, ptr %133, align 4, !tbaa !11
  %135 = icmp slt i32 %131, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %130
  store i32 11, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  br label %171

137:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #5
  store i32 0, ptr %23, align 4, !tbaa !11
  br label %138

138:                                              ; preds = %164, %137
  %139 = load i32, ptr %23, align 4, !tbaa !11
  %140 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %141 = getelementptr inbounds [3 x i32], ptr %140, i64 0, i64 0
  %142 = load i32, ptr %141, align 8, !tbaa !11
  %143 = icmp slt i32 %139, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %138
  store i32 14, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #5
  br label %167

145:                                              ; preds = %138
  %146 = load i32, ptr %23, align 4, !tbaa !11
  %147 = load i32, ptr %22, align 4, !tbaa !11
  %148 = load i32, ptr %20, align 4, !tbaa !11
  %149 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %18, i32 noundef %146, i32 noundef %147, i32 noundef %148)
          to label %150 unwind label %159

150:                                              ; preds = %145
  %151 = fcmp ogt double %149, 0.000000e+00
  br i1 %151, label %152, label %163

152:                                              ; preds = %150
  %153 = load i32, ptr %23, align 4, !tbaa !11
  %154 = load i32, ptr %22, align 4, !tbaa !11
  %155 = load i32, ptr %20, align 4, !tbaa !11
  %156 = load double, ptr %7, align 8, !tbaa !9
  %157 = load i32, ptr %8, align 4, !tbaa !11
  invoke void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %24, i32 noundef %153, i32 noundef %154, i32 noundef %155, double noundef %156, i32 noundef %157)
          to label %158 unwind label %159

158:                                              ; preds = %152
  br label %163

159:                                              ; preds = %152, %145
  %160 = landingpad { ptr, i32 }
          cleanup
  %161 = extractvalue { ptr, i32 } %160, 0
  store ptr %161, ptr %15, align 8
  %162 = extractvalue { ptr, i32 } %160, 1
  store i32 %162, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %176

163:                                              ; preds = %158, %150
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %23, align 4, !tbaa !11
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %23, align 4, !tbaa !11
  br label %138, !llvm.loop !16

167:                                              ; preds = %144
  br label %168

168:                                              ; preds = %167
  %169 = load i32, ptr %22, align 4, !tbaa !11
  %170 = add nsw i32 %169, 1
  store i32 %170, ptr %22, align 4, !tbaa !11
  br label %130, !llvm.loop !17

171:                                              ; preds = %136
  br label %172

172:                                              ; preds = %171
  %173 = load i32, ptr %20, align 4, !tbaa !11
  %174 = add nsw i32 %173, 1
  store i32 %174, ptr %20, align 4, !tbaa !11
  br label %122, !llvm.loop !18

175:                                              ; preds = %128
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %18) #5
  call void @llvm.lifetime.end.p0(i64 592, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %12) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 576, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 192, ptr %9) #5
  ret void

176:                                              ; preds = %159, %117
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %18) #5
  br label %177

177:                                              ; preds = %176, %97
  call void @llvm.lifetime.end.p0(i64 592, ptr %18) #5
  br label %178

178:                                              ; preds = %177, %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %179

179:                                              ; preds = %178, %71
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %12) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 576, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 192, ptr %9) #5
  br label %180

180:                                              ; preds = %179
  %181 = load ptr, ptr %15, align 8
  %182 = load i32, ptr %16, align 4
  %183 = insertvalue { ptr, i32 } poison, ptr %181, 0
  %184 = insertvalue { ptr, i32 } %183, i32 %182, 1
  resume { ptr, i32 } %184
}

declare void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4

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

declare void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind writable sret(%class.R3Point) align 8, ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) #4

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

declare noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) #4

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL13MarchingCubesP7R3PointPddS0_(ptr noundef, ptr noundef, double noundef, ptr noundef) #3

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

declare void @_ZN6R3GridC1Eiii(ptr, i32, i32, i32)

declare void @_ZN6R3GridD1Ev(ptr)

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


; 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.R3Point = type { [3 x double] }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid18RasterizeGridPlaneERK7R3Planedi(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %2, i32 noundef %3) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca [8 x %class.R3Point], align 16
  %6 = alloca [8 x double], align 16
  %7 = alloca [24 x %class.R3Point], align 16
  %8 = alloca %class.R3Box, align 8
  %9 = alloca %class.R3Point, align 8
  %10 = alloca %class.R3Grid, align 8
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %5) #5
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %.ptr.1 = getelementptr inbounds i8, ptr %5, i64 24
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %5, i64 48
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.2)
  %.ptr.3 = getelementptr inbounds i8, ptr %5, i64 72
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.3)
  %.ptr.4 = getelementptr inbounds i8, ptr %5, i64 96
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.4)
  %.ptr.5 = getelementptr inbounds i8, ptr %5, i64 120
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.5)
  %.ptr.6 = getelementptr inbounds i8, ptr %5, i64 144
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.6)
  %.ptr.7 = getelementptr inbounds i8, ptr %5, i64 168
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.7)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 576, ptr nonnull %7) #5
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %7)
  %.ptr42.1 = getelementptr inbounds i8, ptr %7, i64 24
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.1)
  %.ptr42.2 = getelementptr inbounds i8, ptr %7, i64 48
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.2)
  %.ptr42.3 = getelementptr inbounds i8, ptr %7, i64 72
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.3)
  %.ptr42.4 = getelementptr inbounds i8, ptr %7, i64 96
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.4)
  %.ptr42.5 = getelementptr inbounds i8, ptr %7, i64 120
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.5)
  %.ptr42.6 = getelementptr inbounds i8, ptr %7, i64 144
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.6)
  %.ptr42.7 = getelementptr inbounds i8, ptr %7, i64 168
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.7)
  %.ptr42.8 = getelementptr inbounds i8, ptr %7, i64 192
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.8)
  %.ptr42.9 = getelementptr inbounds i8, ptr %7, i64 216
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.9)
  %.ptr42.10 = getelementptr inbounds i8, ptr %7, i64 240
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.10)
  %.ptr42.11 = getelementptr inbounds i8, ptr %7, i64 264
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.11)
  %.ptr42.12 = getelementptr inbounds i8, ptr %7, i64 288
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.12)
  %.ptr42.13 = getelementptr inbounds i8, ptr %7, i64 312
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.13)
  %.ptr42.14 = getelementptr inbounds i8, ptr %7, i64 336
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.14)
  %.ptr42.15 = getelementptr inbounds i8, ptr %7, i64 360
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.15)
  %.ptr42.16 = getelementptr inbounds i8, ptr %7, i64 384
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.16)
  %.ptr42.17 = getelementptr inbounds i8, ptr %7, i64 408
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.17)
  %.ptr42.18 = getelementptr inbounds i8, ptr %7, i64 432
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.18)
  %.ptr42.19 = getelementptr inbounds i8, ptr %7, i64 456
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.19)
  %.ptr42.20 = getelementptr inbounds i8, ptr %7, i64 480
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.20)
  %.ptr42.21 = getelementptr inbounds i8, ptr %7, i64 504
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.21)
  %.ptr42.22 = getelementptr inbounds i8, ptr %7, i64 528
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.22)
  %.ptr42.23 = getelementptr inbounds i8, ptr %7, i64 552
  call void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr42.23)
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %8) #5
  call void @_ZNK6R3Grid7GridBoxEv(ptr dead_on_unwind nonnull writable sret(%class.R3Box) align 8 %8, ptr noundef nonnull align 8 dereferenceable(592) %0)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 0)
          to label %11 unwind label %59

11:                                               ; preds = %4
  %12 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %13 unwind label %59

13:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %14 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %15 unwind label %61

15:                                               ; preds = %13
  store double %14, ptr %6, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 1)
          to label %16 unwind label %59

16:                                               ; preds = %15
  %17 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.1, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %18 unwind label %59

18:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %19 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %.ptr.1)
          to label %20 unwind label %61

20:                                               ; preds = %18
  %21 = getelementptr inbounds i8, ptr %6, i64 8
  store double %19, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 2)
          to label %22 unwind label %59

22:                                               ; preds = %20
  %23 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.2, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %24 unwind label %59

24:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %25 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %.ptr.2)
          to label %26 unwind label %61

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %6, i64 16
  store double %25, ptr %27, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 3)
          to label %28 unwind label %59

28:                                               ; preds = %26
  %29 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.3, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %30 unwind label %59

30:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %31 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %.ptr.3)
          to label %32 unwind label %61

32:                                               ; preds = %30
  %33 = getelementptr inbounds i8, ptr %6, i64 24
  store double %31, ptr %33, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 4)
          to label %34 unwind label %59

34:                                               ; preds = %32
  %35 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.4, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %36 unwind label %59

36:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %37 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %.ptr.4)
          to label %38 unwind label %61

38:                                               ; preds = %36
  %39 = getelementptr inbounds i8, ptr %6, i64 32
  store double %37, ptr %39, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 5)
          to label %40 unwind label %59

40:                                               ; preds = %38
  %41 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.5, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %42 unwind label %59

42:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %43 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %.ptr.5)
          to label %44 unwind label %61

44:                                               ; preds = %42
  %45 = getelementptr inbounds i8, ptr %6, i64 40
  store double %43, ptr %45, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 6)
          to label %46 unwind label %59

46:                                               ; preds = %44
  %47 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.6, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %48 unwind label %59

48:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %49 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %.ptr.6)
          to label %50 unwind label %61

50:                                               ; preds = %48
  %51 = getelementptr inbounds i8, ptr %6, i64 48
  store double %49, ptr %51, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  invoke void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind nonnull writable sret(%class.R3Point) align 8 %9, ptr noundef nonnull align 8 dereferenceable(56) %8, i32 noundef 7)
          to label %52 unwind label %59

52:                                               ; preds = %50
  %53 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24) %.ptr.7, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %54 unwind label %59

54:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  %55 = invoke noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %.ptr.7)
          to label %56 unwind label %61

56:                                               ; preds = %54
  %57 = getelementptr inbounds i8, ptr %6, i64 56
  store double %55, ptr %57, align 8, !tbaa !5
  %58 = invoke noundef i32 @_ZL13MarchingCubesP7R3PointPddS0_(ptr noundef nonnull %5, ptr noundef nonnull %6, double noundef 0.000000e+00, ptr noundef nonnull %7)
          to label %63 unwind label %75

59:                                               ; preds = %52, %50, %46, %44, %40, %38, %34, %32, %28, %26, %22, %20, %16, %15, %11, %4
  %60 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  br label %119

61:                                               ; preds = %54, %48, %42, %36, %30, %24, %18, %13
  %62 = landingpad { ptr, i32 }
          cleanup
  br label %119

63:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 592, ptr nonnull %10) #5
  %64 = getelementptr inbounds i8, ptr %0, i64 568
  %65 = load i32, ptr %64, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %0, i64 572
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = getelementptr inbounds i8, ptr %0, i64 576
  %69 = load i32, ptr %68, align 8, !tbaa !9
  invoke void @_ZN6R3GridC1Eiii(ptr noundef nonnull align 8 dereferenceable(592) %10, i32 noundef %65, i32 noundef %67, i32 noundef %69)
          to label %.preheader52 unwind label %77

.preheader52:                                     ; preds = %63
  %70 = icmp sgt i32 %58, 0
  br i1 %70, label %.lr.ph, label %.preheader51

.preheader51:                                     ; preds = %84, %.preheader52
  %71 = load i32, ptr %68, align 8, !tbaa !9
  %72 = icmp sgt i32 %71, 0
  %73 = load i32, ptr %66, align 4
  %74 = icmp sgt i32 %73, 0
  %or.cond = select i1 %72, i1 %74, i1 false
  br i1 %or.cond, label %.preheader50, label %._crit_edge61

75:                                               ; preds = %56
  %76 = landingpad { ptr, i32 }
          cleanup
  br label %119

77:                                               ; preds = %63
  %78 = landingpad { ptr, i32 }
          cleanup
  br label %118

.lr.ph:                                           ; preds = %.preheader52, %84
  %indvars.iv = phi i64 [ %indvars.iv.next, %84 ], [ 0, %.preheader52 ]
  %79 = getelementptr inbounds [24 x %class.R3Point], ptr %7, i64 0, i64 %indvars.iv
  %80 = add nuw nsw i64 %indvars.iv, 1
  %81 = getelementptr inbounds [24 x %class.R3Point], ptr %7, i64 0, i64 %80
  %82 = add nuw nsw i64 %indvars.iv, 2
  %83 = getelementptr inbounds [24 x %class.R3Point], ptr %7, i64 0, i64 %82
  invoke void @_ZN6R3Grid21RasterizeGridTriangleERK7R3PointS2_S2_di(ptr noundef nonnull align 8 dereferenceable(592) %10, ptr noundef nonnull align 8 dereferenceable(24) %79, ptr noundef nonnull align 8 dereferenceable(24) %81, ptr noundef nonnull align 8 dereferenceable(24) %83, double noundef 1.000000e+00, i32 noundef 0)
          to label %84 unwind label %87

84:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 3
  %85 = trunc nuw i64 %indvars.iv.next to i32
  %86 = icmp sgt i32 %58, %85
  br i1 %86, label %.lr.ph, label %.preheader51, !llvm.loop !11

87:                                               ; preds = %.lr.ph
  %88 = landingpad { ptr, i32 }
          cleanup
  br label %117

.preheader50:                                     ; preds = %.preheader51, %._crit_edge58
  %89 = phi i32 [ %98, %._crit_edge58 ], [ %71, %.preheader51 ]
  %90 = phi i32 [ %99, %._crit_edge58 ], [ %73, %.preheader51 ]
  %91 = phi i32 [ %100, %._crit_edge58 ], [ %73, %.preheader51 ]
  %.03059 = phi i32 [ %101, %._crit_edge58 ], [ 0, %.preheader51 ]
  %92 = icmp sgt i32 %91, 0
  %93 = load i32, ptr %64, align 8
  %94 = icmp sgt i32 %93, 0
  %or.cond70 = select i1 %92, i1 %94, i1 false
  br i1 %or.cond70, label %.preheader, label %._crit_edge58

._crit_edge61:                                    ; preds = %._crit_edge58, %.preheader51
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %10) #5
  call void @llvm.lifetime.end.p0(i64 592, ptr nonnull %10) #5
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %8) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 576, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %5) #5
  ret void

.preheader:                                       ; preds = %.preheader50, %._crit_edge
  %95 = phi i32 [ %103, %._crit_edge ], [ %90, %.preheader50 ]
  %96 = phi i32 [ %104, %._crit_edge ], [ %93, %.preheader50 ]
  %.02957 = phi i32 [ %105, %._crit_edge ], [ 0, %.preheader50 ]
  %97 = icmp sgt i32 %96, 0
  br i1 %97, label %.lr.ph56, label %._crit_edge

._crit_edge58.loopexit:                           ; preds = %._crit_edge
  %.pre66 = load i32, ptr %68, align 8, !tbaa !9
  br label %._crit_edge58

._crit_edge58:                                    ; preds = %._crit_edge58.loopexit, %.preheader50
  %98 = phi i32 [ %.pre66, %._crit_edge58.loopexit ], [ %89, %.preheader50 ]
  %99 = phi i32 [ %103, %._crit_edge58.loopexit ], [ %90, %.preheader50 ]
  %100 = phi i32 [ %103, %._crit_edge58.loopexit ], [ %91, %.preheader50 ]
  %101 = add nuw nsw i32 %.03059, 1
  %102 = icmp slt i32 %101, %98
  br i1 %102, label %.preheader50, label %._crit_edge61, !llvm.loop !13

._crit_edge.loopexit:                             ; preds = %113
  %.pre = load i32, ptr %66, align 4, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %103 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %95, %.preheader ]
  %104 = phi i32 [ %115, %._crit_edge.loopexit ], [ %96, %.preheader ]
  %105 = add nuw nsw i32 %.02957, 1
  %106 = icmp slt i32 %105, %103
  br i1 %106, label %.preheader, label %._crit_edge58.loopexit, !llvm.loop !15

.lr.ph56:                                         ; preds = %.preheader, %113
  %.055 = phi i32 [ %114, %113 ], [ 0, %.preheader ]
  %107 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %10, i32 noundef %.055, i32 noundef %.02957, i32 noundef %.03059)
          to label %108 unwind label %111

108:                                              ; preds = %.lr.ph56
  %109 = fcmp ogt double %107, 0.000000e+00
  br i1 %109, label %110, label %113

110:                                              ; preds = %108
  invoke void @_ZN6R3Grid18RasterizeGridValueEiiidi(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.055, i32 noundef %.02957, i32 noundef %.03059, double noundef %2, i32 noundef %3)
          to label %113 unwind label %111

111:                                              ; preds = %110, %.lr.ph56
  %112 = landingpad { ptr, i32 }
          cleanup
  br label %117

113:                                              ; preds = %108, %110
  %114 = add nuw nsw i32 %.055, 1
  %115 = load i32, ptr %64, align 8, !tbaa !9
  %116 = icmp slt i32 %114, %115
  br i1 %116, label %.lr.ph56, label %._crit_edge.loopexit, !llvm.loop !16

117:                                              ; preds = %111, %87
  %.pn = phi { ptr, i32 } [ %88, %87 ], [ %112, %111 ]
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %10) #5
  br label %118

118:                                              ; preds = %117, %77
  %.pn.pn = phi { ptr, i32 } [ %.pn, %117 ], [ %78, %77 ]
  call void @llvm.lifetime.end.p0(i64 592, ptr nonnull %10) #5
  br label %119

119:                                              ; preds = %75, %118, %59, %61
  %.pn47.pn = phi { ptr, i32 } [ %62, %61 ], [ %60, %59 ], [ %.pn.pn, %118 ], [ %76, %75 ]
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %8) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 576, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %5) #5
  resume { ptr, i32 } %.pn47.pn
}

declare void @_ZN7R3PointC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6R3Grid7GridBoxEv(ptr dead_on_unwind noalias writable sret(%class.R3Box) align 8, ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #1 align 2

declare void @_ZNK5R3Box6CornerEi(ptr dead_on_unwind writable sret(%class.R3Point) align 8, ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) local_unnamed_addr #4

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointaSERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

declare noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL13MarchingCubesP7R3PointPddS0_(ptr noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #3

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

declare void @_ZN6R3GridC1Eiii(ptr, i32, i32, i32) local_unnamed_addr

declare void @_ZN6R3GridD1Ev(ptr) local_unnamed_addr

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

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12, !14}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = distinct !{!15, !12, !14}
!16 = distinct !{!16, !12}


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