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

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

@RestrictedSearch = external dso_local global i32, align 4
@TraceLevel = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [36 x i8], align 1
@FirstNode = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @SolveCompressedSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %12 = load i32, ptr @RestrictedSearch, align 4, !tbaa !5
  store i32 %12, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %13 = load ptr, ptr %6, align 8, !tbaa !9
  %14 = load i64, ptr %13, align 8, !tbaa !11
  store i64 %14, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = srem i32 %15, %16
  store i32 %17, ptr %8, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %3
  %20 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %20, ptr %8, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %19, %3
  store i32 0, ptr @RestrictedSearch, align 4, !tbaa !5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %46, %21
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = icmp sle i32 %23, 10
  br i1 %24, label %25, label %30

25:                                               ; preds = %22
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = load i64, ptr %26, align 8, !tbaa !11
  %28 = load i64, ptr %10, align 8, !tbaa !11
  %29 = icmp eq i64 %27, %28
  br label %30

30:                                               ; preds = %25, %22
  %31 = phi i1 [ false, %22 ], [ %29, %25 ]
  br i1 %31, label %32, label %49

32:                                               ; preds = %30
  %33 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %34 = icmp sge i32 %33, 1
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !5
  call void (ptr, ...) @printff(ptr noundef @.str, i32 noundef %36, i32 noundef %37)
  br label %38

38:                                               ; preds = %35, %32
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  %42 = call i32 @SolveSubproblem(i32 noundef %39, i32 noundef %40, ptr noundef %41)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  br label %49

45:                                               ; preds = %38
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %7, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %7, align 4, !tbaa !5
  br label %22, !llvm.loop !13

49:                                               ; preds = %44, %30
  %50 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %50, ptr @RestrictedSearch, align 4, !tbaa !5
  %51 = load ptr, ptr @FirstNode, align 8, !tbaa !9
  store ptr %51, ptr %11, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %59, %49
  %53 = load ptr, ptr %11, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.Node, ptr %53, i32 0, i32 12
  %55 = load i32, ptr %54, align 8, !tbaa !15
  %56 = call i32 @llvm.abs.i32(i32 %55, i1 true)
  %57 = load ptr, ptr %11, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.Node, ptr %57, i32 0, i32 12
  store i32 %56, ptr %58, align 8, !tbaa !15
  br label %59

59:                                               ; preds = %52
  %60 = load ptr, ptr %11, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.Node, ptr %60, i32 0, i32 16
  %62 = load ptr, ptr %61, align 8, !tbaa !18
  store ptr %62, ptr %11, align 8, !tbaa !9
  %63 = load ptr, ptr @FirstNode, align 8, !tbaa !9
  %64 = icmp ne ptr %62, %63
  br i1 %64, label %52, label %65, !llvm.loop !19

65:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

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

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

declare i32 @SolveSubproblem(i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

; 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 = { 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 = !{!"int", !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, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 48}
!16 = !{!"Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, 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, !17, i64 312, !17, i64 320, !17, i64 328, !17, i64 336, !17, i64 344, !17, i64 352, !7, i64 360, !7, i64 361, !7, i64 362}
!17 = !{!"double", !7, i64 0}
!18 = !{!16, !10, i64 72}
!19 = distinct !{!19, !14}


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

@RestrictedSearch = external dso_local local_unnamed_addr global i32, align 4
@TraceLevel = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [36 x i8], align 1
@FirstNode = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @SolveCompressedSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr @RestrictedSearch, align 4, !tbaa !5
  %5 = load i64, ptr %2, align 8, !tbaa !9
  %6 = srem i32 %0, %1
  %7 = icmp eq i32 %6, 0
  %spec.select = select i1 %7, i32 %1, i32 %6
  store i32 0, ptr @RestrictedSearch, align 4, !tbaa !5
  %8 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %91, label %92

10:                                               ; preds = %92
  %11 = load i64, ptr %2, align 8, !tbaa !9
  %12 = icmp eq i64 %11, %5
  br i1 %12, label %13, label %.critedge

13:                                               ; preds = %10
  %14 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 2) #3
  br label %17

17:                                               ; preds = %16, %13
  %18 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.1 = icmp eq i32 %18, 0
  br i1 %.not.1, label %.critedge, label %19

19:                                               ; preds = %17
  %20 = load i64, ptr %2, align 8, !tbaa !9
  %21 = icmp eq i64 %20, %5
  br i1 %21, label %22, label %.critedge

22:                                               ; preds = %19
  %23 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 3) #3
  br label %26

26:                                               ; preds = %25, %22
  %27 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.2 = icmp eq i32 %27, 0
  br i1 %.not.2, label %.critedge, label %28

28:                                               ; preds = %26
  %29 = load i64, ptr %2, align 8, !tbaa !9
  %30 = icmp eq i64 %29, %5
  br i1 %30, label %31, label %.critedge

31:                                               ; preds = %28
  %32 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 4) #3
  br label %35

35:                                               ; preds = %34, %31
  %36 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.3 = icmp eq i32 %36, 0
  br i1 %.not.3, label %.critedge, label %37

37:                                               ; preds = %35
  %38 = load i64, ptr %2, align 8, !tbaa !9
  %39 = icmp eq i64 %38, %5
  br i1 %39, label %40, label %.critedge

40:                                               ; preds = %37
  %41 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %40
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 5) #3
  br label %44

44:                                               ; preds = %43, %40
  %45 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.4 = icmp eq i32 %45, 0
  br i1 %.not.4, label %.critedge, label %46

46:                                               ; preds = %44
  %47 = load i64, ptr %2, align 8, !tbaa !9
  %48 = icmp eq i64 %47, %5
  br i1 %48, label %49, label %.critedge

49:                                               ; preds = %46
  %50 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %49
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 6) #3
  br label %53

53:                                               ; preds = %52, %49
  %54 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.5 = icmp eq i32 %54, 0
  br i1 %.not.5, label %.critedge, label %55

55:                                               ; preds = %53
  %56 = load i64, ptr %2, align 8, !tbaa !9
  %57 = icmp eq i64 %56, %5
  br i1 %57, label %58, label %.critedge

58:                                               ; preds = %55
  %59 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %60 = icmp sgt i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %58
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 7) #3
  br label %62

62:                                               ; preds = %61, %58
  %63 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.6 = icmp eq i32 %63, 0
  br i1 %.not.6, label %.critedge, label %64

64:                                               ; preds = %62
  %65 = load i64, ptr %2, align 8, !tbaa !9
  %66 = icmp eq i64 %65, %5
  br i1 %66, label %67, label %.critedge

67:                                               ; preds = %64
  %68 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %67
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 8) #3
  br label %71

71:                                               ; preds = %70, %67
  %72 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.7 = icmp eq i32 %72, 0
  br i1 %.not.7, label %.critedge, label %73

73:                                               ; preds = %71
  %74 = load i64, ptr %2, align 8, !tbaa !9
  %75 = icmp eq i64 %74, %5
  br i1 %75, label %76, label %.critedge

76:                                               ; preds = %73
  %77 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %78 = icmp sgt i32 %77, 0
  br i1 %78, label %79, label %80

79:                                               ; preds = %76
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 9) #3
  br label %80

80:                                               ; preds = %79, %76
  %81 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not.8 = icmp eq i32 %81, 0
  br i1 %.not.8, label %.critedge, label %82

82:                                               ; preds = %80
  %83 = load i64, ptr %2, align 8, !tbaa !9
  %84 = icmp eq i64 %83, %5
  br i1 %84, label %85, label %.critedge

85:                                               ; preds = %82
  %86 = load i32, ptr @TraceLevel, align 4, !tbaa !5
  %87 = icmp sgt i32 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %85
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 10) #3
  br label %89

89:                                               ; preds = %88, %85
  %90 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  br label %.critedge

91:                                               ; preds = %3
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %spec.select, i32 noundef 1) #3
  br label %92

92:                                               ; preds = %91, %3
  %93 = tail call i32 @SolveSubproblem(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2) #3
  %.not = icmp eq i32 %93, 0
  br i1 %.not, label %.critedge, label %10

.critedge:                                        ; preds = %89, %82, %80, %73, %71, %64, %62, %55, %53, %46, %44, %37, %35, %28, %26, %19, %17, %10, %92
  store i32 %4, ptr @RestrictedSearch, align 4, !tbaa !5
  %94 = load ptr, ptr @FirstNode, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %95, %.critedge
  %.0 = phi ptr [ %94, %.critedge ], [ %100, %95 ]
  %96 = getelementptr inbounds i8, ptr %.0, i64 48
  %97 = load i32, ptr %96, align 8, !tbaa !13
  %98 = tail call i32 @llvm.abs.i32(i32 %97, i1 true)
  store i32 %98, ptr %96, align 8, !tbaa !13
  %99 = getelementptr inbounds i8, ptr %.0, i64 72
  %100 = load ptr, ptr %99, align 8, !tbaa !16
  %.not19 = icmp eq ptr %100, %94
  br i1 %.not19, label %101, label %95, !llvm.loop !17

101:                                              ; preds = %95
  ret void
}

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

declare i32 @SolveSubproblem(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"int", !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, !6, i64 48}
!14 = !{!"Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, 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, !15, i64 312, !15, i64 320, !15, i64 328, !15, i64 336, !15, i64 344, !15, i64 352, !7, i64 360, !7, i64 361, !7, i64 362}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !12, i64 72}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ADCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass