; LLVM IR from tangjz/acm-icpc :: codeforces/complete (500G)

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

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@lnk = external dso_local global [200001 x i32], align 16
@dep = external dso_local global [200001 x i32], align 16
@e = external dso_local global [400002 x %struct.Edge], 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 [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

; 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 nounwind uwtable
declare dso_local noundef i32 @_Z6deeperii(i32 noundef, i32 noundef) #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5Case1iiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5Case2iiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.Edge, align 4
  %6 = alloca %struct.Edge, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca i64, align 8
  %26 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  br label %28

28:                                               ; preds = %65, %0
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %68

33:                                               ; preds = %28
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %35 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 0
  %36 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %36, ptr %35, align 4, !tbaa !9
  %37 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 1
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [200001 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 !11
  %42 = load i32, ptr @tot, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr @tot, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %44
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %45, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  %46 = load i32, ptr @tot, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200001 x i32], ptr @lnk, i64 0, i64 %48
  store i32 %46, ptr %49, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %50 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 0
  %51 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %51, ptr %50, align 4, !tbaa !9
  %52 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 1
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [200001 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 !11
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @tot, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %59
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %60, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %61 = load i32, ptr @tot, align 4, !tbaa !5
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200001 x i32], ptr @lnk, i64 0, i64 %63
  store i32 %61, ptr %64, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %33
  %66 = load i32, ptr %2, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %2, align 4, !tbaa !5
  br label %28, !llvm.loop !13

68:                                               ; preds = %32
  call void @_Z3dfsi(i32 noundef 1)
  %69 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @q)
  br label %70

70:                                               ; preds = %227, %225, %68
  %71 = load i32, ptr @q, align 4, !tbaa !5
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr @q, align 4, !tbaa !5
  %73 = icmp ne i32 %71, 0
  br i1 %73, label %74, label %228

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %75 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %76 = load i32, ptr %7, align 4, !tbaa !5
  %77 = load i32, ptr %9, align 4, !tbaa !5
  %78 = call noundef i32 @_Z3lcaii(i32 noundef %76, i32 noundef %77)
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = call noundef i32 @_Z3lcaii(i32 noundef %79, i32 noundef %80)
  %82 = call noundef i32 @_Z6deeperii(i32 noundef %78, i32 noundef %81)
  store i32 %82, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = load i32, ptr %10, align 4, !tbaa !5
  %85 = call noundef i32 @_Z3lcaii(i32 noundef %83, i32 noundef %84)
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = load i32, ptr %10, align 4, !tbaa !5
  %88 = call noundef i32 @_Z3lcaii(i32 noundef %86, i32 noundef %87)
  %89 = call noundef i32 @_Z6deeperii(i32 noundef %85, i32 noundef %88)
  store i32 %89, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = load i32, ptr %8, align 4, !tbaa !5
  %92 = call noundef i32 @_Z3lcaii(i32 noundef %90, i32 noundef %91)
  %93 = load i32, ptr %9, align 4, !tbaa !5
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = call noundef i32 @_Z3lcaii(i32 noundef %93, i32 noundef %94)
  %96 = call noundef i32 @_Z6deeperii(i32 noundef %92, i32 noundef %95)
  store i32 %96, ptr %13, align 4, !tbaa !5
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = load i32, ptr %13, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = icmp slt i32 %100, %104
  br i1 %105, label %106, label %118

106:                                              ; preds = %74
  %107 = load i32, ptr %12, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = load i32, ptr %13, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = icmp slt i32 %110, %114
  br i1 %115, label %116, label %118

116:                                              ; preds = %106
  %117 = call i32 @puts(ptr noundef @.str.3)
  store i32 5, ptr %14, align 4
  br label %225, !llvm.loop !15

118:                                              ; preds = %106, %74
  %119 = load i32, ptr %11, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = load i32, ptr %13, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = icmp slt i32 %122, %126
  br i1 %127, label %128, label %130

128:                                              ; preds = %118
  %129 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %129, ptr %11, align 4, !tbaa !5
  br label %143

130:                                              ; preds = %118
  %131 = load i32, ptr %12, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = load i32, ptr %13, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = icmp slt i32 %134, %138
  br i1 %139, label %140, label %142

140:                                              ; preds = %130
  %141 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %141, ptr %12, align 4, !tbaa !5
  br label %142

142:                                              ; preds = %140, %130
  br label %143

143:                                              ; preds = %142, %128
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %144 = load i32, ptr %7, align 4, !tbaa !5
  %145 = load i32, ptr %8, align 4, !tbaa !5
  %146 = call noundef i32 @_Z4distii(i32 noundef %144, i32 noundef %145)
  %147 = shl i32 %146, 1
  store i32 %147, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %148 = load i32, ptr %9, align 4, !tbaa !5
  %149 = load i32, ptr %10, align 4, !tbaa !5
  %150 = call noundef i32 @_Z4distii(i32 noundef %148, i32 noundef %149)
  %151 = shl i32 %150, 1
  store i32 %151, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %152 = load i32, ptr %11, align 4, !tbaa !5
  %153 = load i32, ptr %12, align 4, !tbaa !5
  %154 = call noundef i32 @_Z4distii(i32 noundef %152, i32 noundef %153)
  store i32 %154, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = load i32, ptr %11, align 4, !tbaa !5
  %157 = call noundef i32 @_Z4distii(i32 noundef %155, i32 noundef %156)
  store i32 %157, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %158 = load i32, ptr %7, align 4, !tbaa !5
  %159 = load i32, ptr %12, align 4, !tbaa !5
  %160 = call noundef i32 @_Z4distii(i32 noundef %158, i32 noundef %159)
  store i32 %160, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = load i32, ptr %11, align 4, !tbaa !5
  %163 = call noundef i32 @_Z4distii(i32 noundef %161, i32 noundef %162)
  store i32 %163, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %164 = load i32, ptr %9, align 4, !tbaa !5
  %165 = load i32, ptr %12, align 4, !tbaa !5
  %166 = call noundef i32 @_Z4distii(i32 noundef %164, i32 noundef %165)
  store i32 %166, ptr %21, align 4, !tbaa !5
  %167 = load i32, ptr %18, align 4, !tbaa !5
  %168 = load i32, ptr %19, align 4, !tbaa !5
  %169 = icmp sle i32 %167, %168
  br i1 %169, label %170, label %174

170:                                              ; preds = %143
  %171 = load i32, ptr %15, align 4, !tbaa !5
  %172 = load i32, ptr %19, align 4, !tbaa !5
  %173 = sub nsw i32 %171, %172
  store i32 %173, ptr %19, align 4, !tbaa !5
  br label %178

174:                                              ; preds = %143
  %175 = load i32, ptr %15, align 4, !tbaa !5
  %176 = load i32, ptr %18, align 4, !tbaa !5
  %177 = sub nsw i32 %175, %176
  store i32 %177, ptr %18, align 4, !tbaa !5
  br label %178

178:                                              ; preds = %174, %170
  %179 = load i32, ptr %20, align 4, !tbaa !5
  %180 = load i32, ptr %21, align 4, !tbaa !5
  %181 = icmp sle i32 %179, %180
  br i1 %181, label %182, label %186

182:                                              ; preds = %178
  %183 = load i32, ptr %16, align 4, !tbaa !5
  %184 = load i32, ptr %21, align 4, !tbaa !5
  %185 = sub nsw i32 %183, %184
  store i32 %185, ptr %21, align 4, !tbaa !5
  br label %190

186:                                              ; preds = %178
  %187 = load i32, ptr %16, align 4, !tbaa !5
  %188 = load i32, ptr %20, align 4, !tbaa !5
  %189 = sub nsw i32 %187, %188
  store i32 %189, ptr %20, align 4, !tbaa !5
  br label %190

190:                                              ; preds = %186, %182
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %191 = load i32, ptr %15, align 4, !tbaa !5
  %192 = load i32, ptr %18, align 4, !tbaa !5
  %193 = load i32, ptr %16, align 4, !tbaa !5
  %194 = load i32, ptr %20, align 4, !tbaa !5
  %195 = call noundef i64 @_Z5Case1iiii(i32 noundef %191, i32 noundef %192, i32 noundef %193, i32 noundef %194)
  store i64 %195, ptr %23, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  %196 = load i32, ptr %15, align 4, !tbaa !5
  %197 = load i32, ptr %18, align 4, !tbaa !5
  %198 = load i32, ptr %16, align 4, !tbaa !5
  %199 = load i32, ptr %21, align 4, !tbaa !5
  %200 = load i32, ptr %17, align 4, !tbaa !5
  %201 = call noundef i64 @_Z5Case2iiiii(i32 noundef %196, i32 noundef %197, i32 noundef %198, i32 noundef %199, i32 noundef %200)
  store i64 %201, ptr %24, align 8, !tbaa !16
  %202 = call noundef nonnull align 8 dereferenceable(8) ptr @_Z3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %23, ptr noundef nonnull align 8 dereferenceable(8) %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  %203 = load i32, ptr %15, align 4, !tbaa !5
  %204 = load i32, ptr %19, align 4, !tbaa !5
  %205 = load i32, ptr %16, align 4, !tbaa !5
  %206 = load i32, ptr %21, align 4, !tbaa !5
  %207 = call noundef i64 @_Z5Case1iiii(i32 noundef %203, i32 noundef %204, i32 noundef %205, i32 noundef %206)
  store i64 %207, ptr %25, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #6
  %208 = load i32, ptr %15, align 4, !tbaa !5
  %209 = load i32, ptr %19, align 4, !tbaa !5
  %210 = load i32, ptr %16, align 4, !tbaa !5
  %211 = load i32, ptr %20, align 4, !tbaa !5
  %212 = load i32, ptr %17, align 4, !tbaa !5
  %213 = call noundef i64 @_Z5Case2iiiii(i32 noundef %208, i32 noundef %209, i32 noundef %210, i32 noundef %211, i32 noundef %212)
  store i64 %213, ptr %26, align 8, !tbaa !16
  %214 = call noundef nonnull align 8 dereferenceable(8) ptr @_Z3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef nonnull align 8 dereferenceable(8) %26)
  %215 = call noundef nonnull align 8 dereferenceable(8) ptr @_Z3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %202, ptr noundef nonnull align 8 dereferenceable(8) %214)
  %216 = load i64, ptr %215, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  store i64 %216, ptr %22, align 8, !tbaa !16
  %217 = load i64, ptr %22, align 8, !tbaa !16
  %218 = icmp eq i64 %217, 4557430888798830399
  br i1 %218, label %219, label %221

219:                                              ; preds = %190
  %220 = call i32 @puts(ptr noundef @.str.3)
  br label %224

221:                                              ; preds = %190
  %222 = load i64, ptr %22, align 8, !tbaa !16
  %223 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %222)
  br label %224

224:                                              ; preds = %221, %219
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  store i32 0, ptr %14, align 4
  br label %225

225:                                              ; preds = %224, %116
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  %226 = load i32, ptr %14, align 4
  switch i32 %226, label %229 [
    i32 0, label %227
    i32 5, label %70
  ]

227:                                              ; preds = %225
  br label %70, !llvm.loop !15

228:                                              ; preds = %70
  ret i32 0

229:                                              ; preds = %225
  unreachable
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #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

declare i32 @puts(ptr noundef) #4

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = distinct !{!15, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}


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

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@q = 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 [200001 x i32], align 16
@dep = external dso_local local_unnamed_addr global [200001 x i32], align 16
@e = external dso_local local_unnamed_addr global [400002 x %struct.Edge], 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 [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

; 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 nounwind uwtable
declare dso_local noundef i32 @_Z6deeperii(i32 noundef, i32 noundef) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5Case1iiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5Case2iiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %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 i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 1
  br i1 %13, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  call void @_Z3dfsi(i32 noundef 1)
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @q)
  %15 = load i32, ptr @q, align 4, !tbaa !5
  %16 = add nsw i32 %15, -1
  store i32 %16, ptr @q, align 4, !tbaa !5
  %.not71 = icmp eq i32 %15, 0
  br i1 %.not71, label %._crit_edge74, label %.lr.ph73

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.070 = phi i32 [ %33, %.lr.ph ], [ 1, %0 ]
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [200001 x i32], ptr @lnk, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = load i32, ptr @tot, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %25
  store i32 %18, ptr %26, align 8, !tbaa !5
  %.sroa.449.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 4
  store i32 %22, ptr %.sroa.449.0..sroa_idx, align 4, !tbaa !5
  store i32 %24, ptr %21, align 4, !tbaa !5
  %27 = sext i32 %18 to i64
  %28 = getelementptr inbounds [200001 x i32], ptr @lnk, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %23, 2
  store i32 %30, ptr @tot, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [400002 x %struct.Edge], ptr @e, i64 0, i64 %31
  store i32 %19, ptr %32, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %32, i64 4
  store i32 %29, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  store i32 %30, ptr %28, align 4, !tbaa !5
  %33 = add nuw nsw i32 %.070, 1
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph73:                                         ; preds = %._crit_edge, %107
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = call noundef i32 @_Z3lcaii(i32 noundef %37, i32 noundef %38)
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = call noundef i32 @_Z3lcaii(i32 noundef %40, i32 noundef %41)
  %43 = call noundef i32 @_Z6deeperii(i32 noundef %39, i32 noundef %42)
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = call noundef i32 @_Z3lcaii(i32 noundef %44, i32 noundef %45)
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = call noundef i32 @_Z3lcaii(i32 noundef %47, i32 noundef %48)
  %50 = call noundef i32 @_Z6deeperii(i32 noundef %46, i32 noundef %49)
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = call noundef i32 @_Z3lcaii(i32 noundef %51, i32 noundef %52)
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = call noundef i32 @_Z3lcaii(i32 noundef %54, i32 noundef %55)
  %57 = call noundef i32 @_Z6deeperii(i32 noundef %53, i32 noundef %56)
  %58 = sext i32 %43 to i64
  %59 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %57 to i64
  %62 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp slt i32 %60, %63
  %65 = sext i32 %50 to i64
  %66 = getelementptr inbounds [200001 x i32], ptr @dep, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = icmp slt i32 %67, %63
  br i1 %64, label %69, label %72

69:                                               ; preds = %.lr.ph73
  br i1 %68, label %70, label %.thread

70:                                               ; preds = %69
  %71 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %107, !llvm.loop !11

72:                                               ; preds = %.lr.ph73
  %spec.select = select i1 %68, i32 %57, i32 %50
  br label %.thread

.thread:                                          ; preds = %69, %72
  %.057 = phi i32 [ %spec.select, %72 ], [ %50, %69 ]
  %.056 = phi i32 [ %43, %72 ], [ %57, %69 ]
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = call noundef i32 @_Z4distii(i32 noundef %73, i32 noundef %74)
  %76 = shl i32 %75, 1
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = call noundef i32 @_Z4distii(i32 noundef %77, i32 noundef %78)
  %80 = shl i32 %79, 1
  %81 = call noundef i32 @_Z4distii(i32 noundef %.056, i32 noundef %.057)
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = call noundef i32 @_Z4distii(i32 noundef %82, i32 noundef %.056)
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = call noundef i32 @_Z4distii(i32 noundef %84, i32 noundef %.057)
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = call noundef i32 @_Z4distii(i32 noundef %86, i32 noundef %.056)
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = call noundef i32 @_Z4distii(i32 noundef %88, i32 noundef %.057)
  %.not68 = icmp sgt i32 %83, %85
  %90 = sub nsw i32 %76, %85
  %91 = sub nsw i32 %76, %83
  %.055 = select i1 %.not68, i32 %91, i32 %83
  %.054 = select i1 %.not68, i32 %85, i32 %90
  %.not69 = icmp sgt i32 %87, %89
  %92 = sub nsw i32 %80, %89
  %93 = sub nsw i32 %80, %87
  %.053 = select i1 %.not69, i32 %93, i32 %87
  %.052 = select i1 %.not69, i32 %89, i32 %92
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %94 = call noundef i64 @_Z5Case1iiii(i32 noundef %76, i32 noundef %.055, i32 noundef %80, i32 noundef %.053)
  store i64 %94, ptr %7, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  %95 = call noundef i64 @_Z5Case2iiiii(i32 noundef %76, i32 noundef %.055, i32 noundef %80, i32 noundef %.052, i32 noundef %81)
  store i64 %95, ptr %8, align 8, !tbaa !12
  %96 = call noundef nonnull align 8 dereferenceable(8) ptr @_Z3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  %97 = call noundef i64 @_Z5Case1iiii(i32 noundef %76, i32 noundef %.054, i32 noundef %80, i32 noundef %.052)
  store i64 %97, ptr %9, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  %98 = call noundef i64 @_Z5Case2iiiii(i32 noundef %76, i32 noundef %.054, i32 noundef %80, i32 noundef %.053, i32 noundef %81)
  store i64 %98, ptr %10, align 8, !tbaa !12
  %99 = call noundef nonnull align 8 dereferenceable(8) ptr @_Z3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %100 = call noundef nonnull align 8 dereferenceable(8) ptr @_Z3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %96, ptr noundef nonnull align 8 dereferenceable(8) %99)
  %101 = load i64, ptr %100, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  %102 = icmp eq i64 %101, 4557430888798830399
  br i1 %102, label %103, label %105

103:                                              ; preds = %.thread
  %104 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %107

105:                                              ; preds = %.thread
  %106 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %101)
  br label %107

107:                                              ; preds = %103, %105, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %108 = load i32, ptr @q, align 4, !tbaa !5
  %109 = add nsw i32 %108, -1
  store i32 %109, ptr @q, align 4, !tbaa !5
  %.not = icmp eq i32 %108, 0
  br i1 %.not, label %._crit_edge74, label %.lr.ph73

._crit_edge74:                                    ; preds = %107, %._crit_edge
  ret i32 0
}

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

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

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

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

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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { 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 #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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, !13, i64 0}
!13 = !{!"long long", !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass