; LLVM IR from eyangch/competitive-programming :: USACOcontests/platinum/2020.01 (cave)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@MOD = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@_Z6secondB5cxx11 = external dso_local global [1000 x %"class.std::__cxx11::basic_string"], align 16
@ways = external dso_local global [1000 x [1000 x i64]], align 16
@par = external dso_local global [1000 x [1000 x i64]], align 16
@graph = external dso_local global [2 x [1000 x %"class.std::vector"]], align 16
@vis = external dso_local global [2 x [1000 x i8]], align 16
@active = external dso_local global [1000 x [1000 x i8]], align 16
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsxxxx(i64 noundef, i64 noundef, i64 noundef, i64 noundef) #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 norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, 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 i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %24 = load ptr, ptr @stdin, align 8, !tbaa !5
  %25 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.4, ptr noundef %24)
  %26 = load ptr, ptr @stdout, align 8, !tbaa !5
  %27 = call ptr @freopen(ptr noundef @.str.5, ptr noundef @.str.6, ptr noundef %26)
  %28 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %29 = getelementptr i8, ptr %28, i64 -24
  %30 = load i64, ptr %29, align 8
  %31 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %30
  %32 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %31, ptr noundef null)
  %33 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %34, ptr noundef nonnull align 8 dereferenceable(8) @M)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 0, ptr %2, align 8, !tbaa !11
  br label %36

36:                                               ; preds = %45, %0
  %37 = load i64, ptr %2, align 8, !tbaa !11
  %38 = load i64, ptr @N, align 8, !tbaa !11
  %39 = icmp slt i64 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  br label %48

41:                                               ; preds = %36
  %42 = load i64, ptr %2, align 8, !tbaa !11
  %43 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %42
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %43)
  br label %45

45:                                               ; preds = %41
  %46 = load i64, ptr %2, align 8, !tbaa !11
  %47 = add nsw i64 %46, 1
  store i64 %47, ptr %2, align 8, !tbaa !11
  br label %36, !llvm.loop !13

48:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 0, ptr %3, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %69, %48
  %50 = load i64, ptr %3, align 8, !tbaa !11
  %51 = load i64, ptr @N, align 8, !tbaa !11
  %52 = icmp slt i64 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %72

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %65, %54
  %56 = load i64, ptr %5, align 8, !tbaa !11
  %57 = load i64, ptr @M, align 8, !tbaa !11
  %58 = icmp slt i64 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %68

60:                                               ; preds = %55
  %61 = load i64, ptr %3, align 8, !tbaa !11
  %62 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %61
  %63 = load i64, ptr %5, align 8, !tbaa !11
  %64 = getelementptr inbounds [1000 x i64], ptr %62, i64 0, i64 %63
  store i64 1, ptr %64, align 8, !tbaa !11
  br label %65

65:                                               ; preds = %60
  %66 = load i64, ptr %5, align 8, !tbaa !11
  %67 = add nsw i64 %66, 1
  store i64 %67, ptr %5, align 8, !tbaa !11
  br label %55, !llvm.loop !15

68:                                               ; preds = %59
  br label %69

69:                                               ; preds = %68
  %70 = load i64, ptr %3, align 8, !tbaa !11
  %71 = add nsw i64 %70, 1
  store i64 %71, ptr %3, align 8, !tbaa !11
  br label %49, !llvm.loop !16

72:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %73 = load i64, ptr @N, align 8, !tbaa !11
  %74 = sub nsw i64 %73, 2
  store i64 %74, ptr %6, align 8, !tbaa !11
  br label %75

75:                                               ; preds = %374, %72
  %76 = load i64, ptr %6, align 8, !tbaa !11
  %77 = icmp sgt i64 %76, 0
  br i1 %77, label %79, label %78

78:                                               ; preds = %75
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %377

79:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !11
  br label %80

80:                                               ; preds = %94, %79
  %81 = load i64, ptr %7, align 8, !tbaa !11
  %82 = load i64, ptr @M, align 8, !tbaa !11
  %83 = icmp slt i64 %81, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %80
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %97

85:                                               ; preds = %80
  %86 = load i64, ptr %7, align 8, !tbaa !11
  %87 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @graph, i64 0, i64 %86
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %87) #6
  %88 = load i64, ptr %7, align 8, !tbaa !11
  %89 = getelementptr inbounds [1000 x %"class.std::vector"], ptr getelementptr inbounds ([2 x [1000 x %"class.std::vector"]], ptr @graph, i64 0, i64 1), i64 0, i64 %88
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %89) #6
  %90 = load i64, ptr %7, align 8, !tbaa !11
  %91 = getelementptr inbounds [1000 x i8], ptr getelementptr inbounds ([2 x [1000 x i8]], ptr @vis, i64 0, i64 1), i64 0, i64 %90
  store i8 0, ptr %91, align 1, !tbaa !17
  %92 = load i64, ptr %7, align 8, !tbaa !11
  %93 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %92
  store i8 0, ptr %93, align 1, !tbaa !17
  br label %94

94:                                               ; preds = %85
  %95 = load i64, ptr %7, align 8, !tbaa !11
  %96 = add nsw i64 %95, 1
  store i64 %96, ptr %7, align 8, !tbaa !11
  br label %80, !llvm.loop !19

97:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %98

98:                                               ; preds = %121, %97
  %99 = load i64, ptr %9, align 8, !tbaa !11
  %100 = load i64, ptr @M, align 8, !tbaa !11
  %101 = icmp slt i64 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 17, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %124

103:                                              ; preds = %98
  %104 = load i64, ptr %6, align 8, !tbaa !11
  %105 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %104
  %106 = load i64, ptr %9, align 8, !tbaa !11
  %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 !20
  %109 = sext i8 %108 to i32
  %110 = icmp eq i32 %109, 35
  br i1 %110, label %111, label %114

111:                                              ; preds = %103
  %112 = load i64, ptr %9, align 8, !tbaa !11
  %113 = add nsw i64 %112, 1
  store i64 %113, ptr %8, align 8, !tbaa !11
  br label %120

114:                                              ; preds = %103
  %115 = load i64, ptr %8, align 8, !tbaa !11
  %116 = load i64, ptr %6, align 8, !tbaa !11
  %117 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %116
  %118 = load i64, ptr %9, align 8, !tbaa !11
  %119 = getelementptr inbounds [1000 x i64], ptr %117, i64 0, i64 %118
  store i64 %115, ptr %119, align 8, !tbaa !11
  br label %120

120:                                              ; preds = %114, %111
  br label %121

121:                                              ; preds = %120
  %122 = load i64, ptr %9, align 8, !tbaa !11
  %123 = add nsw i64 %122, 1
  store i64 %123, ptr %9, align 8, !tbaa !11
  br label %98, !llvm.loop !21

124:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %125

125:                                              ; preds = %164, %124
  %126 = load i64, ptr %10, align 8, !tbaa !11
  %127 = load i64, ptr @M, align 8, !tbaa !11
  %128 = icmp slt i64 %126, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %125
  store i32 20, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %167

130:                                              ; preds = %125
  %131 = load i64, ptr %6, align 8, !tbaa !11
  %132 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %131
  %133 = load i64, ptr %10, align 8, !tbaa !11
  %134 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %132, i64 noundef %133)
  %135 = load i8, ptr %134, align 1, !tbaa !20
  %136 = sext i8 %135 to i32
  %137 = icmp eq i32 %136, 35
  br i1 %137, label %147, label %138

138:                                              ; preds = %130
  %139 = load i64, ptr %6, align 8, !tbaa !11
  %140 = add nsw i64 %139, 1
  %141 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %140
  %142 = load i64, ptr %10, align 8, !tbaa !11
  %143 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %141, i64 noundef %142)
  %144 = load i8, ptr %143, align 1, !tbaa !20
  %145 = sext i8 %144 to i32
  %146 = icmp eq i32 %145, 35
  br i1 %146, label %147, label %148

147:                                              ; preds = %138, %130
  br label %164

148:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %149 = load i64, ptr %6, align 8, !tbaa !11
  %150 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %149
  %151 = load i64, ptr %10, align 8, !tbaa !11
  %152 = getelementptr inbounds [1000 x i64], ptr %150, i64 0, i64 %151
  %153 = load i64, ptr %152, align 8, !tbaa !11
  store i64 %153, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %154 = load i64, ptr %6, align 8, !tbaa !11
  %155 = add nsw i64 %154, 1
  %156 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %155
  %157 = load i64, ptr %10, align 8, !tbaa !11
  %158 = getelementptr inbounds [1000 x i64], ptr %156, i64 0, i64 %157
  %159 = load i64, ptr %158, align 8, !tbaa !11
  store i64 %159, ptr %12, align 8, !tbaa !11
  %160 = load i64, ptr %11, align 8, !tbaa !11
  %161 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @graph, i64 0, i64 %160
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %161, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %162 = load i64, ptr %12, align 8, !tbaa !11
  %163 = getelementptr inbounds [1000 x %"class.std::vector"], ptr getelementptr inbounds ([2 x [1000 x %"class.std::vector"]], ptr @graph, i64 0, i64 1), i64 0, i64 %162
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %163, ptr noundef nonnull align 8 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %164

164:                                              ; preds = %148, %147
  %165 = load i64, ptr %10, align 8, !tbaa !11
  %166 = add nsw i64 %165, 1
  store i64 %166, ptr %10, align 8, !tbaa !11
  br label %125, !llvm.loop !22

167:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 0, ptr %13, align 8, !tbaa !11
  br label %168

168:                                              ; preds = %195, %167
  %169 = load i64, ptr %13, align 8, !tbaa !11
  %170 = load i64, ptr @M, align 8, !tbaa !11
  %171 = icmp slt i64 %169, %170
  br i1 %171, label %173, label %172

172:                                              ; preds = %168
  store i32 23, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %198

173:                                              ; preds = %168
  %174 = load i64, ptr %6, align 8, !tbaa !11
  %175 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %174
  %176 = load i64, ptr %13, align 8, !tbaa !11
  %177 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %175, i64 noundef %176)
  %178 = load i8, ptr %177, align 1, !tbaa !20
  %179 = sext i8 %178 to i32
  %180 = icmp eq i32 %179, 35
  br i1 %180, label %186, label %181

181:                                              ; preds = %173
  %182 = load i64, ptr %13, align 8, !tbaa !11
  %183 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %182
  %184 = load i8, ptr %183, align 1, !tbaa !17, !range !23, !noundef !24
  %185 = trunc i8 %184 to i1
  br i1 %185, label %186, label %187

186:                                              ; preds = %181, %173
  br label %195

187:                                              ; preds = %181
  %188 = load i64, ptr %13, align 8, !tbaa !11
  %189 = load i64, ptr %6, align 8, !tbaa !11
  %190 = load i64, ptr %6, align 8, !tbaa !11
  %191 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %190
  %192 = load i64, ptr %13, align 8, !tbaa !11
  %193 = getelementptr inbounds [1000 x i64], ptr %191, i64 0, i64 %192
  %194 = load i64, ptr %193, align 8, !tbaa !11
  call void @_Z3dfsxxxx(i64 noundef 0, i64 noundef %188, i64 noundef %189, i64 noundef %194)
  br label %195

195:                                              ; preds = %187, %186
  %196 = load i64, ptr %13, align 8, !tbaa !11
  %197 = add nsw i64 %196, 1
  store i64 %197, ptr %13, align 8, !tbaa !11
  br label %168, !llvm.loop !25

198:                                              ; preds = %172
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %199

199:                                              ; preds = %227, %198
  %200 = load i64, ptr %14, align 8, !tbaa !11
  %201 = load i64, ptr @M, align 8, !tbaa !11
  %202 = icmp slt i64 %200, %201
  br i1 %202, label %204, label %203

203:                                              ; preds = %199
  store i32 26, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %230

204:                                              ; preds = %199
  %205 = load i64, ptr %6, align 8, !tbaa !11
  %206 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %205
  %207 = load i64, ptr %14, align 8, !tbaa !11
  %208 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %206, i64 noundef %207)
  %209 = load i8, ptr %208, align 1, !tbaa !20
  %210 = sext i8 %209 to i32
  %211 = icmp eq i32 %210, 35
  br i1 %211, label %212, label %213

212:                                              ; preds = %204
  br label %227

213:                                              ; preds = %204
  %214 = load i64, ptr %6, align 8, !tbaa !11
  %215 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %214
  %216 = load i64, ptr %6, align 8, !tbaa !11
  %217 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %216
  %218 = load i64, ptr %14, align 8, !tbaa !11
  %219 = getelementptr inbounds [1000 x i64], ptr %217, i64 0, i64 %218
  %220 = load i64, ptr %219, align 8, !tbaa !11
  %221 = getelementptr inbounds [1000 x i64], ptr %215, i64 0, i64 %220
  %222 = load i64, ptr %221, align 8, !tbaa !11
  %223 = load i64, ptr %6, align 8, !tbaa !11
  %224 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %223
  %225 = load i64, ptr %14, align 8, !tbaa !11
  %226 = getelementptr inbounds [1000 x i64], ptr %224, i64 0, i64 %225
  store i64 %222, ptr %226, align 8, !tbaa !11
  br label %227

227:                                              ; preds = %213, %212
  %228 = load i64, ptr %14, align 8, !tbaa !11
  %229 = add nsw i64 %228, 1
  store i64 %229, ptr %14, align 8, !tbaa !11
  br label %199, !llvm.loop !26

230:                                              ; preds = %203
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 0, ptr %15, align 8, !tbaa !11
  br label %231

231:                                              ; preds = %239, %230
  %232 = load i64, ptr %15, align 8, !tbaa !11
  %233 = load i64, ptr @M, align 8, !tbaa !11
  %234 = icmp slt i64 %232, %233
  br i1 %234, label %236, label %235

235:                                              ; preds = %231
  store i32 29, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %242

236:                                              ; preds = %231
  %237 = load i64, ptr %15, align 8, !tbaa !11
  %238 = getelementptr inbounds [1000 x i8], ptr getelementptr inbounds ([2 x [1000 x i8]], ptr @vis, i64 0, i64 1), i64 0, i64 %237
  store i8 0, ptr %238, align 1, !tbaa !17
  br label %239

239:                                              ; preds = %236
  %240 = load i64, ptr %15, align 8, !tbaa !11
  %241 = add nsw i64 %240, 1
  store i64 %241, ptr %15, align 8, !tbaa !11
  br label %231, !llvm.loop !27

242:                                              ; preds = %235
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store i64 0, ptr %16, align 8, !tbaa !11
  br label %243

243:                                              ; preds = %312, %242
  %244 = load i64, ptr %16, align 8, !tbaa !11
  %245 = load i64, ptr @M, align 8, !tbaa !11
  %246 = icmp slt i64 %244, %245
  br i1 %246, label %248, label %247

247:                                              ; preds = %243
  store i32 32, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %315

248:                                              ; preds = %243
  %249 = load i64, ptr %6, align 8, !tbaa !11
  %250 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %249
  %251 = load i64, ptr %16, align 8, !tbaa !11
  %252 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %250, i64 noundef %251)
  %253 = load i8, ptr %252, align 1, !tbaa !20
  %254 = sext i8 %253 to i32
  %255 = icmp eq i32 %254, 35
  br i1 %255, label %265, label %256

256:                                              ; preds = %248
  %257 = load i64, ptr %6, align 8, !tbaa !11
  %258 = add nsw i64 %257, 1
  %259 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %258
  %260 = load i64, ptr %16, align 8, !tbaa !11
  %261 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %259, i64 noundef %260)
  %262 = load i8, ptr %261, align 1, !tbaa !20
  %263 = sext i8 %262 to i32
  %264 = icmp eq i32 %263, 35
  br i1 %264, label %265, label %266

265:                                              ; preds = %256, %248
  br label %312

266:                                              ; preds = %256
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %267 = load i64, ptr %6, align 8, !tbaa !11
  %268 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %267
  %269 = load i64, ptr %16, align 8, !tbaa !11
  %270 = getelementptr inbounds [1000 x i64], ptr %268, i64 0, i64 %269
  %271 = load i64, ptr %270, align 8, !tbaa !11
  store i64 %271, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %272 = load i64, ptr %6, align 8, !tbaa !11
  %273 = add nsw i64 %272, 1
  %274 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %273
  %275 = load i64, ptr %16, align 8, !tbaa !11
  %276 = getelementptr inbounds [1000 x i64], ptr %274, i64 0, i64 %275
  %277 = load i64, ptr %276, align 8, !tbaa !11
  store i64 %277, ptr %18, align 8, !tbaa !11
  %278 = load i64, ptr %18, align 8, !tbaa !11
  %279 = getelementptr inbounds [1000 x i8], ptr getelementptr inbounds ([2 x [1000 x i8]], ptr @vis, i64 0, i64 1), i64 0, i64 %278
  %280 = load i8, ptr %279, align 1, !tbaa !17, !range !23, !noundef !24
  %281 = trunc i8 %280 to i1
  br i1 %281, label %282, label %283

282:                                              ; preds = %266
  store i32 34, ptr %4, align 4
  br label %309

283:                                              ; preds = %266
  %284 = load i64, ptr %18, align 8, !tbaa !11
  %285 = getelementptr inbounds [1000 x i8], ptr getelementptr inbounds ([2 x [1000 x i8]], ptr @vis, i64 0, i64 1), i64 0, i64 %284
  store i8 1, ptr %285, align 1, !tbaa !17
  %286 = load i64, ptr %6, align 8, !tbaa !11
  %287 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %286
  %288 = load i64, ptr %17, align 8, !tbaa !11
  %289 = getelementptr inbounds [1000 x i64], ptr %287, i64 0, i64 %288
  %290 = load i64, ptr %289, align 8, !tbaa !11
  %291 = load i64, ptr %6, align 8, !tbaa !11
  %292 = add nsw i64 %291, 1
  %293 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %292
  %294 = load i64, ptr %18, align 8, !tbaa !11
  %295 = getelementptr inbounds [1000 x i64], ptr %293, i64 0, i64 %294
  %296 = load i64, ptr %295, align 8, !tbaa !11
  %297 = mul nsw i64 %290, %296
  %298 = load i64, ptr @MOD, align 8, !tbaa !11
  %299 = srem i64 %297, %298
  %300 = load i64, ptr %6, align 8, !tbaa !11
  %301 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %300
  %302 = load i64, ptr %17, align 8, !tbaa !11
  %303 = getelementptr inbounds [1000 x i64], ptr %301, i64 0, i64 %302
  store i64 %299, ptr %303, align 8, !tbaa !11
  %304 = load i64, ptr %6, align 8, !tbaa !11
  %305 = add nsw i64 %304, 1
  %306 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %305
  %307 = load i64, ptr %18, align 8, !tbaa !11
  %308 = getelementptr inbounds [1000 x i8], ptr %306, i64 0, i64 %307
  store i8 0, ptr %308, align 1, !tbaa !17
  store i32 0, ptr %4, align 4
  br label %309

309:                                              ; preds = %283, %282
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  %310 = load i32, ptr %4, align 4
  switch i32 %310, label %419 [
    i32 0, label %311
    i32 34, label %312
  ]

311:                                              ; preds = %309
  br label %312

312:                                              ; preds = %311, %309, %265
  %313 = load i64, ptr %16, align 8, !tbaa !11
  %314 = add nsw i64 %313, 1
  store i64 %314, ptr %16, align 8, !tbaa !11
  br label %243, !llvm.loop !28

315:                                              ; preds = %247
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  store i64 0, ptr %19, align 8, !tbaa !11
  br label %316

316:                                              ; preds = %339, %315
  %317 = load i64, ptr %19, align 8, !tbaa !11
  %318 = load i64, ptr @M, align 8, !tbaa !11
  %319 = icmp slt i64 %317, %318
  br i1 %319, label %321, label %320

320:                                              ; preds = %316
  store i32 35, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %342

321:                                              ; preds = %316
  %322 = load i64, ptr %6, align 8, !tbaa !11
  %323 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %322
  %324 = load i64, ptr %19, align 8, !tbaa !11
  %325 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %323, i64 noundef %324)
  %326 = load i8, ptr %325, align 1, !tbaa !20
  %327 = sext i8 %326 to i32
  %328 = icmp eq i32 %327, 35
  br i1 %328, label %329, label %330

329:                                              ; preds = %321
  br label %339

330:                                              ; preds = %321
  %331 = load i64, ptr %6, align 8, !tbaa !11
  %332 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %331
  %333 = load i64, ptr %6, align 8, !tbaa !11
  %334 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %333
  %335 = load i64, ptr %19, align 8, !tbaa !11
  %336 = getelementptr inbounds [1000 x i64], ptr %334, i64 0, i64 %335
  %337 = load i64, ptr %336, align 8, !tbaa !11
  %338 = getelementptr inbounds [1000 x i8], ptr %332, i64 0, i64 %337
  store i8 1, ptr %338, align 1, !tbaa !17
  br label %339

339:                                              ; preds = %330, %329
  %340 = load i64, ptr %19, align 8, !tbaa !11
  %341 = add nsw i64 %340, 1
  store i64 %341, ptr %19, align 8, !tbaa !11
  br label %316, !llvm.loop !29

342:                                              ; preds = %320
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  store i64 0, ptr %20, align 8, !tbaa !11
  br label %343

343:                                              ; preds = %370, %342
  %344 = load i64, ptr %20, align 8, !tbaa !11
  %345 = load i64, ptr @M, align 8, !tbaa !11
  %346 = icmp slt i64 %344, %345
  br i1 %346, label %348, label %347

347:                                              ; preds = %343
  store i32 38, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  br label %373

348:                                              ; preds = %343
  %349 = load i64, ptr %20, align 8, !tbaa !11
  %350 = load i64, ptr %6, align 8, !tbaa !11
  %351 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %350
  %352 = load i64, ptr %20, align 8, !tbaa !11
  %353 = getelementptr inbounds [1000 x i64], ptr %351, i64 0, i64 %352
  %354 = load i64, ptr %353, align 8, !tbaa !11
  %355 = icmp eq i64 %349, %354
  br i1 %355, label %356, label %369

356:                                              ; preds = %348
  %357 = load i64, ptr %6, align 8, !tbaa !11
  %358 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %357
  %359 = load i64, ptr %20, align 8, !tbaa !11
  %360 = getelementptr inbounds [1000 x i64], ptr %358, i64 0, i64 %359
  %361 = load i64, ptr %360, align 8, !tbaa !11
  %362 = add nsw i64 %361, 1
  %363 = load i64, ptr @MOD, align 8, !tbaa !11
  %364 = srem i64 %362, %363
  %365 = load i64, ptr %6, align 8, !tbaa !11
  %366 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %365
  %367 = load i64, ptr %20, align 8, !tbaa !11
  %368 = getelementptr inbounds [1000 x i64], ptr %366, i64 0, i64 %367
  store i64 %364, ptr %368, align 8, !tbaa !11
  br label %369

369:                                              ; preds = %356, %348
  br label %370

370:                                              ; preds = %369
  %371 = load i64, ptr %20, align 8, !tbaa !11
  %372 = add nsw i64 %371, 1
  store i64 %372, ptr %20, align 8, !tbaa !11
  br label %343, !llvm.loop !30

373:                                              ; preds = %347
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %374

374:                                              ; preds = %373
  %375 = load i64, ptr %6, align 8, !tbaa !11
  %376 = add nsw i64 %375, -1
  store i64 %376, ptr %6, align 8, !tbaa !11
  br label %75, !llvm.loop !31

377:                                              ; preds = %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  store i64 1, ptr %21, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  store i64 0, ptr %22, align 8, !tbaa !11
  br label %378

378:                                              ; preds = %411, %377
  %379 = load i64, ptr %22, align 8, !tbaa !11
  %380 = load i64, ptr @N, align 8, !tbaa !11
  %381 = icmp slt i64 %379, %380
  br i1 %381, label %383, label %382

382:                                              ; preds = %378
  store i32 41, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  br label %414

383:                                              ; preds = %378
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  store i64 0, ptr %23, align 8, !tbaa !11
  br label %384

384:                                              ; preds = %407, %383
  %385 = load i64, ptr %23, align 8, !tbaa !11
  %386 = load i64, ptr @M, align 8, !tbaa !11
  %387 = icmp slt i64 %385, %386
  br i1 %387, label %389, label %388

388:                                              ; preds = %384
  store i32 44, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  br label %410

389:                                              ; preds = %384
  %390 = load i64, ptr %22, align 8, !tbaa !11
  %391 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %390
  %392 = load i64, ptr %23, align 8, !tbaa !11
  %393 = getelementptr inbounds [1000 x i8], ptr %391, i64 0, i64 %392
  %394 = load i8, ptr %393, align 1, !tbaa !17, !range !23, !noundef !24
  %395 = trunc i8 %394 to i1
  br i1 %395, label %396, label %406

396:                                              ; preds = %389
  %397 = load i64, ptr %21, align 8, !tbaa !11
  %398 = load i64, ptr %22, align 8, !tbaa !11
  %399 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %398
  %400 = load i64, ptr %23, align 8, !tbaa !11
  %401 = getelementptr inbounds [1000 x i64], ptr %399, i64 0, i64 %400
  %402 = load i64, ptr %401, align 8, !tbaa !11
  %403 = mul nsw i64 %397, %402
  %404 = load i64, ptr @MOD, align 8, !tbaa !11
  %405 = srem i64 %403, %404
  store i64 %405, ptr %21, align 8, !tbaa !11
  br label %406

406:                                              ; preds = %396, %389
  br label %407

407:                                              ; preds = %406
  %408 = load i64, ptr %23, align 8, !tbaa !11
  %409 = add nsw i64 %408, 1
  store i64 %409, ptr %23, align 8, !tbaa !11
  br label %384, !llvm.loop !32

410:                                              ; preds = %388
  br label %411

411:                                              ; preds = %410
  %412 = load i64, ptr %22, align 8, !tbaa !11
  %413 = add nsw i64 %412, 1
  store i64 %413, ptr %22, align 8, !tbaa !11
  br label %378, !llvm.loop !33

414:                                              ; preds = %382
  %415 = load i64, ptr %21, align 8, !tbaa !11
  %416 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %415)
  %417 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %416, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  %418 = load i32, ptr %1, align 4
  ret i32 %418

419:                                              ; preds = %309
  unreachable
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #4 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 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) #4 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse 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 = { "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 = { 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 = { inlinehint 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 #6 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = distinct !{!19, !14}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = distinct !{!25, !14}
!26 = distinct !{!26, !14}
!27 = distinct !{!27, !14}
!28 = distinct !{!28, !14}
!29 = distinct !{!29, !14}
!30 = distinct !{!30, !14}
!31 = distinct !{!31, !14}
!32 = distinct !{!32, !14}
!33 = distinct !{!33, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@MOD = external dso_local local_unnamed_addr global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@_Z6secondB5cxx11 = external dso_local global [1000 x %"class.std::__cxx11::basic_string"], align 16
@ways = external dso_local local_unnamed_addr global [1000 x [1000 x i64]], align 16
@par = external dso_local local_unnamed_addr global [1000 x [1000 x i64]], align 16
@graph = external dso_local global [2 x [1000 x %"class.std::vector"]], align 16
@vis = external dso_local local_unnamed_addr global [2 x [1000 x i8]], align 16
@active = external dso_local local_unnamed_addr global [1000 x [1000 x i8]], align 16
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsxxxx(i64 noundef, i64 noundef, i64 noundef, i64 noundef) 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = load ptr, ptr @stdin, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4, ptr noundef %3)
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, ptr noundef %5)
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %15 = load i64, ptr @N, align 8, !tbaa !11
  %16 = icmp sgt i64 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge169

.preheader132:                                    ; preds = %.lr.ph
  %17 = icmp sgt i64 %29, 0
  br i1 %17, label %.preheader131.lr.ph, label %._crit_edge169

.preheader131.lr.ph:                              ; preds = %.preheader132
  %18 = load i64, ptr @M, align 8, !tbaa !11
  %19 = icmp sgt i64 %18, 0
  br i1 %19, label %.preheader131.us.preheader, label %._crit_edge139

.preheader131.us.preheader:                       ; preds = %.preheader131.lr.ph
  %min.iters.check = icmp ult i64 %18, 4
  %n.vec = and i64 %18, 9223372036854775804
  %cmp.n = icmp eq i64 %18, %n.vec
  br label %.preheader131.us

.preheader131.us:                                 ; preds = %.preheader131.us.preheader, %._crit_edge.us
  %.0108138.us = phi i64 [ %25, %._crit_edge.us ], [ 0, %.preheader131.us.preheader ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.preheader131.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader131.us ]
  %20 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %.0108138.us, i64 %index
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store <2 x i64> <i64 1, i64 1>, ptr %20, align 16, !tbaa !11
  store <2 x i64> <i64 1, i64 1>, ptr %21, align 16, !tbaa !11
  %index.next = add nuw i64 %index, 4
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader131.us
  %.0119136.us.ph = phi i64 [ 0, %.preheader131.us ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.0119136.us = phi i64 [ %24, %scalar.ph ], [ %.0119136.us.ph, %scalar.ph.preheader ]
  %23 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %.0108138.us, i64 %.0119136.us
  store i64 1, ptr %23, align 8, !tbaa !11
  %24 = add nuw nsw i64 %.0119136.us, 1
  %exitcond.not = icmp eq i64 %24, %18
  br i1 %exitcond.not, label %._crit_edge.us, label %scalar.ph, !llvm.loop !17

._crit_edge.us:                                   ; preds = %scalar.ph, %middle.block
  %25 = add nuw nsw i64 %.0108138.us, 1
  %exitcond176.not = icmp eq i64 %25, %29
  br i1 %exitcond176.not, label %._crit_edge139, label %.preheader131.us, !llvm.loop !18

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.0107135 = phi i64 [ %28, %.lr.ph ], [ 0, %0 ]
  %26 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %.0107135
  %27 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %26)
  %28 = add nuw nsw i64 %.0107135, 1
  %29 = load i64, ptr @N, align 8, !tbaa !11
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %.lr.ph, label %.preheader132, !llvm.loop !19

._crit_edge139:                                   ; preds = %._crit_edge.us, %.preheader131.lr.ph
  %31 = icmp sgt i64 %29, 2
  br i1 %31, label %.preheader130.preheader, label %.preheader121

.preheader130.preheader:                          ; preds = %._crit_edge139
  %32 = add nsw i64 %29, -2
  %.pre = load i64, ptr @M, align 8, !tbaa !11
  br label %.preheader130

.preheader130:                                    ; preds = %.preheader130.preheader, %._crit_edge
  %33 = phi i64 [ %195, %._crit_edge ], [ %.pre, %.preheader130.preheader ]
  %.0118161 = phi i64 [ %196, %._crit_edge ], [ %32, %.preheader130.preheader ]
  %34 = icmp sgt i64 %33, 0
  br i1 %34, label %.lr.ph141, label %._crit_edge

.preheader121.loopexit:                           ; preds = %._crit_edge
  %.pre180 = load i64, ptr @N, align 8, !tbaa !11
  br label %.preheader121

.preheader121:                                    ; preds = %.preheader121.loopexit, %._crit_edge139
  %35 = phi i64 [ %.pre180, %.preheader121.loopexit ], [ %29, %._crit_edge139 ]
  %36 = icmp sgt i64 %35, 0
  br i1 %36, label %.preheader.lr.ph, label %._crit_edge169

.preheader.lr.ph:                                 ; preds = %.preheader121
  %37 = load i64, ptr @M, align 8, !tbaa !11
  %38 = icmp sgt i64 %37, 0
  %39 = load i64, ptr @MOD, align 8
  br i1 %38, label %.preheader.us.preheader, label %._crit_edge169

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %xtraiter = and i64 %37, 1
  %40 = icmp eq i64 %37, 1
  %unroll_iter = and i64 %37, 9223372036854775806
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge165.us
  %.0103168.us = phi i64 [ %69, %._crit_edge165.us ], [ 0, %.preheader.us.preheader ]
  %.0104167.us = phi i64 [ %.2.us.lcssa, %._crit_edge165.us ], [ 1, %.preheader.us.preheader ]
  br i1 %40, label %._crit_edge165.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %59
  %.0163.us = phi i64 [ %60, %59 ], [ 0, %.preheader.us ]
  %.1162.us = phi i64 [ %.2.us.1, %59 ], [ %.0104167.us, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %59 ], [ 0, %.preheader.us ]
  %41 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %.0103168.us, i64 %.0163.us
  %42 = load i8, ptr %41, align 2, !tbaa !20, !range !22, !noundef !23
  %43 = trunc nuw i8 %42 to i1
  br i1 %43, label %44, label %49

44:                                               ; preds = %.preheader.us.new
  %45 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %.0103168.us, i64 %.0163.us
  %46 = load i64, ptr %45, align 16, !tbaa !11
  %47 = mul nsw i64 %46, %.1162.us
  %48 = srem i64 %47, %39
  br label %49

49:                                               ; preds = %44, %.preheader.us.new
  %.2.us = phi i64 [ %48, %44 ], [ %.1162.us, %.preheader.us.new ]
  %50 = or disjoint i64 %.0163.us, 1
  %51 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %.0103168.us, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !20, !range !22, !noundef !23
  %53 = trunc nuw i8 %52 to i1
  br i1 %53, label %54, label %59

54:                                               ; preds = %49
  %55 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %.0103168.us, i64 %50
  %56 = load i64, ptr %55, align 8, !tbaa !11
  %57 = mul nsw i64 %56, %.2.us
  %58 = srem i64 %57, %39
  br label %59

59:                                               ; preds = %54, %49
  %.2.us.1 = phi i64 [ %58, %54 ], [ %.2.us, %49 ]
  %60 = add nuw nsw i64 %.0163.us, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge165.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !24

._crit_edge165.us.unr-lcssa:                      ; preds = %59, %.preheader.us
  %.2.us.lcssa.ph = phi i64 [ poison, %.preheader.us ], [ %.2.us.1, %59 ]
  %.0163.us.unr = phi i64 [ 0, %.preheader.us ], [ %60, %59 ]
  %.1162.us.unr = phi i64 [ %.0104167.us, %.preheader.us ], [ %.2.us.1, %59 ]
  br i1 %lcmp.mod.not, label %._crit_edge165.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge165.us.unr-lcssa
  %61 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %.0103168.us, i64 %.0163.us.unr
  %62 = load i8, ptr %61, align 1, !tbaa !20, !range !22, !noundef !23
  %63 = trunc nuw i8 %62 to i1
  br i1 %63, label %64, label %._crit_edge165.us

64:                                               ; preds = %.epil.preheader
  %65 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %.0103168.us, i64 %.0163.us.unr
  %66 = load i64, ptr %65, align 8, !tbaa !11
  %67 = mul nsw i64 %66, %.1162.us.unr
  %68 = srem i64 %67, %39
  br label %._crit_edge165.us

._crit_edge165.us:                                ; preds = %.epil.preheader, %64, %._crit_edge165.us.unr-lcssa
  %.2.us.lcssa = phi i64 [ %.2.us.lcssa.ph, %._crit_edge165.us.unr-lcssa ], [ %68, %64 ], [ %.1162.us.unr, %.epil.preheader ]
  %69 = add nuw nsw i64 %.0103168.us, 1
  %exitcond179.not = icmp eq i64 %69, %35
  br i1 %exitcond179.not, label %._crit_edge169, label %.preheader.us, !llvm.loop !25

.preheader129:                                    ; preds = %.lr.ph141
  %70 = icmp sgt i64 %77, 0
  br i1 %70, label %.lr.ph144, label %._crit_edge

.lr.ph144:                                        ; preds = %.preheader129
  %71 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %.0118161
  br label %83

.lr.ph141:                                        ; preds = %.preheader130, %.lr.ph141
  %.0117140 = phi i64 [ %76, %.lr.ph141 ], [ 0, %.preheader130 ]
  %72 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @graph, i64 0, i64 %.0117140
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %72) #7
  %73 = getelementptr inbounds [1000 x %"class.std::vector"], ptr getelementptr inbounds (i8, ptr @graph, i64 24000), i64 0, i64 %.0117140
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %73) #7
  %74 = getelementptr inbounds [1000 x i8], ptr getelementptr inbounds (i8, ptr @vis, i64 1000), i64 0, i64 %.0117140
  store i8 0, ptr %74, align 1, !tbaa !20
  %75 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %.0117140
  store i8 0, ptr %75, align 1, !tbaa !20
  %76 = add nuw nsw i64 %.0117140, 1
  %77 = load i64, ptr @M, align 8, !tbaa !11
  %78 = icmp slt i64 %76, %77
  br i1 %78, label %.lr.ph141, label %.preheader129, !llvm.loop !26

.preheader128:                                    ; preds = %91
  %79 = icmp sgt i64 %92, 0
  br i1 %79, label %.lr.ph146, label %._crit_edge

.lr.ph146:                                        ; preds = %.preheader128
  %80 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %.0118161
  %81 = add nuw nsw i64 %.0118161, 1
  %82 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %81
  br label %96

83:                                               ; preds = %.lr.ph144, %91
  %.0114143 = phi i64 [ 0, %.lr.ph144 ], [ %.pre-phi, %91 ]
  %.0115142 = phi i64 [ 0, %.lr.ph144 ], [ %.1116, %91 ]
  %84 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %71, i64 noundef %.0114143)
  %85 = load i8, ptr %84, align 1, !tbaa !27
  %86 = icmp eq i8 %85, 35
  br i1 %86, label %87, label %89

87:                                               ; preds = %83
  %88 = add nuw nsw i64 %.0114143, 1
  br label %91

89:                                               ; preds = %83
  %90 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %.0114143
  store i64 %.0115142, ptr %90, align 8, !tbaa !11
  %.pre181 = add nuw nsw i64 %.0114143, 1
  br label %91

91:                                               ; preds = %87, %89
  %.pre-phi = phi i64 [ %88, %87 ], [ %.pre181, %89 ]
  %.1116 = phi i64 [ %88, %87 ], [ %.0115142, %89 ]
  %92 = load i64, ptr @M, align 8, !tbaa !11
  %93 = icmp slt i64 %.pre-phi, %92
  br i1 %93, label %83, label %.preheader128, !llvm.loop !28

.preheader127:                                    ; preds = %112
  %94 = icmp sgt i64 %114, 0
  br i1 %94, label %.lr.ph148, label %._crit_edge

.lr.ph148:                                        ; preds = %.preheader127
  %95 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %.0118161
  br label %118

96:                                               ; preds = %.lr.ph146, %112
  %.0113145 = phi i64 [ 0, %.lr.ph146 ], [ %113, %112 ]
  %97 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %80, i64 noundef %.0113145)
  %98 = load i8, ptr %97, align 1, !tbaa !27
  %99 = icmp eq i8 %98, 35
  br i1 %99, label %112, label %100

100:                                              ; preds = %96
  %101 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %82, i64 noundef %.0113145)
  %102 = load i8, ptr %101, align 1, !tbaa !27
  %103 = icmp eq i8 %102, 35
  br i1 %103, label %112, label %104

104:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %105 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %.0113145
  %106 = load i64, ptr %105, align 8, !tbaa !11
  store i64 %106, ptr %1, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %107 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %81, i64 %.0113145
  %108 = load i64, ptr %107, align 8, !tbaa !11
  store i64 %108, ptr %2, align 8, !tbaa !11
  %109 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @graph, i64 0, i64 %106
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %109, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %110 = load i64, ptr %2, align 8, !tbaa !11
  %111 = getelementptr inbounds [1000 x %"class.std::vector"], ptr getelementptr inbounds (i8, ptr @graph, i64 24000), i64 0, i64 %110
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %111, ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  br label %112

112:                                              ; preds = %96, %100, %104
  %113 = add nuw nsw i64 %.0113145, 1
  %114 = load i64, ptr @M, align 8, !tbaa !11
  %115 = icmp slt i64 %113, %114
  br i1 %115, label %96, label %.preheader127, !llvm.loop !29

.preheader126:                                    ; preds = %129
  %116 = icmp sgt i64 %131, 0
  br i1 %116, label %.lr.ph150, label %._crit_edge

.lr.ph150:                                        ; preds = %.preheader126
  %117 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %.0118161
  br label %134

118:                                              ; preds = %.lr.ph148, %129
  %.0112147 = phi i64 [ 0, %.lr.ph148 ], [ %130, %129 ]
  %119 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %95, i64 noundef %.0112147)
  %120 = load i8, ptr %119, align 1, !tbaa !27
  %121 = icmp eq i8 %120, 35
  br i1 %121, label %129, label %122

122:                                              ; preds = %118
  %123 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %.0112147
  %124 = load i8, ptr %123, align 1, !tbaa !20, !range !22, !noundef !23
  %125 = trunc nuw i8 %124 to i1
  br i1 %125, label %129, label %126

126:                                              ; preds = %122
  %127 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %.0112147
  %128 = load i64, ptr %127, align 8, !tbaa !11
  call void @_Z3dfsxxxx(i64 noundef 0, i64 noundef %.0112147, i64 noundef %.0118161, i64 noundef %128)
  br label %129

129:                                              ; preds = %118, %122, %126
  %130 = add nuw nsw i64 %.0112147, 1
  %131 = load i64, ptr @M, align 8, !tbaa !11
  %132 = icmp slt i64 %130, %131
  br i1 %132, label %118, label %.preheader126, !llvm.loop !30

.preheader125:                                    ; preds = %143
  %133 = icmp sgt i64 %145, 0
  br i1 %133, label %.lr.ph155, label %._crit_edge

134:                                              ; preds = %.lr.ph150, %143
  %.0111149 = phi i64 [ 0, %.lr.ph150 ], [ %144, %143 ]
  %135 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %117, i64 noundef %.0111149)
  %136 = load i8, ptr %135, align 1, !tbaa !27
  %137 = icmp eq i8 %136, 35
  br i1 %137, label %143, label %138

138:                                              ; preds = %134
  %139 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %.0111149
  %140 = load i64, ptr %139, align 8, !tbaa !11
  %141 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %140
  %142 = load i64, ptr %141, align 8, !tbaa !11
  store i64 %142, ptr %139, align 8, !tbaa !11
  br label %143

143:                                              ; preds = %134, %138
  %144 = add nuw nsw i64 %.0111149, 1
  %145 = load i64, ptr @M, align 8, !tbaa !11
  %146 = icmp slt i64 %144, %145
  br i1 %146, label %134, label %.preheader125, !llvm.loop !31

.lr.ph155:                                        ; preds = %.preheader125
  call void @llvm.memset.p0.i64(ptr nonnull align 8 getelementptr inbounds (i8, ptr @vis, i64 1000), i8 0, i64 %145, i1 false), !tbaa !20
  %147 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %.0118161
  %148 = add nuw nsw i64 %.0118161, 1
  %149 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %148
  br label %152

.preheader123:                                    ; preds = %177
  %150 = icmp sgt i64 %179, 0
  br i1 %150, label %.lr.ph157, label %._crit_edge

.lr.ph157:                                        ; preds = %.preheader123
  %151 = getelementptr inbounds [1000 x %"class.std::__cxx11::basic_string"], ptr @_Z6secondB5cxx11, i64 0, i64 %.0118161
  br label %183

152:                                              ; preds = %.lr.ph155, %177
  %.0109154 = phi i64 [ 0, %.lr.ph155 ], [ %178, %177 ]
  %153 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %147, i64 noundef %.0109154)
  %154 = load i8, ptr %153, align 1, !tbaa !27
  %155 = icmp eq i8 %154, 35
  br i1 %155, label %177, label %156

156:                                              ; preds = %152
  %157 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %149, i64 noundef %.0109154)
  %158 = load i8, ptr %157, align 1, !tbaa !27
  %159 = icmp eq i8 %158, 35
  br i1 %159, label %177, label %160

160:                                              ; preds = %156
  %161 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %148, i64 %.0109154
  %162 = load i64, ptr %161, align 8, !tbaa !11
  %163 = getelementptr inbounds [1000 x i8], ptr getelementptr inbounds (i8, ptr @vis, i64 1000), i64 0, i64 %162
  %164 = load i8, ptr %163, align 1, !tbaa !20, !range !22, !noundef !23
  %165 = trunc nuw i8 %164 to i1
  br i1 %165, label %177, label %166

166:                                              ; preds = %160
  %167 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %.0109154
  %168 = load i64, ptr %167, align 8, !tbaa !11
  store i8 1, ptr %163, align 1, !tbaa !20
  %169 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %.0118161, i64 %168
  %170 = load i64, ptr %169, align 8, !tbaa !11
  %171 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %148, i64 %162
  %172 = load i64, ptr %171, align 8, !tbaa !11
  %173 = mul nsw i64 %172, %170
  %174 = load i64, ptr @MOD, align 8, !tbaa !11
  %175 = srem i64 %173, %174
  store i64 %175, ptr %169, align 8, !tbaa !11
  %176 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %148, i64 %162
  store i8 0, ptr %176, align 1, !tbaa !20
  br label %177

177:                                              ; preds = %166, %160, %152, %156
  %178 = add nuw nsw i64 %.0109154, 1
  %179 = load i64, ptr @M, align 8, !tbaa !11
  %180 = icmp slt i64 %178, %179
  br i1 %180, label %152, label %.preheader123, !llvm.loop !32

.preheader122:                                    ; preds = %191
  %181 = icmp sgt i64 %193, 0
  br i1 %181, label %.lr.ph160, label %._crit_edge

.lr.ph160:                                        ; preds = %.preheader122
  %182 = load i64, ptr @MOD, align 8
  br label %198

183:                                              ; preds = %.lr.ph157, %191
  %.0106156 = phi i64 [ 0, %.lr.ph157 ], [ %192, %191 ]
  %184 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %151, i64 noundef %.0106156)
  %185 = load i8, ptr %184, align 1, !tbaa !27
  %186 = icmp eq i8 %185, 35
  br i1 %186, label %191, label %187

187:                                              ; preds = %183
  %188 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %.0106156
  %189 = load i64, ptr %188, align 8, !tbaa !11
  %190 = getelementptr inbounds [1000 x [1000 x i8]], ptr @active, i64 0, i64 %.0118161, i64 %189
  store i8 1, ptr %190, align 1, !tbaa !20
  br label %191

191:                                              ; preds = %183, %187
  %192 = add nuw nsw i64 %.0106156, 1
  %193 = load i64, ptr @M, align 8, !tbaa !11
  %194 = icmp slt i64 %192, %193
  br i1 %194, label %183, label %.preheader122, !llvm.loop !33

._crit_edge:                                      ; preds = %207, %.preheader125, %.preheader130, %.preheader129, %.preheader128, %.preheader127, %.preheader126, %.preheader123, %.preheader122
  %195 = phi i64 [ %193, %.preheader122 ], [ %179, %.preheader123 ], [ %131, %.preheader126 ], [ %114, %.preheader127 ], [ %92, %.preheader128 ], [ %77, %.preheader129 ], [ %33, %.preheader130 ], [ %145, %.preheader125 ], [ %193, %207 ]
  %196 = add nsw i64 %.0118161, -1
  %197 = icmp sgt i64 %.0118161, 1
  br i1 %197, label %.preheader130, label %.preheader121.loopexit, !llvm.loop !34

198:                                              ; preds = %.lr.ph160, %207
  %.0105159 = phi i64 [ 0, %.lr.ph160 ], [ %208, %207 ]
  %199 = getelementptr inbounds [1000 x [1000 x i64]], ptr @par, i64 0, i64 %.0118161, i64 %.0105159
  %200 = load i64, ptr %199, align 8, !tbaa !11
  %201 = icmp eq i64 %.0105159, %200
  br i1 %201, label %202, label %207

202:                                              ; preds = %198
  %203 = getelementptr inbounds [1000 x [1000 x i64]], ptr @ways, i64 0, i64 %.0118161, i64 %.0105159
  %204 = load i64, ptr %203, align 8, !tbaa !11
  %205 = add nsw i64 %204, 1
  %206 = srem i64 %205, %182
  store i64 %206, ptr %203, align 8, !tbaa !11
  br label %207

207:                                              ; preds = %198, %202
  %208 = add nuw nsw i64 %.0105159, 1
  %exitcond177.not = icmp eq i64 %208, %193
  br i1 %exitcond177.not, label %._crit_edge, label %198, !llvm.loop !35

._crit_edge169:                                   ; preds = %._crit_edge165.us, %.preheader132, %0, %.preheader.lr.ph, %.preheader121
  %.0104.lcssa = phi i64 [ 1, %.preheader121 ], [ 1, %.preheader.lr.ph ], [ 1, %0 ], [ 1, %.preheader132 ], [ %.2.us.lcssa, %._crit_edge165.us ]
  %209 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.0104.lcssa)
  %210 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %209, i8 noundef signext 10)
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #4 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 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 #4 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse 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 = { "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 = { 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 = { inlinehint 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14, !15, !16}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !14, !16, !15}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !14}
!25 = distinct !{!25, !14}
!26 = distinct !{!26, !14}
!27 = !{!7, !7, i64 0}
!28 = distinct !{!28, !14}
!29 = distinct !{!29, !14}
!30 = distinct !{!30, !14}
!31 = distinct !{!31, !14}
!32 = distinct !{!32, !14}
!33 = distinct !{!33, !14}
!34 = distinct !{!34, !14}
!35 = distinct !{!35, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass