; LLVM IR from tangjz/acm-icpc :: uoj (19)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@s = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@pre = external dso_local global [10001 x i32], align 16
@suf = external dso_local global [10001 x i32], align 16
@que = external dso_local global [10001 x i32], align 16
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@dis = external dso_local global [10001 x i32], align 16
@vis = external dso_local global [10001 x i8], align 16
@g = external dso_local global [10001 x i8], align 16
@e = external dso_local global [400002 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %struct.Edge, align 4
  %5 = alloca %struct.Edge, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  br label %14

14:                                               ; preds = %18, %0
  %15 = load i32, ptr @m, align 4, !tbaa !5
  %16 = add nsw i32 %15, -1
  store i32 %16, ptr @m, align 4, !tbaa !5
  %17 = icmp ne i32 %15, 0
  br i1 %17, label %18, label %50

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %20 = getelementptr inbounds %struct.Edge, ptr %4, i32 0, i32 0
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [10001 x i32], ptr @pre, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %20, align 4, !tbaa !9
  %25 = getelementptr inbounds %struct.Edge, ptr %4, i32 0, i32 1
  %26 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %26, ptr %25, align 4, !tbaa !11
  %27 = load i32, ptr @tot, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr @tot, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %29
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %30, ptr align 4 %4, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %31 = load i32, ptr @tot, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [10001 x i32], ptr @pre, i64 0, i64 %33
  store i32 %31, ptr %34, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %35 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 0
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [10001 x i32], ptr @suf, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  store i32 %39, ptr %35, align 4, !tbaa !9
  %40 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 1
  %41 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %41, ptr %40, align 4, !tbaa !11
  %42 = load i32, ptr @tot, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr @tot, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %44
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %45, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %46 = load i32, ptr @tot, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [10001 x i32], ptr @suf, i64 0, i64 %48
  store i32 %46, ptr %49, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %14, !llvm.loop !13

50:                                               ; preds = %14
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @s, ptr noundef @t)
  %52 = load i32, ptr @t, align 4, !tbaa !5
  %53 = load i32, ptr @R, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr @R, align 4, !tbaa !5
  %55 = sext i32 %53 to i64
  %56 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %55
  store i32 %52, ptr %56, align 4, !tbaa !5
  %57 = load i32, ptr @t, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [10001 x i8], ptr @vis, i64 0, i64 %58
  store i8 1, ptr %59, align 1, !tbaa !15
  br label %60

60:                                               ; preds = %112, %50
  %61 = load i32, ptr @L, align 4, !tbaa !5
  %62 = load i32, ptr @R, align 4, !tbaa !5
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %64, label %113

64:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %65 = load i32, ptr @L, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr @L, align 4, !tbaa !5
  %67 = sext i32 %65 to i64
  %68 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  store i32 %69, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [10001 x i32], ptr @suf, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  store i32 %73, ptr %7, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %106, %64
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %78, label %77

77:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %112

78:                                               ; preds = %74
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %80
  %82 = getelementptr inbounds %struct.Edge, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !11
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [10001 x i8], ptr @vis, i64 0, i64 %84
  %86 = load i8, ptr %85, align 1, !tbaa !15, !range !17, !noundef !18
  %87 = trunc i8 %86 to i1
  br i1 %87, label %105, label %88

88:                                               ; preds = %78
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %90
  %92 = getelementptr inbounds %struct.Edge, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !11
  %94 = load i32, ptr @R, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr @R, align 4, !tbaa !5
  %96 = sext i32 %94 to i64
  %97 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %96
  store i32 %93, ptr %97, align 4, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %99
  %101 = getelementptr inbounds %struct.Edge, ptr %100, i32 0, i32 1
  %102 = load i32, ptr %101, align 4, !tbaa !11
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [10001 x i8], ptr @vis, i64 0, i64 %103
  store i8 1, ptr %104, align 1, !tbaa !15
  br label %105

105:                                              ; preds = %88, %78
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %7, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %108
  %110 = getelementptr inbounds %struct.Edge, ptr %109, i32 0, i32 0
  %111 = load i32, ptr %110, align 8, !tbaa !9
  store i32 %111, ptr %7, align 4, !tbaa !5
  br label %74, !llvm.loop !19

112:                                              ; preds = %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %60, !llvm.loop !20

113:                                              ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %166, %113
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = load i32, ptr @n, align 4, !tbaa !5
  %117 = icmp sle i32 %115, %116
  br i1 %117, label %119, label %118

118:                                              ; preds = %114
  store i32 9, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %169

119:                                              ; preds = %114
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %121
  store i8 1, ptr %122, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [10001 x i32], ptr @pre, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  store i32 %126, ptr %10, align 4, !tbaa !5
  br label %127

127:                                              ; preds = %159, %119
  %128 = load i32, ptr %10, align 4, !tbaa !5
  %129 = icmp ne i32 %128, 0
  br i1 %129, label %130, label %136

130:                                              ; preds = %127
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %132
  %134 = load i8, ptr %133, align 1, !tbaa !15, !range !17, !noundef !18
  %135 = trunc i8 %134 to i1
  br label %136

136:                                              ; preds = %130, %127
  %137 = phi i1 [ false, %127 ], [ %135, %130 ]
  br i1 %137, label %139, label %138

138:                                              ; preds = %136
  store i32 12, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %165

139:                                              ; preds = %136
  %140 = load i32, ptr %10, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %141
  %143 = getelementptr inbounds %struct.Edge, ptr %142, i32 0, i32 1
  %144 = load i32, ptr %143, align 4, !tbaa !11
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [10001 x i8], ptr @vis, i64 0, i64 %145
  %147 = load i8, ptr %146, align 1, !tbaa !15, !range !17, !noundef !18
  %148 = trunc i8 %147 to i1
  %149 = zext i1 %148 to i32
  %150 = load i32, ptr %8, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %151
  %153 = load i8, ptr %152, align 1, !tbaa !15, !range !17, !noundef !18
  %154 = trunc i8 %153 to i1
  %155 = zext i1 %154 to i32
  %156 = and i32 %155, %149
  %157 = icmp ne i32 %156, 0
  %158 = zext i1 %157 to i8
  store i8 %158, ptr %152, align 1, !tbaa !15
  br label %159

159:                                              ; preds = %139
  %160 = load i32, ptr %10, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %161
  %163 = getelementptr inbounds %struct.Edge, ptr %162, i32 0, i32 0
  %164 = load i32, ptr %163, align 8, !tbaa !9
  store i32 %164, ptr %10, align 4, !tbaa !5
  br label %127, !llvm.loop !21

165:                                              ; preds = %138
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %8, align 4, !tbaa !5
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %8, align 4, !tbaa !5
  br label %114, !llvm.loop !22

169:                                              ; preds = %118
  %170 = load i32, ptr @s, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %171
  %173 = load i8, ptr %172, align 1, !tbaa !15, !range !17, !noundef !18
  %174 = trunc i8 %173 to i1
  br i1 %174, label %177, label %175

175:                                              ; preds = %169
  %176 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  br label %265

177:                                              ; preds = %169
  store i32 0, ptr @R, align 4, !tbaa !5
  store i32 0, ptr @L, align 4, !tbaa !5
  %178 = load i32, ptr @s, align 4, !tbaa !5
  %179 = load i32, ptr @R, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr @R, align 4, !tbaa !5
  %181 = sext i32 %179 to i64
  %182 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %181
  store i32 %178, ptr %182, align 4, !tbaa !5
  %183 = load i32, ptr @s, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %184
  store i32 1, ptr %185, align 4, !tbaa !5
  br label %186

186:                                              ; preds = %253, %177
  %187 = load i32, ptr @L, align 4, !tbaa !5
  %188 = load i32, ptr @R, align 4, !tbaa !5
  %189 = icmp slt i32 %187, %188
  br i1 %189, label %190, label %254

190:                                              ; preds = %186
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %191 = load i32, ptr @L, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr @L, align 4, !tbaa !5
  %193 = sext i32 %191 to i64
  %194 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %193
  %195 = load i32, ptr %194, align 4, !tbaa !5
  store i32 %195, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %196 = load i32, ptr %11, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [10001 x i32], ptr @pre, i64 0, i64 %197
  %199 = load i32, ptr %198, align 4, !tbaa !5
  store i32 %199, ptr %12, align 4, !tbaa !5
  br label %200

200:                                              ; preds = %247, %190
  %201 = load i32, ptr %12, align 4, !tbaa !5
  %202 = icmp ne i32 %201, 0
  br i1 %202, label %204, label %203

203:                                              ; preds = %200
  store i32 17, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %253

204:                                              ; preds = %200
  %205 = load i32, ptr %12, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %206
  %208 = getelementptr inbounds %struct.Edge, ptr %207, i32 0, i32 1
  %209 = load i32, ptr %208, align 4, !tbaa !11
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %210
  %212 = load i8, ptr %211, align 1, !tbaa !15, !range !17, !noundef !18
  %213 = trunc i8 %212 to i1
  br i1 %213, label %214, label %246

214:                                              ; preds = %204
  %215 = load i32, ptr %12, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %216
  %218 = getelementptr inbounds %struct.Edge, ptr %217, i32 0, i32 1
  %219 = load i32, ptr %218, align 4, !tbaa !11
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %220
  %222 = load i32, ptr %221, align 4, !tbaa !5
  %223 = icmp ne i32 %222, 0
  br i1 %223, label %246, label %224

224:                                              ; preds = %214
  %225 = load i32, ptr %12, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %226
  %228 = getelementptr inbounds %struct.Edge, ptr %227, i32 0, i32 1
  %229 = load i32, ptr %228, align 4, !tbaa !11
  %230 = load i32, ptr @R, align 4, !tbaa !5
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr @R, align 4, !tbaa !5
  %232 = sext i32 %230 to i64
  %233 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %232
  store i32 %229, ptr %233, align 4, !tbaa !5
  %234 = load i32, ptr %11, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %235
  %237 = load i32, ptr %236, align 4, !tbaa !5
  %238 = add nsw i32 %237, 1
  %239 = load i32, ptr %12, align 4, !tbaa !5
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %240
  %242 = getelementptr inbounds %struct.Edge, ptr %241, i32 0, i32 1
  %243 = load i32, ptr %242, align 4, !tbaa !11
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %244
  store i32 %238, ptr %245, align 4, !tbaa !5
  br label %246

246:                                              ; preds = %224, %214, %204
  br label %247

247:                                              ; preds = %246
  %248 = load i32, ptr %12, align 4, !tbaa !5
  %249 = sext i32 %248 to i64
  %250 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %249
  %251 = getelementptr inbounds %struct.Edge, ptr %250, i32 0, i32 0
  %252 = load i32, ptr %251, align 8, !tbaa !9
  store i32 %252, ptr %12, align 4, !tbaa !5
  br label %200, !llvm.loop !23

253:                                              ; preds = %203
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %186, !llvm.loop !24

254:                                              ; preds = %186
  %255 = load i32, ptr @t, align 4, !tbaa !5
  %256 = sext i32 %255 to i64
  %257 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %256
  %258 = load i32, ptr %257, align 4, !tbaa !5
  %259 = load i32, ptr @s, align 4, !tbaa !5
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %260
  %262 = load i32, ptr %261, align 4, !tbaa !5
  %263 = sub nsw i32 %258, %262
  %264 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %263)
  store i32 0, ptr %1, align 4
  br label %265

265:                                              ; preds = %254, %175
  %266 = load i32, ptr %1, align 4
  ret i32 %266
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

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

declare i32 @puts(ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #1

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}
!24 = distinct !{!24, !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"

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@s = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global [10001 x i32], align 16
@suf = external dso_local local_unnamed_addr global [10001 x i32], align 16
@que = external dso_local local_unnamed_addr global [10001 x i32], align 16
@L = external dso_local local_unnamed_addr global i32, align 4
@R = external dso_local local_unnamed_addr global i32, align 4
@dis = external dso_local local_unnamed_addr global [10001 x i32], align 16
@vis = external dso_local local_unnamed_addr global [10001 x i8], align 16
@g = external dso_local local_unnamed_addr global [10001 x i8], align 16
@e = external dso_local local_unnamed_addr global [400002 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %4 = load i32, ptr @m, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @m, align 4, !tbaa !5
  %.not38 = icmp eq i32 %4, 0
  br i1 %.not38, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [10001 x i32], ptr @pre, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr @tot, align 4, !tbaa !5
  %13 = add nsw i32 %12, 1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %14
  store i32 %10, ptr %15, align 8, !tbaa !5
  %.sroa.424.0..sroa_idx = getelementptr inbounds i8, ptr %15, i64 4
  store i32 %11, ptr %.sroa.424.0..sroa_idx, align 4, !tbaa !5
  store i32 %13, ptr %9, align 4, !tbaa !5
  %16 = sext i32 %11 to i64
  %17 = getelementptr inbounds [10001 x i32], ptr @suf, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %12, 2
  store i32 %19, ptr @tot, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %20
  store i32 %18, ptr %21, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %21, i64 4
  store i32 %7, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  store i32 %19, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  %22 = load i32, ptr @m, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr @m, align 4, !tbaa !5
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %0
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @s, ptr noundef nonnull @t)
  %25 = load i32, ptr @t, align 4, !tbaa !5
  %26 = load i32, ptr @R, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @R, align 4, !tbaa !5
  %28 = sext i32 %26 to i64
  %29 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %28
  store i32 %25, ptr %29, align 4, !tbaa !5
  %30 = sext i32 %25 to i64
  %31 = getelementptr inbounds [10001 x i8], ptr @vis, i64 0, i64 %30
  store i8 1, ptr %31, align 1, !tbaa !11
  %L.promoted = load i32, ptr @L, align 4, !tbaa !5
  %.not87 = icmp sgt i32 %L.promoted, %26
  br i1 %.not87, label %.preheader, label %.lr.ph51.preheader

.lr.ph51.preheader:                               ; preds = %._crit_edge
  %32 = sext i32 %L.promoted to i64
  br label %.lr.ph51

.loopexit37:                                      ; preds = %55, %.lr.ph51
  %R.promoted47 = phi i32 [ %R.promoted4849, %.lr.ph51 ], [ %R.promoted45, %55 ]
  %33 = sext i32 %R.promoted47 to i64
  %34 = icmp slt i64 %indvars.iv.next, %33
  br i1 %34, label %.lr.ph51, label %..preheader_crit_edge, !llvm.loop !13

..preheader_crit_edge:                            ; preds = %.loopexit37
  %35 = trunc nsw i64 %indvars.iv.next to i32
  store i32 %35, ptr @L, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %..preheader_crit_edge, %._crit_edge
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %.not3258 = icmp slt i32 %36, 1
  br i1 %.not3258, label %._crit_edge61, label %.lr.ph60.preheader

.lr.ph60.preheader:                               ; preds = %.preheader
  %37 = add nuw i32 %36, 1
  %wide.trip.count = zext i32 %37 to i64
  br label %.lr.ph60

.lr.ph51:                                         ; preds = %.lr.ph51.preheader, %.loopexit37
  %indvars.iv = phi i64 [ %32, %.lr.ph51.preheader ], [ %indvars.iv.next, %.loopexit37 ]
  %R.promoted4849 = phi i32 [ %27, %.lr.ph51.preheader ], [ %R.promoted47, %.loopexit37 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %38 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %indvars.iv
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [10001 x i32], ptr @suf, i64 0, i64 %40
  %.02939 = load i32, ptr %41, align 4, !tbaa !5
  %.not3640 = icmp eq i32 %.02939, 0
  br i1 %.not3640, label %.loopexit37, label %.lr.ph43

.lr.ph43:                                         ; preds = %.lr.ph51, %55
  %R.promoted46 = phi i32 [ %R.promoted45, %55 ], [ %R.promoted4849, %.lr.ph51 ]
  %.02941 = phi i32 [ %.029, %55 ], [ %.02939, %.lr.ph51 ]
  %42 = phi i32 [ %56, %55 ], [ %R.promoted4849, %.lr.ph51 ]
  %43 = sext i32 %.02941 to i64
  %44 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %43
  %45 = getelementptr inbounds i8, ptr %44, i64 4
  %46 = load i32, ptr %45, align 4, !tbaa !14
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [10001 x i8], ptr @vis, i64 0, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !11, !range !16, !noundef !17
  %50 = trunc nuw i8 %49 to i1
  br i1 %50, label %55, label %51

51:                                               ; preds = %.lr.ph43
  %52 = add nsw i32 %42, 1
  store i32 %52, ptr @R, align 4, !tbaa !5
  %53 = sext i32 %42 to i64
  %54 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %53
  store i32 %46, ptr %54, align 4, !tbaa !5
  store i8 1, ptr %48, align 1, !tbaa !11
  br label %55

55:                                               ; preds = %.lr.ph43, %51
  %R.promoted45 = phi i32 [ %R.promoted46, %.lr.ph43 ], [ %52, %51 ]
  %56 = phi i32 [ %42, %.lr.ph43 ], [ %52, %51 ]
  %.029 = load i32, ptr %44, align 8, !tbaa !5
  %.not36 = icmp eq i32 %.029, 0
  br i1 %.not36, label %.loopexit37, label %.lr.ph43, !llvm.loop !18

._crit_edge61:                                    ; preds = %.critedge, %.preheader
  %57 = load i32, ptr @s, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11, !range !16, !noundef !17
  %61 = trunc nuw i8 %60 to i1
  br i1 %61, label %.lr.ph75.preheader, label %74

.lr.ph60:                                         ; preds = %.lr.ph60.preheader, %.critedge
  %indvars.iv80 = phi i64 [ 1, %.lr.ph60.preheader ], [ %indvars.iv.next81, %.critedge ]
  %62 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %indvars.iv80
  store i8 1, ptr %62, align 1, !tbaa !11
  %63 = getelementptr inbounds [10001 x i32], ptr @pre, i64 0, i64 %indvars.iv80
  %.02752 = load i32, ptr %63, align 4, !tbaa !5
  %.not3553 = icmp eq i32 %.02752, 0
  br i1 %.not3553, label %.critedge, label %.lr.ph56

.lr.ph56:                                         ; preds = %.lr.ph60, %66
  %64 = phi i8 [ %73, %66 ], [ 1, %.lr.ph60 ]
  %.02754 = phi i32 [ %.027, %66 ], [ %.02752, %.lr.ph60 ]
  %65 = trunc nuw i8 %64 to i1
  br i1 %65, label %66, label %.critedge

.critedge:                                        ; preds = %.lr.ph56, %66, %.lr.ph60
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next81, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge61, label %.lr.ph60, !llvm.loop !19

66:                                               ; preds = %.lr.ph56
  %67 = sext i32 %.02754 to i64
  %68 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %67
  %69 = getelementptr inbounds i8, ptr %68, i64 4
  %70 = load i32, ptr %69, align 4, !tbaa !14
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [10001 x i8], ptr @vis, i64 0, i64 %71
  %73 = load i8, ptr %72, align 1, !tbaa !11, !range !16, !noundef !17
  store i8 %73, ptr %62, align 1, !tbaa !11
  %.027 = load i32, ptr %68, align 8, !tbaa !5
  %.not35 = icmp eq i32 %.027, 0
  br i1 %.not35, label %.critedge, label %.lr.ph56, !llvm.loop !20

74:                                               ; preds = %._crit_edge61
  %75 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %111

.lr.ph75.preheader:                               ; preds = %._crit_edge61
  store i32 1, ptr @R, align 4, !tbaa !5
  store i32 %57, ptr @que, align 16, !tbaa !5
  %76 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %58
  store i32 1, ptr %76, align 4, !tbaa !5
  br label %.lr.ph75

.loopexit:                                        ; preds = %103, %.lr.ph75
  %R.promoted71 = phi i32 [ %R.promoted7273, %.lr.ph75 ], [ %R.promoted69, %103 ]
  %77 = sext i32 %R.promoted71 to i64
  %78 = icmp slt i64 %indvars.iv.next84, %77
  br i1 %78, label %.lr.ph75, label %105, !llvm.loop !21

.lr.ph75:                                         ; preds = %.lr.ph75.preheader, %.loopexit
  %indvars.iv83 = phi i64 [ 0, %.lr.ph75.preheader ], [ %indvars.iv.next84, %.loopexit ]
  %R.promoted7273 = phi i32 [ 1, %.lr.ph75.preheader ], [ %R.promoted71, %.loopexit ]
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %79 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %indvars.iv83
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [10001 x i32], ptr @pre, i64 0, i64 %81
  %.062 = load i32, ptr %82, align 4, !tbaa !5
  %.not3363 = icmp eq i32 %.062, 0
  br i1 %.not3363, label %.loopexit, label %.lr.ph66

.lr.ph66:                                         ; preds = %.lr.ph75
  %83 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %81
  br label %84

84:                                               ; preds = %.lr.ph66, %103
  %R.promoted70 = phi i32 [ %R.promoted7273, %.lr.ph66 ], [ %R.promoted69, %103 ]
  %.064 = phi i32 [ %.062, %.lr.ph66 ], [ %.0, %103 ]
  %85 = phi i32 [ %R.promoted7273, %.lr.ph66 ], [ %104, %103 ]
  %86 = sext i32 %.064 to i64
  %87 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %86
  %88 = getelementptr inbounds i8, ptr %87, i64 4
  %89 = load i32, ptr %88, align 4, !tbaa !14
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [10001 x i8], ptr @g, i64 0, i64 %90
  %92 = load i8, ptr %91, align 1, !tbaa !11, !range !16, !noundef !17
  %93 = trunc nuw i8 %92 to i1
  br i1 %93, label %94, label %103

94:                                               ; preds = %84
  %95 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %90
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %.not34 = icmp eq i32 %96, 0
  br i1 %.not34, label %97, label %103

97:                                               ; preds = %94
  %98 = add nsw i32 %85, 1
  store i32 %98, ptr @R, align 4, !tbaa !5
  %99 = sext i32 %85 to i64
  %100 = getelementptr inbounds [10001 x i32], ptr @que, i64 0, i64 %99
  store i32 %89, ptr %100, align 4, !tbaa !5
  %101 = load i32, ptr %83, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %95, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %84, %94, %97
  %R.promoted69 = phi i32 [ %R.promoted70, %84 ], [ %R.promoted70, %94 ], [ %98, %97 ]
  %104 = phi i32 [ %85, %84 ], [ %85, %94 ], [ %98, %97 ]
  %.0 = load i32, ptr %87, align 8, !tbaa !5
  %.not33 = icmp eq i32 %.0, 0
  br i1 %.not33, label %.loopexit, label %84, !llvm.loop !22

105:                                              ; preds = %.loopexit
  %106 = trunc nuw nsw i64 %indvars.iv.next84 to i32
  store i32 %106, ptr @L, align 4, !tbaa !5
  %.pre = load i32, ptr %76, align 4, !tbaa !5
  %107 = getelementptr inbounds [10001 x i32], ptr @dis, i64 0, i64 %30
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sub nsw i32 %108, %.pre
  %110 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %109)
  br label %111

111:                                              ; preds = %105, %74
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = !{!15, !6, i64 4}
!15 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}


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