; LLVM IR from Yinxiaoli/iros2015_folding :: src/folding_planner/src (distancefield)

; 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.SSDFPoint = type { double, double }
%struct.SSDFGrid = type { ptr, i32, i32 }
%"struct._BlueTail::_Image::SImage" = type { i32, i32, ptr }

@_ZL5EMPTY = external hidden constant %struct.SSDFPoint, align 8
@_ZL6INSIDE = external hidden constant %struct.SSDFPoint, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { double, double } @_Z8getPointR8SSDFGridii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(16)) #0

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z15generateSDFGridR8SSDFGrid(ptr noundef nonnull align 8 dereferenceable(16)) #2

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind
declare double @sqrt(double noundef) #5

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10generateDFRKN9_BlueTail6_Image6SImageIdLi1EEERS2_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.SSDFGrid, align 8
  %6 = alloca %struct.SSDFGrid, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca %struct.SSDFPoint, align 8
  %14 = alloca double, align 8
  %15 = alloca %struct.SSDFPoint, align 8
  %16 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp ne i32 %19, %22
  br i1 %23, label %32, label %24

24:                                               ; preds = %2
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !12
  %31 = icmp ne i32 %27, %30
  br i1 %31, label %32, label %41

32:                                               ; preds = %24, %2
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !9
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !12
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call noundef i32 @_ZN9_BlueTail6_Image12reallocImageIdLi1EEEN10_BlackBill7_Result8BBRESULTEiiRNS0_6SImageIT_XT0_EEE(i32 noundef %35, i32 noundef %38, ptr noundef nonnull align 8 dereferenceable(16) %39)
  br label %41

41:                                               ; preds = %32, %24
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #7
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.SSDFGrid, ptr %5, i32 0, i32 1
  store i32 %44, ptr %45, align 8, !tbaa !13
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !12
  %49 = getelementptr inbounds %struct.SSDFGrid, ptr %5, i32 0, i32 2
  store i32 %48, ptr %49, align 4, !tbaa !15
  %50 = getelementptr inbounds %struct.SSDFGrid, ptr %5, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !13
  %52 = sext i32 %51 to i64
  %53 = mul i64 16, %52
  %54 = getelementptr inbounds %struct.SSDFGrid, ptr %5, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !15
  %56 = sext i32 %55 to i64
  %57 = mul i64 %53, %56
  %58 = call noalias ptr @malloc(i64 noundef %57) #8
  %59 = getelementptr inbounds %struct.SSDFGrid, ptr %5, i32 0, i32 0
  store ptr %58, ptr %59, align 8, !tbaa !16
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.SSDFGrid, ptr %6, i32 0, i32 1
  store i32 %62, ptr %63, align 8, !tbaa !13
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !12
  %67 = getelementptr inbounds %struct.SSDFGrid, ptr %6, i32 0, i32 2
  store i32 %66, ptr %67, align 4, !tbaa !15
  %68 = getelementptr inbounds %struct.SSDFGrid, ptr %6, i32 0, i32 1
  %69 = load i32, ptr %68, align 8, !tbaa !13
  %70 = sext i32 %69 to i64
  %71 = mul i64 16, %70
  %72 = getelementptr inbounds %struct.SSDFGrid, ptr %6, i32 0, i32 2
  %73 = load i32, ptr %72, align 4, !tbaa !15
  %74 = sext i32 %73 to i64
  %75 = mul i64 %71, %74
  %76 = call noalias ptr @malloc(i64 noundef %75) #8
  %77 = getelementptr inbounds %struct.SSDFGrid, ptr %6, i32 0, i32 0
  store ptr %76, ptr %77, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !17
  br label %78

78:                                               ; preds = %123, %41
  %79 = load i32, ptr %7, align 4, !tbaa !17
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !12
  %83 = icmp slt i32 %79, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %78
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %126

85:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !17
  br label %86

86:                                               ; preds = %119, %85
  %87 = load i32, ptr %9, align 4, !tbaa !17
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %88, i32 0, i32 0
  %90 = load i32, ptr %89, align 8, !tbaa !9
  %91 = icmp slt i32 %87, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %86
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %122

93:                                               ; preds = %86
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !18
  %97 = load i32, ptr %7, align 4, !tbaa !17
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %98, i32 0, i32 0
  %100 = load i32, ptr %99, align 8, !tbaa !9
  %101 = mul nsw i32 %97, %100
  %102 = load i32, ptr %9, align 4, !tbaa !17
  %103 = add nsw i32 %101, %102
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds double, ptr %96, i64 %104
  %106 = load double, ptr %105, align 8, !tbaa !19
  %107 = fcmp olt double %106, 5.000000e-01
  br i1 %107, label %108, label %113

108:                                              ; preds = %93
  %109 = load i32, ptr %9, align 4, !tbaa !17
  %110 = load i32, ptr %7, align 4, !tbaa !17
  call void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %109, i32 noundef %110, ptr noundef nonnull align 8 dereferenceable(16) @_ZL6INSIDE)
  %111 = load i32, ptr %9, align 4, !tbaa !17
  %112 = load i32, ptr %7, align 4, !tbaa !17
  call void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16) %6, i32 noundef %111, i32 noundef %112, ptr noundef nonnull align 8 dereferenceable(16) @_ZL5EMPTY)
  br label %118

113:                                              ; preds = %93
  %114 = load i32, ptr %9, align 4, !tbaa !17
  %115 = load i32, ptr %7, align 4, !tbaa !17
  call void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16) %6, i32 noundef %114, i32 noundef %115, ptr noundef nonnull align 8 dereferenceable(16) @_ZL6INSIDE)
  %116 = load i32, ptr %9, align 4, !tbaa !17
  %117 = load i32, ptr %7, align 4, !tbaa !17
  call void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %116, i32 noundef %117, ptr noundef nonnull align 8 dereferenceable(16) @_ZL5EMPTY)
  br label %118

118:                                              ; preds = %113, %108
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %9, align 4, !tbaa !17
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %9, align 4, !tbaa !17
  br label %86, !llvm.loop !21

122:                                              ; preds = %92
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %7, align 4, !tbaa !17
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %7, align 4, !tbaa !17
  br label %78, !llvm.loop !23

126:                                              ; preds = %84
  call void @_Z15generateSDFGridR8SSDFGrid(ptr noundef nonnull align 8 dereferenceable(16) %5)
  call void @_Z15generateSDFGridR8SSDFGrid(ptr noundef nonnull align 8 dereferenceable(16) %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !17
  br label %127

127:                                              ; preds = %182, %126
  %128 = load i32, ptr %10, align 4, !tbaa !17
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %129, i32 0, i32 1
  %131 = load i32, ptr %130, align 4, !tbaa !12
  %132 = icmp slt i32 %128, %131
  br i1 %132, label %134, label %133

133:                                              ; preds = %127
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %185

134:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !17
  br label %135

135:                                              ; preds = %178, %134
  %136 = load i32, ptr %11, align 4, !tbaa !17
  %137 = load ptr, ptr %3, align 8, !tbaa !5
  %138 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %137, i32 0, i32 0
  %139 = load i32, ptr %138, align 8, !tbaa !9
  %140 = icmp slt i32 %136, %139
  br i1 %140, label %142, label %141

141:                                              ; preds = %135
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %181

142:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #7
  %143 = load i32, ptr %11, align 4, !tbaa !17
  %144 = load i32, ptr %10, align 4, !tbaa !17
  %145 = call { double, double } @_Z8getPointR8SSDFGridii(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %143, i32 noundef %144)
  %146 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %147 = extractvalue { double, double } %145, 0
  store double %147, ptr %146, align 8
  %148 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %149 = extractvalue { double, double } %145, 1
  store double %149, ptr %148, align 8
  %150 = call noundef double @_ZNK9SSDFPoint6distSqEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  %151 = call double @sqrt(double noundef %150) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  store double %151, ptr %12, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #7
  %152 = load i32, ptr %11, align 4, !tbaa !17
  %153 = load i32, ptr %10, align 4, !tbaa !17
  %154 = call { double, double } @_Z8getPointR8SSDFGridii(ptr noundef nonnull align 8 dereferenceable(16) %6, i32 noundef %152, i32 noundef %153)
  %155 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %156 = extractvalue { double, double } %154, 0
  store double %156, ptr %155, align 8
  %157 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %158 = extractvalue { double, double } %154, 1
  store double %158, ptr %157, align 8
  %159 = call noundef double @_ZNK9SSDFPoint6distSqEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
  %160 = call double @sqrt(double noundef %159) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #7
  store double %160, ptr %14, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %161 = load double, ptr %12, align 8, !tbaa !19
  %162 = load double, ptr %14, align 8, !tbaa !19
  %163 = fsub double %161, %162
  store double %163, ptr %16, align 8, !tbaa !19
  %164 = load double, ptr %16, align 8, !tbaa !19
  %165 = call double @llvm.fabs.f64(double %164)
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %166, i32 0, i32 2
  %168 = load ptr, ptr %167, align 8, !tbaa !18
  %169 = load i32, ptr %10, align 4, !tbaa !17
  %170 = load ptr, ptr %3, align 8, !tbaa !5
  %171 = getelementptr inbounds %"struct._BlueTail::_Image::SImage", ptr %170, i32 0, i32 0
  %172 = load i32, ptr %171, align 8, !tbaa !9
  %173 = mul nsw i32 %169, %172
  %174 = load i32, ptr %11, align 4, !tbaa !17
  %175 = add nsw i32 %173, %174
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds double, ptr %168, i64 %176
  store double %165, ptr %177, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %178

178:                                              ; preds = %142
  %179 = load i32, ptr %11, align 4, !tbaa !17
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %11, align 4, !tbaa !17
  br label %135, !llvm.loop !24

181:                                              ; preds = %141
  br label %182

182:                                              ; preds = %181
  %183 = load i32, ptr %10, align 4, !tbaa !17
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %10, align 4, !tbaa !17
  br label %127, !llvm.loop !25

185:                                              ; preds = %133
  %186 = getelementptr inbounds %struct.SSDFGrid, ptr %5, i32 0, i32 0
  %187 = load ptr, ptr %186, align 8, !tbaa !16
  call void @free(ptr noundef %187) #7
  %188 = getelementptr inbounds %struct.SSDFGrid, ptr %6, i32 0, i32 0
  %189 = load ptr, ptr %188, align 8, !tbaa !16
  call void @free(ptr noundef %189) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #7
  ret void
}

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

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 = { 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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, !11, i64 0}
!10 = !{!"_ZTSN9_BlueTail6_Image6SImageIdLi1EEE", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !11, i64 8}
!14 = !{!"_ZTS8SSDFGrid", !6, i64 0, !11, i64 8, !11, i64 12}
!15 = !{!14, !11, i64 12}
!16 = !{!14, !6, i64 0}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !6, i64 8}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = distinct !{!24, !22}
!25 = distinct !{!25, !22}


; 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.SSDFPoint = type { double, double }
%struct.SSDFGrid = type { ptr, i32, i32 }

@_ZL5EMPTY = external hidden constant %struct.SSDFPoint, align 8
@_ZL6INSIDE = external hidden constant %struct.SSDFPoint, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { double, double } @_Z8getPointR8SSDFGridii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(16)) 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 nounwind uwtable
declare dso_local noundef double @_ZNK9SSDFPoint6distSqEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z15generateSDFGridR8SSDFGrid(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10generateDFRKN9_BlueTail6_Image6SImageIdLi1EEERS2_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #2 {
  %3 = alloca %struct.SSDFGrid, align 8
  %4 = alloca %struct.SSDFGrid, align 8
  %5 = alloca %struct.SSDFPoint, align 8
  %6 = alloca %struct.SSDFPoint, align 8
  %7 = load i32, ptr %0, align 8, !tbaa !5
  %8 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %7, %8
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %1, i64 4
  %12 = load i32, ptr %11, align 4
  %.not49 = icmp eq i32 %10, %12
  %or.cond = select i1 %.not, i1 %.not49, i1 false
  br i1 %or.cond, label %15, label %._crit_edge61

._crit_edge61:                                    ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  %14 = tail call noundef i32 @_ZN9_BlueTail6_Image12reallocImageIdLi1EEEN10_BlackBill7_Result8BBRESULTEiiRNS0_6SImageIT_XT0_EEE(i32 noundef %7, i32 noundef %10, ptr noundef nonnull align 8 dereferenceable(16) %1)
  %.pre62 = load i32, ptr %0, align 8, !tbaa !5
  %.pre64 = load i32, ptr %13, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %2, %._crit_edge61
  %16 = phi i32 [ %.pre64, %._crit_edge61 ], [ %10, %2 ]
  %17 = phi i32 [ %.pre62, %._crit_edge61 ], [ %7, %2 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #8
  %18 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %17, ptr %18, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %0, i64 4
  %20 = getelementptr inbounds i8, ptr %3, i64 12
  store i32 %16, ptr %20, align 4, !tbaa !14
  %21 = sext i32 %17 to i64
  %22 = shl nsw i64 %21, 4
  %23 = sext i32 %16 to i64
  %24 = mul i64 %22, %23
  %25 = tail call noalias ptr @malloc(i64 noundef %24) #9
  store ptr %25, ptr %3, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %17, ptr %26, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %4, i64 12
  store i32 %16, ptr %27, align 4, !tbaa !14
  %28 = tail call noalias ptr @malloc(i64 noundef %24) #9
  store ptr %28, ptr %4, align 8, !tbaa !15
  %29 = icmp sgt i32 %16, 0
  br i1 %29, label %.preheader50.lr.ph, label %._crit_edge53

.preheader50.lr.ph:                               ; preds = %15
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  %31 = icmp sgt i32 %17, 0
  br i1 %31, label %.preheader50, label %._crit_edge53

.preheader50:                                     ; preds = %.preheader50.lr.ph, %._crit_edge
  %32 = phi i32 [ %42, %._crit_edge ], [ %16, %.preheader50.lr.ph ]
  %33 = phi i32 [ %43, %._crit_edge ], [ %17, %.preheader50.lr.ph ]
  %.052 = phi i32 [ %44, %._crit_edge ], [ 0, %.preheader50.lr.ph ]
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %.lr.ph, label %._crit_edge

._crit_edge53:                                    ; preds = %._crit_edge, %.preheader50.lr.ph, %15
  call void @_Z15generateSDFGridR8SSDFGrid(ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @_Z15generateSDFGridR8SSDFGrid(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %35 = load i32, ptr %19, align 4, !tbaa !11
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.preheader.lr.ph, label %._crit_edge58

.preheader.lr.ph:                                 ; preds = %._crit_edge53
  %37 = getelementptr inbounds i8, ptr %5, i64 8
  %38 = getelementptr inbounds i8, ptr %6, i64 8
  %39 = getelementptr inbounds i8, ptr %1, i64 8
  %40 = load i32, ptr %0, align 8, !tbaa !5
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %.preheader, label %._crit_edge58

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre68 = load i32, ptr %19, align 4, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader50
  %42 = phi i32 [ %.pre68, %._crit_edge.loopexit ], [ %32, %.preheader50 ]
  %43 = phi i32 [ %55, %._crit_edge.loopexit ], [ %33, %.preheader50 ]
  %44 = add nuw nsw i32 %.052, 1
  %45 = icmp slt i32 %44, %42
  br i1 %45, label %.preheader50, label %._crit_edge53, !llvm.loop !16

.lr.ph:                                           ; preds = %.preheader50, %.lr.ph
  %46 = phi i32 [ %55, %.lr.ph ], [ %33, %.preheader50 ]
  %.04551 = phi i32 [ %54, %.lr.ph ], [ 0, %.preheader50 ]
  %47 = load ptr, ptr %30, align 8, !tbaa !19
  %48 = mul nsw i32 %46, %.052
  %49 = add nsw i32 %48, %.04551
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds double, ptr %47, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !20
  %53 = fcmp olt double %52, 5.000000e-01
  %. = select i1 %53, ptr %3, ptr %4
  %.72 = select i1 %53, ptr %4, ptr %3
  call void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16) %., i32 noundef %.04551, i32 noundef %.052, ptr noundef nonnull align 8 dereferenceable(16) @_ZL6INSIDE)
  call void @_Z8putPointR8SSDFGridiiRK9SSDFPoint(ptr noundef nonnull align 8 dereferenceable(16) %.72, i32 noundef %.04551, i32 noundef %.052, ptr noundef nonnull align 8 dereferenceable(16) @_ZL5EMPTY)
  %54 = add nuw nsw i32 %.04551, 1
  %55 = load i32, ptr %0, align 8, !tbaa !5
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !22

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge56
  %57 = phi i32 [ %62, %._crit_edge56 ], [ %35, %.preheader.lr.ph ]
  %58 = phi i32 [ %63, %._crit_edge56 ], [ %40, %.preheader.lr.ph ]
  %.04757 = phi i32 [ %64, %._crit_edge56 ], [ 0, %.preheader.lr.ph ]
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %.lr.ph55, label %._crit_edge56

._crit_edge58:                                    ; preds = %._crit_edge56, %.preheader.lr.ph, %._crit_edge53
  %60 = load ptr, ptr %3, align 8, !tbaa !15
  call void @free(ptr noundef %60) #8
  %61 = load ptr, ptr %4, align 8, !tbaa !15
  call void @free(ptr noundef %61) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #8
  ret void

._crit_edge56.loopexit:                           ; preds = %.lr.ph55
  %.pre67 = load i32, ptr %19, align 4, !tbaa !11
  br label %._crit_edge56

._crit_edge56:                                    ; preds = %._crit_edge56.loopexit, %.preheader
  %62 = phi i32 [ %.pre67, %._crit_edge56.loopexit ], [ %57, %.preheader ]
  %63 = phi i32 [ %79, %._crit_edge56.loopexit ], [ %58, %.preheader ]
  %64 = add nuw nsw i32 %.04757, 1
  %65 = icmp slt i32 %64, %62
  br i1 %65, label %.preheader, label %._crit_edge58, !llvm.loop !23

.lr.ph55:                                         ; preds = %.preheader, %.lr.ph55
  %.04654 = phi i32 [ %84, %.lr.ph55 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #8
  %66 = call { double, double } @_Z8getPointR8SSDFGridii(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.04654, i32 noundef %.04757)
  %67 = extractvalue { double, double } %66, 0
  store double %67, ptr %5, align 8
  %68 = extractvalue { double, double } %66, 1
  store double %68, ptr %37, align 8
  %69 = call noundef double @_ZNK9SSDFPoint6distSqEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %70 = call double @sqrt(double noundef %69) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #8
  %71 = call { double, double } @_Z8getPointR8SSDFGridii(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %.04654, i32 noundef %.04757)
  %72 = extractvalue { double, double } %71, 0
  store double %72, ptr %6, align 8
  %73 = extractvalue { double, double } %71, 1
  store double %73, ptr %38, align 8
  %74 = call noundef double @_ZNK9SSDFPoint6distSqEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
  %75 = call double @sqrt(double noundef %74) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #8
  %76 = fsub double %70, %75
  %77 = call double @llvm.fabs.f64(double %76)
  %78 = load ptr, ptr %39, align 8, !tbaa !19
  %79 = load i32, ptr %0, align 8, !tbaa !5
  %80 = mul nsw i32 %79, %.04757
  %81 = add nsw i32 %80, %.04654
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds double, ptr %78, i64 %82
  store double %77, ptr %83, align 8, !tbaa !20
  %84 = add nuw nsw i32 %.04654, 1
  %85 = icmp slt i32 %84, %79
  br i1 %85, label %.lr.ph55, label %._crit_edge56.loopexit, !llvm.loop !24
}

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

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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nofree nounwind willreturn memory(write) "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }

!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 = !{!"_ZTSN9_BlueTail6_Image6SImageIdLi1EEE", !7, i64 0, !7, i64 4, !10, i64 8}
!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 = !{!13, !7, i64 8}
!13 = !{!"_ZTS8SSDFGrid", !10, i64 0, !7, i64 8, !7, i64 12}
!14 = !{!13, !7, i64 12}
!15 = !{!13, !10, i64 0}
!16 = distinct !{!16, !17, !18}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{!6, !10, i64 8}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !8, i64 0}
!22 = distinct !{!22, !17}
!23 = distinct !{!23, !17, !18}
!24 = distinct !{!24, !17}


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