; LLVM IR from AdarshGaur/Competitive-Programming :: Codeforces/Random Problems/B. Biridian Forest.ll (Z4bfs2ll)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.std::pair" = type { i64, i64 }

@_Z6secondB5cxx11 = external dso_local global %"class.std::vector", align 8
@r = external dso_local global i64, align 8
@c = external dso_local global i64, align 8
@dis1 = external dso_local global i64, align 8
@vis = external dso_local global [1002 x [1002 x i8]], align 16
@dis = external dso_local global [1002 x [1002 x i64]], align 16
@dx = external dso_local global %"class.std::vector.0", align 8
@dy = external dso_local global %"class.std::vector.0", align 8

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

; 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) #1

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #3 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4bfs2ll(i64 noundef %0, i64 noundef %1) #2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %"class.std::queue", align 8
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca %"struct.std::pair", align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr %5) #5
  call void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  invoke void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %16 unwind label %38

16:                                               ; preds = %2
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %17 unwind label %38

17:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %18
  %20 = load i64, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds [1002 x i8], ptr %19, i64 0, i64 %20
  store i8 1, ptr %21, align 1, !tbaa !9
  br label %22

22:                                               ; preds = %133, %17
  %23 = invoke noundef zeroext i1 @_ZNKSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %24 unwind label %42

24:                                               ; preds = %22
  %25 = xor i1 %23, true
  br i1 %25, label %26, label %136

26:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  %27 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %28 unwind label %46

28:                                               ; preds = %26
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %27, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %29 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %30 = load i64, ptr %29, align 8, !tbaa !11
  store i64 %30, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %31 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !13
  store i64 %32, ptr %11, align 8, !tbaa !5
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %33 unwind label %50

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i64 0, ptr %12, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %129, %33
  %35 = load i64, ptr %12, align 8, !tbaa !5
  %36 = icmp slt i64 %35, 4
  br i1 %36, label %54, label %37

37:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %133

38:                                               ; preds = %16, %2
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %7, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  br label %137

42:                                               ; preds = %22
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %7, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %8, align 4
  br label %137

46:                                               ; preds = %26
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %7, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %8, align 4
  br label %135

50:                                               ; preds = %28
  %51 = landingpad { ptr, i32 }
          cleanup
  %52 = extractvalue { ptr, i32 } %51, 0
  store ptr %52, ptr %7, align 8
  %53 = extractvalue { ptr, i32 } %51, 1
  store i32 %53, ptr %8, align 4
  br label %134

54:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %55 = load i64, ptr %10, align 8, !tbaa !5
  %56 = load i64, ptr %12, align 8, !tbaa !5
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dx, i64 noundef %56) #5
  %58 = load i64, ptr %57, align 8, !tbaa !5
  %59 = add nsw i64 %55, %58
  store i64 %59, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %60 = load i64, ptr %11, align 8, !tbaa !5
  %61 = load i64, ptr %12, align 8, !tbaa !5
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dy, i64 noundef %61) #5
  %63 = load i64, ptr %62, align 8, !tbaa !5
  %64 = add nsw i64 %60, %63
  store i64 %64, ptr %14, align 8, !tbaa !5
  %65 = load i64, ptr %13, align 8, !tbaa !5
  %66 = load i64, ptr @r, align 8, !tbaa !5
  %67 = icmp slt i64 %65, %66
  br i1 %67, label %68, label %128

68:                                               ; preds = %54
  %69 = load i64, ptr %13, align 8, !tbaa !5
  %70 = icmp sge i64 %69, 0
  br i1 %70, label %71, label %128

71:                                               ; preds = %68
  %72 = load i64, ptr %14, align 8, !tbaa !5
  %73 = icmp sge i64 %72, 0
  br i1 %73, label %74, label %128

74:                                               ; preds = %71
  %75 = load i64, ptr %14, align 8, !tbaa !5
  %76 = load i64, ptr @c, align 8, !tbaa !5
  %77 = icmp slt i64 %75, %76
  br i1 %77, label %78, label %128

78:                                               ; preds = %74
  %79 = load i64, ptr %13, align 8, !tbaa !5
  %80 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_Z6secondB5cxx11, i64 noundef %79) #5
  %81 = load i64, ptr %14, align 8, !tbaa !5
  %82 = invoke noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %80, i64 noundef %81)
          to label %83 unwind label %119

83:                                               ; preds = %78
  %84 = load i8, ptr %82, align 1, !tbaa !14
  %85 = sext i8 %84 to i32
  %86 = icmp ne i32 %85, 84
  br i1 %86, label %87, label %128

87:                                               ; preds = %83
  %88 = load i64, ptr %13, align 8, !tbaa !5
  %89 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %88
  %90 = load i64, ptr %14, align 8, !tbaa !5
  %91 = getelementptr inbounds [1002 x i8], ptr %89, i64 0, i64 %90
  %92 = load i8, ptr %91, align 1, !tbaa !9, !range !15, !noundef !16
  %93 = trunc i8 %92 to i1
  br i1 %93, label %127, label %94

94:                                               ; preds = %87
  %95 = load i64, ptr %10, align 8, !tbaa !5
  %96 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %95
  %97 = load i64, ptr %11, align 8, !tbaa !5
  %98 = getelementptr inbounds [1002 x i64], ptr %96, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !5
  %100 = load i64, ptr @dis1, align 8, !tbaa !5
  %101 = icmp ne i64 %99, %100
  br i1 %101, label %102, label %127

102:                                              ; preds = %94
  %103 = load i64, ptr %13, align 8, !tbaa !5
  %104 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %103
  %105 = load i64, ptr %14, align 8, !tbaa !5
  %106 = getelementptr inbounds [1002 x i8], ptr %104, i64 0, i64 %105
  store i8 1, ptr %106, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  invoke void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %14)
          to label %107 unwind label %123

107:                                              ; preds = %102
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(16) %15)
          to label %108 unwind label %123

108:                                              ; preds = %107
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  %109 = load i64, ptr %10, align 8, !tbaa !5
  %110 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %109
  %111 = load i64, ptr %11, align 8, !tbaa !5
  %112 = getelementptr inbounds [1002 x i64], ptr %110, i64 0, i64 %111
  %113 = load i64, ptr %112, align 8, !tbaa !5
  %114 = add nsw i64 %113, 1
  %115 = load i64, ptr %13, align 8, !tbaa !5
  %116 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %115
  %117 = load i64, ptr %14, align 8, !tbaa !5
  %118 = getelementptr inbounds [1002 x i64], ptr %116, i64 0, i64 %117
  store i64 %114, ptr %118, align 8, !tbaa !5
  br label %127

119:                                              ; preds = %78
  %120 = landingpad { ptr, i32 }
          cleanup
  %121 = extractvalue { ptr, i32 } %120, 0
  store ptr %121, ptr %7, align 8
  %122 = extractvalue { ptr, i32 } %120, 1
  store i32 %122, ptr %8, align 4
  br label %132

123:                                              ; preds = %107, %102
  %124 = landingpad { ptr, i32 }
          cleanup
  %125 = extractvalue { ptr, i32 } %124, 0
  store ptr %125, ptr %7, align 8
  %126 = extractvalue { ptr, i32 } %124, 1
  store i32 %126, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  br label %132

127:                                              ; preds = %108, %94, %87
  br label %128

128:                                              ; preds = %127, %83, %74, %71, %68, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %129

129:                                              ; preds = %128
  %130 = load i64, ptr %12, align 8, !tbaa !5
  %131 = add nsw i64 %130, 1
  store i64 %131, ptr %12, align 8, !tbaa !5
  br label %34, !llvm.loop !17

132:                                              ; preds = %123, %119
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %134

133:                                              ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  br label %22, !llvm.loop !19

134:                                              ; preds = %132, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %135

135:                                              ; preds = %134, %46
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  br label %137

136:                                              ; preds = %24
  call void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #5
  ret void

137:                                              ; preds = %135, %42, %38
  call void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #5
  br label %138

138:                                              ; preds = %137
  %139 = load ptr, ptr %7, align 8
  %140 = load i32, ptr %8, align 4
  %141 = insertvalue { ptr, i32 } poison, ptr %139, 0
  %142 = insertvalue { ptr, i32 } %141, i32 %140, 1
  resume { ptr, i32 } %142
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt4pairIllE", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.std::pair" = type { i64, i64 }

@_Z6secondB5cxx11 = external dso_local global %"class.std::vector", align 8
@r = external dso_local local_unnamed_addr global i64, align 8
@c = external dso_local local_unnamed_addr global i64, align 8
@dis1 = external dso_local local_unnamed_addr global i64, align 8
@vis = external dso_local local_unnamed_addr global [1002 x [1002 x i8]], align 16
@dis = external dso_local local_unnamed_addr global [1002 x [1002 x i64]], align 16
@dx = external dso_local global %"class.std::vector.0", align 8
@dy = external dso_local global %"class.std::vector.0", align 8

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #1 align 2

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4bfs2ll(i64 noundef %0, i64 noundef %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %"class.std::queue", align 8
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %"struct.std::pair", align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %5) #4
  call void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %10 unwind label %30

10:                                               ; preds = %2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = load i64, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %11, i64 %12
  store i8 1, ptr %13, align 1, !tbaa !9
  %14 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  br i1 %14, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10, %.loopexit
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  %.sroa.0.0.copyload = load i64, ptr %15, align 8
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %15, i64 8
  %.sroa.5.0.copyload = load i64, ptr %.sroa.5.0..sroa_idx, align 8
  call void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  %16 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %.sroa.0.0.copyload, i64 %.sroa.5.0.copyload
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dx, i64 noundef 0) #4
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = add nsw i64 %18, %.sroa.0.0.copyload
  store i64 %19, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dy, i64 noundef 0) #4
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = add nsw i64 %21, %.sroa.5.0.copyload
  store i64 %22, ptr %8, align 8, !tbaa !5
  %23 = load i64, ptr %7, align 8
  %24 = load i64, ptr @r, align 8, !tbaa !5
  %25 = icmp slt i64 %23, %24
  %26 = icmp sgt i64 %23, -1
  %or.cond = and i1 %26, %25
  %27 = icmp sgt i64 %22, -1
  %or.cond3 = select i1 %or.cond, i1 %27, i1 false
  %28 = load i64, ptr @c, align 8
  %29 = icmp slt i64 %22, %28
  %or.cond21 = select i1 %or.cond3, i1 %29, i1 false
  br i1 %or.cond21, label %32, label %55

30:                                               ; preds = %2
  %31 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  br label %161

32:                                               ; preds = %.lr.ph
  %33 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_Z6secondB5cxx11, i64 noundef %23) #4
  %34 = load i64, ptr %8, align 8, !tbaa !5
  %35 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %33, i64 noundef %34)
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %.not = icmp eq i8 %36, 84
  br i1 %.not, label %55, label %37

37:                                               ; preds = %32
  %38 = load i64, ptr %7, align 8, !tbaa !5
  %39 = load i64, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %38, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !9, !range !12, !noundef !13
  %42 = trunc nuw i8 %41 to i1
  br i1 %42, label %55, label %43

43:                                               ; preds = %37
  %44 = load i64, ptr %16, align 8, !tbaa !5
  %45 = load i64, ptr @dis1, align 8, !tbaa !5
  %.not18 = icmp eq i64 %44, %45
  br i1 %.not18, label %55, label %46

46:                                               ; preds = %43
  store i8 1, ptr %40, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %47 unwind label %53

47:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  %48 = load i64, ptr %16, align 8, !tbaa !5
  %49 = add nsw i64 %48, 1
  %50 = load i64, ptr %7, align 8, !tbaa !5
  %51 = load i64, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %50, i64 %51
  store i64 %49, ptr %52, align 8, !tbaa !5
  br label %55

53:                                               ; preds = %153, %118, %83, %46
  %54 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  br label %161

55:                                               ; preds = %37, %43, %47, %32, %.lr.ph
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dx, i64 noundef 1) #4
  %57 = load i64, ptr %56, align 8, !tbaa !5
  %58 = add nsw i64 %57, %.sroa.0.0.copyload
  store i64 %58, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dy, i64 noundef 1) #4
  %60 = load i64, ptr %59, align 8, !tbaa !5
  %61 = add nsw i64 %60, %.sroa.5.0.copyload
  store i64 %61, ptr %8, align 8, !tbaa !5
  %62 = load i64, ptr %7, align 8
  %63 = load i64, ptr @r, align 8, !tbaa !5
  %64 = icmp slt i64 %62, %63
  %65 = icmp sgt i64 %62, -1
  %or.cond.1 = and i1 %65, %64
  %66 = icmp sgt i64 %61, -1
  %or.cond3.1 = select i1 %or.cond.1, i1 %66, i1 false
  %67 = load i64, ptr @c, align 8
  %68 = icmp slt i64 %61, %67
  %or.cond21.1 = select i1 %or.cond3.1, i1 %68, i1 false
  br i1 %or.cond21.1, label %69, label %90

69:                                               ; preds = %55
  %70 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_Z6secondB5cxx11, i64 noundef %62) #4
  %71 = load i64, ptr %8, align 8, !tbaa !5
  %72 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %70, i64 noundef %71)
  %73 = load i8, ptr %72, align 1, !tbaa !11
  %.not.1 = icmp eq i8 %73, 84
  br i1 %.not.1, label %90, label %74

74:                                               ; preds = %69
  %75 = load i64, ptr %7, align 8, !tbaa !5
  %76 = load i64, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %75, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !9, !range !12, !noundef !13
  %79 = trunc nuw i8 %78 to i1
  br i1 %79, label %90, label %80

80:                                               ; preds = %74
  %81 = load i64, ptr %16, align 8, !tbaa !5
  %82 = load i64, ptr @dis1, align 8, !tbaa !5
  %.not18.1 = icmp eq i64 %81, %82
  br i1 %.not18.1, label %90, label %83

83:                                               ; preds = %80
  store i8 1, ptr %77, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %84 unwind label %53

84:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  %85 = load i64, ptr %16, align 8, !tbaa !5
  %86 = add nsw i64 %85, 1
  %87 = load i64, ptr %7, align 8, !tbaa !5
  %88 = load i64, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %87, i64 %88
  store i64 %86, ptr %89, align 8, !tbaa !5
  br label %90

90:                                               ; preds = %84, %80, %74, %69, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dx, i64 noundef 2) #4
  %92 = load i64, ptr %91, align 8, !tbaa !5
  %93 = add nsw i64 %92, %.sroa.0.0.copyload
  store i64 %93, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %94 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dy, i64 noundef 2) #4
  %95 = load i64, ptr %94, align 8, !tbaa !5
  %96 = add nsw i64 %95, %.sroa.5.0.copyload
  store i64 %96, ptr %8, align 8, !tbaa !5
  %97 = load i64, ptr %7, align 8
  %98 = load i64, ptr @r, align 8, !tbaa !5
  %99 = icmp slt i64 %97, %98
  %100 = icmp sgt i64 %97, -1
  %or.cond.2 = and i1 %100, %99
  %101 = icmp sgt i64 %96, -1
  %or.cond3.2 = select i1 %or.cond.2, i1 %101, i1 false
  %102 = load i64, ptr @c, align 8
  %103 = icmp slt i64 %96, %102
  %or.cond21.2 = select i1 %or.cond3.2, i1 %103, i1 false
  br i1 %or.cond21.2, label %104, label %125

104:                                              ; preds = %90
  %105 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_Z6secondB5cxx11, i64 noundef %97) #4
  %106 = load i64, ptr %8, align 8, !tbaa !5
  %107 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %105, i64 noundef %106)
  %108 = load i8, ptr %107, align 1, !tbaa !11
  %.not.2 = icmp eq i8 %108, 84
  br i1 %.not.2, label %125, label %109

109:                                              ; preds = %104
  %110 = load i64, ptr %7, align 8, !tbaa !5
  %111 = load i64, ptr %8, align 8, !tbaa !5
  %112 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %110, i64 %111
  %113 = load i8, ptr %112, align 1, !tbaa !9, !range !12, !noundef !13
  %114 = trunc nuw i8 %113 to i1
  br i1 %114, label %125, label %115

115:                                              ; preds = %109
  %116 = load i64, ptr %16, align 8, !tbaa !5
  %117 = load i64, ptr @dis1, align 8, !tbaa !5
  %.not18.2 = icmp eq i64 %116, %117
  br i1 %.not18.2, label %125, label %118

118:                                              ; preds = %115
  store i8 1, ptr %112, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %119 unwind label %53

119:                                              ; preds = %118
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  %120 = load i64, ptr %16, align 8, !tbaa !5
  %121 = add nsw i64 %120, 1
  %122 = load i64, ptr %7, align 8, !tbaa !5
  %123 = load i64, ptr %8, align 8, !tbaa !5
  %124 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %122, i64 %123
  store i64 %121, ptr %124, align 8, !tbaa !5
  br label %125

125:                                              ; preds = %119, %115, %109, %104, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %126 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dx, i64 noundef 3) #4
  %127 = load i64, ptr %126, align 8, !tbaa !5
  %128 = add nsw i64 %127, %.sroa.0.0.copyload
  store i64 %128, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %129 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dy, i64 noundef 3) #4
  %130 = load i64, ptr %129, align 8, !tbaa !5
  %131 = add nsw i64 %130, %.sroa.5.0.copyload
  store i64 %131, ptr %8, align 8, !tbaa !5
  %132 = load i64, ptr %7, align 8
  %133 = load i64, ptr @r, align 8, !tbaa !5
  %134 = icmp slt i64 %132, %133
  %135 = icmp sgt i64 %132, -1
  %or.cond.3 = and i1 %135, %134
  %136 = icmp sgt i64 %131, -1
  %or.cond3.3 = select i1 %or.cond.3, i1 %136, i1 false
  %137 = load i64, ptr @c, align 8
  %138 = icmp slt i64 %131, %137
  %or.cond21.3 = select i1 %or.cond3.3, i1 %138, i1 false
  br i1 %or.cond21.3, label %139, label %.loopexit

139:                                              ; preds = %125
  %140 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_Z6secondB5cxx11, i64 noundef %132) #4
  %141 = load i64, ptr %8, align 8, !tbaa !5
  %142 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %140, i64 noundef %141)
  %143 = load i8, ptr %142, align 1, !tbaa !11
  %.not.3 = icmp eq i8 %143, 84
  br i1 %.not.3, label %.loopexit, label %144

144:                                              ; preds = %139
  %145 = load i64, ptr %7, align 8, !tbaa !5
  %146 = load i64, ptr %8, align 8, !tbaa !5
  %147 = getelementptr inbounds [1002 x [1002 x i8]], ptr @vis, i64 0, i64 %145, i64 %146
  %148 = load i8, ptr %147, align 1, !tbaa !9, !range !12, !noundef !13
  %149 = trunc nuw i8 %148 to i1
  br i1 %149, label %.loopexit, label %150

150:                                              ; preds = %144
  %151 = load i64, ptr %16, align 8, !tbaa !5
  %152 = load i64, ptr @dis1, align 8, !tbaa !5
  %.not18.3 = icmp eq i64 %151, %152
  br i1 %.not18.3, label %.loopexit, label %153

153:                                              ; preds = %150
  store i8 1, ptr %147, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  invoke void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %154 unwind label %53

154:                                              ; preds = %153
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  %155 = load i64, ptr %16, align 8, !tbaa !5
  %156 = add nsw i64 %155, 1
  %157 = load i64, ptr %7, align 8, !tbaa !5
  %158 = load i64, ptr %8, align 8, !tbaa !5
  %159 = getelementptr inbounds [1002 x [1002 x i64]], ptr @dis, i64 0, i64 %157, i64 %158
  store i64 %156, ptr %159, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %154, %150, %144, %139, %125
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  %160 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  br i1 %160, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.loopexit, %10
  call void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %5) #4
  ret void

161:                                              ; preds = %53, %30
  %.pn = phi { ptr, i32 } [ %54, %53 ], [ %31, %30 ]
  call void @_ZNSt5queueISt4pairIllESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %5) #4
  resume { ptr, i32 } %.pn
}

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

!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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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