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

; 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] }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [29 x i8], align 1

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

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #2

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

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

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

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

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

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

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

; 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 @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16)) #7 align 2

; 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) #6

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid13MaskNonMaximaEd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef %1) #6 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 %172

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 %172

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 %174

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 %173

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 %173

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 %170

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
  %97 = load i32, ptr %11, align 4, !tbaa !11
  %98 = sub nsw i32 %97, 1
  store i32 %98, ptr %15, align 4, !tbaa !11
  br label %99

99:                                               ; preds = %161, %96
  %100 = load i32, ptr %15, align 4, !tbaa !11
  %101 = icmp sge i32 %100, 0
  br i1 %101, label %103, label %102

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

103:                                              ; preds = %99
  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
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  %105 = load i32, ptr %15, align 4, !tbaa !11
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds ptr, ptr %104, i64 %106
  %108 = load ptr, ptr %107, align 8, !tbaa !5
  store ptr %108, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #9
  %109 = load ptr, ptr %18, align 8, !tbaa !5
  %110 = getelementptr inbounds %class.R2Grid, ptr %8, i32 0, i32 3
  %111 = load ptr, ptr %110, align 8, !tbaa !13
  %112 = ptrtoint ptr %109 to i64
  %113 = ptrtoint ptr %111 to i64
  %114 = sub i64 %112, %113
  %115 = sdiv exact i64 %114, 8
  %116 = trunc i64 %115 to i32
  store i32 %116, ptr %19, align 4, !tbaa !11
  %117 = load i32, ptr %19, align 4, !tbaa !11
  %118 = invoke noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %8)
          to label %119 unwind label %123

119:                                              ; preds = %103
  %120 = icmp slt i32 %117, %118
  br i1 %120, label %127, label %121

121:                                              ; preds = %119
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.14, i32 noundef 1235, ptr noundef @.str.2)
          to label %122 unwind label %123

122:                                              ; preds = %121
  br label %127

123:                                              ; preds = %141, %135, %129, %127, %121, %103
  %124 = landingpad { ptr, i32 }
          cleanup
  %125 = extractvalue { ptr, i32 } %124, 0
  store ptr %125, ptr %9, align 8
  %126 = extractvalue { ptr, i32 } %124, 1
  store i32 %126, ptr %10, align 4
  br label %164

127:                                              ; preds = %122, %119
  %128 = load i32, ptr %19, align 4, !tbaa !11
  invoke void @_ZNK6R2Grid14IndexToIndicesEiRiS0_(ptr noundef nonnull align 8 dereferenceable(208) %8, i32 noundef %128, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %17)
          to label %129 unwind label %123

129:                                              ; preds = %127
  %130 = load ptr, ptr %18, align 8, !tbaa !5
  %131 = load double, ptr %130, align 8, !tbaa !9
  %132 = invoke noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %133 unwind label %123

133:                                              ; preds = %129
  %134 = fcmp oge double %131, %132
  br i1 %134, label %135, label %160

135:                                              ; preds = %133
  %136 = load i32, ptr %16, align 4, !tbaa !11
  %137 = load i32, ptr %17, align 4, !tbaa !11
  %138 = invoke noundef i32 @_ZL15IsLocalExtremumRK6R2Gridiii(ptr noundef nonnull align 8 dereferenceable(208) %7, i32 noundef %136, i32 noundef %137, i32 noundef 1)
          to label %139 unwind label %123

139:                                              ; preds = %135
  %140 = icmp ne i32 %138, 0
  br i1 %140, label %141, label %147

141:                                              ; preds = %139
  %142 = load i32, ptr %16, align 4, !tbaa !11
  %143 = load i32, ptr %17, align 4, !tbaa !11
  %144 = load ptr, ptr %18, align 8, !tbaa !5
  %145 = load double, ptr %144, align 8, !tbaa !9
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %21, i32 noundef %142, i32 noundef %143, double noundef %145)
          to label %146 unwind label %123

146:                                              ; preds = %141
  br label %147

147:                                              ; preds = %146, %139
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #9
  %148 = load i32, ptr %16, align 4, !tbaa !11
  %149 = sitofp i32 %148 to double
  %150 = load i32, ptr %17, align 4, !tbaa !11
  %151 = sitofp i32 %150 to double
  invoke void @_ZN7R2PointC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %20, double noundef %149, double noundef %151)
          to label %152 unwind label %156

152:                                              ; preds = %147
  %153 = load double, ptr %4, align 8, !tbaa !9
  %154 = 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 %153, double noundef %154, i32 noundef 0)
          to label %155 unwind label %156

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

156:                                              ; preds = %152, %147
  %157 = landingpad { ptr, i32 }
          cleanup
  %158 = extractvalue { ptr, i32 } %157, 0
  store ptr %158, ptr %9, align 8
  %159 = extractvalue { ptr, i32 } %157, 1
  store i32 %159, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #9
  br label %164

160:                                              ; preds = %155, %133
  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 %161

161:                                              ; preds = %160
  %162 = load i32, ptr %15, align 4, !tbaa !11
  %163 = add nsw i32 %162, -1
  store i32 %163, ptr %15, align 4, !tbaa !11
  br label %99, !llvm.loop !20

164:                                              ; preds = %156, %123
  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 %173

165:                                              ; preds = %102
  %166 = load ptr, ptr %12, align 8, !tbaa !5
  %167 = icmp eq ptr %166, null
  br i1 %167, label %169, label %168

168:                                              ; preds = %165
  call void @_ZdaPv(ptr noundef %166) #11
  br label %169

169:                                              ; preds = %168, %165
  store i32 0, ptr %14, align 4
  br label %170

170:                                              ; preds = %169, %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
  %171 = load i32, ptr %14, align 4
  switch i32 %171, label %180 [
    i32 0, label %172
    i32 1, label %172
  ]

172:                                              ; preds = %170, %170, %28, %24
  ret void

173:                                              ; preds = %164, %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 %174

174:                                              ; preds = %173, %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 %175

175:                                              ; preds = %174
  %176 = load ptr, ptr %9, align 8
  %177 = load i32, ptr %10, align 4
  %178 = insertvalue { ptr, i32 } poison, ptr %176, 0
  %179 = insertvalue { ptr, i32 } %178, i32 %177, 1
  resume { ptr, i32 } %179

180:                                              ; preds = %170
  unreachable
}

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

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [29 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress 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) local_unnamed_addr #3 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #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)) local_unnamed_addr #5 align 2

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

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

; 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 @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #7 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid13MaskNonMaximaEd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef %1) local_unnamed_addr #5 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 %88, 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 %88, 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 %.preheader37 unwind label %29

.preheader37:                                     ; 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 = %.preheader37
  %25 = getelementptr inbounds i8, ptr %5, i64 184
  br label %31

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

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

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

31:                                               ; preds = %.lr.ph, %40
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %40 ]
  %.03138 = phi i32 [ 0, %.lr.ph ], [ %.132, %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 %.03138 to i64
  %38 = getelementptr inbounds ptr, ptr %22, i64 %37
  store ptr %33, ptr %38, align 8, !tbaa !16
  %39 = add nsw i32 %.03138, 1
  br label %40

40:                                               ; preds = %31, %36
  %.132 = phi i32 [ %.03138, %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 %.132 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 %.132, 0
  br i1 %46, label %.lr.ph42, label %._crit_edge.thread

.lr.ph42:                                         ; preds = %.preheader
  %47 = getelementptr inbounds i8, ptr %5, i64 184
  %48 = zext nneg i32 %.132 to i64
  br label %49

49:                                               ; preds = %.lr.ph42, %85
  %indvars.iv45 = phi i64 [ %48, %.lr.ph42 ], [ %indvars.iv.next46, %85 ]
  %indvars.iv.next46 = add nsw i64 %indvars.iv45, -1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #9
  %50 = getelementptr inbounds ptr, ptr %22, i64 %indvars.iv.next46
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = load ptr, ptr %47, align 8, !tbaa !5
  %53 = ptrtoint ptr %51 to i64
  %54 = ptrtoint ptr %52 to i64
  %55 = sub i64 %53, %54
  %56 = lshr exact i64 %55, 3
  %57 = trunc i64 %56 to i32
  %58 = call noundef i32 @_ZNK6R2Grid8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(208) %5)
  %59 = icmp sgt i32 %58, %57
  br i1 %59, label %63, label %60

60:                                               ; preds = %49
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.14, i32 noundef 1235, ptr noundef nonnull @.str.2)
          to label %63 unwind label %61

61:                                               ; preds = %72, %67, %60
  %62 = landingpad { ptr, i32 }
          cleanup
  br label %87

63:                                               ; preds = %60, %49
  call void @_ZNK6R2Grid14IndexToIndicesEiRiS0_(ptr noundef nonnull align 8 dereferenceable(208) %5, i32 noundef %57, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %64 = load double, ptr %51, align 8, !tbaa !15
  %65 = call noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %66 = fcmp ult double %64, %65
  br i1 %66, label %85, label %67

67:                                               ; preds = %63
  %68 = load i32, ptr %6, align 4, !tbaa !19
  %69 = load i32, ptr %7, align 4, !tbaa !19
  %70 = invoke noundef i32 @_ZL15IsLocalExtremumRK6R2Gridiii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %68, i32 noundef %69, i32 noundef 1)
          to label %71 unwind label %61

71:                                               ; preds = %67
  %.not33 = icmp eq i32 %70, 0
  br i1 %.not33, label %76, label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %6, align 4, !tbaa !19
  %74 = load i32, ptr %7, align 4, !tbaa !19
  %75 = load double, ptr %51, align 8, !tbaa !15
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %73, i32 noundef %74, double noundef %75)
          to label %76 unwind label %61

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

81:                                               ; preds = %76
  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 %82 unwind label %83

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

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

85:                                               ; preds = %82, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  %86 = icmp ugt i64 %indvars.iv45, 1
  br i1 %86, label %49, label %._crit_edge.thread, !llvm.loop !20

87:                                               ; preds = %83, %61
  %.pn = phi { ptr, i32 } [ %84, %83 ], [ %62, %61 ]
  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 %89

._crit_edge.thread:                               ; preds = %85, %.preheader, %._crit_edge, %.preheader37
  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 %88

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

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

90:                                               ; preds = %89, %27
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %89 ], [ %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
}

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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress 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 = { 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 #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