; LLVM IR from bbenligiray/stag :: src/ED/ValidateEdgeSegments.ll (Z35ValidateEdgeSegmentsWithGradientMapP7EdgeMapPsd)

; 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"

%struct.EdgeMap = type <{ i32, i32, ptr, ptr, ptr, i32, [4 x i8] }>
%struct.EdgeSegment = type { ptr, i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z18ExtractNewSegmentsP7EdgeMap(ptr noundef) #0

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL11TestSegmentP7EdgeMapPsiiiiPdd(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, double noundef) #5

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #6

; Function Attrs: mustprogress uwtable
define dso_local void @_Z35ValidateEdgeSegmentsWithGradientMapP7EdgeMapPsd(ptr noundef %0, ptr noundef %1, double noundef %2) #5 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %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 %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.EdgeMap, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !11
  store i32 %26, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.EdgeMap, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !15
  store i32 %29, ptr %8, align 4, !tbaa !14
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.EdgeMap, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = load i32, ptr %7, align 4, !tbaa !14
  %34 = load i32, ptr %8, align 4, !tbaa !14
  %35 = mul nsw i32 %33, %34
  %36 = sext i32 %35 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %32, i8 0, i64 %36, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 32768, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %37 = load i32, ptr %9, align 4, !tbaa !14
  %38 = sext i32 %37 to i64
  %39 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %38, i64 8)
  %40 = extractvalue { i64, i1 } %39, 1
  %41 = extractvalue { i64, i1 } %39, 0
  %42 = select i1 %40, i64 -1, i64 %41
  %43 = call noalias noundef nonnull ptr @_Znam(i64 noundef %42) #8
  store ptr %43, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load i32, ptr %9, align 4, !tbaa !14
  %46 = sext i32 %45 to i64
  %47 = mul i64 8, %46
  call void @llvm.memset.p0.i64(ptr align 8 %44, i8 0, i64 %47, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %48 = load i32, ptr %9, align 4, !tbaa !14
  %49 = sext i32 %48 to i64
  %50 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %49, i64 4)
  %51 = extractvalue { i64, i1 } %50, 1
  %52 = extractvalue { i64, i1 } %50, 0
  %53 = select i1 %51, i64 -1, i64 %52
  %54 = call noalias noundef nonnull ptr @_Znam(i64 noundef %53) #8
  store ptr %54, ptr %11, align 8, !tbaa !5
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !14
  %57 = sext i32 %56 to i64
  %58 = mul i64 4, %57
  call void @llvm.memset.p0.i64(ptr align 4 %55, i8 0, i64 %58, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 1, ptr %12, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %59 = load i32, ptr %12, align 4, !tbaa !14
  store i32 %59, ptr %13, align 4, !tbaa !14
  br label %60

60:                                               ; preds = %97, %3
  %61 = load i32, ptr %13, align 4, !tbaa !14
  %62 = load i32, ptr %8, align 4, !tbaa !14
  %63 = load i32, ptr %12, align 4, !tbaa !14
  %64 = sub nsw i32 %62, %63
  %65 = icmp slt i32 %61, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %60
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %100

67:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %68 = load i32, ptr %12, align 4, !tbaa !14
  store i32 %68, ptr %15, align 4, !tbaa !14
  br label %69

69:                                               ; preds = %93, %67
  %70 = load i32, ptr %15, align 4, !tbaa !14
  %71 = load i32, ptr %7, align 4, !tbaa !14
  %72 = load i32, ptr %12, align 4, !tbaa !14
  %73 = sub nsw i32 %71, %72
  %74 = icmp slt i32 %70, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %69
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %96

76:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load i32, ptr %13, align 4, !tbaa !14
  %79 = load i32, ptr %7, align 4, !tbaa !14
  %80 = mul nsw i32 %78, %79
  %81 = load i32, ptr %15, align 4, !tbaa !14
  %82 = add nsw i32 %80, %81
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i16, ptr %77, i64 %83
  %85 = load i16, ptr %84, align 2, !tbaa !17
  %86 = sext i16 %85 to i32
  store i32 %86, ptr %16, align 4, !tbaa !14
  %87 = load ptr, ptr %11, align 8, !tbaa !5
  %88 = load i32, ptr %16, align 4, !tbaa !14
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i32, ptr %87, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !14
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %90, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %93

93:                                               ; preds = %76
  %94 = load i32, ptr %15, align 4, !tbaa !14
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %15, align 4, !tbaa !14
  br label %69, !llvm.loop !19

96:                                               ; preds = %75
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %13, align 4, !tbaa !14
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %13, align 4, !tbaa !14
  br label %60, !llvm.loop !21

100:                                              ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %101 = load i32, ptr %7, align 4, !tbaa !14
  %102 = load i32, ptr %12, align 4, !tbaa !14
  %103 = mul nsw i32 2, %102
  %104 = sub nsw i32 %101, %103
  %105 = load i32, ptr %8, align 4, !tbaa !14
  %106 = load i32, ptr %12, align 4, !tbaa !14
  %107 = mul nsw i32 2, %106
  %108 = sub nsw i32 %105, %107
  %109 = mul nsw i32 %104, %108
  store i32 %109, ptr %17, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %110 = load i32, ptr %9, align 4, !tbaa !14
  %111 = sub nsw i32 %110, 1
  store i32 %111, ptr %18, align 4, !tbaa !14
  br label %112

112:                                              ; preds = %129, %100
  %113 = load i32, ptr %18, align 4, !tbaa !14
  %114 = icmp sgt i32 %113, 0
  br i1 %114, label %116, label %115

115:                                              ; preds = %112
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %132

116:                                              ; preds = %112
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  %118 = load i32, ptr %18, align 4, !tbaa !14
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i32, ptr %117, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !14
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = load i32, ptr %18, align 4, !tbaa !14
  %124 = sub nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds i32, ptr %122, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !14
  %128 = add nsw i32 %127, %121
  store i32 %128, ptr %126, align 4, !tbaa !14
  br label %129

129:                                              ; preds = %116
  %130 = load i32, ptr %18, align 4, !tbaa !14
  %131 = add nsw i32 %130, -1
  store i32 %131, ptr %18, align 4, !tbaa !14
  br label %112, !llvm.loop !22

132:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 0, ptr %19, align 4, !tbaa !14
  br label %133

133:                                              ; preds = %152, %132
  %134 = load i32, ptr %19, align 4, !tbaa !14
  %135 = load i32, ptr %9, align 4, !tbaa !14
  %136 = icmp slt i32 %134, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %133
  store i32 11, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %155

138:                                              ; preds = %133
  %139 = load ptr, ptr %11, align 8, !tbaa !5
  %140 = load i32, ptr %19, align 4, !tbaa !14
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds i32, ptr %139, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !14
  %144 = sitofp i32 %143 to double
  %145 = load i32, ptr %17, align 4, !tbaa !14
  %146 = sitofp i32 %145 to double
  %147 = fdiv double %144, %146
  %148 = load ptr, ptr %10, align 8, !tbaa !5
  %149 = load i32, ptr %19, align 4, !tbaa !14
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds double, ptr %148, i64 %150
  store double %147, ptr %151, align 8, !tbaa !9
  br label %152

152:                                              ; preds = %138
  %153 = load i32, ptr %19, align 4, !tbaa !14
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %19, align 4, !tbaa !14
  br label %133, !llvm.loop !23

155:                                              ; preds = %137
  %156 = load ptr, ptr %11, align 8, !tbaa !5
  %157 = icmp eq ptr %156, null
  br i1 %157, label %159, label %158

158:                                              ; preds = %155
  call void @_ZdlPvm(ptr noundef %156, i64 noundef 4) #9
  br label %159

159:                                              ; preds = %158, %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  store i32 0, ptr %20, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store i32 0, ptr %21, align 4, !tbaa !14
  br label %160

160:                                              ; preds = %183, %159
  %161 = load i32, ptr %21, align 4, !tbaa !14
  %162 = load ptr, ptr %4, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.EdgeMap, ptr %162, i32 0, i32 5
  %164 = load i32, ptr %163, align 8, !tbaa !24
  %165 = icmp slt i32 %161, %164
  br i1 %165, label %167, label %166

166:                                              ; preds = %160
  store i32 14, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %186

167:                                              ; preds = %160
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  %168 = load ptr, ptr %4, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.EdgeMap, ptr %168, i32 0, i32 4
  %170 = load ptr, ptr %169, align 8, !tbaa !25
  %171 = load i32, ptr %21, align 4, !tbaa !14
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds %struct.EdgeSegment, ptr %170, i64 %172
  %174 = getelementptr inbounds %struct.EdgeSegment, ptr %173, i32 0, i32 1
  %175 = load i32, ptr %174, align 8, !tbaa !26
  store i32 %175, ptr %22, align 4, !tbaa !14
  %176 = load i32, ptr %22, align 4, !tbaa !14
  %177 = load i32, ptr %22, align 4, !tbaa !14
  %178 = sub nsw i32 %177, 1
  %179 = mul nsw i32 %176, %178
  %180 = sdiv i32 %179, 2
  %181 = load i32, ptr %20, align 4, !tbaa !14
  %182 = add nsw i32 %181, %180
  store i32 %182, ptr %20, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %183

183:                                              ; preds = %167
  %184 = load i32, ptr %21, align 4, !tbaa !14
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %21, align 4, !tbaa !14
  br label %160, !llvm.loop !28

186:                                              ; preds = %166
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 0, ptr %23, align 4, !tbaa !14
  br label %187

187:                                              ; preds = %210, %186
  %188 = load i32, ptr %23, align 4, !tbaa !14
  %189 = load ptr, ptr %4, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.EdgeMap, ptr %189, i32 0, i32 5
  %191 = load i32, ptr %190, align 8, !tbaa !24
  %192 = icmp slt i32 %188, %191
  br i1 %192, label %194, label %193

193:                                              ; preds = %187
  store i32 17, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  br label %213

194:                                              ; preds = %187
  %195 = load ptr, ptr %4, align 8, !tbaa !5
  %196 = load ptr, ptr %5, align 8, !tbaa !5
  %197 = load i32, ptr %23, align 4, !tbaa !14
  %198 = load ptr, ptr %4, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.EdgeMap, ptr %198, i32 0, i32 4
  %200 = load ptr, ptr %199, align 8, !tbaa !25
  %201 = load i32, ptr %23, align 4, !tbaa !14
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds %struct.EdgeSegment, ptr %200, i64 %202
  %204 = getelementptr inbounds %struct.EdgeSegment, ptr %203, i32 0, i32 1
  %205 = load i32, ptr %204, align 8, !tbaa !26
  %206 = sub nsw i32 %205, 1
  %207 = load i32, ptr %20, align 4, !tbaa !14
  %208 = load ptr, ptr %10, align 8, !tbaa !5
  %209 = load double, ptr %6, align 8, !tbaa !9
  call void @_ZL11TestSegmentP7EdgeMapPsiiiiPdd(ptr noundef %195, ptr noundef %196, i32 noundef %197, i32 noundef 0, i32 noundef %206, i32 noundef %207, ptr noundef %208, double noundef %209)
  br label %210

210:                                              ; preds = %194
  %211 = load i32, ptr %23, align 4, !tbaa !14
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %23, align 4, !tbaa !14
  br label %187, !llvm.loop !29

213:                                              ; preds = %193
  %214 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z18ExtractNewSegmentsP7EdgeMap(ptr noundef %214)
  %215 = load ptr, ptr %10, align 8, !tbaa !5
  %216 = icmp eq ptr %215, null
  br i1 %216, label %218, label %217

217:                                              ; preds = %213
  call void @_ZdlPvm(ptr noundef %215, i64 noundef 8) #9
  br label %218

218:                                              ; preds = %217, %213
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { 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, !13, i64 0}
!12 = !{!"_ZTS7EdgeMap", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 4}
!16 = !{!12, !6, i64 8}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !20}
!24 = !{!12, !13, i64 32}
!25 = !{!12, !6, i64 24}
!26 = !{!27, !13, i64 8}
!27 = !{!"_ZTS11EdgeSegment", !6, i64 0, !13, i64 8}
!28 = distinct !{!28, !20}
!29 = distinct !{!29, !20}


; 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"

%struct.EdgeSegment = type { ptr, i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z18ExtractNewSegmentsP7EdgeMap(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z35ValidateEdgeSegmentsWithGradientMapP7EdgeMapPsd(ptr noundef %0, ptr noundef %1, double noundef %2) local_unnamed_addr #3 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = mul nsw i32 %6, %4
  %10 = sext i32 %9 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %8, i8 0, i64 %10, i1 false)
  %11 = tail call noalias noundef nonnull dereferenceable(262144) ptr @_Znam(i64 noundef 262144) #6
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(262144) %11, i8 0, i64 262144, i1 false)
  %12 = tail call noalias noundef nonnull dereferenceable(131072) ptr @_Znam(i64 noundef 131072) #6
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(131072) %12, i8 0, i64 131072, i1 false)
  %13 = icmp sgt i32 %6, 2
  %14 = icmp sgt i32 %4, 2
  %or.cond = select i1 %13, i1 %14, i1 false
  br i1 %or.cond, label %.preheader74.us.preheader, label %._crit_edge77

.preheader74.us.preheader:                        ; preds = %3
  %15 = add nsw i32 %6, -1
  %16 = add nsw i32 %4, -1
  %17 = zext nneg i32 %4 to i64
  %wide.trip.count89 = zext nneg i32 %15 to i64
  %wide.trip.count = zext i32 %16 to i64
  %18 = add nsw i64 %wide.trip.count, -1
  %19 = add nsw i64 %wide.trip.count, -2
  %xtraiter = and i64 %18, 3
  %20 = icmp ult i64 %19, 3
  %unroll_iter = and i64 %18, -4
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader74.us

.preheader74.us:                                  ; preds = %.preheader74.us.preheader, %._crit_edge.us
  %indvars.iv86 = phi i64 [ 1, %.preheader74.us.preheader ], [ %indvars.iv.next87, %._crit_edge.us ]
  %21 = mul nuw nsw i64 %indvars.iv86, %17
  %invariant.gep = getelementptr inbounds i16, ptr %1, i64 %21
  br i1 %20, label %._crit_edge.us.unr-lcssa, label %.preheader74.us.new

.preheader74.us.new:                              ; preds = %.preheader74.us
  %invariant.gep119 = getelementptr inbounds i8, ptr %invariant.gep, i64 2
  %invariant.gep121 = getelementptr inbounds i8, ptr %invariant.gep, i64 4
  %invariant.gep123 = getelementptr inbounds i8, ptr %invariant.gep, i64 6
  br label %22

22:                                               ; preds = %22, %.preheader74.us.new
  %indvars.iv = phi i64 [ 1, %.preheader74.us.new ], [ %indvars.iv.next.3, %22 ]
  %niter = phi i64 [ 0, %.preheader74.us.new ], [ %niter.next.3, %22 ]
  %gep = getelementptr inbounds i16, ptr %invariant.gep, i64 %indvars.iv
  %23 = load i16, ptr %gep, align 2, !tbaa !13
  %24 = sext i16 %23 to i64
  %25 = getelementptr inbounds i32, ptr %12, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !15
  %gep120 = getelementptr inbounds i16, ptr %invariant.gep119, i64 %indvars.iv
  %28 = load i16, ptr %gep120, align 2, !tbaa !13
  %29 = sext i16 %28 to i64
  %30 = getelementptr inbounds i32, ptr %12, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !15
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %30, align 4, !tbaa !15
  %gep122 = getelementptr inbounds i16, ptr %invariant.gep121, i64 %indvars.iv
  %33 = load i16, ptr %gep122, align 2, !tbaa !13
  %34 = sext i16 %33 to i64
  %35 = getelementptr inbounds i32, ptr %12, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !15
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 4, !tbaa !15
  %gep124 = getelementptr inbounds i16, ptr %invariant.gep123, i64 %indvars.iv
  %38 = load i16, ptr %gep124, align 2, !tbaa !13
  %39 = sext i16 %38 to i64
  %40 = getelementptr inbounds i32, ptr %12, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !15
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !15
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.us.unr-lcssa, label %22, !llvm.loop !16

._crit_edge.us.unr-lcssa:                         ; preds = %22, %.preheader74.us
  %indvars.iv.unr = phi i64 [ 1, %.preheader74.us ], [ %indvars.iv.next.3, %22 ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.us.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.unr-lcssa ]
  %gep.epil = getelementptr inbounds i16, ptr %invariant.gep, i64 %indvars.iv.epil
  %43 = load i16, ptr %gep.epil, align 2, !tbaa !13
  %44 = sext i16 %43 to i64
  %45 = getelementptr inbounds i32, ptr %12, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !15
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %45, align 4, !tbaa !15
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.us, label %.epil.preheader, !llvm.loop !18

._crit_edge.us:                                   ; preds = %.epil.preheader, %._crit_edge.us.unr-lcssa
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %exitcond90.not = icmp eq i64 %indvars.iv.next87, %wide.trip.count89
  br i1 %exitcond90.not, label %._crit_edge77, label %.preheader74.us, !llvm.loop !20

._crit_edge77:                                    ; preds = %._crit_edge.us, %3
  %48 = add nsw i32 %6, -2
  %scevgep = getelementptr inbounds i8, ptr %12, i64 131068
  %load_initial = load i32, ptr %scevgep, align 4
  %invariant.gep125 = getelementptr i8, ptr %12, i64 -4
  %invariant.gep127 = getelementptr i8, ptr %12, i64 -8
  %invariant.gep129 = getelementptr i8, ptr %12, i64 -4
  %invariant.gep131 = getelementptr i8, ptr %12, i64 -16
  br label %69

vector.ph:                                        ; preds = %69
  %49 = add nsw i32 %4, -2
  %50 = mul nsw i32 %48, %49
  %51 = sitofp i32 %50 to double
  %broadcast.splatinsert = insertelement <2 x double> poison, double %51, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.3, %vector.body ]
  %52 = getelementptr inbounds i32, ptr %12, i64 %index
  %wide.load = load <2 x i32>, ptr %52, align 4, !tbaa !15
  %53 = sitofp <2 x i32> %wide.load to <2 x double>
  %54 = fdiv <2 x double> %53, %broadcast.splat
  %55 = getelementptr inbounds double, ptr %11, i64 %index
  store <2 x double> %54, ptr %55, align 8, !tbaa !21
  %index.next = or disjoint i64 %index, 2
  %56 = getelementptr inbounds i32, ptr %12, i64 %index.next
  %wide.load.1 = load <2 x i32>, ptr %56, align 4, !tbaa !15
  %57 = sitofp <2 x i32> %wide.load.1 to <2 x double>
  %58 = fdiv <2 x double> %57, %broadcast.splat
  %59 = getelementptr inbounds double, ptr %11, i64 %index.next
  store <2 x double> %58, ptr %59, align 8, !tbaa !21
  %index.next.1 = or disjoint i64 %index, 4
  %60 = getelementptr inbounds i32, ptr %12, i64 %index.next.1
  %wide.load.2 = load <2 x i32>, ptr %60, align 4, !tbaa !15
  %61 = sitofp <2 x i32> %wide.load.2 to <2 x double>
  %62 = fdiv <2 x double> %61, %broadcast.splat
  %63 = getelementptr inbounds double, ptr %11, i64 %index.next.1
  store <2 x double> %62, ptr %63, align 8, !tbaa !21
  %index.next.2 = or disjoint i64 %index, 6
  %64 = getelementptr inbounds i32, ptr %12, i64 %index.next.2
  %wide.load.3 = load <2 x i32>, ptr %64, align 4, !tbaa !15
  %65 = sitofp <2 x i32> %wide.load.3 to <2 x double>
  %66 = fdiv <2 x double> %65, %broadcast.splat
  %67 = getelementptr inbounds double, ptr %11, i64 %index.next.2
  store <2 x double> %66, ptr %67, align 8, !tbaa !21
  %index.next.3 = add nuw nsw i64 %index, 8
  %68 = icmp eq i64 %index.next.3, 32768
  br i1 %68, label %middle.block, label %vector.body, !llvm.loop !23

69:                                               ; preds = %77, %._crit_edge77
  %store_forwarded = phi i32 [ %load_initial, %._crit_edge77 ], [ %79, %77 ]
  %indvars.iv91 = phi i64 [ 32767, %._crit_edge77 ], [ %indvars.iv.next92.3, %77 ]
  %gep126 = getelementptr i32, ptr %invariant.gep125, i64 %indvars.iv91
  %70 = load i32, ptr %gep126, align 4, !tbaa !15
  %71 = add nsw i32 %70, %store_forwarded
  store i32 %71, ptr %gep126, align 4, !tbaa !15
  %gep128 = getelementptr i32, ptr %invariant.gep127, i64 %indvars.iv91
  %72 = load i32, ptr %gep128, align 4, !tbaa !15
  %73 = add nsw i32 %72, %71
  store i32 %73, ptr %gep128, align 4, !tbaa !15
  %indvars.iv.next92.1 = add nsw i64 %indvars.iv91, -2
  %gep130 = getelementptr i32, ptr %invariant.gep129, i64 %indvars.iv.next92.1
  %74 = load i32, ptr %gep130, align 4, !tbaa !15
  %75 = add nsw i32 %74, %73
  store i32 %75, ptr %gep130, align 4, !tbaa !15
  %76 = icmp ugt i64 %indvars.iv.next92.1, 1
  br i1 %76, label %77, label %vector.ph, !llvm.loop !26

77:                                               ; preds = %69
  %gep132 = getelementptr i32, ptr %invariant.gep131, i64 %indvars.iv91
  %78 = load i32, ptr %gep132, align 4, !tbaa !15
  %79 = add nsw i32 %78, %75
  store i32 %79, ptr %gep132, align 4, !tbaa !15
  %indvars.iv.next92.3 = add nsw i64 %indvars.iv91, -4
  br label %69

middle.block:                                     ; preds = %vector.body
  tail call void @_ZdlPvm(ptr noundef nonnull %12, i64 noundef 4) #7
  %80 = getelementptr inbounds i8, ptr %0, i64 32
  %81 = load i32, ptr %80, align 8, !tbaa !27
  %82 = icmp sgt i32 %81, 0
  br i1 %82, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %middle.block
  %83 = getelementptr inbounds i8, ptr %0, i64 24
  %84 = load ptr, ptr %83, align 8, !tbaa !28
  %wide.trip.count101 = zext nneg i32 %81 to i64
  %min.iters.check = icmp ult i32 %81, 9
  br i1 %min.iters.check, label %scalar.ph108.preheader, label %vector.ph109

scalar.ph108.preheader:                           ; preds = %middle.block107, %.lr.ph
  %indvars.iv98.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block107 ]
  %.06980.ph = phi i32 [ 0, %.lr.ph ], [ %127, %middle.block107 ]
  br label %scalar.ph108

vector.ph109:                                     ; preds = %.lr.ph
  %n.mod.vf = and i64 %wide.trip.count101, 7
  %85 = icmp eq i64 %n.mod.vf, 0
  %86 = select i1 %85, i64 8, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count101, %86
  br label %vector.body111

vector.body111:                                   ; preds = %vector.body111, %vector.ph109
  %index112 = phi i64 [ 0, %vector.ph109 ], [ %index.next114, %vector.body111 ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph109 ], [ %124, %vector.body111 ]
  %vec.phi113 = phi <4 x i32> [ zeroinitializer, %vector.ph109 ], [ %125, %vector.body111 ]
  %87 = or disjoint i64 %index112, 1
  %88 = or disjoint i64 %index112, 2
  %89 = or disjoint i64 %index112, 3
  %90 = or disjoint i64 %index112, 4
  %91 = or disjoint i64 %index112, 5
  %92 = or disjoint i64 %index112, 6
  %93 = or disjoint i64 %index112, 7
  %94 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %index112, i32 1
  %95 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %87, i32 1
  %96 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %88, i32 1
  %97 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %89, i32 1
  %98 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %90, i32 1
  %99 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %91, i32 1
  %100 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %92, i32 1
  %101 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %93, i32 1
  %102 = load i32, ptr %94, align 8, !tbaa !29
  %103 = load i32, ptr %95, align 8, !tbaa !29
  %104 = load i32, ptr %96, align 8, !tbaa !29
  %105 = load i32, ptr %97, align 8, !tbaa !29
  %106 = insertelement <4 x i32> poison, i32 %102, i64 0
  %107 = insertelement <4 x i32> %106, i32 %103, i64 1
  %108 = insertelement <4 x i32> %107, i32 %104, i64 2
  %109 = insertelement <4 x i32> %108, i32 %105, i64 3
  %110 = load i32, ptr %98, align 8, !tbaa !29
  %111 = load i32, ptr %99, align 8, !tbaa !29
  %112 = load i32, ptr %100, align 8, !tbaa !29
  %113 = load i32, ptr %101, align 8, !tbaa !29
  %114 = insertelement <4 x i32> poison, i32 %110, i64 0
  %115 = insertelement <4 x i32> %114, i32 %111, i64 1
  %116 = insertelement <4 x i32> %115, i32 %112, i64 2
  %117 = insertelement <4 x i32> %116, i32 %113, i64 3
  %118 = add nsw <4 x i32> %109, <i32 -1, i32 -1, i32 -1, i32 -1>
  %119 = add nsw <4 x i32> %117, <i32 -1, i32 -1, i32 -1, i32 -1>
  %120 = mul nsw <4 x i32> %118, %109
  %121 = mul nsw <4 x i32> %119, %117
  %122 = sdiv <4 x i32> %120, <i32 2, i32 2, i32 2, i32 2>
  %123 = sdiv <4 x i32> %121, <i32 2, i32 2, i32 2, i32 2>
  %124 = add <4 x i32> %122, %vec.phi
  %125 = add <4 x i32> %123, %vec.phi113
  %index.next114 = add nuw i64 %index112, 8
  %126 = icmp eq i64 %index.next114, %n.vec
  br i1 %126, label %middle.block107, label %vector.body111, !llvm.loop !31

middle.block107:                                  ; preds = %vector.body111
  %bin.rdx = add <4 x i32> %125, %124
  %127 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  br label %scalar.ph108.preheader

.preheader:                                       ; preds = %scalar.ph108
  br i1 %82, label %.lr.ph83, label %._crit_edge

.lr.ph83:                                         ; preds = %.preheader
  %128 = getelementptr inbounds i8, ptr %0, i64 24
  br label %135

scalar.ph108:                                     ; preds = %scalar.ph108.preheader, %scalar.ph108
  %indvars.iv98 = phi i64 [ %indvars.iv.next99, %scalar.ph108 ], [ %indvars.iv98.ph, %scalar.ph108.preheader ]
  %.06980 = phi i32 [ %134, %scalar.ph108 ], [ %.06980.ph, %scalar.ph108.preheader ]
  %129 = getelementptr inbounds %struct.EdgeSegment, ptr %84, i64 %indvars.iv98, i32 1
  %130 = load i32, ptr %129, align 8, !tbaa !29
  %131 = add nsw i32 %130, -1
  %132 = mul nsw i32 %131, %130
  %133 = sdiv i32 %132, 2
  %134 = add nsw i32 %133, %.06980
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %exitcond102.not = icmp eq i64 %indvars.iv.next99, %wide.trip.count101
  br i1 %exitcond102.not, label %.preheader, label %scalar.ph108, !llvm.loop !32

._crit_edge:                                      ; preds = %135, %middle.block, %.preheader
  tail call void @_Z18ExtractNewSegmentsP7EdgeMap(ptr noundef nonnull %0)
  tail call void @_ZdlPvm(ptr noundef nonnull %11, i64 noundef 8) #7
  ret void

135:                                              ; preds = %.lr.ph83, %135
  %indvars.iv103 = phi i64 [ 0, %.lr.ph83 ], [ %indvars.iv.next104, %135 ]
  %136 = load ptr, ptr %128, align 8, !tbaa !28
  %137 = getelementptr inbounds %struct.EdgeSegment, ptr %136, i64 %indvars.iv103, i32 1
  %138 = load i32, ptr %137, align 8, !tbaa !29
  %139 = add nsw i32 %138, -1
  %140 = trunc nuw nsw i64 %indvars.iv103 to i32
  tail call void @_ZL11TestSegmentP7EdgeMapPsiiiiPdd(ptr noundef nonnull %0, ptr noundef %1, i32 noundef %140, i32 noundef 0, i32 noundef %139, i32 noundef %134, ptr noundef nonnull %11, double noundef %2)
  %indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
  %141 = load i32, ptr %80, align 8, !tbaa !27
  %142 = sext i32 %141 to i64
  %143 = icmp slt i64 %indvars.iv.next104, %142
  br i1 %143, label %135, label %._crit_edge, !llvm.loop !33
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #5

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTS7EdgeMap", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}
!20 = distinct !{!20, !17}
!21 = !{!22, !22, i64 0}
!22 = !{!"double", !8, i64 0}
!23 = distinct !{!23, !17, !24, !25}
!24 = !{!"llvm.loop.isvectorized", i32 1}
!25 = !{!"llvm.loop.unroll.runtime.disable"}
!26 = distinct !{!26, !17}
!27 = !{!6, !7, i64 32}
!28 = !{!6, !10, i64 24}
!29 = !{!30, !7, i64 8}
!30 = !{!"_ZTS11EdgeSegment", !10, i64 0, !7, i64 8}
!31 = distinct !{!31, !17, !24, !25}
!32 = distinct !{!32, !17, !25, !24}
!33 = distinct !{!33, !17}


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