; LLVM IR from fcimeson/cbTSP :: cbLKH/SRC (SolveKarpSubproblems)

; 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.Node = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double, double, double, double, double, double, i8, i8, i8 }

@GlobalBestCost = external hidden global i64, align 8
@FirstNode = external dso_local global ptr, align 8
@Distance = external dso_local global ptr, align 8
@TraceLevel = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [41 x i8], align 1
@WeightType = external dso_local global i32, align 4
@CoordType = external dso_local global i32, align 4
@SubproblemSize = external dso_local global i32, align 4
@KDTree = external hidden global ptr, align 8
@Subproblems = external hidden global i32, align 4
@Dimension = external dso_local global i32, align 4
@CurrentSubproblem = external hidden global i32, align 4
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@Optimum = external dso_local global i64, align 8
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [1 x i8], align 1
@SubproblemBorders = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @SolveKarpSubproblems() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %3 = call double @GetTime()
  store double %3, ptr %2, align 8, !tbaa !5
  call void @AllocateStructures()
  %4 = call i32 @ReadPenalties()
  store i64 0, ptr @GlobalBestCost, align 8, !tbaa !9
  %5 = load ptr, ptr @FirstNode, align 8, !tbaa !11
  store ptr %5, ptr %1, align 8, !tbaa !11
  br label %6

6:                                                ; preds = %35, %0
  %7 = load ptr, ptr %1, align 8, !tbaa !11
  %8 = getelementptr inbounds %struct.Node, ptr %7, i32 0, i32 26
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = load ptr, ptr %1, align 8, !tbaa !11
  %11 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 35
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  %13 = icmp eq ptr %9, %12
  br i1 %13, label %32, label %14

14:                                               ; preds = %6
  %15 = load ptr, ptr %1, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.Node, ptr %15, i32 0, i32 27
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = load ptr, ptr %1, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.Node, ptr %18, i32 0, i32 35
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = icmp eq ptr %17, %20
  br i1 %21, label %32, label %22

22:                                               ; preds = %14
  %23 = load ptr, ptr @Distance, align 8, !tbaa !11
  %24 = load ptr, ptr %1, align 8, !tbaa !11
  %25 = load ptr, ptr %1, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.Node, ptr %25, i32 0, i32 35
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = call i32 %23(ptr noundef %24, ptr noundef %27)
  %29 = sext i32 %28 to i64
  %30 = load i64, ptr @GlobalBestCost, align 8, !tbaa !9
  %31 = add nsw i64 %30, %29
  store i64 %31, ptr @GlobalBestCost, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %22, %14, %6
  %33 = load ptr, ptr %1, align 8, !tbaa !11
  %34 = getelementptr inbounds %struct.Node, ptr %33, i32 0, i32 12
  store i32 0, ptr %34, align 8, !tbaa !18
  br label %35

35:                                               ; preds = %32
  %36 = load ptr, ptr %1, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.Node, ptr %36, i32 0, i32 35
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  store ptr %38, ptr %1, align 8, !tbaa !11
  %39 = load ptr, ptr @FirstNode, align 8, !tbaa !11
  %40 = icmp ne ptr %38, %39
  br i1 %40, label %6, label %41, !llvm.loop !19

41:                                               ; preds = %35
  %42 = load i32, ptr @TraceLevel, align 4, !tbaa !21
  %43 = icmp sge i32 %42, 1
  br i1 %43, label %44, label %50

44:                                               ; preds = %41
  %45 = load i32, ptr @TraceLevel, align 4, !tbaa !21
  %46 = icmp sge i32 %45, 2
  br i1 %46, label %47, label %48

47:                                               ; preds = %44
  call void (ptr, ...) @printff(ptr noundef @.str)
  br label %48

48:                                               ; preds = %47, %44
  %49 = load i64, ptr @GlobalBestCost, align 8, !tbaa !9
  call void (ptr, ...) @printff(ptr noundef @.str.1, i64 noundef %49)
  br label %50

50:                                               ; preds = %48, %41
  %51 = load i32, ptr @WeightType, align 4, !tbaa !21
  %52 = icmp eq i32 %51, 9
  br i1 %52, label %62, label %53

