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

; 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.RNInterval = type { double, double }
%class.R2Grid = type { %class.R2Affine, %class.R2Affine, double, ptr, [2 x i32], i32, i32 }
%class.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }
%class.R2Point = type { [2 x double] }

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 uwtable
declare dso_local void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, double noundef) #3 align 2

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

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

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

declare void @_ZN7R2PointC1Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #6

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid13MaskNonMinimaEd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef %1) #5 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca %class.RNInterval, align 8
  %6 = alloca double, align 8
  %7 = alloca %class.R2Grid, align 8
  %8 = alloca %class.R2Grid, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca %class.R2Point, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %21 = load ptr, ptr %3, align 8
  %22 = call noundef ptr @_ZNK6R2Grid10GridValuesEv(ptr noundef nonnull align 8 dereferenceable(208) %21)
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %2
  br label %164

25:                                               ; preds = %2
  %26 = call noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %21)
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  br label %164

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #9
  call void @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind writable sret(%class.RNInterval) align 8 %5, ptr noundef nonnull align 8 dereferenceable(208) %21)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #9
  %30 = call noundef double @_ZNK10RNInterval8DiameterEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %31 = fmul double 2.000000e+00, %30
  store double %31, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 208, ptr %7) #9
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %7, ptr noundef nonnull align 8 dereferenceable(208) %21)
  call void @llvm.lifetime.start.p0(i64 208, ptr %8) #9
  invoke void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %8, ptr noundef nonnull align 8 dereferenceable(208) %21)
          to label %32 unwind label %48

32:                                               ; preds = %29
  call void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208) %21, double noundef -3.210000e+02)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  store i32 0, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  %33 = invoke noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %8)
          to label %34 unwind label %52

34:                                               ; preds = %32
  %35 = sext i32 %33 to i64
  %36 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %35, i64 8)
  %37 = extractvalue { i64, i1 } %36, 1
  %38 = extractvalue { i64, i1 } %36, 0
  %39 = select i1 %37, i64 -1, i64 %38
  %40 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %39) #10
          to label %41 unwind label %52

41:                                               ; preds = %34
  store ptr %40, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %81, %41
  %43 = load i32, ptr %13, align 4, !tbaa !11
  %44 = invoke noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %8)
          to label %45 unwind label %56

45:                                               ; preds = %42
  %46 = icmp slt i32 %43, %44
  br i1 %46, label %60, label %47

47:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  br label %84

48:                                               ; preds = %29
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %9, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %10, align 4
  br label %166

52:                                               ; preds = %92, %34, %32
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %9, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %10, align 4
  br label %165

56:                                               ; preds = %42
  %57 = landingpad { ptr, i32 }
          cleanup
  %58 = extractvalue { ptr, i32 } %57, 0
  store ptr %58, ptr %9, align 8
  %59 = extractvalue { ptr, i32 } %57, 1
  store i32 %59, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  br label %165

60:                                               ; preds = %45
  %61 = getelementptr inbounds %class.R2Grid, ptr %8, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !13
  %63 = load i32, ptr %13, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %62, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = fcmp oeq double %66, -3.210000e+02
  br i1 %67, label %68, label %69

68:                                               ; preds = %60
  br label %81

69:                                               ; preds = %60
  %70 = getelementptr inbounds %class.R2Grid, ptr %8, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !13
  %72 = load i32, ptr %13, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds double, ptr %71, i64 %73
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = load i32, ptr %11, align 4, !tbaa !11
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds ptr, ptr %75, i64 %77
  store ptr %74, ptr %78, align 8, !tbaa !5
  %79 = load i32, ptr %11, align 4, !tbaa !11
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %11, align 4, !tbaa !11
  br label %81

81:                                               ; preds = %69, %68
  %82 = load i32, ptr %13, align 4, !tbaa !11
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %13, align 4, !tbaa !11
  br label %42, !llvm.loop !18

84:                                               ; preds = %47
  %85 = load i32, ptr %11, align 4, !tbaa !11
  %86 = icmp eq i32 %85, 0
  br i1 %86, label %87, label %92

87:                                               ; preds = %84
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = icmp eq ptr %88, null
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  call void @_ZdaPv(ptr noundef %88) #11
  br label %91

91:                                               ; preds = %90, %87
  store i32 1, ptr %14, align 4
  br label %162

92:                                               ; preds = %84
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = load i32, ptr %11, align 4, !tbaa !11
  %95 = sext i32 %94 to i64
  invoke void @qsort(ptr noundef %93, i64 noundef %95, i64 noundef 8, ptr noundef @_ZL19RNCompareScalarPtrsPKvS0_)
          to label %96 unwind label %52

96:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  store i32 0, ptr %15, align 4, !tbaa !11
  br label %97

97:                                               ; preds = %153, %96
  %98 = load i32, ptr %15, align 4, !tbaa !11
  %99 = load i32, ptr %11, align 4, !tbaa !11
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %97
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  br label %157

102:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #9
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = load i32, ptr %15, align 4, !tbaa !11
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds ptr, ptr %103, i64 %105
  %107 = load ptr, ptr %106, align 8, !tbaa !5
  store ptr %107, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #9
  %108 = load ptr, ptr %18, align 8, !tbaa !5
  %109 = getelementptr inbounds %class.R2Grid, ptr %8, i32 0, i32 3
  %110 = load ptr, ptr %109, align 8, !tbaa !13
  %111 = ptrtoint ptr %108 to i64
  %112 = ptrtoint ptr %110 to i64
  %113 = sub i64 %111, %112
  %114 = sdiv exact i64 %113, 8
  %115 = trunc i64 %114 to i32
  store i32 %115, ptr %19, align 4, !tbaa !11
  %116 = load i32, ptr %19, align 4, !tbaa !11
  invoke void @_ZNK6R2Grid14IndexToIndicesEiRiS0_(ptr noundef nonnull align 8 dereferenceable(208) %8, i32 noundef %116, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %17)
          to label %117 unwind label %135

117:                                              ; preds = %102
  %118 = load ptr, ptr %18, align 8, !tbaa !5
  %119 = load double, ptr %118, align 8, !tbaa !9
  %120 = invoke noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %121 unwind label %135

121:                                              ; preds = %117
  %122 = fcmp ole double %119, %120
  br i1 %122, label %123, label %152

123:                                              ; preds = %121
  %124 = load i32, ptr %16, align 4, !tbaa !11
  %125 = load i32, ptr %17, align 4, !tbaa !11
  %126 = invoke noundef i32 @_ZL15IsLocalExtremumRK6R2Gridiii(ptr noundef nonnull align 8 dereferenceable(208) %7, i32 noundef %124, i32 noundef %125, i32 noundef 0)
          to label %127 unwind label %135

127:                                              ; preds = %123
  %128 = icmp ne i32 %126, 0
  br i1 %128, label %129, label %139

129:                                              ; preds = %127
  %130 = load i32, ptr %16, align 4, !tbaa !11
  %131 = load i32, ptr %17, align 4, !tbaa !11
  %132 = load ptr, ptr %18, align 8, !tbaa !5
  %133 = load double, ptr %132, align 8, !tbaa !9
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %21, i32 noundef %130, i32 noundef %131, double noundef %133)
          to label %134 unwind label %135

134:                                              ; preds = %129
  br label %139

135:                                              ; preds = %129, %123, %117, %102
  %136 = landingpad { ptr, i32 }
          cleanup
  %137 = extractvalue { ptr, i32 } %136, 0
  store ptr %137, ptr %9, align 8
  %138 = extractvalue { ptr, i32 } %136, 1
  store i32 %138, ptr %10, align 4
  br label %156

139:                                              ; preds = %134, %127
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #9
  %140 = load i32, ptr %16, align 4, !tbaa !11
  %141 = sitofp i32 %140 to double
  %142 = load i32, ptr %17, align 4, !tbaa !11
  %143 = sitofp i32 %142 to double
  invoke void @_ZN7R2PointC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %20, double noundef %141, double noundef %143)
          to label %144 unwind label %148

144:                                              ; preds = %139
  %145 = load double, ptr %4, align 8, !tbaa !9
  %146 = load double, ptr %6, align 8, !tbaa !9
  invoke void @_ZN6R2Grid19RasterizeGridCircleERK7R2Pointddi(ptr noundef nonnull align 8 dereferenceable(208) %8, ptr noundef nonnull align 8 dereferenceable(16) %20, double noundef %145, double noundef %146, i32 noundef 0)
          to label %147 unwind label %148

147:                                              ; preds = %144
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #9
  br label %152

148:                                              ; preds = %144, %139
  %149 = landingpad { ptr, i32 }
          cleanup
  %150 = extractvalue { ptr, i32 } %149, 0
  store ptr %150, ptr %9, align 8
  %151 = extractvalue { ptr, i32 } %149, 1
  store i32 %151, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #9
  br label %156

152:                                              ; preds = %147, %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %15, align 4, !tbaa !11
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %15, align 4, !tbaa !11
  br label %97, !llvm.loop !20

156:                                              ; preds = %148, %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  br label %165

157:                                              ; preds = %101
  %158 = load ptr, ptr %12, align 8, !tbaa !5
  %159 = icmp eq ptr %158, null
  br i1 %159, label %161, label %160

160:                                              ; preds = %157
  call void @_ZdaPv(ptr noundef %158) #11
  br label %161

161:                                              ; preds = %160, %157
  store i32 0, ptr %14, align 4
  br label %162

162:                                              ; preds = %161, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %8) #9
  call void @llvm.lifetime.end.p0(i64 208, ptr %8) #9
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %7) #9
  call void @llvm.lifetime.end.p0(i64 208, ptr %7) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #9
  %163 = load i32, ptr %14, align 4
  switch i32 %163, label %172 [
    i32 0, label %164
    i32 1, label %164
  ]

164:                                              ; preds = %162, %162, %28, %24
  ret void

165:                                              ; preds = %156, %56, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %8) #9
  br label %166

166:                                              ; preds = %165, %48
  call void @llvm.lifetime.end.p0(i64 208, ptr %8) #9
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %7) #9
  call void @llvm.lifetime.end.p0(i64 208, ptr %7) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #9
  br label %167

167:                                              ; preds = %166
  %168 = load ptr, ptr %9, align 8
  %169 = load i32, ptr %10, align 4
  %170 = insertvalue { ptr, i32 } poison, ptr %168, 0
  %171 = insertvalue { ptr, i32 } %170, i32 %169, 1
  resume { ptr, i32 } %171

172:                                              ; preds = %162
  unreachable
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL19RNCompareScalarPtrsPKvS0_(ptr noundef, ptr noundef) #8

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL15IsLocalExtremumRK6R2Gridiii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, i32 noundef) #5

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

declare void @_ZN6R2GridC1ERKS_(ptr, ptr)

declare void @_ZN6R2GridD1Ev(ptr)

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 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 = { 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 #6 = { "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 = { 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 #8 = { 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 #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, !6, i64 184}
!14 = !{!"_ZTS6R2Grid", !15, i64 0, !15, i64 88, !10, i64 176, !6, i64 184, !7, i64 192, !12, i64 200, !12, i64 204}
!15 = !{!"_ZTS8R2Affine", !16, i64 0, !17, i64 8, !12, i64 80}
!16 = !{!"_ZTS16R2Transformation"}
!17 = !{!"_ZTS8R3Matrix", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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.RNInterval = type { double, double }
%class.R2Grid = type { %class.R2Affine, %class.R2Affine, double, ptr, [2 x i32], i32, i32 }
%class.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }
%class.R2Point = type { [2 x double] }

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 uwtable
declare dso_local void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, double noundef) local_unnamed_addr #2 align 2

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

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

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

declare void @_ZN7R2PointC1Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #6

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid13MaskNonMinimaEd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef %1) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.RNInterval, align 8
  %4 = alloca %class.R2Grid, align 8
  %5 = alloca %class.R2Grid, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %class.R2Point, align 8
  %9 = tail call noundef ptr @_ZNK6R2Grid10GridValuesEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %82, label %10

10:                                               ; preds = %2
  %11 = tail call noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %82, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #9
  call void @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind nonnull writable sret(%class.RNInterval) align 8 %3, ptr noundef nonnull align 8 dereferenceable(208) %0)
  %14 = call noundef double @_ZNK10RNInterval8DiameterEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %15 = fmul double %14, 2.000000e+00
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %4) #9
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %4, ptr noundef nonnull align 8 dereferenceable(208) %0)
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %5) #9
  invoke void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %5, ptr noundef nonnull align 8 dereferenceable(208) %0)
          to label %16 unwind label %27

16:                                               ; preds = %13
  call void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef -3.210000e+02)
  %17 = call noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %5)
  %18 = zext nneg i32 %17 to i64
  %19 = icmp slt i32 %17, 0
  %20 = shl nuw nsw i64 %18, 3
  %21 = select i1 %19, i64 -1, i64 %20
  %22 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %21) #10
          to label %.preheader36 unwind label %29

.preheader36:                                     ; preds = %16
  %23 = call noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %5)
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.lr.ph, label %._crit_edge.thread

.lr.ph:                                           ; preds = %.preheader36
  %25 = getelementptr inbounds i8, ptr %5, i64 184
  br label %31

._crit_edge:                                      ; preds = %40
  %26 = icmp eq i32 %.131, 0
  br i1 %26, label %._crit_edge.thread, label %44

27:                                               ; preds = %13
  %28 = landingpad { ptr, i32 }
          cleanup
  br label %84

29:                                               ; preds = %44, %16
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %83

31:                                               ; preds = %.lr.ph, %40
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %40 ]
  %.03037 = phi i32 [ 0, %.lr.ph ], [ %.131, %40 ]
  %32 = load ptr, ptr %25, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 %indvars.iv
  %34 = load double, ptr %33, align 8, !tbaa !15
  %35 = fcmp oeq double %34, -3.210000e+02
  br i1 %35, label %40, label %36

36:                                               ; preds = %31
  %37 = sext i32 %.03037 to i64
  %38 = getelementptr inbounds ptr, ptr %22, i64 %37
  store ptr %33, ptr %38, align 8, !tbaa !16
  %39 = add nsw i32 %.03037, 1
  br label %40

40:                                               ; preds = %31, %36
  %.131 = phi i32 [ %.03037, %31 ], [ %39, %36 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = call noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %5)
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %31, label %._crit_edge, !llvm.loop !17

44:                                               ; preds = %._crit_edge
  %45 = sext i32 %.131 to i64
  invoke void @qsort(ptr noundef nonnull %22, i64 noundef %45, i64 noundef 8, ptr noundef nonnull @_ZL19RNCompareScalarPtrsPKvS0_)
          to label %.preheader unwind label %29

.preheader:                                       ; preds = %44
  %46 = icmp sgt i32 %.131, 0
  br i1 %46, label %.lr.ph40, label %._crit_edge.thread

.lr.ph40:                                         ; preds = %.preheader
  %47 = getelementptr inbounds i8, ptr %5, i64 184
  %wide.trip.count = zext nneg i32 %.131 to i64
  br label %48

48:                                               ; preds = %.lr.ph40, %80
  %indvars.iv43 = phi i64 [ 0, %.lr.ph40 ], [ %indvars.iv.next44, %80 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #9
  %49 = getelementptr inbounds ptr, ptr %22, i64 %indvars.iv43
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = load ptr, ptr %47, align 8, !tbaa !5
  %52 = ptrtoint ptr %50 to i64
  %53 = ptrtoint ptr %51 to i64
  %54 = sub i64 %52, %53
  %55 = lshr exact i64 %54, 3
  %56 = trunc i64 %55 to i32
  call void @_ZNK6R2Grid14IndexToIndicesEiRiS0_(ptr noundef nonnull align 8 dereferenceable(208) %5, i32 noundef %56, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %57 = load double, ptr %50, align 8, !tbaa !15
  %58 = call noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %59 = fcmp ugt double %57, %58
  br i1 %59, label %80, label %60

60:                                               ; preds = %48
  %61 = load i32, ptr %6, align 4, !tbaa !19
  %62 = load i32, ptr %7, align 4, !tbaa !19
  %63 = invoke noundef i32 @_ZL15IsLocalExtremumRK6R2Gridiii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %61, i32 noundef %62, i32 noundef 0)
          to label %64 unwind label %69

64:                                               ; preds = %60
  %.not32 = icmp eq i32 %63, 0
  br i1 %.not32, label %71, label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %6, align 4, !tbaa !19
  %67 = load i32, ptr %7, align 4, !tbaa !19
  %68 = load double, ptr %50, align 8, !tbaa !15
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %66, i32 noundef %67, double noundef %68)
          to label %71 unwind label %69

69:                                               ; preds = %65, %60
  %70 = landingpad { ptr, i32 }
          cleanup
  br label %81

71:                                               ; preds = %65, %64
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #9
  %72 = load i32, ptr %6, align 4, !tbaa !19
  %73 = sitofp i32 %72 to double
  %74 = load i32, ptr %7, align 4, !tbaa !19
  %75 = sitofp i32 %74 to double
  invoke void @_ZN7R2PointC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %8, double noundef %73, double noundef %75)
          to label %76 unwind label %78

76:                                               ; preds = %71
  invoke void @_ZN6R2Grid19RasterizeGridCircleERK7R2Pointddi(ptr noundef nonnull align 8 dereferenceable(208) %5, ptr noundef nonnull align 8 dereferenceable(16) %8, double noundef %1, double noundef %15, i32 noundef 0)
          to label %77 unwind label %78

77:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #9
  br label %80

78:                                               ; preds = %76, %71
  %79 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #9
  br label %81

80:                                               ; preds = %77, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next44, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.thread, label %48, !llvm.loop !20

81:                                               ; preds = %78, %69
  %.pn = phi { ptr, i32 } [ %79, %78 ], [ %70, %69 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  br label %83

._crit_edge.thread:                               ; preds = %80, %.preheader, %._crit_edge, %.preheader36
  call void @_ZdaPv(ptr noundef nonnull %22) #11
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %5) #9
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %5) #9
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #9
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #9
  br label %82

82:                                               ; preds = %10, %2, %._crit_edge.thread
  ret void

83:                                               ; preds = %81, %29
  %.pn.pn = phi { ptr, i32 } [ %.pn, %81 ], [ %30, %29 ]
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %5) #9
  br label %84

84:                                               ; preds = %83, %27
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %83 ], [ %28, %27 ]
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %5) #9
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #9
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #9
  resume { ptr, i32 } %.pn.pn.pn
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL19RNCompareScalarPtrsPKvS0_(ptr noundef, ptr noundef) #8

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL15IsLocalExtremumRK6R2Gridiii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

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

declare void @_ZN6R2GridC1ERKS_(ptr, ptr) local_unnamed_addr

declare void @_ZN6R2GridD1Ev(ptr) local_unnamed_addr

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 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 = { 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 #5 = { 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 #6 = { "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 = { 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 #8 = { 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 #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, !14, i64 184}
!6 = !{!"_ZTS6R2Grid", !7, i64 0, !7, i64 88, !13, i64 176, !14, i64 184, !10, i64 192, !12, i64 200, !12, i64 204}
!7 = !{!"_ZTS8R2Affine", !8, i64 0, !9, i64 8, !12, i64 80}
!8 = !{!"_ZTS16R2Transformation"}
!9 = !{!"_ZTS8R3Matrix", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"double", !10, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!14, !14, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !12, i64 0}
!20 = distinct !{!20, !18}


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