; LLVM IR from tangjz/acm-icpc :: hdu (6041)

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

%struct.Edge = type { i32, i32, i32 }
%struct.NonTreeEdge = type { i32, i32, i32 }
%struct.PriorityQueue = type { i32, [1001 x i32], [1001 x i32] }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@lnk = external dso_local global [1001 x i32], align 16
@dsu = external dso_local global [1001 x i32], align 16
@fa = external dso_local global [1001 x i32], align 16
@dep = external dso_local global [1001 x i32], align 16
@eval = external dso_local global [1001 x i32], align 16
@cnt = external dso_local global i32, align 4
@sum = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@e = external dso_local global [2003 x %struct.Edge], align 16
@que = external dso_local global [501 x %struct.NonTreeEdge], align 16
@f = external dso_local global [3 x [100001 x i32]], align 16
@cur = external dso_local global i32, align 4
@pre = external dso_local global i32, align 4
@idx = external dso_local global [1001 x i32], align 16
@Q = external dso_local global %struct.PriorityQueue, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9dsu_mergeii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsi(i32 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 i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.Edge, align 4
  %8 = alloca %struct.Edge, align 4
  %9 = alloca %struct.NonTreeEdge, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %323, %0
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %21 = icmp eq i32 %20, 2
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %326

23:                                               ; preds = %19
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @sum, align 4, !tbaa !5
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = mul i64 %25, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @lnk, i64 1), i8 -1, i64 %26, i1 false)
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = mul i64 %28, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @dsu, i64 1), i8 -1, i64 %29, i1 false)
  br label %30

30:                                               ; preds = %88, %23
  %31 = load i32, ptr @m, align 4, !tbaa !5
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr @m, align 4, !tbaa !5
  %33 = icmp ne i32 %31, 0
  br i1 %33, label %34, label %89

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load i32, ptr @sum, align 4, !tbaa !5
  %38 = add nsw i32 %37, %36
  store i32 %38, ptr @sum, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = call noundef zeroext i1 @_Z9dsu_mergeii(i32 noundef %39, i32 noundef %40)
  br i1 %41, label %42, label %77

42:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #7
  %43 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 0
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1001 x i32], ptr @lnk, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  store i32 %47, ptr %43, align 4, !tbaa !9
  %48 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 1
  %49 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %49, ptr %48, align 4, !tbaa !11
  %50 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 2
  %51 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %51, ptr %50, align 4, !tbaa !12
  %52 = load i32, ptr @tot, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [2003 x %struct.Edge], ptr @e, i64 0, i64 %53
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %54, ptr align 4 %7, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #7
  %55 = load i32, ptr @tot, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr @tot, align 4, !tbaa !5
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1001 x i32], ptr @lnk, i64 0, i64 %58
  store i32 %55, ptr %59, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #7
  %60 = getelementptr inbounds %struct.Edge, ptr %8, i32 0, i32 0
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1001 x i32], ptr @lnk, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  store i32 %64, ptr %60, align 4, !tbaa !9
  %65 = getelementptr inbounds %struct.Edge, ptr %8, i32 0, i32 1
  %66 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %66, ptr %65, align 4, !tbaa !11
  %67 = getelementptr inbounds %struct.Edge, ptr %8, i32 0, i32 2
  %68 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %68, ptr %67, align 4, !tbaa !12
  %69 = load i32, ptr @tot, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [2003 x %struct.Edge], ptr @e, i64 0, i64 %70
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %71, ptr align 4 %8, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #7
  %72 = load i32, ptr @tot, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr @tot, align 4, !tbaa !5
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1001 x i32], ptr @lnk, i64 0, i64 %75
  store i32 %72, ptr %76, align 4, !tbaa !5
  br label %88

77:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #7
  %78 = getelementptr inbounds %struct.NonTreeEdge, ptr %9, i32 0, i32 0
  %79 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %79, ptr %78, align 4, !tbaa !14
  %80 = getelementptr inbounds %struct.NonTreeEdge, ptr %9, i32 0, i32 1
  %81 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %81, ptr %80, align 4, !tbaa !16
  %82 = getelementptr inbounds %struct.NonTreeEdge, ptr %9, i32 0, i32 2
  %83 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %83, ptr %82, align 4, !tbaa !17
  %84 = load i32, ptr @cnt, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr @cnt, align 4, !tbaa !5
  %86 = sext i32 %84 to i64
  %87 = getelementptr inbounds [501 x %struct.NonTreeEdge], ptr @que, i64 0, i64 %86
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %87, ptr align 4 %9, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #7
  br label %88

88:                                               ; preds = %77, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %30, !llvm.loop !18

89:                                               ; preds = %30
  call void @_Z3dfsi(i32 noundef 1)
  %90 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @m)
  %91 = load i32, ptr @cur, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %92
  %94 = getelementptr inbounds [100001 x i32], ptr %93, i64 0, i64 0
  store i32 1, ptr %94, align 4, !tbaa !5
  %95 = load i32, ptr @cur, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %96
  %98 = getelementptr inbounds [100001 x i32], ptr %97, i64 0, i64 1
  store i32 0, ptr %98, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %289, %89
  %100 = load i32, ptr %10, align 4, !tbaa !5
  %101 = load i32, ptr @cnt, align 4, !tbaa !5
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  store i32 7, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %292

104:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %105 = load i32, ptr %10, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [501 x %struct.NonTreeEdge], ptr @que, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.NonTreeEdge, ptr %107, i32 0, i32 0
  %109 = load i32, ptr %108, align 4, !tbaa !14
  store i32 %109, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %110 = load i32, ptr %10, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [501 x %struct.NonTreeEdge], ptr @que, i64 0, i64 %111
  %113 = getelementptr inbounds %struct.NonTreeEdge, ptr %112, i32 0, i32 1
  %114 = load i32, ptr %113, align 4, !tbaa !16
  store i32 %114, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store i32 1, ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), align 8, !tbaa !5
  store ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), ptr %13, align 8, !tbaa !20
  %115 = load i32, ptr %10, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [501 x %struct.NonTreeEdge], ptr @que, i64 0, i64 %116
  %118 = getelementptr inbounds %struct.NonTreeEdge, ptr %117, i32 0, i32 2
  %119 = load i32, ptr %118, align 4, !tbaa !17
  store i32 %119, ptr getelementptr inbounds ([100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), i64 0, i64 1), align 4, !tbaa !5
  br label %120

120:                                              ; preds = %140, %104
  %121 = load i32, ptr %11, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = load i32, ptr %12, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = icmp sgt i32 %124, %128
  br i1 %129, label %130, label %145

130:                                              ; preds = %120
  %131 = load i32, ptr %11, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = load ptr, ptr %13, align 8, !tbaa !20
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %135, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), i64 0, i64 %138
  store i32 %134, ptr %139, align 4, !tbaa !5
  br label %140

140:                                              ; preds = %130
  %141 = load i32, ptr %11, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  store i32 %144, ptr %11, align 4, !tbaa !5
  br label %120, !llvm.loop !22

145:                                              ; preds = %120
  br label %146

146:                                              ; preds = %166, %145
  %147 = load i32, ptr %11, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = load i32, ptr %12, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = icmp slt i32 %150, %154
  br i1 %155, label %156, label %171

156:                                              ; preds = %146
  %157 = load i32, ptr %12, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = load ptr, ptr %13, align 8, !tbaa !20
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %161, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), i64 0, i64 %164
  store i32 %160, ptr %165, align 4, !tbaa !5
  br label %166

166:                                              ; preds = %156
  %167 = load i32, ptr %12, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  store i32 %170, ptr %12, align 4, !tbaa !5
  br label %146, !llvm.loop !23

171:                                              ; preds = %146
  br label %172

172:                                              ; preds = %195, %171
  %173 = load i32, ptr %11, align 4, !tbaa !5
  %174 = load i32, ptr %12, align 4, !tbaa !5
  %175 = icmp ne i32 %173, %174
  br i1 %175, label %176, label %204

176:                                              ; preds = %172
  %177 = load i32, ptr %11, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = load ptr, ptr %13, align 8, !tbaa !20
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %181, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), i64 0, i64 %184
  store i32 %180, ptr %185, align 4, !tbaa !5
  %186 = load i32, ptr %12, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !5
  %190 = load ptr, ptr %13, align 8, !tbaa !20
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr %190, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), i64 0, i64 %193
  store i32 %189, ptr %194, align 4, !tbaa !5
  br label %195

195:                                              ; preds = %176
  %196 = load i32, ptr %11, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %197
  %199 = load i32, ptr %198, align 4, !tbaa !5
  store i32 %199, ptr %11, align 4, !tbaa !5
  %200 = load i32, ptr %12, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  store i32 %203, ptr %12, align 4, !tbaa !5
  br label %172, !llvm.loop !24

204:                                              ; preds = %172
  %205 = load i32, ptr @pre, align 4, !tbaa !5
  %206 = xor i32 %205, 1
  store i32 %206, ptr @pre, align 4, !tbaa !5
  %207 = load i32, ptr @cur, align 4, !tbaa !5
  %208 = xor i32 %207, 1
  store i32 %208, ptr @cur, align 4, !tbaa !5
  store i32 0, ptr @Q, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 1, ptr %14, align 4, !tbaa !5
  br label %209

209:                                              ; preds = %230, %204
  %210 = load i32, ptr %14, align 4, !tbaa !5
  %211 = load ptr, ptr %13, align 8, !tbaa !20
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = icmp sle i32 %210, %212
  br i1 %213, label %215, label %214

214:                                              ; preds = %209
  store i32 19, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %233

215:                                              ; preds = %209
  %216 = load i32, ptr %14, align 4, !tbaa !5
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), i64 0, i64 %217
  %219 = load i32, ptr %218, align 4, !tbaa !5
  %220 = load i32, ptr @pre, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %221
  %223 = load i32, ptr %14, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [1001 x i32], ptr @idx, i64 0, i64 %224
  store i32 1, ptr %225, align 4, !tbaa !5
  %226 = getelementptr inbounds [100001 x i32], ptr %222, i64 0, i64 1
  %227 = load i32, ptr %226, align 4, !tbaa !5
  %228 = add nsw i32 %219, %227
  %229 = load i32, ptr %14, align 4, !tbaa !5
  call void @_ZN13PriorityQueue4pushEii(ptr noundef nonnull align 4 dereferenceable(8012) @Q, i32 noundef %228, i32 noundef %229)
  br label %230

230:                                              ; preds = %215
  %231 = load i32, ptr %14, align 4, !tbaa !5
  %232 = add nsw i32 %231, 1
  store i32 %232, ptr %14, align 4, !tbaa !5
  br label %209, !llvm.loop !27

233:                                              ; preds = %214
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %234 = load i32, ptr @cur, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %235
  %237 = getelementptr inbounds [100001 x i32], ptr %236, i64 0, i64 0
  store i32 0, ptr %237, align 4, !tbaa !5
  store ptr %237, ptr %15, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  br label %238

238:                                              ; preds = %287, %233
  %239 = load ptr, ptr %15, align 8, !tbaa !20
  %240 = load i32, ptr %239, align 4, !tbaa !5
  %241 = load i32, ptr @m, align 4, !tbaa !5
  %242 = icmp slt i32 %240, %241
  br i1 %242, label %243, label %246

243:                                              ; preds = %238
  %244 = load i32, ptr @Q, align 4, !tbaa !25
  %245 = icmp ne i32 %244, 0
  br label %246

246:                                              ; preds = %243, %238
  %247 = phi i1 [ false, %238 ], [ %245, %243 ]
  br i1 %247, label %249, label %248

248:                                              ; preds = %246
  store i32 22, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %288

249:                                              ; preds = %246
  call void @_ZN13PriorityQueue9topAndPopERiS0_(ptr noundef nonnull align 4 dereferenceable(8012) @Q, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %250 = load i32, ptr %16, align 4, !tbaa !5
  %251 = load i32, ptr @cur, align 4, !tbaa !5
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %252
  %254 = load ptr, ptr %15, align 8, !tbaa !20
  %255 = load i32, ptr %254, align 4, !tbaa !5
  %256 = add nsw i32 %255, 1
  store i32 %256, ptr %254, align 4, !tbaa !5
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [100001 x i32], ptr %253, i64 0, i64 %257
  store i32 %250, ptr %258, align 4, !tbaa !5
  %259 = load i32, ptr %17, align 4, !tbaa !5
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [1001 x i32], ptr @idx, i64 0, i64 %260
  %262 = load i32, ptr %261, align 4, !tbaa !5
  %263 = load i32, ptr @pre, align 4, !tbaa !5
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %264
  %266 = getelementptr inbounds [100001 x i32], ptr %265, i64 0, i64 0
  %267 = load i32, ptr %266, align 4, !tbaa !5
  %268 = icmp slt i32 %262, %267
  br i1 %268, label %269, label %287

269:                                              ; preds = %249
  %270 = load i32, ptr %17, align 4, !tbaa !5
  %271 = sext i32 %270 to i64
  %272 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @f, i64 0, i64 2), i64 0, i64 %271
  %273 = load i32, ptr %272, align 4, !tbaa !5
  %274 = load i32, ptr @pre, align 4, !tbaa !5
  %275 = sext i32 %274 to i64
  %276 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %275
  %277 = load i32, ptr %17, align 4, !tbaa !5
  %278 = sext i32 %277 to i64
  %279 = getelementptr inbounds [1001 x i32], ptr @idx, i64 0, i64 %278
  %280 = load i32, ptr %279, align 4, !tbaa !5
  %281 = add nsw i32 %280, 1
  store i32 %281, ptr %279, align 4, !tbaa !5
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [100001 x i32], ptr %276, i64 0, i64 %282
  %284 = load i32, ptr %283, align 4, !tbaa !5
  %285 = add nsw i32 %273, %284
  %286 = load i32, ptr %17, align 4, !tbaa !5
  call void @_ZN13PriorityQueue4pushEii(ptr noundef nonnull align 4 dereferenceable(8012) @Q, i32 noundef %285, i32 noundef %286)
  br label %287

287:                                              ; preds = %269, %249
  br label %238, !llvm.loop !28

288:                                              ; preds = %248
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %289

289:                                              ; preds = %288
  %290 = load i32, ptr %10, align 4, !tbaa !5
  %291 = add nsw i32 %290, 1
  store i32 %291, ptr %10, align 4, !tbaa !5
  br label %99, !llvm.loop !29

292:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store i32 1, ptr %18, align 4, !tbaa !5
  br label %293

293:                                              ; preds = %316, %292
  %294 = load i32, ptr %18, align 4, !tbaa !5
  %295 = load i32, ptr @cur, align 4, !tbaa !5
  %296 = sext i32 %295 to i64
  %297 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %296
  %298 = getelementptr inbounds [100001 x i32], ptr %297, i64 0, i64 0
  %299 = load i32, ptr %298, align 4, !tbaa !5
  %300 = icmp sle i32 %294, %299
  br i1 %300, label %302, label %301

301:                                              ; preds = %293
  store i32 24, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %319

302:                                              ; preds = %293
  %303 = load i32, ptr %18, align 4, !tbaa !5
  %304 = load i32, ptr @sum, align 4, !tbaa !5
  %305 = load i32, ptr @cur, align 4, !tbaa !5
  %306 = sext i32 %305 to i64
  %307 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %306
  %308 = load i32, ptr %18, align 4, !tbaa !5
  %309 = sext i32 %308 to i64
  %310 = getelementptr inbounds [100001 x i32], ptr %307, i64 0, i64 %309
  %311 = load i32, ptr %310, align 4, !tbaa !5
  %312 = sub nsw i32 %304, %311
  %313 = mul nsw i32 %303, %312
  %314 = load i32, ptr @ans, align 4, !tbaa !5
  %315 = add nsw i32 %314, %313
  store i32 %315, ptr @ans, align 4, !tbaa !5
  br label %316

316:                                              ; preds = %302
  %317 = load i32, ptr %18, align 4, !tbaa !5
  %318 = add nsw i32 %317, 1
  store i32 %318, ptr %18, align 4, !tbaa !5
  br label %293, !llvm.loop !30

319:                                              ; preds = %301
  %320 = load i32, ptr %2, align 4, !tbaa !5
  %321 = load i32, ptr @ans, align 4, !tbaa !5
  %322 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %320, i32 noundef %321)
  br label %323

323:                                              ; preds = %319
  %324 = load i32, ptr %2, align 4, !tbaa !5
  %325 = add nsw i32 %324, 1
  store i32 %325, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !31

326:                                              ; preds = %22
  ret i32 0
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN13PriorityQueue4pushEii(ptr noundef nonnull align 4 dereferenceable(8012), i32 noundef, i32 noundef) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN13PriorityQueue9topAndPopERiS0_(ptr noundef nonnull align 4 dereferenceable(8012), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #6 align 2

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!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, !6, i64 8}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS11NonTreeEdge", !6, i64 0, !6, i64 4, !6, i64 8}
!16 = !{!15, !6, i64 4}
!17 = !{!15, !6, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !21, i64 0}
!21 = !{!"any pointer", !7, i64 0}
!22 = distinct !{!22, !19}
!23 = distinct !{!23, !19}
!24 = distinct !{!24, !19}
!25 = !{!26, !6, i64 0}
!26 = !{!"_ZTS13PriorityQueue", !6, i64 0, !7, i64 4, !7, i64 4008}
!27 = distinct !{!27, !19}
!28 = distinct !{!28, !19}
!29 = distinct !{!29, !19}
!30 = distinct !{!30, !19}
!31 = distinct !{!31, !19}


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

%struct.Edge = type { i32, i32, i32 }
%struct.NonTreeEdge = type { i32, i32, i32 }
%struct.PriorityQueue = type { i32, [1001 x i32], [1001 x i32] }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@lnk = external dso_local local_unnamed_addr global [1001 x i32], align 16
@dsu = external dso_local local_unnamed_addr global [1001 x i32], align 16
@fa = external dso_local local_unnamed_addr global [1001 x i32], align 16
@dep = external dso_local local_unnamed_addr global [1001 x i32], align 16
@eval = external dso_local local_unnamed_addr global [1001 x i32], align 16
@cnt = external dso_local local_unnamed_addr global i32, align 4
@sum = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local local_unnamed_addr global [2003 x %struct.Edge], align 16
@que = external dso_local local_unnamed_addr global [501 x %struct.NonTreeEdge], align 16
@f = external dso_local local_unnamed_addr global [3 x [100001 x i32]], align 16
@cur = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global i32, align 4
@idx = external dso_local local_unnamed_addr global [1001 x i32], align 16
@Q = external dso_local global %struct.PriorityQueue, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9dsu_mergeii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsi(i32 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 i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %7 = icmp eq i32 %6, 2
  br i1 %7, label %.lr.ph83, label %._crit_edge84

._crit_edge84:                                    ; preds = %185, %0
  ret i32 0

.lr.ph83:                                         ; preds = %0, %185
  %.04281 = phi i32 [ %188, %185 ], [ 1, %0 ]
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @sum, align 4, !tbaa !5
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %9, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @lnk, i64 4), i8 -1, i64 %10, i1 false)
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @dsu, i64 4), i8 -1, i64 %10, i1 false)
  %11 = load i32, ptr @m, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @m, align 4, !tbaa !5
  %.not54 = icmp eq i32 %11, 0
  br i1 %.not54, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph83, %44
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = load i32, ptr @sum, align 4, !tbaa !5
  %16 = add nsw i32 %15, %14
  store i32 %16, ptr @sum, align 4, !tbaa !5
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = call noundef zeroext i1 @_Z9dsu_mergeii(i32 noundef %17, i32 noundef %18)
  %20 = load i32, ptr %1, align 4, !tbaa !5
  br i1 %19, label %21, label %37

21:                                               ; preds = %.lr.ph
  %22 = sext i32 %20 to i64
  %23 = getelementptr inbounds [1001 x i32], ptr @lnk, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr @tot, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2003 x %struct.Edge], ptr @e, i64 0, i64 %28
  store i32 %24, ptr %29, align 4, !tbaa !5
  %.sroa.438.0..sroa_idx = getelementptr inbounds i8, ptr %29, i64 4
  store i32 %25, ptr %.sroa.438.0..sroa_idx, align 4, !tbaa !5
  %.sroa.539.0..sroa_idx = getelementptr inbounds i8, ptr %29, i64 8
  store i32 %26, ptr %.sroa.539.0..sroa_idx, align 4, !tbaa !5
  %30 = add nsw i32 %27, 1
  store i32 %27, ptr %23, align 4, !tbaa !5
  %31 = sext i32 %25 to i64
  %32 = getelementptr inbounds [1001 x i32], ptr @lnk, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = sext i32 %30 to i64
  %35 = getelementptr inbounds [2003 x %struct.Edge], ptr @e, i64 0, i64 %34
  store i32 %33, ptr %35, align 4, !tbaa !5
  %.sroa.435.0..sroa_idx = getelementptr inbounds i8, ptr %35, i64 4
  store i32 %20, ptr %.sroa.435.0..sroa_idx, align 4, !tbaa !5
  %.sroa.536.0..sroa_idx = getelementptr inbounds i8, ptr %35, i64 8
  store i32 %26, ptr %.sroa.536.0..sroa_idx, align 4, !tbaa !5
  %36 = add nsw i32 %27, 2
  store i32 %36, ptr @tot, align 4, !tbaa !5
  store i32 %30, ptr %32, align 4, !tbaa !5
  br label %44

37:                                               ; preds = %.lr.ph
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr @cnt, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr @cnt, align 4, !tbaa !5
  %42 = sext i32 %40 to i64
  %43 = getelementptr inbounds [501 x %struct.NonTreeEdge], ptr @que, i64 0, i64 %42
  store i32 %20, ptr %43, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 4
  store i32 %38, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 8
  store i32 %39, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %37, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %45 = load i32, ptr @m, align 4, !tbaa !5
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr @m, align 4, !tbaa !5
  %.not = icmp eq i32 %45, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %44, %.lr.ph83
  call void @_Z3dfsi(i32 noundef 1)
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @m)
  %48 = load i32, ptr @cur, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %49
  store i32 1, ptr %50, align 4, !tbaa !5
  %51 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %49, i64 1
  store i32 0, ptr %51, align 4, !tbaa !5
  %52 = load i32, ptr @cnt, align 4, !tbaa !5
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %.lr.ph75, label %.lr.ph78

.preheader53:                                     ; preds = %._crit_edge72
  %.pre97 = load i32, ptr @cur, align 4, !tbaa !5
  %.phi.trans.insert = sext i32 %.pre97 to i64
  %.phi.trans.insert98 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %.phi.trans.insert
  %.pre99 = load i32, ptr %.phi.trans.insert98, align 4, !tbaa !5
  %.not4976 = icmp slt i32 %.pre99, 1
  br i1 %.not4976, label %.preheader53._crit_edge, label %.lr.ph78

.preheader53._crit_edge:                          ; preds = %.preheader53
  %.pre100 = load i32, ptr @ans, align 4, !tbaa !5
  br label %185

.lr.ph78:                                         ; preds = %._crit_edge, %.preheader53
  %54 = phi i32 [ %.pre99, %.preheader53 ], [ 1, %._crit_edge ]
  %.pre-phi103 = phi i64 [ %.phi.trans.insert, %.preheader53 ], [ %49, %._crit_edge ]
  %ans.promoted = load i32, ptr @ans, align 4, !tbaa !5
  %55 = load i32, ptr @sum, align 4, !tbaa !5
  %56 = add nuw i32 %54, 1
  %wide.trip.count = zext i32 %56 to i64
  %57 = zext nneg i32 %54 to i64
  %min.iters.check = icmp ult i32 %54, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph78
  %indvars.iv93.ph = phi i64 [ 1, %.lr.ph78 ], [ %ind.end, %middle.block ]
  %.ph = phi i32 [ %ans.promoted, %.lr.ph78 ], [ %68, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph78
  %n.vec = and i64 %57, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  %58 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %ans.promoted, i64 0
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %55, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ %58, %vector.ph ], [ %65, %vector.body ]
  %vec.phi112 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %66, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %offset.idx = or disjoint i64 %index, 1
  %59 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %.pre-phi103, i64 %offset.idx
  %60 = getelementptr inbounds i8, ptr %59, i64 16
  %wide.load = load <4 x i32>, ptr %59, align 4, !tbaa !5
  %wide.load114 = load <4 x i32>, ptr %60, align 4, !tbaa !5
  %61 = sub nsw <4 x i32> %broadcast.splat, %wide.load
  %62 = sub nsw <4 x i32> %broadcast.splat, %wide.load114
  %63 = mul nsw <4 x i32> %61, %vec.ind
  %64 = mul nsw <4 x i32> %62, %step.add
  %65 = add <4 x i32> %63, %vec.phi
  %66 = add <4 x i32> %64, %vec.phi112
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %67 = icmp eq i64 %index.next, %n.vec
  br i1 %67, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %66, %65
  %68 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %57
  br i1 %cmp.n, label %._crit_edge79, label %scalar.ph.preheader

.lr.ph75:                                         ; preds = %._crit_edge, %._crit_edge72
  %indvars.iv90 = phi i64 [ %indvars.iv.next91, %._crit_edge72 ], [ 0, %._crit_edge ]
  %69 = getelementptr inbounds [501 x %struct.NonTreeEdge], ptr @que, i64 0, i64 %indvars.iv90
  %70 = load i32, ptr %69, align 4, !tbaa !14
  %71 = getelementptr inbounds i8, ptr %69, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !16
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %69, i64 8
  %74 = load i32, ptr %73, align 4, !tbaa !17
  store i32 %74, ptr getelementptr inbounds (i8, ptr @f, i64 800012), align 4, !tbaa !5
  %75 = sext i32 %72 to i64
  %76 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = sext i32 %70 to i64
  %79 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = icmp sgt i32 %80, %77
  br i1 %81, label %.lr.ph56, label %.preheader52

.preheader52:                                     ; preds = %.lr.ph56, %.lr.ph75
  %.045.lcssa = phi i32 [ %70, %.lr.ph75 ], [ %91, %.lr.ph56 ]
  %.lcssa = phi i32 [ %80, %.lr.ph75 ], [ %94, %.lr.ph56 ]
  %82 = icmp slt i32 %.lcssa, %77
  br i1 %82, label %.lr.ph58, label %.preheader

.lr.ph56:                                         ; preds = %.lr.ph75, %.lr.ph56
  %83 = phi i64 [ %92, %.lr.ph56 ], [ %78, %.lr.ph75 ]
  %84 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = load i32, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 800008), i64 0, i64 %88
  store i32 %85, ptr %89, align 4, !tbaa !5
  %90 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %83
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = icmp sgt i32 %94, %77
  br i1 %95, label %.lr.ph56, label %.preheader52, !llvm.loop !18

.preheader:                                       ; preds = %.lr.ph58, %.preheader52
  %.044.lcssa = phi i32 [ %72, %.preheader52 ], [ %104, %.lr.ph58 ]
  %.not5060 = icmp eq i32 %.045.lcssa, %.044.lcssa
  br i1 %.not5060, label %._crit_edge64, label %.lr.ph63

.lr.ph58:                                         ; preds = %.preheader52, %.lr.ph58
  %96 = phi i64 [ %105, %.lr.ph58 ], [ %75, %.preheader52 ]
  %97 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = load i32, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 800008), i64 0, i64 %101
  store i32 %98, ptr %102, align 4, !tbaa !5
  %103 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %96
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1001 x i32], ptr @dep, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = icmp slt i32 %.lcssa, %107
  br i1 %108, label %.lr.ph58, label %.preheader, !llvm.loop !19

.lr.ph63:                                         ; preds = %.preheader, %.lr.ph63
  %.162 = phi i32 [ %126, %.lr.ph63 ], [ %.044.lcssa, %.preheader ]
  %.14661 = phi i32 [ %124, %.lr.ph63 ], [ %.045.lcssa, %.preheader ]
  %109 = sext i32 %.14661 to i64
  %110 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = load i32, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 800008), i64 0, i64 %114
  store i32 %111, ptr %115, align 4, !tbaa !5
  %116 = sext i32 %.162 to i64
  %117 = getelementptr inbounds [1001 x i32], ptr @eval, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = load i32, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 800008), i64 0, i64 %121
  store i32 %118, ptr %122, align 4, !tbaa !5
  %123 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %109
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %116
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %.not50 = icmp eq i32 %124, %126
  br i1 %.not50, label %._crit_edge64, label %.lr.ph63, !llvm.loop !20

._crit_edge64:                                    ; preds = %.lr.ph63, %.preheader
  %127 = load i32, ptr @pre, align 4, !tbaa !5
  %128 = xor i32 %127, 1
  store i32 %128, ptr @pre, align 4, !tbaa !5
  %129 = load i32, ptr @cur, align 4, !tbaa !5
  %130 = xor i32 %129, 1
  store i32 %130, ptr @cur, align 4, !tbaa !5
  store i32 0, ptr @Q, align 4, !tbaa !21
  %131 = load i32, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %.not5165 = icmp slt i32 %131, 1
  br i1 %.not5165, label %._crit_edge69, label %.lr.ph68

._crit_edge69.loopexit:                           ; preds = %.lr.ph68
  %.pre = load i32, ptr @cur, align 4, !tbaa !5
  %.pre96 = load i32, ptr @Q, align 4
  br label %._crit_edge69

._crit_edge69:                                    ; preds = %._crit_edge69.loopexit, %._crit_edge64
  %132 = phi i32 [ %.pre96, %._crit_edge69.loopexit ], [ 0, %._crit_edge64 ]
  %133 = phi i32 [ %.pre, %._crit_edge69.loopexit ], [ %130, %._crit_edge64 ]
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %134
  store i32 0, ptr %135, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %136 = load i32, ptr @m, align 4, !tbaa !5
  %137 = icmp sgt i32 %136, 0
  %138 = icmp ne i32 %132, 0
  %139 = select i1 %137, i1 %138, i1 false
  br i1 %139, label %.lr.ph71, label %._crit_edge72

.lr.ph68:                                         ; preds = %._crit_edge64, %.lr.ph68
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph68 ], [ 1, %._crit_edge64 ]
  %140 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 800008), i64 0, i64 %indvars.iv
  %141 = load i32, ptr %140, align 4, !tbaa !5
  %142 = load i32, ptr @pre, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [1001 x i32], ptr @idx, i64 0, i64 %indvars.iv
  store i32 1, ptr %144, align 4, !tbaa !5
  %145 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %143, i64 1
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = add nsw i32 %146, %141
  %148 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_ZN13PriorityQueue4pushEii(ptr noundef nonnull align 4 dereferenceable(8012) @Q, i32 noundef %147, i32 noundef %148)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %149 = load i32, ptr getelementptr inbounds (i8, ptr @f, i64 800008), align 8, !tbaa !5
  %150 = sext i32 %149 to i64
  %.not51.not = icmp slt i64 %indvars.iv, %150
  br i1 %.not51.not, label %.lr.ph68, label %._crit_edge69.loopexit, !llvm.loop !23

._crit_edge72:                                    ; preds = %178, %._crit_edge69
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %151 = load i32, ptr @cnt, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = icmp slt i64 %indvars.iv.next91, %152
  br i1 %153, label %.lr.ph75, label %.preheader53, !llvm.loop !24

.lr.ph71:                                         ; preds = %._crit_edge69, %178
  call void @_ZN13PriorityQueue9topAndPopERiS0_(ptr noundef nonnull align 4 dereferenceable(8012) @Q, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %154 = load i32, ptr %4, align 4, !tbaa !5
  %155 = load i32, ptr @cur, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = load i32, ptr %135, align 4, !tbaa !5
  %158 = add nsw i32 %157, 1
  store i32 %158, ptr %135, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %156, i64 %159
  store i32 %154, ptr %160, align 4, !tbaa !5
  %161 = load i32, ptr %5, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1001 x i32], ptr @idx, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = load i32, ptr @pre, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !5
  %169 = icmp slt i32 %164, %168
  br i1 %169, label %170, label %178

170:                                              ; preds = %.lr.ph71
  %171 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 800008), i64 0, i64 %162
  %172 = load i32, ptr %171, align 4, !tbaa !5
  %173 = add nsw i32 %164, 1
  store i32 %173, ptr %163, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %166, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = add nsw i32 %176, %172
  call void @_ZN13PriorityQueue4pushEii(ptr noundef nonnull align 4 dereferenceable(8012) @Q, i32 noundef %177, i32 noundef %161)
  br label %178

178:                                              ; preds = %170, %.lr.ph71
  %179 = load i32, ptr %135, align 4, !tbaa !5
  %180 = load i32, ptr @m, align 4, !tbaa !5
  %181 = icmp slt i32 %179, %180
  %182 = load i32, ptr @Q, align 4
  %183 = icmp ne i32 %182, 0
  %184 = select i1 %181, i1 %183, i1 false
  br i1 %184, label %.lr.ph71, label %._crit_edge72, !llvm.loop !25

._crit_edge79:                                    ; preds = %scalar.ph, %middle.block
  %.lcssa111 = phi i32 [ %68, %middle.block ], [ %197, %scalar.ph ]
  store i32 %.lcssa111, ptr @ans, align 4, !tbaa !5
  br label %185

185:                                              ; preds = %.preheader53._crit_edge, %._crit_edge79
  %186 = phi i32 [ %.pre100, %.preheader53._crit_edge ], [ %.lcssa111, %._crit_edge79 ]
  %187 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.04281, i32 noundef %186)
  %188 = add nuw nsw i32 %.04281, 1
  %189 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %190 = icmp eq i32 %189, 2
  br i1 %190, label %.lr.ph83, label %._crit_edge84, !llvm.loop !26

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %scalar.ph ], [ %indvars.iv93.ph, %scalar.ph.preheader ]
  %191 = phi i32 [ %197, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %192 = getelementptr inbounds [3 x [100001 x i32]], ptr @f, i64 0, i64 %.pre-phi103, i64 %indvars.iv93
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %194 = sub nsw i32 %55, %193
  %195 = trunc nuw nsw i64 %indvars.iv93 to i32
  %196 = mul nsw i32 %194, %195
  %197 = add nsw i32 %196, %191
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next94, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge79, label %scalar.ph, !llvm.loop !27
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN13PriorityQueue4pushEii(ptr noundef nonnull align 4 dereferenceable(8012), i32 noundef, i32 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN13PriorityQueue9topAndPopERiS0_(ptr noundef nonnull align 4 dereferenceable(8012), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #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 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS11NonTreeEdge", !6, i64 0, !6, i64 4, !6, i64 8}
!16 = !{!15, !6, i64 4}
!17 = !{!15, !6, i64 8}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = !{!22, !6, i64 0}
!22 = !{!"_ZTS13PriorityQueue", !6, i64 0, !7, i64 4, !7, i64 4008}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !10, !13, !12}


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