53:                                               ; preds = %50
  %54 = load i32, ptr @WeightType, align 4, !tbaa !21
  %55 = icmp eq i32 %54, 10
  br i1 %55, label %62, label %56

56:                                               ; preds = %53
  %57 = load i32, ptr @WeightType, align 4, !tbaa !21
  %58 = icmp eq i32 %57, 11
  br i1 %58, label %62, label %59

59:                                               ; preds = %56
  %60 = load i32, ptr @WeightType, align 4, !tbaa !21
  %61 = icmp eq i32 %60, 12
  br i1 %61, label %62, label %119

62:                                               ; preds = %59, %56, %53, %50
  %63 = load ptr, ptr @FirstNode, align 8, !tbaa !11
  store ptr %63, ptr %1, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %112, %62
  %65 = load ptr, ptr %1, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct.Node, ptr %65, i32 0, i32 46
  %67 = load double, ptr %66, align 8, !tbaa !22
  %68 = load ptr, ptr %1, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.Node, ptr %68, i32 0, i32 49
  store double %67, ptr %69, align 8, !tbaa !23
  %70 = load ptr, ptr %1, align 8, !tbaa !11
  %71 = getelementptr inbounds %struct.Node, ptr %70, i32 0, i32 47
  %72 = load double, ptr %71, align 8, !tbaa !24
  %73 = load ptr, ptr %1, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.Node, ptr %73, i32 0, i32 50
  store double %72, ptr %74, align 8, !tbaa !25
  %75 = load ptr, ptr %1, align 8, !tbaa !11
  %76 = getelementptr inbounds %struct.Node, ptr %75, i32 0, i32 48
  %77 = load double, ptr %76, align 8, !tbaa !26
  %78 = load ptr, ptr %1, align 8, !tbaa !11
  %79 = getelementptr inbounds %struct.Node, ptr %78, i32 0, i32 51
  store double %77, ptr %79, align 8, !tbaa !27
  %80 = load i32, ptr @WeightType, align 4, !tbaa !21
  %81 = icmp eq i32 %80, 9
  br i1 %81, label %85, label %82

82:                                               ; preds = %64
  %83 = load i32, ptr @WeightType, align 4, !tbaa !21
  %84 = icmp eq i32 %83, 11
  br i1 %84, label %85, label %98

85:                                               ; preds = %82, %64
  %86 = load ptr, ptr %1, align 8, !tbaa !11
  %87 = getelementptr inbounds %struct.Node, ptr %86, i32 0, i32 49
  %88 = load double, ptr %87, align 8, !tbaa !23
  %89 = load ptr, ptr %1, align 8, !tbaa !11
  %90 = getelementptr inbounds %struct.Node, ptr %89, i32 0, i32 50
  %91 = load double, ptr %90, align 8, !tbaa !25
  %92 = load ptr, ptr %1, align 8, !tbaa !11
  %93 = getelementptr inbounds %struct.Node, ptr %92, i32 0, i32 46
  %94 = load ptr, ptr %1, align 8, !tbaa !11
  %95 = getelementptr inbounds %struct.Node, ptr %94, i32 0, i32 47
  %96 = load ptr, ptr %1, align 8, !tbaa !11
  %97 = getelementptr inbounds %struct.Node, ptr %96, i32 0, i32 48
  call void @GEO2XYZ(double noundef %88, double noundef %91, ptr noundef %93, ptr noundef %95, ptr noundef %97)
  br label %111

98:                                               ; preds = %82
  %99 = load ptr, ptr %1, align 8, !tbaa !11
  %100 = getelementptr inbounds %struct.Node, ptr %99, i32 0, i32 49
  %101 = load double, ptr %100, align 8, !tbaa !23
  %102 = load ptr, ptr %1, align 8, !tbaa !11
  %103 = getelementptr inbounds %struct.Node, ptr %102, i32 0, i32 50
  %104 = load double, ptr %103, align 8, !tbaa !25
  %105 = load ptr, ptr %1, align 8, !tbaa !11
  %106 = getelementptr inbounds %struct.Node, ptr %105, i32 0, i32 46
  %107 = load ptr, ptr %1, align 8, !tbaa !11
  %108 = getelementptr inbounds %struct.Node, ptr %107, i32 0, i32 47
  %109 = load ptr, ptr %1, align 8, !tbaa !11
  %110 = getelementptr inbounds %struct.Node, ptr %109, i32 0, i32 48
  call void @GEOM2XYZ(double noundef %101, double noundef %104, ptr noundef %106, ptr noundef %108, ptr noundef %110)
  br label %111

