; LLVM IR from tangjz/acm-icpc :: Summer_Training/2016-07-19/upsolved (A - Abandoned country - tjz)

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

@t = external dso_local global i32, align 4
@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 [100001 x i32], align 16
@dsu = external dso_local global [100001 x i32], align 16
@val = external dso_local global [1000001 x i32], align 16
@ord = external dso_local global [1000001 x i32], align 16
@que = external dso_local global [100001 x i32], align 16
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@sz = external dso_local global [100001 x i32], align 16
@e = external dso_local global [2000002 x %struct.Edge], align 16
@vis = external dso_local global [1000001 x i8], align 16
@ans1 = external dso_local global i64, align 8
@ans2 = external dso_local global x86_fp80, align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 %struct.Edge, align 4
  %7 = alloca %struct.Edge, 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
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %17

17:                                               ; preds = %309, %0
  %18 = load i32, ptr @t, align 4, !tbaa !5
  %19 = add nsw i32 %18, -1
  store i32 %19, ptr @t, align 4, !tbaa !5
  %20 = icmp ne i32 %18, 0
  br i1 %20, label %21, label %323

21:                                               ; preds = %17
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  store i32 0, ptr @tot, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = mul i64 %24, 4
  call void @llvm.memset.p0.i64(ptr align 16 @lnk, i8 -1, i64 %25, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %75, %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = load i32, ptr @m, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %78

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = add nsw i32 %33, -1
  store i32 %34, ptr %3, align 4, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %37 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 0
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  store i32 %41, ptr %37, align 4, !tbaa !9
  %42 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 1
  %43 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %43, ptr %42, align 4, !tbaa !11
  %44 = load i32, ptr @tot, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %45
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %46, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  %47 = load i32, ptr @tot, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr @tot, align 4, !tbaa !5
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %50
  store i32 %47, ptr %51, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %52 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 0
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  store i32 %56, ptr %52, align 4, !tbaa !9
  %57 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 1
  %58 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %58, ptr %57, align 4, !tbaa !11
  %59 = load i32, ptr @tot, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %60
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %61, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  %62 = load i32, ptr @tot, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr @tot, align 4, !tbaa !5
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !5
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [1000001 x i32], ptr @val, i64 0, i64 %69
  store i32 %67, ptr %70, align 4, !tbaa !5
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1000001 x i32], ptr @ord, i64 0, i64 %73
  store i32 %71, ptr %74, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %75

75:                                               ; preds = %31
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %2, align 4, !tbaa !5
  br label %26, !llvm.loop !13

78:                                               ; preds = %30
  %79 = load i32, ptr @m, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds i32, ptr @ord, i64 %80
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %81, ptr noundef @_Z3cmpRKiS0_)
  store i64 0, ptr @ans1, align 8, !tbaa !15
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = mul i64 %83, 4
  call void @llvm.memset.p0.i64(ptr align 16 @dsu, i8 -1, i64 %84, i1 false)
  %85 = load i32, ptr @m, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = mul i64 %86, 1
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 %87, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %140, %78
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = load i32, ptr @m, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %92, label %96

92:                                               ; preds = %88
  %93 = load i32, ptr %9, align 4, !tbaa !5
  %94 = load i32, ptr @n, align 4, !tbaa !5
  %95 = icmp slt i32 %93, %94
  br label %96

96:                                               ; preds = %92, %88
  %97 = phi i1 [ false, %88 ], [ %95, %92 ]
  br i1 %97, label %99, label %98

98:                                               ; preds = %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %143

99:                                               ; preds = %96
  %100 = load i32, ptr %8, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [1000001 x i32], ptr @ord, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = shl i32 %103, 1
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %105
  %107 = getelementptr inbounds %struct.Edge, ptr %106, i32 0, i32 1
  %108 = load i32, ptr %107, align 4, !tbaa !11
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1000001 x i32], ptr @ord, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = shl i32 %112, 1
  %114 = or i32 %113, 1
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %115
  %117 = getelementptr inbounds %struct.Edge, ptr %116, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !11
  %119 = call noundef zeroext i1 @_Z5mergeii(i32 noundef %108, i32 noundef %118)
  br i1 %119, label %120, label %139

120:                                              ; preds = %99
  %121 = load i32, ptr %9, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %9, align 4, !tbaa !5
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1000001 x i32], ptr @ord, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1000001 x i32], ptr @val, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = load i64, ptr @ans1, align 8, !tbaa !15
  %132 = add nsw i64 %131, %130
  store i64 %132, ptr @ans1, align 8, !tbaa !15
  %133 = load i32, ptr %8, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1000001 x i32], ptr @ord, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %137
  store i8 1, ptr %138, align 1, !tbaa !17
  br label %139

139:                                              ; preds = %120, %99
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %8, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %8, align 4, !tbaa !5
  br label %88, !llvm.loop !19

143:                                              ; preds = %98
  store i32 0, ptr @R, align 4, !tbaa !5
  store i32 0, ptr @L, align 4, !tbaa !5
  %144 = load i32, ptr @n, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = mul i64 %145, 4
  call void @llvm.memset.p0.i64(ptr align 16 @dsu, i8 -1, i64 %146, i1 false)
  store i32 -2, ptr @dsu, align 16, !tbaa !5
  %147 = load i32, ptr @R, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr @R, align 4, !tbaa !5
  %149 = sext i32 %147 to i64
  %150 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %149
  store i32 0, ptr %150, align 4, !tbaa !5
  br label %151

151:                                              ; preds = %211, %143
  %152 = load i32, ptr @L, align 4, !tbaa !5
  %153 = load i32, ptr @R, align 4, !tbaa !5
  %154 = icmp slt i32 %152, %153
  br i1 %154, label %155, label %212

155:                                              ; preds = %151
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %156 = load i32, ptr @L, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr @L, align 4, !tbaa !5
  %158 = sext i32 %156 to i64
  %159 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  store i32 %160, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %161 = load i32, ptr %10, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  store i32 %164, ptr %11, align 4, !tbaa !5
  br label %165

165:                                              ; preds = %205, %155
  %166 = load i32, ptr %11, align 4, !tbaa !5
  %167 = icmp ne i32 %166, -1
  br i1 %167, label %169, label %168

168:                                              ; preds = %165
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %211

169:                                              ; preds = %165
  %170 = load i32, ptr %11, align 4, !tbaa !5
  %171 = ashr i32 %170, 1
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %172
  %174 = load i8, ptr %173, align 1, !tbaa !17, !range !20, !noundef !21
  %175 = trunc i8 %174 to i1
  br i1 %175, label %176, label %204

176:                                              ; preds = %169
  %177 = load i32, ptr %11, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %178
  %180 = getelementptr inbounds %struct.Edge, ptr %179, i32 0, i32 1
  %181 = load i32, ptr %180, align 4, !tbaa !11
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [100001 x i32], ptr @dsu, i64 0, i64 %182
  %184 = load i32, ptr %183, align 4, !tbaa !5
  %185 = icmp eq i32 %184, -1
  br i1 %185, label %186, label %204

186:                                              ; preds = %176
  %187 = load i32, ptr %10, align 4, !tbaa !5
  %188 = load i32, ptr %11, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %189
  %191 = getelementptr inbounds %struct.Edge, ptr %190, i32 0, i32 1
  %192 = load i32, ptr %191, align 4, !tbaa !11
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [100001 x i32], ptr @dsu, i64 0, i64 %193
  store i32 %187, ptr %194, align 4, !tbaa !5
  %195 = load i32, ptr %11, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %196
  %198 = getelementptr inbounds %struct.Edge, ptr %197, i32 0, i32 1
  %199 = load i32, ptr %198, align 4, !tbaa !11
  %200 = load i32, ptr @R, align 4, !tbaa !5
  %201 = add nsw i32 %200, 1
  store i32 %201, ptr @R, align 4, !tbaa !5
  %202 = sext i32 %200 to i64
  %203 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %202
  store i32 %199, ptr %203, align 4, !tbaa !5
  br label %204

204:                                              ; preds = %186, %176, %169
  br label %205

205:                                              ; preds = %204
  %206 = load i32, ptr %11, align 4, !tbaa !5
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %207
  %209 = getelementptr inbounds %struct.Edge, ptr %208, i32 0, i32 0
  %210 = load i32, ptr %209, align 8, !tbaa !9
  store i32 %210, ptr %11, align 4, !tbaa !5
  br label %165, !llvm.loop !22

211:                                              ; preds = %168
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %151, !llvm.loop !23

212:                                              ; preds = %151
  store x86_fp80 0xK00000000000000000000, ptr @ans2, align 16, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %213 = load i32, ptr @n, align 4, !tbaa !5
  %214 = sub nsw i32 %213, 1
  store i32 %214, ptr %12, align 4, !tbaa !5
  br label %215

215:                                              ; preds = %306, %212
  %216 = load i32, ptr %12, align 4, !tbaa !5
  %217 = icmp sge i32 %216, 0
  br i1 %217, label %219, label %218

218:                                              ; preds = %215
  store i32 15, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %309

219:                                              ; preds = %215
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %220 = load i32, ptr %12, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %221
  %223 = load i32, ptr %222, align 4, !tbaa !5
  store i32 %223, ptr %14, align 4, !tbaa !5
  %224 = load i32, ptr %14, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [100001 x i32], ptr @sz, i64 0, i64 %225
  store i32 1, ptr %226, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %227 = load i32, ptr %14, align 4, !tbaa !5
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %228
  %230 = load i32, ptr %229, align 4, !tbaa !5
  store i32 %230, ptr %15, align 4, !tbaa !5
  br label %231

231:                                              ; preds = %299, %219
  %232 = load i32, ptr %15, align 4, !tbaa !5
  %233 = icmp ne i32 %232, -1
  br i1 %233, label %235, label %234

234:                                              ; preds = %231
  store i32 18, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %305

235:                                              ; preds = %231
  %236 = load i32, ptr %15, align 4, !tbaa !5
  %237 = ashr i32 %236, 1
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %238
  %240 = load i8, ptr %239, align 1, !tbaa !17, !range !20, !noundef !21
  %241 = trunc i8 %240 to i1
  br i1 %241, label %242, label %298

242:                                              ; preds = %235
  %243 = load i32, ptr %15, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %244
  %246 = getelementptr inbounds %struct.Edge, ptr %245, i32 0, i32 1
  %247 = load i32, ptr %246, align 4, !tbaa !11
  %248 = sext i32 %247 to i64
  %249 = getelementptr inbounds [100001 x i32], ptr @dsu, i64 0, i64 %248
  %250 = load i32, ptr %249, align 4, !tbaa !5
  %251 = load i32, ptr %14, align 4, !tbaa !5
  %252 = icmp eq i32 %250, %251
  br i1 %252, label %253, label %298

253:                                              ; preds = %242
  %254 = load i32, ptr %15, align 4, !tbaa !5
  %255 = ashr i32 %254, 1
  %256 = sext i32 %255 to i64
  %257 = getelementptr inbounds [1000001 x i32], ptr @val, i64 0, i64 %256
  %258 = load i32, ptr %257, align 4, !tbaa !5
  %259 = sext i32 %258 to i64
  %260 = load i32, ptr %15, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %261
  %263 = getelementptr inbounds %struct.Edge, ptr %262, i32 0, i32 1
  %264 = load i32, ptr %263, align 4, !tbaa !11
  %265 = sext i32 %264 to i64
  %266 = getelementptr inbounds [100001 x i32], ptr @sz, i64 0, i64 %265
  %267 = load i32, ptr %266, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = mul nsw i64 %259, %268
  %270 = load i32, ptr @n, align 4, !tbaa !5
  %271 = load i32, ptr %15, align 4, !tbaa !5
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %272
  %274 = getelementptr inbounds %struct.Edge, ptr %273, i32 0, i32 1
  %275 = load i32, ptr %274, align 4, !tbaa !11
  %276 = sext i32 %275 to i64
  %277 = getelementptr inbounds [100001 x i32], ptr @sz, i64 0, i64 %276
  %278 = load i32, ptr %277, align 4, !tbaa !5
  %279 = sub nsw i32 %270, %278
  %280 = sext i32 %279 to i64
  %281 = mul nsw i64 %269, %280
  %282 = sitofp i64 %281 to x86_fp80
  %283 = load x86_fp80, ptr @ans2, align 16, !tbaa !24
  %284 = fadd x86_fp80 %283, %282
  store x86_fp80 %284, ptr @ans2, align 16, !tbaa !24
  %285 = load i32, ptr %15, align 4, !tbaa !5
  %286 = sext i32 %285 to i64
  %287 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %286
  %288 = getelementptr inbounds %struct.Edge, ptr %287, i32 0, i32 1
  %289 = load i32, ptr %288, align 4, !tbaa !11
  %290 = sext i32 %289 to i64
  %291 = getelementptr inbounds [100001 x i32], ptr @sz, i64 0, i64 %290
  %292 = load i32, ptr %291, align 4, !tbaa !5
  %293 = load i32, ptr %14, align 4, !tbaa !5
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [100001 x i32], ptr @sz, i64 0, i64 %294
  %296 = load i32, ptr %295, align 4, !tbaa !5
  %297 = add nsw i32 %296, %292
  store i32 %297, ptr %295, align 4, !tbaa !5
  br label %298

298:                                              ; preds = %253, %242, %235
  br label %299

299:                                              ; preds = %298
  %300 = load i32, ptr %15, align 4, !tbaa !5
  %301 = sext i32 %300 to i64
  %302 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %301
  %303 = getelementptr inbounds %struct.Edge, ptr %302, i32 0, i32 0
  %304 = load i32, ptr %303, align 8, !tbaa !9
  store i32 %304, ptr %15, align 4, !tbaa !5
  br label %231, !llvm.loop !26

305:                                              ; preds = %234
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %306

306:                                              ; preds = %305
  %307 = load i32, ptr %12, align 4, !tbaa !5
  %308 = add nsw i32 %307, -1
  store i32 %308, ptr %12, align 4, !tbaa !5
  br label %215, !llvm.loop !27

309:                                              ; preds = %218
  %310 = load i64, ptr @ans1, align 8, !tbaa !15
  %311 = load x86_fp80, ptr @ans2, align 16, !tbaa !24
  %312 = load i32, ptr @n, align 4, !tbaa !5
  %313 = sext i32 %312 to i64
  %314 = load i32, ptr @n, align 4, !tbaa !5
  %315 = sext i32 %314 to i64
  %316 = sub nsw i64 %315, 1
  %317 = mul nsw i64 %313, %316
  %318 = ashr i64 %317, 1
  %319 = sitofp i64 %318 to x86_fp80
  %320 = fdiv x86_fp80 %311, %319
  %321 = fptrunc x86_fp80 %320 to double
  %322 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %310, double noundef %321)
  br label %17, !llvm.loop !28

323:                                              ; preds = %17
  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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #5

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #7

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 = { 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 #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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { 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 = !{!"long long", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = distinct !{!19, !14}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}
!24 = !{!25, !25, i64 0}
!25 = !{!"long double", !7, i64 0}
!26 = distinct !{!26, !14}
!27 = distinct !{!27, !14}
!28 = distinct !{!28, !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 }

@t = external dso_local global i32, align 4
@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 [100001 x i32], align 16
@dsu = external dso_local local_unnamed_addr global [100001 x i32], align 16
@val = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@ord = external dso_local global [1000001 x i32], align 16
@que = external dso_local local_unnamed_addr global [100001 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
@sz = external dso_local local_unnamed_addr global [100001 x i32], align 16
@e = external dso_local local_unnamed_addr global [2000002 x %struct.Edge], align 16
@vis = external dso_local local_unnamed_addr global [1000001 x i8], align 16
@ans1 = external dso_local local_unnamed_addr global i64, align 8
@ans2 = external dso_local local_unnamed_addr global x86_fp80, align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %5 = load i32, ptr @t, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @t, align 4, !tbaa !5
  %.not87 = icmp eq i32 %5, 0
  br i1 %.not87, label %._crit_edge90, label %.lr.ph89

.lr.ph89:                                         ; preds = %0, %._crit_edge86
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  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 16 @lnk, i8 -1, i64 %10, i1 false)
  %11 = load i32, ptr @m, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %.lr.ph89.._crit_edge_crit_edge

.lr.ph89.._crit_edge_crit_edge:                   ; preds = %.lr.ph89
  %.pre106 = sext i32 %11 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph89.._crit_edge_crit_edge
  %.pre-phi107 = phi i64 [ %.pre106, %.lr.ph89.._crit_edge_crit_edge ], [ %45, %.lr.ph ]
  %13 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi107
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %13, ptr noundef nonnull @_Z3cmpRKiS0_)
  store i64 0, ptr @ans1, align 8, !tbaa !9
  %14 = load i32, ptr @n, align 4
  %15 = sext i32 %14 to i64
  %16 = shl nsw i64 %15, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @dsu, i8 -1, i64 %16, i1 false)
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @vis, i8 0, i64 %18, i1 false)
  %19 = icmp sgt i32 %17, 0
  %20 = icmp sgt i32 %14, 1
  %21 = select i1 %19, i1 %20, i1 false
  br i1 %21, label %.lr.ph53, label %.lr.ph68.preheader

.lr.ph:                                           ; preds = %.lr.ph89, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph89 ]
  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
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = add nsw i32 %23, -1
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  %27 = sext i32 %24 to i64
  %28 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr @tot, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %31
  store i32 %29, ptr %32, align 8, !tbaa !5
  %.sroa.432.0..sroa_idx = getelementptr inbounds i8, ptr %32, i64 4
  store i32 %26, ptr %.sroa.432.0..sroa_idx, align 4, !tbaa !5
  %33 = add nsw i32 %30, 1
  store i32 %30, ptr %28, align 4, !tbaa !5
  %34 = sext i32 %26 to i64
  %35 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %33 to i64
  %38 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %37
  store i32 %36, ptr %38, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %38, i64 4
  store i32 %24, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %39 = add nsw i32 %30, 2
  store i32 %39, ptr @tot, align 4, !tbaa !5
  store i32 %33, ptr %35, align 4, !tbaa !5
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = getelementptr inbounds [1000001 x i32], ptr @val, i64 0, i64 %indvars.iv
  store i32 %40, ptr %41, align 4, !tbaa !5
  %42 = getelementptr inbounds [1000001 x i32], ptr @ord, i64 0, i64 %indvars.iv
  %43 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %43, ptr %42, align 4, !tbaa !5
  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
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %44 = load i32, ptr @m, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = icmp slt i64 %indvars.iv.next, %45
  br i1 %46, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge54.loopexit:                           ; preds = %68
  %.pre = sext i32 %72 to i64
  %.pre104 = shl nsw i64 %.pre, 2
  br label %.lr.ph68.preheader

.lr.ph68.preheader:                               ; preds = %._crit_edge, %._crit_edge54.loopexit
  %.pre-phi105 = phi i64 [ %.pre104, %._crit_edge54.loopexit ], [ %16, %._crit_edge ]
  %.pre-phi = phi i64 [ %.pre, %._crit_edge54.loopexit ], [ %15, %._crit_edge ]
  %.lcssa48 = phi i32 [ %72, %._crit_edge54.loopexit ], [ %14, %._crit_edge ]
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @dsu, i8 -1, i64 %.pre-phi105, i1 false)
  store i32 -2, ptr @dsu, align 16, !tbaa !5
  store i32 1, ptr @R, align 4, !tbaa !5
  store i32 0, ptr @que, align 16, !tbaa !5
  br label %.lr.ph68

.lr.ph53:                                         ; preds = %._crit_edge, %68
  %indvars.iv95 = phi i64 [ %indvars.iv.next96, %68 ], [ 0, %._crit_edge ]
  %.04250 = phi i32 [ %.1, %68 ], [ 1, %._crit_edge ]
  %47 = getelementptr inbounds [1000001 x i32], ptr @ord, i64 0, i64 %indvars.iv95
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = shl i32 %48, 1
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %50, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !13
  %53 = or disjoint i32 %49, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %54, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !13
  %57 = call noundef zeroext i1 @_Z5mergeii(i32 noundef %52, i32 noundef %56)
  br i1 %57, label %58, label %68

58:                                               ; preds = %.lr.ph53
  %59 = add nsw i32 %.04250, 1
  %60 = load i32, ptr %47, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1000001 x i32], ptr @val, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = load i64, ptr @ans1, align 8, !tbaa !9
  %66 = add nsw i64 %65, %64
  store i64 %66, ptr @ans1, align 8, !tbaa !9
  %67 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %61
  store i8 1, ptr %67, align 1, !tbaa !15
  br label %68

68:                                               ; preds = %.lr.ph53, %58
  %.1 = phi i32 [ %59, %58 ], [ %.04250, %.lr.ph53 ]
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %69 = load i32, ptr @m, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = icmp slt i64 %indvars.iv.next96, %70
  %72 = load i32, ptr @n, align 4
  %73 = icmp slt i32 %.1, %72
  %74 = select i1 %71, i1 %73, i1 false
  br i1 %74, label %.lr.ph53, label %._crit_edge54.loopexit, !llvm.loop !17

.loopexit47:                                      ; preds = %.lr.ph60._crit_edge, %.lr.ph68
  %R.promoted64 = phi i32 [ %R.promoted6566, %.lr.ph68 ], [ %R.promoted62, %.lr.ph60._crit_edge ]
  %75 = sext i32 %R.promoted64 to i64
  %76 = icmp slt i64 %indvars.iv.next99, %75
  br i1 %76, label %.lr.ph68, label %101, !llvm.loop !18

.lr.ph68:                                         ; preds = %.lr.ph68.preheader, %.loopexit47
  %indvars.iv98 = phi i64 [ 0, %.lr.ph68.preheader ], [ %indvars.iv.next99, %.loopexit47 ]
  %R.promoted6566 = phi i32 [ 1, %.lr.ph68.preheader ], [ %R.promoted64, %.loopexit47 ]
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %77 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %indvars.iv98
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %79
  %.04056 = load i32, ptr %80, align 4, !tbaa !5
  %.not4657 = icmp eq i32 %.04056, -1
  br i1 %.not4657, label %.loopexit47, label %.lr.ph60

.lr.ph60:                                         ; preds = %.lr.ph68, %.lr.ph60._crit_edge
  %R.promoted63 = phi i32 [ %R.promoted62, %.lr.ph60._crit_edge ], [ %R.promoted6566, %.lr.ph68 ]
  %.04058 = phi i32 [ %.040, %.lr.ph60._crit_edge ], [ %.04056, %.lr.ph68 ]
  %81 = phi i32 [ %99, %.lr.ph60._crit_edge ], [ %R.promoted6566, %.lr.ph68 ]
  %82 = ashr i32 %.04058, 1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !15, !range !19, !noundef !20
  %86 = trunc nuw i8 %85 to i1
  %87 = sext i32 %.04058 to i64
  br i1 %86, label %88, label %.lr.ph60._crit_edge

88:                                               ; preds = %.lr.ph60
  %89 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %87, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !13
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100001 x i32], ptr @dsu, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = icmp eq i32 %93, -1
  br i1 %94, label %95, label %.lr.ph60._crit_edge

95:                                               ; preds = %88
  store i32 %78, ptr %92, align 4, !tbaa !5
  %96 = add nsw i32 %81, 1
  store i32 %96, ptr @R, align 4, !tbaa !5
  %97 = sext i32 %81 to i64
  %98 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %97
  store i32 %90, ptr %98, align 4, !tbaa !5
  br label %.lr.ph60._crit_edge

.lr.ph60._crit_edge:                              ; preds = %.lr.ph60, %88, %95
  %R.promoted62 = phi i32 [ %R.promoted63, %88 ], [ %96, %95 ], [ %R.promoted63, %.lr.ph60 ]
  %99 = phi i32 [ %81, %88 ], [ %96, %95 ], [ %81, %.lr.ph60 ]
  %100 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %87
  %.040 = load i32, ptr %100, align 8, !tbaa !5
  %.not46 = icmp eq i32 %.040, -1
  br i1 %.not46, label %.loopexit47, label %.lr.ph60, !llvm.loop !21

101:                                              ; preds = %.loopexit47
  %102 = trunc nsw i64 %indvars.iv.next99 to i32
  store i32 %102, ptr @L, align 4, !tbaa !5
  store x86_fp80 0xK00000000000000000000, ptr @ans2, align 16, !tbaa !22
  %103 = icmp sgt i32 %.lcssa48, 0
  br i1 %103, label %.lr.ph85.preheader, label %._crit_edge86

.lr.ph85.preheader:                               ; preds = %101
  %104 = zext nneg i32 %.lcssa48 to i64
  br label %.lr.ph85

.loopexit:                                        ; preds = %.lr.ph75._crit_edge, %.lr.ph85
  %ans2.promoted79 = phi x86_fp80 [ %ans2.promoted8082, %.lr.ph85 ], [ %ans2.promoted77, %.lr.ph75._crit_edge ]
  %105 = icmp sgt i64 %indvars.iv101, 1
  br i1 %105, label %.lr.ph85, label %._crit_edge86, !llvm.loop !24

._crit_edge86:                                    ; preds = %.loopexit, %101
  %106 = phi x86_fp80 [ 0xK00000000000000000000, %101 ], [ %ans2.promoted79, %.loopexit ]
  %107 = load i64, ptr @ans1, align 8, !tbaa !9
  %108 = add nsw i64 %.pre-phi, -1
  %109 = mul nsw i64 %108, %.pre-phi
  %110 = ashr i64 %109, 1
  %111 = sitofp i64 %110 to x86_fp80
  %112 = fdiv x86_fp80 %106, %111
  %113 = fptrunc x86_fp80 %112 to double
  %114 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %107, double noundef %113)
  %115 = load i32, ptr @t, align 4, !tbaa !5
  %116 = add nsw i32 %115, -1
  store i32 %116, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %115, 0
  br i1 %.not, label %._crit_edge90, label %.lr.ph89, !llvm.loop !25

.lr.ph85:                                         ; preds = %.lr.ph85.preheader, %.loopexit
  %indvars.iv101 = phi i64 [ %104, %.lr.ph85.preheader ], [ %indvars.iv.next102, %.loopexit ]
  %ans2.promoted8082 = phi x86_fp80 [ 0xK00000000000000000000, %.lr.ph85.preheader ], [ %ans2.promoted79, %.loopexit ]
  %indvars.iv.next102 = add nsw i64 %indvars.iv101, -1
  %117 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %indvars.iv.next102
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100001 x i32], ptr @sz, i64 0, i64 %119
  store i32 1, ptr %120, align 4, !tbaa !5
  %121 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %119
  %.071 = load i32, ptr %121, align 4, !tbaa !5
  %.not4572 = icmp eq i32 %.071, -1
  br i1 %.not4572, label %.loopexit, label %.lr.ph75

.lr.ph75:                                         ; preds = %.lr.ph85, %.lr.ph75._crit_edge
  %122 = phi i32 [ %151, %.lr.ph75._crit_edge ], [ 1, %.lr.ph85 ]
  %ans2.promoted78 = phi x86_fp80 [ %ans2.promoted77, %.lr.ph75._crit_edge ], [ %ans2.promoted8082, %.lr.ph85 ]
  %.073 = phi i32 [ %.0, %.lr.ph75._crit_edge ], [ %.071, %.lr.ph85 ]
  %123 = phi x86_fp80 [ %152, %.lr.ph75._crit_edge ], [ %ans2.promoted8082, %.lr.ph85 ]
  %124 = ashr i32 %.073, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %125
  %127 = load i8, ptr %126, align 1, !tbaa !15, !range !19, !noundef !20
  %128 = trunc nuw i8 %127 to i1
  %129 = sext i32 %.073 to i64
  br i1 %128, label %130, label %.lr.ph75._crit_edge

130:                                              ; preds = %.lr.ph75
  %131 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %129, i32 1
  %132 = load i32, ptr %131, align 4, !tbaa !13
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [100001 x i32], ptr @dsu, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = icmp eq i32 %135, %118
  br i1 %136, label %137, label %.lr.ph75._crit_edge

137:                                              ; preds = %130
  %138 = getelementptr inbounds [1000001 x i32], ptr @val, i64 0, i64 %125
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [100001 x i32], ptr @sz, i64 0, i64 %133
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = mul nsw i64 %143, %140
  %145 = sub nsw i32 %.lcssa48, %142
  %146 = sext i32 %145 to i64
  %147 = mul nsw i64 %144, %146
  %148 = sitofp i64 %147 to x86_fp80
  %149 = fadd x86_fp80 %123, %148
  store x86_fp80 %149, ptr @ans2, align 16, !tbaa !22
  %150 = add nsw i32 %122, %142
  store i32 %150, ptr %120, align 4, !tbaa !5
  br label %.lr.ph75._crit_edge

.lr.ph75._crit_edge:                              ; preds = %.lr.ph75, %130, %137
  %151 = phi i32 [ %122, %130 ], [ %150, %137 ], [ %122, %.lr.ph75 ]
  %ans2.promoted77 = phi x86_fp80 [ %ans2.promoted78, %130 ], [ %149, %137 ], [ %ans2.promoted78, %.lr.ph75 ]
  %152 = phi x86_fp80 [ %123, %130 ], [ %149, %137 ], [ %123, %.lr.ph75 ]
  %153 = getelementptr inbounds [2000002 x %struct.Edge], ptr @e, i64 0, i64 %129
  %.0 = load i32, ptr %153, align 8, !tbaa !5
  %.not45 = icmp eq i32 %.0, -1
  br i1 %.not45, label %.loopexit, label %.lr.ph75, !llvm.loop !26

._crit_edge90:                                    ; preds = %._crit_edge86, %0
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 4}
!14 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !12}
!22 = !{!23, !23, i64 0}
!23 = !{!"long double", !7, i64 0}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}


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