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

; 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.Candidate = type { ptr, i32, i32 }
%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 }

@FirstNode = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @ResetCandidateSet() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.Candidate, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #3
  %5 = load ptr, ptr @FirstNode, align 8, !tbaa !5
  store ptr %5, ptr %1, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %96, %0
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.Node, ptr %7, i32 0, i32 43
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  br label %96

12:                                               ; preds = %6
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 43
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr %2, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %68, %12
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Candidate, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %71

21:                                               ; preds = %16
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %22, i64 16, i1 false), !tbaa.struct !15
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Candidate, ptr %23, i64 -1
  store ptr %24, ptr %3, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %62, %21
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load ptr, ptr %1, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Node, ptr %27, i32 0, i32 43
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = icmp uge ptr %26, %29
  br i1 %30, label %31, label %56

31:                                               ; preds = %25
  %32 = getelementptr inbounds %struct.Candidate, ptr %4, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !17
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Candidate, ptr %34, i32 0, i32 2
  %36 = load i32, ptr %35, align 4, !tbaa !17
  %37 = icmp slt i32 %33, %36
  br i1 %37, label %54, label %38

38:                                               ; preds = %31
  %39 = getelementptr inbounds %struct.Candidate, ptr %4, i32 0, i32 2
  %40 = load i32, ptr %39, align 4, !tbaa !17
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.Candidate, ptr %41, i32 0, i32 2
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = icmp eq i32 %40, %43
  br i1 %44, label %45, label %52

45:                                               ; preds = %38
  %46 = getelementptr inbounds %struct.Candidate, ptr %4, i32 0, i32 1
  %47 = load i32, ptr %46, align 8, !tbaa !18
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Candidate, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !18
  %51 = icmp slt i32 %47, %50
  br label %52

52:                                               ; preds = %45, %38
  %53 = phi i1 [ false, %38 ], [ %51, %45 ]
  br label %54

54:                                               ; preds = %52, %31
  %55 = phi i1 [ true, %31 ], [ %53, %52 ]
  br label %56

56:                                               ; preds = %54, %25
  %57 = phi i1 [ false, %25 ], [ %55, %54 ]
  br i1 %57, label %58, label %65

58:                                               ; preds = %56
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Candidate, ptr %59, i64 1
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %60, ptr align 8 %61, i64 16, i1 false), !tbaa.struct !15
  br label %62

62:                                               ; preds = %58
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Candidate, ptr %63, i32 -1
  store ptr %64, ptr %3, align 8, !tbaa !5
  br label %25, !llvm.loop !19

65:                                               ; preds = %56
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Candidate, ptr %66, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %67, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !15
  br label %68

68:                                               ; preds = %65
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.Candidate, ptr %69, i32 1
  store ptr %70, ptr %2, align 8, !tbaa !5
  br label %16, !llvm.loop !21

71:                                               ; preds = %16
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.Candidate, ptr %72, i32 -1
  store ptr %73, ptr %2, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %88, %71
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = load ptr, ptr %1, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.Node, ptr %76, i32 0, i32 43
  %78 = load ptr, ptr %77, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.Candidate, ptr %78, i64 2
  %80 = icmp uge ptr %75, %79
  br i1 %80, label %81, label %86

81:                                               ; preds = %74
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.Candidate, ptr %82, i32 0, i32 2
  %84 = load i32, ptr %83, align 4, !tbaa !17
  %85 = icmp eq i32 %84, 2147483647
  br label %86

86:                                               ; preds = %81, %74
  %87 = phi i1 [ false, %74 ], [ %85, %81 ]
  br i1 %87, label %88, label %91

88:                                               ; preds = %86
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.Candidate, ptr %89, i32 -1
  store ptr %90, ptr %2, align 8, !tbaa !5
  br label %74, !llvm.loop !22

91:                                               ; preds = %86
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Candidate, ptr %92, i32 1
  store ptr %93, ptr %2, align 8, !tbaa !5
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.Candidate, ptr %94, i32 0, i32 0
  store ptr null, ptr %95, align 8, !tbaa !13
  br label %96

96:                                               ; preds = %91, %11
  %97 = load ptr, ptr %1, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.Node, ptr %97, i32 0, i32 16
  %99 = load ptr, ptr %98, align 8, !tbaa !23
  store ptr %99, ptr %1, align 8, !tbaa !5
  %100 = load ptr, ptr @FirstNode, align 8, !tbaa !5
  %101 = icmp ne ptr %99, %100
  br i1 %101, label %6, label %102, !llvm.loop !24

102:                                              ; preds = %96
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

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

@FirstNode = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @ResetCandidateSet() local_unnamed_addr #0 {
  %1 = load ptr, ptr @FirstNode, align 8, !tbaa !5
  br label %2

2:                                                ; preds = %28, %0
  %3 = phi ptr [ %1, %0 ], [ %29, %28 ]
  %.0 = phi ptr [ %1, %0 ], [ %31, %28 ]
  %4 = getelementptr inbounds i8, ptr %.0, i64 288
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %28, label %.preheader44

.preheader44:                                     ; preds = %2
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not3953 = icmp eq ptr %6, null
  br i1 %.not3953, label %.preheader, label %.lr.ph55

.preheader.loopexit:                              ; preds = %.critedge
  %.pre = load ptr, ptr %4, align 8, !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.preheader44
  %7 = phi ptr [ %5, %.preheader44 ], [ %.pre, %.preheader.loopexit ]
  %.033.lcssa = phi ptr [ %5, %.preheader44 ], [ %21, %.preheader.loopexit ]
  %8 = getelementptr inbounds i8, ptr %7, i64 32
  br label %23

.lr.ph55:                                         ; preds = %.preheader44, %.critedge
  %9 = phi ptr [ %22, %.critedge ], [ %6, %.preheader44 ]
  %.03354 = phi ptr [ %21, %.critedge ], [ %5, %.preheader44 ]
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %.03354, i64 8
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !13
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %.03354, i64 12
  %.sroa.5.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !13
  %.03445 = getelementptr inbounds i8, ptr %.03354, i64 -16
  %10 = load ptr, ptr %4, align 8, !tbaa !9
  %.not4246 = icmp ult ptr %.03445, %10
  br i1 %.not4246, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph55, %.critedge2
  %.03448 = phi ptr [ %.034, %.critedge2 ], [ %.03445, %.lr.ph55 ]
  %.033.pn4347 = phi ptr [ %.03448, %.critedge2 ], [ %.03354, %.lr.ph55 ]
  %11 = getelementptr inbounds i8, ptr %.033.pn4347, i64 -4
  %12 = load i32, ptr %11, align 4, !tbaa !14
  %13 = icmp slt i32 %.sroa.5.0.copyload, %12
  br i1 %13, label %.critedge2, label %14

14:                                               ; preds = %.lr.ph
  %15 = icmp eq i32 %.sroa.5.0.copyload, %12
  br i1 %15, label %16, label %.critedge

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %.033.pn4347, i64 -8
  %18 = load i32, ptr %17, align 8, !tbaa !16
  %19 = icmp slt i32 %.sroa.4.0.copyload, %18
  br i1 %19, label %.critedge2, label %.critedge

.critedge2:                                       ; preds = %.lr.ph, %16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %.033.pn4347, ptr noundef nonnull align 8 dereferenceable(16) %.03448, i64 16, i1 false), !tbaa.struct !17
  %.034 = getelementptr inbounds i8, ptr %.03448, i64 -16
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  %.not42 = icmp ult ptr %.034, %20
  br i1 %.not42, label %.critedge, label %.lr.ph, !llvm.loop !18

.critedge:                                        ; preds = %16, %14, %.critedge2, %.lr.ph55
  %.033.pn43.lcssa = phi ptr [ %.03354, %.lr.ph55 ], [ %.03448, %.critedge2 ], [ %.033.pn4347, %14 ], [ %.033.pn4347, %16 ]
  store ptr %9, ptr %.033.pn43.lcssa, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx6 = getelementptr inbounds i8, ptr %.033.pn43.lcssa, i64 8
  store i32 %.sroa.4.0.copyload, ptr %.sroa.4.0..sroa_idx6, align 8, !tbaa !13
  %.sroa.5.0..sroa_idx8 = getelementptr inbounds i8, ptr %.033.pn43.lcssa, i64 12
  store i32 %.sroa.5.0.copyload, ptr %.sroa.5.0..sroa_idx8, align 4, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %.03354, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %.not39 = icmp eq ptr %22, null
  br i1 %.not39, label %.preheader.loopexit, label %.lr.ph55, !llvm.loop !20

23:                                               ; preds = %.preheader, %24
  %.033.pn = phi ptr [ %.1, %24 ], [ %.033.lcssa, %.preheader ]
  %.1 = getelementptr inbounds i8, ptr %.033.pn, i64 -16
  %.not40 = icmp ult ptr %.1, %8
  br i1 %.not40, label %.critedge4, label %24

24:                                               ; preds = %23
  %25 = getelementptr inbounds i8, ptr %.033.pn, i64 -4
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = icmp eq i32 %26, 2147483647
  br i1 %27, label %23, label %.critedge4, !llvm.loop !21

.critedge4:                                       ; preds = %23, %24
  store ptr null, ptr %.033.pn, align 8, !tbaa !22
  %.pre57 = load ptr, ptr @FirstNode, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %2, %.critedge4
  %29 = phi ptr [ %3, %2 ], [ %.pre57, %.critedge4 ]
  %30 = getelementptr inbounds i8, ptr %.0, i64 72
  %31 = load ptr, ptr %30, align 8, !tbaa !23
  %.not41 = icmp eq ptr %31, %29
  br i1 %.not41, label %32, label %2, !llvm.loop !24

32:                                               ; preds = %28
  ret void
}

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

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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: readwrite) }

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


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