111:                                              ; preds = %98, %85
  br label %112

112:                                              ; preds = %111
  %113 = load ptr, ptr %1, align 8, !tbaa !11
  %114 = getelementptr inbounds %struct.Node, ptr %113, i32 0, i32 35
  %115 = load ptr, ptr %114, align 8, !tbaa !16
  store ptr %115, ptr %1, align 8, !tbaa !11
  %116 = load ptr, ptr @FirstNode, align 8, !tbaa !11
  %117 = icmp ne ptr %115, %116
  br i1 %117, label %64, label %118, !llvm.loop !28

118:                                              ; preds = %112
  store i32 1, ptr @CoordType, align 4, !tbaa !21
  br label %119

119:                                              ; preds = %118, %59
  %120 = load i32, ptr @SubproblemSize, align 4, !tbaa !21
  %121 = call ptr @BuildKDTree(i32 noundef %120)
  store ptr %121, ptr @KDTree, align 8, !tbaa !11
  %122 = load i32, ptr @WeightType, align 4, !tbaa !21
  %123 = icmp eq i32 %122, 9
  br i1 %123, label %133, label %124

124:                                              ; preds = %119
  %125 = load i32, ptr @WeightType, align 4, !tbaa !21
  %126 = icmp eq i32 %125, 10
  br i1 %126, label %133, label %127

127:                                              ; preds = %124
  %128 = load i32, ptr @WeightType, align 4, !tbaa !21
  %129 = icmp eq i32 %128, 11
  br i1 %129, label %133, label %130

130:                                              ; preds = %127
  %131 = load i32, ptr @WeightType, align 4, !tbaa !21
  %132 = icmp eq i32 %131, 12
  br i1 %132, label %133, label %158

133:                                              ; preds = %130, %127, %124, %119
  %134 = load ptr, ptr @FirstNode, align 8, !tbaa !11
  store ptr %134, ptr %1, align 8, !tbaa !11
  br label %135

135:                                              ; preds = %151, %133
  %136 = load ptr, ptr %1, align 8, !tbaa !11
  %137 = getelementptr inbounds %struct.Node, ptr %136, i32 0, i32 49
  %138 = load double, ptr %137, align 8, !tbaa !23
  %139 = load ptr, ptr %1, align 8, !tbaa !11
  %140 = getelementptr inbounds %struct.Node, ptr %139, i32 0, i32 46
  store double %138, ptr %140, align 8, !tbaa !22
  %141 = load ptr, ptr %1, align 8, !tbaa !11
  %142 = getelementptr inbounds %struct.Node, ptr %141, i32 0, i32 50
  %143 = load double, ptr %142, align 8, !tbaa !25
  %144 = load ptr, ptr %1, align 8, !tbaa !11
  %145 = getelementptr inbounds %struct.Node, ptr %144, i32 0, i32 47
  store double %143, ptr %145, align 8, !tbaa !24
  %146 = load ptr, ptr %1, align 8, !tbaa !11
  %147 = getelementptr inbounds %struct.Node, ptr %146, i32 0, i32 51
  %148 = load double, ptr %147, align 8, !tbaa !27
  %149 = load ptr, ptr %1, align 8, !tbaa !11
  %150 = getelementptr inbounds %struct.Node, ptr %149, i32 0, i32 48
  store double %148, ptr %150, align 8, !tbaa !26
  br label %151

151:                                              ; preds = %135
  %152 = load ptr, ptr %1, align 8, !tbaa !11
  %153 = getelementptr inbounds %struct.Node, ptr %152, i32 0, i32 35
  %154 = load ptr, ptr %153, align 8, !tbaa !16
  store ptr %154, ptr %1, align 8, !tbaa !11
  %155 = load ptr, ptr @FirstNode, align 8, !tbaa !11
  %156 = icmp ne ptr %154, %155
  br i1 %156, label %135, label %157, !llvm.loop !29

157:                                              ; preds = %151
  store i32 0, ptr @CoordType, align 4, !tbaa !21
  br label %158

158:                                              ; preds = %157, %130
  store i32 0, ptr @Subproblems, align 4, !tbaa !21
  %159 = load i32, ptr @Dimension, align 4, !tbaa !21
  %160 = sub nsw i32 %159, 1
  call void @CalculateSubproblems(i32 noundef 0, i32 noundef %160)
  store i32 0, ptr @CurrentSubproblem, align 4, !tbaa !21
  %161 = load i32, ptr @Dimension, align 4, !tbaa !21
  %162 = sub nsw i32 %161, 1
  call void @KarpPartition(i32 noundef 0, i32 noundef %162)
  %163 = load ptr, ptr @KDTree, align 8, !tbaa !11
  call void @free(ptr noundef %163) #5
  %164 = load i64, ptr @GlobalBestCost, align 8, !tbaa !9
  call void (ptr, ...) @printff(ptr noundef @.str.2, i64 noundef %164)
  %165 = load i64, ptr @Optimum, align 8, !tbaa !9
  %166 = icmp ne i64 %165, -9223372036854775808
  br i1 %166, label %167, label %179

167:                                              ; preds = %158
  %168 = load i64, ptr @Optimum, align 8, !tbaa !9
  %169 = icmp ne i64 %168, 0
  br i1 %169, label %170, label %179

170:                                              ; preds = %167
  %171 = load i64, ptr @GlobalBestCost, align 8, !tbaa !9
  %172 = load i64, ptr @Optimum, align 8, !tbaa !9
  %173 = sub nsw i64 %171, %172
  %174 = sitofp i64 %173 to double
  %175 = fmul double 1.000000e+02, %174
  %176 = load i64, ptr @Optimum, align 8, !tbaa !9
  %177 = sitofp i64 %176 to double
  %178 = fdiv double %175, %177
  call void (ptr, ...) @printff(ptr noundef @.str.3, double noundef %178)
  br label %179

179:                                              ; preds = %170, %167, %158
  %180 = call double @GetTime()
  %181 = load double, ptr %2, align 8, !tbaa !5
  %182 = fsub double %180, %181
  %183 = call double @llvm.fabs.f64(double %182)
  %184 = load i64, ptr @GlobalBestCost, align 8, !tbaa !9
  %185 = load i64, ptr @Optimum, align 8, !tbaa !9
  %186 = icmp slt i64 %184, %185
  br i1 %186, label %187, label %188

187:                                              ; preds = %179
  br label %194

188:                                              ; preds = %179
  %189 = load i64, ptr @GlobalBestCost, align 8, !tbaa !9
  %190 = load i64, ptr @Optimum, align 8, !tbaa !9
  %191 = icmp eq i64 %189, %190
  %192 = zext i1 %191 to i64
  %193 = select i1 %191, ptr @.str.6, ptr @.str.7
  br label %194

194:                                              ; preds = %188, %187
  %195 = phi ptr [ @.str.5, %187 ], [ %193, %188 ]
  call void (ptr, ...) @printff(ptr noundef @.str.4, double noundef %183, ptr noundef %195)
  %196 = load i32, ptr @SubproblemBorders, align 4, !tbaa !21
  %197 = icmp ne i32 %196, 0
  br i1 %197, label %198, label %203

198:                                              ; preds = %194
  %199 = load i32, ptr @Subproblems, align 4, !tbaa !21
  %200 = icmp sgt i32 %199, 1
  br i1 %200, label %201, label %203

201:                                              ; preds = %198
  %202 = load i32, ptr @Subproblems, align 4, !tbaa !21
  call void @SolveSubproblemBorderProblems(i32 noundef %202, ptr noundef @GlobalBestCost)
  br label %203

203:                                              ; preds = %201, %198, %194
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret void
}

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

declare double @GetTime() #2

declare void @AllocateStructures() #2

declare i32 @ReadPenalties() #2

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

declare void @GEO2XYZ(double noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @GEOM2XYZ(double noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @BuildKDTree(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @CalculateSubproblems(i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @KarpPartition(i32 noundef, i32 noundef) #0

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

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

declare void @SolveSubproblemBorderProblems(i32 noundef, ptr noundef) #2

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 152}
!14 = !{!"Node", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !12, i64 224, !12, i64 232, !12, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !12, i64 272, !12, i64 280, !12, i64 288, !12, i64 296, !12, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !7, i64 360, !7, i64 361, !7, i64 362}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !12, i64 224}
!17 = !{!14, !12, i64 160}
!18 = !{!14, !15, i64 48}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!15, !15, i64 0}
!22 = !{!14, !6, i64 312}
!23 = !{!14, !6, i64 336}
!24 = !{!14, !6, i64 320}
!25 = !{!14, !6, i64 344}
!26 = !{!14, !6, i64 328}
!27 = !{!14, !6, i64 352}
!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"

@GlobalBestCost = external hidden global i64, align 8
@FirstNode = external dso_local local_unnamed_addr global ptr, align 8
@Distance = external dso_local local_unnamed_addr global ptr, align 8
@TraceLevel = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [41 x i8], align 1
@WeightType = external dso_local local_unnamed_addr global i32, align 4
@CoordType = external dso_local local_unnamed_addr global i32, align 4
@SubproblemSize = external dso_local local_unnamed_addr global i32, align 4
@KDTree = external hidden local_unnamed_addr global ptr, align 8
@Subproblems = external hidden local_unnamed_addr global i32, align 4
@Dimension = external dso_local local_unnamed_addr global i32, align 4
@CurrentSubproblem = external hidden local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@Optimum = external dso_local local_unnamed_addr global i64, align 8
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [1 x i8], align 1
@SubproblemBorders = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @SolveKarpSubproblems() local_unnamed_addr #0 {
  %1 = tail call double @GetTime() #4
  tail call void @AllocateStructures() #4
  %2 = tail call i32 @ReadPenalties() #4
  store i64 0, ptr @GlobalBestCost, align 8, !tbaa !5
  %3 = load ptr, ptr @FirstNode, align 8, !tbaa !9
  br label %4

4:                                                ; preds = %22, %0
  %5 = phi i64 [ 0, %0 ], [ %23, %22 ]
  %6 = phi ptr [ %3, %0 ], [ %24, %22 ]
  %.0 = phi ptr [ %3, %0 ], [ %25, %22 ]
  %7 = getelementptr inbounds i8, ptr %.0, i64 152
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %.0, i64 224
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = icmp eq ptr %8, %10
  br i1 %11, label %22, label %12

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %.0, i64 160
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = icmp eq ptr %14, %10
  br i1 %15, label %22, label %16

16:                                               ; preds = %12
  %17 = load ptr, ptr @Distance, align 8, !tbaa !9
  %18 = tail call i32 %17(ptr noundef nonnull %.0, ptr noundef %10) #4
  %19 = sext i32 %18 to i64
  %20 = load i64, ptr @GlobalBestCost, align 8, !tbaa !5
  %21 = add nsw i64 %20, %19
  store i64 %21, ptr @GlobalBestCost, align 8, !tbaa !5
  %.pre = load ptr, ptr %9, align 8, !tbaa !15
  %.pre61 = load ptr, ptr @FirstNode, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %16, %12, %4
  %23 = phi i64 [ %21, %16 ], [ %5, %12 ], [ %5, %4 ]
  %24 = phi ptr [ %.pre61, %16 ], [ %6, %12 ], [ %6, %4 ]
  %25 = phi ptr [ %.pre, %16 ], [ %10, %12 ], [ %10, %4 ]
  %26 = getelementptr inbounds i8, ptr %.0, i64 48
  store i32 0, ptr %26, align 8, !tbaa !17
  %.not = icmp eq ptr %25, %24
  br i1 %.not, label %27, label %4, !llvm.loop !18

27:                                               ; preds = %22
  %28 = load i32, ptr @TraceLevel, align 4, !tbaa !20
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %34

30:                                               ; preds = %27
  %.not58 = icmp eq i32 %28, 1
  br i1 %.not58, label %32, label %31

31:                                               ; preds = %30
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str) #4
  %.pre62 = load i64, ptr @GlobalBestCost, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %31, %30
  %33 = phi i64 [ %.pre62, %31 ], [ %23, %30 ]
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.1, i64 noundef %33) #4
  br label %34

34:                                               ; preds = %32, %27
  %35 = load i32, ptr @WeightType, align 4
  %36 = add i32 %35, -9
  %or.cond5 = icmp ult i32 %36, 4
  br i1 %or.cond5, label %37, label %60

37:                                               ; preds = %34
  %38 = load ptr, ptr @FirstNode, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %55, %37
  %.1 = phi ptr [ %38, %37 ], [ %57, %55 ]
  %40 = getelementptr inbounds i8, ptr %.1, i64 312
  %41 = getelementptr inbounds i8, ptr %.1, i64 336
  %42 = getelementptr inbounds i8, ptr %.1, i64 320
  %43 = load <2 x double>, ptr %40, align 8, !tbaa !21
  store <2 x double> %43, ptr %41, align 8, !tbaa !21
  %44 = getelementptr inbounds i8, ptr %.1, i64 328
  %45 = load double, ptr %44, align 8, !tbaa !22
  %46 = getelementptr inbounds i8, ptr %.1, i64 352
  store double %45, ptr %46, align 8, !tbaa !23
  %47 = load i32, ptr @WeightType, align 4
  %48 = and i32 %47, -3
  %or.cond7 = icmp eq i32 %48, 9
  br i1 %or.cond7, label %49, label %52

49:                                               ; preds = %39
  %50 = extractelement <2 x double> %43, i64 0
  %51 = extractelement <2 x double> %43, i64 1
  tail call void @GEO2XYZ(double noundef %50, double noundef %51, ptr noundef nonnull %40, ptr noundef nonnull %42, ptr noundef nonnull %44) #4
  br label %55

52:                                               ; preds = %39
  %53 = extractelement <2 x double> %43, i64 0
  %54 = extractelement <2 x double> %43, i64 1
  tail call void @GEOM2XYZ(double noundef %53, double noundef %54, ptr noundef nonnull %40, ptr noundef nonnull %42, ptr noundef nonnull %44) #4
  br label %55

55:                                               ; preds = %49, %52
  %56 = getelementptr inbounds i8, ptr %.1, i64 224
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = load ptr, ptr @FirstNode, align 8, !tbaa !9
  %.not59 = icmp eq ptr %57, %58
  br i1 %.not59, label %59, label %39, !llvm.loop !24

59:                                               ; preds = %55
  store i32 1, ptr @CoordType, align 4, !tbaa !20
  br label %60

60:                                               ; preds = %34, %59
  %61 = load i32, ptr @SubproblemSize, align 4, !tbaa !20
  %62 = tail call ptr @BuildKDTree(i32 noundef %61) #4
  store ptr %62, ptr @KDTree, align 8, !tbaa !9
  %63 = load i32, ptr @WeightType, align 4
  %64 = add i32 %63, -9
  %or.cond13 = icmp ult i32 %64, 4
  br i1 %or.cond13, label %65, label %77

65:                                               ; preds = %60
  %66 = load ptr, ptr @FirstNode, align 8, !tbaa !9
  br label %67

67:                                               ; preds = %67, %65
  %.2 = phi ptr [ %66, %65 ], [ %75, %67 ]
  %68 = getelementptr inbounds i8, ptr %.2, i64 336
  %69 = getelementptr inbounds i8, ptr %.2, i64 312
  %70 = load <2 x double>, ptr %68, align 8, !tbaa !21
  store <2 x double> %70, ptr %69, align 8, !tbaa !21
  %71 = getelementptr inbounds i8, ptr %.2, i64 352
  %72 = load double, ptr %71, align 8, !tbaa !23
  %73 = getelementptr inbounds i8, ptr %.2, i64 328
  store double %72, ptr %73, align 8, !tbaa !22
  %74 = getelementptr inbounds i8, ptr %.2, i64 224
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  %.not60 = icmp eq ptr %75, %66
  br i1 %.not60, label %76, label %67, !llvm.loop !25

76:                                               ; preds = %67
  store i32 0, ptr @CoordType, align 4, !tbaa !20
  br label %77

77:                                               ; preds = %60, %76
  store i32 0, ptr @Subproblems, align 4, !tbaa !20
  %78 = load i32, ptr @Dimension, align 4, !tbaa !20
  %79 = add nsw i32 %78, -1
  tail call void @CalculateSubproblems(i32 noundef 0, i32 noundef %79)
  store i32 0, ptr @CurrentSubproblem, align 4, !tbaa !20
  %80 = load i32, ptr @Dimension, align 4, !tbaa !20
  %81 = add nsw i32 %80, -1
  tail call void @KarpPartition(i32 noundef 0, i32 noundef %81)
  %82 = load ptr, ptr @KDTree, align 8, !tbaa !9
  tail call void @free(ptr noundef %82) #4
  %83 = load i64, ptr @GlobalBestCost, align 8, !tbaa !5
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.2, i64 noundef %83) #4
  %84 = load i64, ptr @Optimum, align 8
  %85 = and i64 %84, 9223372036854775807
  %or.cond15.not = icmp eq i64 %85, 0
  br i1 %or.cond15.not, label %93, label %86

86:                                               ; preds = %77
  %87 = load i64, ptr @GlobalBestCost, align 8, !tbaa !5
  %88 = sub nsw i64 %87, %84
  %89 = sitofp i64 %88 to double
  %90 = fmul double %89, 1.000000e+02
  %91 = sitofp i64 %84 to double
  %92 = fdiv double %90, %91
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.3, double noundef %92) #4
  br label %93

93:                                               ; preds = %86, %77
  %94 = tail call double @GetTime() #4
  %95 = fsub double %94, %1
  %96 = tail call double @llvm.fabs.f64(double %95)
  %97 = load i64, ptr @GlobalBestCost, align 8, !tbaa !5
  %98 = load i64, ptr @Optimum, align 8, !tbaa !5
  %99 = icmp slt i64 %97, %98
  %100 = icmp eq i64 %97, %98
  %101 = select i1 %100, ptr @.str.6, ptr @.str.7
  %102 = select i1 %99, ptr @.str.5, ptr %101
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.4, double noundef %96, ptr noundef nonnull %102) #4
  %103 = load i32, ptr @SubproblemBorders, align 4, !tbaa !20
  %104 = icmp ne i32 %103, 0
  %105 = load i32, ptr @Subproblems, align 4
  %106 = icmp sgt i32 %105, 1
  %or.cond17 = select i1 %104, i1 %106, i1 false
  br i1 %or.cond17, label %107, label %108

107:                                              ; preds = %93
  tail call void @SolveSubproblemBorderProblems(i32 noundef %105, ptr noundef nonnull @GlobalBestCost) #4
  br label %108

108:                                              ; preds = %107, %93
  ret void
}

declare double @GetTime() local_unnamed_addr #1

declare void @AllocateStructures() local_unnamed_addr #1

declare i32 @ReadPenalties() local_unnamed_addr #1

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

declare void @GEO2XYZ(double noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @GEOM2XYZ(double noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @BuildKDTree(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @CalculateSubproblems(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @KarpPartition(i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

declare void @SolveSubproblemBorderProblems(i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 152}
!12 = !{!"Node", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !14, i64 312, !14, i64 320, !14, i64 328, !14, i64 336, !14, i64 344, !14, i64 352, !7, i64 360, !7, i64 361, !7, i64 362}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!12, !10, i64 224}
!16 = !{!12, !10, i64 160}
!17 = !{!12, !13, i64 48}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!13, !13, i64 0}
!21 = !{!14, !14, i64 0}
!22 = !{!12, !14, i64 328}
!23 = !{!12, !14, i64 352}
!24 = distinct !{!24, !19}
!25 = distinct !{!25, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass