; LLVM IR from tangjz/acm-icpc :: lydsy/2967.ll (Z3bfsv)

; 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.Edge = type { i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@__dso_handle = external hidden global i8
@N = external dso_local global i32, align 4
@S = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@lnk = external dso_local global [7203 x i32], align 16
@dis = external dso_local global [7203 x i32], align 16
@sum = external dso_local global i32, align 4
@e = external dso_local global [28811 x %struct.Edge], align 16
@vis = external dso_local global [7203 x i8], align 16
@_ZZ3bfsvE4cand = external hidden global [3601 x %"class.std::vector"], align 16
@_ZGVZ3bfsvE4cand = external hidden global i64, align 8

; Function Attrs: nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z3bfsv() #2 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = load atomic i8, ptr @_ZGVZ3bfsvE4cand acquire, align 8
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %13, label %23, !prof !5

13:                                               ; preds = %0
  %14 = call i32 @__cxa_guard_acquire(ptr @_ZGVZ3bfsvE4cand) #0
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %23

16:                                               ; preds = %13
  br label %17

17:                                               ; preds = %17, %16
  %18 = phi ptr [ @_ZZ3bfsvE4cand, %16 ], [ %19, %17 ]
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %18) #0
  %19 = getelementptr inbounds %"class.std::vector", ptr %18, i64 1
  %20 = icmp eq ptr %19, getelementptr inbounds (%"class.std::vector", ptr @_ZZ3bfsvE4cand, i64 3601)
  br i1 %20, label %21, label %17

21:                                               ; preds = %17
  %22 = call i32 @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr null, ptr @__dso_handle) #0
  call void @__cxa_guard_release(ptr @_ZGVZ3bfsvE4cand) #0
  br label %23

23:                                               ; preds = %21, %13, %0
  %24 = load i32, ptr @N, align 4, !tbaa !6
  %25 = sext i32 %24 to i64
  %26 = mul i64 %25, 4
  call void @llvm.memset.p0.i64(ptr align 16 @dis, i8 63, i64 %26, i1 false)
  %27 = load i32, ptr @N, align 4, !tbaa !6
  %28 = sext i32 %27 to i64
  %29 = mul i64 %28, 1
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 %29, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #0
  %30 = load i32, ptr @T, align 4, !tbaa !6
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %31
  store i32 0, ptr %32, align 4, !tbaa !6
  store i32 0, ptr %2, align 4, !tbaa !6
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ3bfsvE4cand, ptr noundef nonnull align 4 dereferenceable(4) @T)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #0
  store i32 0, ptr %3, align 4, !tbaa !6
  br label %33

33:                                               ; preds = %125, %123, %43, %23
  %34 = load i32, ptr %3, align 4, !tbaa !6
  %35 = load i32, ptr %2, align 4, !tbaa !6
  %36 = icmp sle i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #0
  br label %126

38:                                               ; preds = %33
  %39 = load i32, ptr %3, align 4, !tbaa !6
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [3601 x %"class.std::vector"], ptr @_ZZ3bfsvE4cand, i64 0, i64 %40
  %42 = call noundef zeroext i1 @_ZNKSt6vectorIiSaIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %41) #0
  br i1 %42, label %43, label %46

43:                                               ; preds = %38
  %44 = load i32, ptr %3, align 4, !tbaa !6
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !6
  br label %33, !llvm.loop !10

46:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #0
  %47 = load i32, ptr %3, align 4, !tbaa !6
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [3601 x %"class.std::vector"], ptr @_ZZ3bfsvE4cand, i64 0, i64 %48
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %49) #0
  %51 = load i32, ptr %50, align 4, !tbaa !6
  store i32 %51, ptr %5, align 4, !tbaa !6
  %52 = load i32, ptr %3, align 4, !tbaa !6
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [3601 x %"class.std::vector"], ptr @_ZZ3bfsvE4cand, i64 0, i64 %53
  call void @_ZNSt6vectorIiSaIiEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %54) #0
  %55 = load i32, ptr %5, align 4, !tbaa !6
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [7203 x i8], ptr @vis, i64 0, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !12, !range !14, !noundef !15
  %59 = trunc i8 %58 to i1
  br i1 %59, label %60, label %61

60:                                               ; preds = %46
  store i32 3, ptr %4, align 4
  br label %123, !llvm.loop !10

61:                                               ; preds = %46
  %62 = load i32, ptr %5, align 4, !tbaa !6
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [7203 x i8], ptr @vis, i64 0, i64 %63
  store i8 1, ptr %64, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #0
  %65 = load i32, ptr %5, align 4, !tbaa !6
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [7203 x i32], ptr @lnk, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !6
  store i32 %68, ptr %6, align 4, !tbaa !6
  br label %69

69:                                               ; preds = %116, %61
  %70 = load i32, ptr %6, align 4, !tbaa !6
  %71 = icmp ne i32 %70, -1
  br i1 %71, label %73, label %72

72:                                               ; preds = %69
  store i32 4, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #0
  br label %122

73:                                               ; preds = %69
  %74 = load i32, ptr %6, align 4, !tbaa !6
  %75 = xor i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.Edge, ptr %77, i32 0, i32 2
  %79 = load i32, ptr %78, align 8, !tbaa !16
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %82, label %81

81:                                               ; preds = %73
  br label %116

82:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #0
  %83 = load i32, ptr %6, align 4, !tbaa !6
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %84
  %86 = getelementptr inbounds %struct.Edge, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %86, align 4, !tbaa !18
  store i32 %87, ptr %7, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #0
  %88 = load i32, ptr %5, align 4, !tbaa !6
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !6
  %92 = load i32, ptr %6, align 4, !tbaa !6
  %93 = xor i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %94
  %96 = getelementptr inbounds %struct.Edge, ptr %95, i32 0, i32 3
  %97 = load i32, ptr %96, align 4, !tbaa !19
  %98 = add nsw i32 %91, %97
  store i32 %98, ptr %8, align 4, !tbaa !6
  %99 = load i32, ptr %8, align 4, !tbaa !6
  %100 = load i32, ptr %7, align 4, !tbaa !6
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !6
  %104 = icmp slt i32 %99, %103
  br i1 %104, label %105, label %115

105:                                              ; preds = %82
  %106 = load i32, ptr %8, align 4, !tbaa !6
  %107 = load i32, ptr %7, align 4, !tbaa !6
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %108
  store i32 %106, ptr %109, align 4, !tbaa !6
  %110 = load i32, ptr %8, align 4, !tbaa !6
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [3601 x %"class.std::vector"], ptr @_ZZ3bfsvE4cand, i64 0, i64 %111
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %112, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %113 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %114 = load i32, ptr %113, align 4, !tbaa !6
  store i32 %114, ptr %2, align 4, !tbaa !6
  br label %115

115:                                              ; preds = %105, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #0
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #0
  br label %116

116:                                              ; preds = %115, %81
  %117 = load i32, ptr %6, align 4, !tbaa !6
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %118
  %120 = getelementptr inbounds %struct.Edge, ptr %119, i32 0, i32 0
  %121 = load i32, ptr %120, align 16, !tbaa !20
  store i32 %121, ptr %6, align 4, !tbaa !6
  br label %69, !llvm.loop !21

122:                                              ; preds = %72
  store i32 0, ptr %4, align 4
  br label %123

123:                                              ; preds = %122, %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #0
  %124 = load i32, ptr %4, align 4
  switch i32 %124, label %187 [
    i32 0, label %125
    i32 3, label %33
  ]

125:                                              ; preds = %123
  br label %33, !llvm.loop !10

126:                                              ; preds = %37
  %127 = load i32, ptr @S, align 4, !tbaa !6
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !6
  %131 = icmp eq i32 %130, 1061109567
  br i1 %131, label %132, label %133

132:                                              ; preds = %126
  store i1 false, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %185

133:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #0
  store i32 0, ptr %9, align 4, !tbaa !6
  br label %134

134:                                              ; preds = %175, %133
  %135 = load i32, ptr %9, align 4, !tbaa !6
  %136 = load i32, ptr @N, align 4, !tbaa !6
  %137 = icmp slt i32 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #0
  br label %178

139:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #0
  %140 = load i32, ptr %9, align 4, !tbaa !6
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [7203 x i32], ptr @lnk, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !6
  store i32 %143, ptr %10, align 4, !tbaa !6
  br label %144

144:                                              ; preds = %168, %139
  %145 = load i32, ptr %10, align 4, !tbaa !6
  %146 = icmp ne i32 %145, -1
  br i1 %146, label %148, label %147

147:                                              ; preds = %144
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #0
  br label %174

148:                                              ; preds = %144
  %149 = load i32, ptr %10, align 4, !tbaa !6
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %150
  %152 = getelementptr inbounds %struct.Edge, ptr %151, i32 0, i32 1
  %153 = load i32, ptr %152, align 4, !tbaa !18
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !6
  %157 = load i32, ptr %9, align 4, !tbaa !6
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !6
  %161 = sub nsw i32 %156, %160
  %162 = load i32, ptr %10, align 4, !tbaa !6
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %163
  %165 = getelementptr inbounds %struct.Edge, ptr %164, i32 0, i32 3
  %166 = load i32, ptr %165, align 4, !tbaa !19
  %167 = add nsw i32 %166, %161
  store i32 %167, ptr %165, align 4, !tbaa !19
  br label %168

168:                                              ; preds = %148
  %169 = load i32, ptr %10, align 4, !tbaa !6
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %170
  %172 = getelementptr inbounds %struct.Edge, ptr %171, i32 0, i32 0
  %173 = load i32, ptr %172, align 16, !tbaa !20
  store i32 %173, ptr %10, align 4, !tbaa !6
  br label %144, !llvm.loop !22

174:                                              ; preds = %147
  br label %175

175:                                              ; preds = %174
  %176 = load i32, ptr %9, align 4, !tbaa !6
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr %9, align 4, !tbaa !6
  br label %134, !llvm.loop !23

178:                                              ; preds = %138
  %179 = load i32, ptr @S, align 4, !tbaa !6
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %180
  %182 = load i32, ptr %181, align 4, !tbaa !6
  %183 = load i32, ptr @sum, align 4, !tbaa !6
  %184 = add nsw i32 %183, %182
  store i32 %184, ptr @sum, align 4, !tbaa !6
  store i1 true, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %185

185:                                              ; preds = %178, %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #0
  %186 = load i1, ptr %1, align 1
  ret i1 %186

187:                                              ; preds = %123
  unreachable
}

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: uwtable
declare hidden void @__cxx_global_array_dtor(ptr noundef) #4 section ".text.startup"

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIiSaIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #6

attributes #0 = { nounwind }
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 = { 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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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" }

!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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!17, !7, i64 8}
!17 = !{!"_ZTS4Edge", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!18 = !{!17, !7, i64 4}
!19 = !{!17, !7, i64 12}
!20 = !{!17, !7, i64 0}
!21 = distinct !{!21, !11}
!22 = distinct !{!22, !11}
!23 = distinct !{!23, !11}


; 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.Edge = type { i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@__dso_handle = external hidden global i8
@N = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local local_unnamed_addr global i32, align 4
@T = external dso_local global i32, align 4
@lnk = external dso_local local_unnamed_addr global [7203 x i32], align 16
@dis = external dso_local local_unnamed_addr global [7203 x i32], align 16
@sum = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local local_unnamed_addr global [28811 x %struct.Edge], align 16
@vis = external dso_local local_unnamed_addr global [7203 x i8], align 16
@_ZZ3bfsvE4cand = external hidden global [3601 x %"class.std::vector"], align 16
@_ZGVZ3bfsvE4cand = external hidden global i64, align 8

; Function Attrs: nofree nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z3bfsv() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = load atomic i8, ptr @_ZGVZ3bfsvE4cand acquire, align 8
  %5 = icmp eq i8 %4, 0
  br i1 %5, label %6, label %.lr.ph37.preheader, !prof !5

6:                                                ; preds = %0
  %7 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZ3bfsvE4cand) #7
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.lr.ph37.preheader, label %.preheader32

.preheader32:                                     ; preds = %6, %.preheader32
  %.idx = phi i64 [ %.add, %.preheader32 ], [ 0, %6 ]
  %.ptr = getelementptr inbounds i8, ptr @_ZZ3bfsvE4cand, i64 %.idx
  tail call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr) #7
  %.add = add nuw nsw i64 %.idx, 24
  %8 = icmp eq i64 %.add, 86424
  br i1 %8, label %9, label %.preheader32

9:                                                ; preds = %.preheader32
  %10 = tail call i32 @__cxa_atexit(ptr nonnull @__cxx_global_array_dtor, ptr null, ptr nonnull @__dso_handle) #7
  tail call void @__cxa_guard_release(ptr nonnull @_ZGVZ3bfsvE4cand) #7
  br label %.lr.ph37.preheader

.lr.ph37.preheader:                               ; preds = %0, %6, %9
  %11 = load i32, ptr @N, align 4, !tbaa !6
  %12 = sext i32 %11 to i64
  %13 = shl nsw i64 %12, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @dis, i8 63, i64 %13, i1 false)
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @vis, i8 0, i64 %12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %14 = load i32, ptr @T, align 4, !tbaa !6
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %15
  store i32 0, ptr %16, align 4, !tbaa !6
  store i32 0, ptr %1, align 4, !tbaa !6
  tail call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ3bfsvE4cand, ptr noundef nonnull align 4 dereferenceable(4) @T)
  br label %.lr.ph37

.lr.ph37:                                         ; preds = %.lr.ph37.preheader, %.outer
  %indvars.iv = phi i64 [ 0, %.lr.ph37.preheader ], [ %indvars.iv.next, %.outer ]
  %17 = getelementptr inbounds [3601 x %"class.std::vector"], ptr @_ZZ3bfsvE4cand, i64 0, i64 %indvars.iv
  br label %25

.outer._crit_edge:                                ; preds = %.outer, %.loopexit
  %18 = load i32, ptr @S, align 4, !tbaa !6
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !6
  %22 = icmp ne i32 %21, 1061109567
  br i1 %22, label %.preheader, label %84

.preheader:                                       ; preds = %.outer._crit_edge
  %23 = load i32, ptr @N, align 4, !tbaa !6
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.lr.ph47.preheader, label %._crit_edge48

.lr.ph47.preheader:                               ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %23 to i64
  br label %.lr.ph47

25:                                               ; preds = %.lr.ph37, %.loopexit
  %26 = call noundef zeroext i1 @_ZNKSt6vectorIiSaIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #7
  br i1 %26, label %.outer, label %29

.outer:                                           ; preds = %25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr %1, align 4, !tbaa !6
  %28 = sext i32 %27 to i64
  %.not2836.not = icmp slt i64 %indvars.iv, %28
  br i1 %.not2836.not, label %.lr.ph37, label %.outer._crit_edge, !llvm.loop !10

29:                                               ; preds = %25
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #7
  %31 = load i32, ptr %30, align 4, !tbaa !6
  call void @_ZNSt6vectorIiSaIiEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #7
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [7203 x i8], ptr @vis, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !12, !range !14, !noundef !15
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %.loopexit, label %36, !llvm.loop !10

36:                                               ; preds = %29
  store i8 1, ptr %33, align 1, !tbaa !12
  %37 = getelementptr inbounds [7203 x i32], ptr @lnk, i64 0, i64 %32
  %.02333 = load i32, ptr %37, align 4, !tbaa !6
  %.not3034 = icmp eq i32 %.02333, -1
  br i1 %.not3034, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %36
  %38 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %32
  br label %39

39:                                               ; preds = %.lr.ph, %63
  %.02335 = phi i32 [ %.02333, %.lr.ph ], [ %.023, %63 ]
  %40 = xor i32 %.02335, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %41
  %43 = getelementptr inbounds i8, ptr %42, i64 8
  %44 = load i32, ptr %43, align 8, !tbaa !16
  %.not31 = icmp eq i32 %44, 0
  br i1 %.not31, label %._crit_edge, label %45

._crit_edge:                                      ; preds = %39
  %.pre = sext i32 %.02335 to i64
  br label %63

45:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %46 = sext i32 %.02335 to i64
  %47 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %46, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !18
  store i32 %48, ptr %2, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %49 = load i32, ptr %38, align 4, !tbaa !6
  %50 = getelementptr inbounds i8, ptr %42, i64 12
  %51 = load i32, ptr %50, align 4, !tbaa !19
  %52 = add nsw i32 %51, %49
  store i32 %52, ptr %3, align 4, !tbaa !6
  %53 = sext i32 %48 to i64
  %54 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !6
  %56 = icmp slt i32 %52, %55
  br i1 %56, label %57, label %62

57:                                               ; preds = %45
  store i32 %52, ptr %54, align 4, !tbaa !6
  %58 = sext i32 %52 to i64
  %59 = getelementptr inbounds [3601 x %"class.std::vector"], ptr @_ZZ3bfsvE4cand, i64 0, i64 %58
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %59, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %61 = load i32, ptr %60, align 4, !tbaa !6
  store i32 %61, ptr %1, align 4, !tbaa !6
  br label %62

62:                                               ; preds = %57, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  br label %63

63:                                               ; preds = %._crit_edge, %62
  %.pre-phi = phi i64 [ %.pre, %._crit_edge ], [ %46, %62 ]
  %64 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %.pre-phi
  %.023 = load i32, ptr %64, align 16, !tbaa !6
  %.not30 = icmp eq i32 %.023, -1
  br i1 %.not30, label %.loopexit, label %39, !llvm.loop !20

.loopexit:                                        ; preds = %63, %36, %29
  %65 = load i32, ptr %1, align 4, !tbaa !6
  %66 = sext i32 %65 to i64
  %.not28 = icmp sgt i64 %indvars.iv, %66
  br i1 %.not28, label %.outer._crit_edge, label %25

._crit_edge48:                                    ; preds = %._crit_edge45, %.preheader
  %67 = load i32, ptr @sum, align 4, !tbaa !6
  %68 = add nsw i32 %67, %21
  store i32 %68, ptr @sum, align 4, !tbaa !6
  br label %84

.lr.ph47:                                         ; preds = %.lr.ph47.preheader, %._crit_edge45
  %indvars.iv51 = phi i64 [ 0, %.lr.ph47.preheader ], [ %indvars.iv.next52, %._crit_edge45 ]
  %69 = getelementptr inbounds [7203 x i32], ptr @lnk, i64 0, i64 %indvars.iv51
  %.040 = load i32, ptr %69, align 4, !tbaa !6
  %.not2941 = icmp eq i32 %.040, -1
  br i1 %.not2941, label %._crit_edge45, label %.lr.ph44

.lr.ph44:                                         ; preds = %.lr.ph47
  %70 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %indvars.iv51
  %71 = load i32, ptr %70, align 4, !tbaa !6
  br label %72

._crit_edge45:                                    ; preds = %72, %.lr.ph47
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next52, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge48, label %.lr.ph47, !llvm.loop !21

72:                                               ; preds = %.lr.ph44, %72
  %.042 = phi i32 [ %.040, %.lr.ph44 ], [ %.0, %72 ]
  %73 = sext i32 %.042 to i64
  %74 = getelementptr inbounds [28811 x %struct.Edge], ptr @e, i64 0, i64 %73
  %75 = getelementptr inbounds i8, ptr %74, i64 4
  %76 = load i32, ptr %75, align 4, !tbaa !18
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [7203 x i32], ptr @dis, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !6
  %80 = sub i32 %79, %71
  %81 = getelementptr inbounds i8, ptr %74, i64 12
  %82 = load i32, ptr %81, align 4, !tbaa !19
  %83 = add nsw i32 %80, %82
  store i32 %83, ptr %81, align 4, !tbaa !19
  %.0 = load i32, ptr %74, align 16, !tbaa !6
  %.not29 = icmp eq i32 %.0, -1
  br i1 %.not29, label %._crit_edge45, label %72, !llvm.loop !22

84:                                               ; preds = %.outer._crit_edge, %._crit_edge48
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i1 %22
}

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: uwtable
declare hidden void @__cxx_global_array_dtor(ptr noundef) #4 section ".text.startup"

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIiSaIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

attributes #0 = { nofree nounwind }
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 = { 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 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { 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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!17, !7, i64 8}
!17 = !{!"_ZTS4Edge", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!18 = !{!17, !7, i64 4}
!19 = !{!17, !7, i64 12}
!20 = distinct !{!20, !11}
!21 = distinct !{!21, !11}
!22 = distinct !{!22, !11}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass