; LLVM IR from tangjz/acm-icpc :: lydsy (2127)

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

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@S = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@lnk = external dso_local global [50003 x i32], align 16
@cur = external dso_local global [50003 x i32], align 16
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7addEdgeiii(i32 noundef, i32 noundef, 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; 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 zeroext i1 @_Z3bfsv() #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsii(i32 noundef, i32 noundef) #4

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #5 {
  %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 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 i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = mul nsw i32 %26, %27
  %29 = add nsw i32 %28, 2
  store i32 %29, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  %30 = load i32, ptr @N, align 4, !tbaa !5
  %31 = sub nsw i32 %30, 2
  store i32 %31, ptr @S, align 4, !tbaa !5
  %32 = load i32, ptr @N, align 4, !tbaa !5
  %33 = sub nsw i32 %32, 1
  store i32 %33, ptr @T, align 4, !tbaa !5
  %34 = load i32, ptr @N, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = mul i64 %35, 4
  call void @llvm.memset.p0.i64(ptr align 16 @lnk, i8 -1, i64 %36, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %62, %0
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %65

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %56, %42
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %61

48:                                               ; preds = %43
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = load i32, ptr @ans, align 4, !tbaa !5
  %52 = add nsw i32 %51, %50
  store i32 %52, ptr @ans, align 4, !tbaa !5
  %53 = load i32, ptr @S, align 4, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %53, i32 noundef %54, i32 noundef %55)
  br label %56

56:                                               ; preds = %48
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %8, align 4, !tbaa !5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %6, align 4, !tbaa !5
  br label %43, !llvm.loop !9

61:                                               ; preds = %47
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %5, align 4, !tbaa !5
  br label %37, !llvm.loop !11

65:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, 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 %66

66:                                               ; preds = %91, %65
  %67 = load i32, ptr %9, align 4, !tbaa !5
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %94

71:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %85, %71
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = load i32, ptr %3, align 4, !tbaa !5
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %90

77:                                               ; preds = %72
  %78 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = load i32, ptr @ans, align 4, !tbaa !5
  %81 = add nsw i32 %80, %79
  store i32 %81, ptr @ans, align 4, !tbaa !5
  %82 = load i32, ptr %10, align 4, !tbaa !5
  %83 = load i32, ptr @T, align 4, !tbaa !5
  %84 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %82, i32 noundef %83, i32 noundef %84)
  br label %85

85:                                               ; preds = %77
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %11, align 4, !tbaa !5
  %88 = load i32, ptr %10, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %10, align 4, !tbaa !5
  br label %72, !llvm.loop !12

90:                                               ; preds = %76
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %9, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %9, align 4, !tbaa !5
  br label %66, !llvm.loop !13

94:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %132, %94
  %96 = load i32, ptr %12, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  %98 = load i32, ptr %2, align 4, !tbaa !5
  %99 = icmp slt i32 %97, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %95
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %135

101:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %124, %101
  %103 = load i32, ptr %14, align 4, !tbaa !5
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = icmp slt i32 %103, %104
  br i1 %105, label %107, label %106

106:                                              ; preds = %102
  store i32 17, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %131

107:                                              ; preds = %102
  %108 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %109 = load i32, ptr %4, align 4, !tbaa !5
  %110 = load i32, ptr @ans, align 4, !tbaa !5
  %111 = add nsw i32 %110, %109
  store i32 %111, ptr @ans, align 4, !tbaa !5
  %112 = load i32, ptr @N, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %113
  store i32 -1, ptr %114, align 4, !tbaa !5
  %115 = load i32, ptr @S, align 4, !tbaa !5
  %116 = load i32, ptr @N, align 4, !tbaa !5
  %117 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %115, i32 noundef %116, i32 noundef %117)
  %118 = load i32, ptr @N, align 4, !tbaa !5
  %119 = load i32, ptr %13, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %118, i32 noundef %119, i32 noundef 1061109567)
  %120 = load i32, ptr @N, align 4, !tbaa !5
  %121 = load i32, ptr %13, align 4, !tbaa !5
  %122 = load i32, ptr %3, align 4, !tbaa !5
  %123 = add nsw i32 %121, %122
  call void @_Z7addEdgeiii(i32 noundef %120, i32 noundef %123, i32 noundef 1061109567)
  br label %124

124:                                              ; preds = %107
  %125 = load i32, ptr %14, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %14, align 4, !tbaa !5
  %127 = load i32, ptr %13, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %13, align 4, !tbaa !5
  %129 = load i32, ptr @N, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr @N, align 4, !tbaa !5
  br label %102, !llvm.loop !14

131:                                              ; preds = %106
  br label %132

132:                                              ; preds = %131
  %133 = load i32, ptr %12, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %12, align 4, !tbaa !5
  br label %95, !llvm.loop !15

135:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %136

136:                                              ; preds = %173, %135
  %137 = load i32, ptr %15, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  %139 = load i32, ptr %2, align 4, !tbaa !5
  %140 = icmp slt i32 %138, %139
  br i1 %140, label %142, label %141

141:                                              ; preds = %136
  store i32 20, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %176

142:                                              ; preds = %136
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %165, %142
  %144 = load i32, ptr %17, align 4, !tbaa !5
  %145 = load i32, ptr %3, align 4, !tbaa !5
  %146 = icmp slt i32 %144, %145
  br i1 %146, label %148, label %147

147:                                              ; preds = %143
  store i32 23, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %172

148:                                              ; preds = %143
  %149 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %150 = load i32, ptr %4, align 4, !tbaa !5
  %151 = load i32, ptr @ans, align 4, !tbaa !5
  %152 = add nsw i32 %151, %150
  store i32 %152, ptr @ans, align 4, !tbaa !5
  %153 = load i32, ptr @N, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %154
  store i32 -1, ptr %155, align 4, !tbaa !5
  %156 = load i32, ptr @N, align 4, !tbaa !5
  %157 = load i32, ptr @T, align 4, !tbaa !5
  %158 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %156, i32 noundef %157, i32 noundef %158)
  %159 = load i32, ptr %16, align 4, !tbaa !5
  %160 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %159, i32 noundef %160, i32 noundef 1061109567)
  %161 = load i32, ptr %16, align 4, !tbaa !5
  %162 = load i32, ptr %3, align 4, !tbaa !5
  %163 = add nsw i32 %161, %162
  %164 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %163, i32 noundef %164, i32 noundef 1061109567)
  br label %165

165:                                              ; preds = %148
  %166 = load i32, ptr %17, align 4, !tbaa !5
  %167 = add nsw i32 %166, 1
  store i32 %167, ptr %17, align 4, !tbaa !5
  %168 = load i32, ptr %16, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %16, align 4, !tbaa !5
  %170 = load i32, ptr @N, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr @N, align 4, !tbaa !5
  br label %143, !llvm.loop !16

172:                                              ; preds = %147
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %15, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %15, align 4, !tbaa !5
  br label %136, !llvm.loop !17

176:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store i32 0, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %177

177:                                              ; preds = %213, %176
  %178 = load i32, ptr %18, align 4, !tbaa !5
  %179 = load i32, ptr %2, align 4, !tbaa !5
  %180 = icmp slt i32 %178, %179
  br i1 %180, label %182, label %181

181:                                              ; preds = %177
  store i32 26, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %218

182:                                              ; preds = %177
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  store i32 0, ptr %20, align 4, !tbaa !5
  br label %183

183:                                              ; preds = %205, %182
  %184 = load i32, ptr %20, align 4, !tbaa !5
  %185 = add nsw i32 %184, 1
  %186 = load i32, ptr %3, align 4, !tbaa !5
  %187 = icmp slt i32 %185, %186
  br i1 %187, label %189, label %188

188:                                              ; preds = %183
  store i32 29, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  br label %212

189:                                              ; preds = %183
  %190 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %191 = load i32, ptr %4, align 4, !tbaa !5
  %192 = load i32, ptr @ans, align 4, !tbaa !5
  %193 = add nsw i32 %192, %191
  store i32 %193, ptr @ans, align 4, !tbaa !5
  %194 = load i32, ptr @N, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %195
  store i32 -1, ptr %196, align 4, !tbaa !5
  %197 = load i32, ptr @S, align 4, !tbaa !5
  %198 = load i32, ptr @N, align 4, !tbaa !5
  %199 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %197, i32 noundef %198, i32 noundef %199)
  %200 = load i32, ptr @N, align 4, !tbaa !5
  %201 = load i32, ptr %19, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %200, i32 noundef %201, i32 noundef 1061109567)
  %202 = load i32, ptr @N, align 4, !tbaa !5
  %203 = load i32, ptr %19, align 4, !tbaa !5
  %204 = add nsw i32 %203, 1
  call void @_Z7addEdgeiii(i32 noundef %202, i32 noundef %204, i32 noundef 1061109567)
  br label %205

205:                                              ; preds = %189
  %206 = load i32, ptr %20, align 4, !tbaa !5
  %207 = add nsw i32 %206, 1
  store i32 %207, ptr %20, align 4, !tbaa !5
  %208 = load i32, ptr %19, align 4, !tbaa !5
  %209 = add nsw i32 %208, 1
  store i32 %209, ptr %19, align 4, !tbaa !5
  %210 = load i32, ptr @N, align 4, !tbaa !5
  %211 = add nsw i32 %210, 1
  store i32 %211, ptr @N, align 4, !tbaa !5
  br label %183, !llvm.loop !18

212:                                              ; preds = %188
  br label %213

213:                                              ; preds = %212
  %214 = load i32, ptr %18, align 4, !tbaa !5
  %215 = add nsw i32 %214, 1
  store i32 %215, ptr %18, align 4, !tbaa !5
  %216 = load i32, ptr %19, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %19, align 4, !tbaa !5
  br label %177, !llvm.loop !19

218:                                              ; preds = %181
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store i32 0, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 0, ptr %22, align 4, !tbaa !5
  br label %219

219:                                              ; preds = %255, %218
  %220 = load i32, ptr %21, align 4, !tbaa !5
  %221 = load i32, ptr %2, align 4, !tbaa !5
  %222 = icmp slt i32 %220, %221
  br i1 %222, label %224, label %223

223:                                              ; preds = %219
  store i32 32, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %260

224:                                              ; preds = %219
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 0, ptr %23, align 4, !tbaa !5
  br label %225

225:                                              ; preds = %247, %224
  %226 = load i32, ptr %23, align 4, !tbaa !5
  %227 = add nsw i32 %226, 1
  %228 = load i32, ptr %3, align 4, !tbaa !5
  %229 = icmp slt i32 %227, %228
  br i1 %229, label %231, label %230

230:                                              ; preds = %225
  store i32 35, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  br label %254

231:                                              ; preds = %225
  %232 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %233 = load i32, ptr %4, align 4, !tbaa !5
  %234 = load i32, ptr @ans, align 4, !tbaa !5
  %235 = add nsw i32 %234, %233
  store i32 %235, ptr @ans, align 4, !tbaa !5
  %236 = load i32, ptr @N, align 4, !tbaa !5
  %237 = sext i32 %236 to i64
  %238 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %237
  store i32 -1, ptr %238, align 4, !tbaa !5
  %239 = load i32, ptr @N, align 4, !tbaa !5
  %240 = load i32, ptr @T, align 4, !tbaa !5
  %241 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %239, i32 noundef %240, i32 noundef %241)
  %242 = load i32, ptr %22, align 4, !tbaa !5
  %243 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %242, i32 noundef %243, i32 noundef 1061109567)
  %244 = load i32, ptr %22, align 4, !tbaa !5
  %245 = add nsw i32 %244, 1
  %246 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %245, i32 noundef %246, i32 noundef 1061109567)
  br label %247

247:                                              ; preds = %231
  %248 = load i32, ptr %23, align 4, !tbaa !5
  %249 = add nsw i32 %248, 1
  store i32 %249, ptr %23, align 4, !tbaa !5
  %250 = load i32, ptr %22, align 4, !tbaa !5
  %251 = add nsw i32 %250, 1
  store i32 %251, ptr %22, align 4, !tbaa !5
  %252 = load i32, ptr @N, align 4, !tbaa !5
  %253 = add nsw i32 %252, 1
  store i32 %253, ptr @N, align 4, !tbaa !5
  br label %225, !llvm.loop !20

254:                                              ; preds = %230
  br label %255

255:                                              ; preds = %254
  %256 = load i32, ptr %21, align 4, !tbaa !5
  %257 = add nsw i32 %256, 1
  store i32 %257, ptr %21, align 4, !tbaa !5
  %258 = load i32, ptr %22, align 4, !tbaa !5
  %259 = add nsw i32 %258, 1
  store i32 %259, ptr %22, align 4, !tbaa !5
  br label %219, !llvm.loop !21

260:                                              ; preds = %223
  br label %261

261:                                              ; preds = %277, %260
  %262 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %262, label %263, label %278

263:                                              ; preds = %261
  %264 = load i32, ptr @N, align 4, !tbaa !5
  %265 = sext i32 %264 to i64
  %266 = mul i64 %265, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @cur, ptr align 16 @lnk, i64 %266, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  br label %267

267:                                              ; preds = %273, %263
  %268 = load i32, ptr @S, align 4, !tbaa !5
  %269 = call noundef i32 @_Z3dfsii(i32 noundef %268, i32 noundef 1061109567)
  store i32 %269, ptr %24, align 4, !tbaa !5
  %270 = icmp sgt i32 %269, 0
  br i1 %270, label %272, label %271

271:                                              ; preds = %267
  store i32 40, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  br label %277

272:                                              ; preds = %267
  br label %273

273:                                              ; preds = %272
  %274 = load i32, ptr %24, align 4, !tbaa !5
  %275 = load i32, ptr @ans, align 4, !tbaa !5
  %276 = sub nsw i32 %275, %274
  store i32 %276, ptr @ans, align 4, !tbaa !5
  br label %267, !llvm.loop !22

277:                                              ; preds = %271
  br label %261, !llvm.loop !23

278:                                              ; preds = %261
  %279 = load i32, ptr @ans, align 4, !tbaa !5
  %280 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %279)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %281 = load i32, ptr %1, align 4
  ret i32 %281
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #6 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}


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

@N = external dso_local local_unnamed_addr global i32, align 4
@M = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local local_unnamed_addr global i32, align 4
@T = external dso_local local_unnamed_addr global i32, align 4
@lnk = external dso_local local_unnamed_addr global [50003 x i32], align 16
@cur = external dso_local local_unnamed_addr global [50003 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7addEdgeiii(i32 noundef, i32 noundef, 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; 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 zeroext i1 @_Z3bfsv() local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  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
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = mul nsw i32 %6, %5
  %8 = add nsw i32 %7, 2
  store i32 %8, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  store i32 %7, ptr @S, align 4, !tbaa !5
  %9 = add nsw i32 %7, 1
  store i32 %9, ptr @T, align 4, !tbaa !5
  %10 = sext i32 %8 to i64
  %11 = shl nsw i64 %10, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @lnk, i8 -1, i64 %11, i1 false)
  %12 = icmp sgt i32 %5, 0
  br i1 %12, label %.preheader83.lr.ph, label %.preheader

.preheader83.lr.ph:                               ; preds = %0
  %13 = icmp sgt i32 %6, 0
  br i1 %13, label %.preheader83, label %.preheader80

.preheader83:                                     ; preds = %.preheader83.lr.ph, %._crit_edge
  %14 = phi i32 [ %19, %._crit_edge ], [ %5, %.preheader83.lr.ph ]
  %15 = phi i32 [ %20, %._crit_edge ], [ %6, %.preheader83.lr.ph ]
  %.06387 = phi i32 [ %.164.lcssa, %._crit_edge ], [ 0, %.preheader83.lr.ph ]
  %.06586 = phi i32 [ %21, %._crit_edge ], [ 0, %.preheader83.lr.ph ]
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

.preheader82:                                     ; preds = %._crit_edge
  %17 = icmp sgt i32 %19, 0
  br i1 %17, label %.preheader81.lr.ph, label %.preheader

.preheader81.lr.ph:                               ; preds = %.preheader82
  %18 = icmp sgt i32 %20, 0
  br i1 %18, label %.preheader81, label %.preheader80

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader83
  %19 = phi i32 [ %14, %.preheader83 ], [ %.pre, %._crit_edge.loopexit ]
  %20 = phi i32 [ %15, %.preheader83 ], [ %30, %._crit_edge.loopexit ]
  %.164.lcssa = phi i32 [ %.06387, %.preheader83 ], [ %29, %._crit_edge.loopexit ]
  %21 = add nuw nsw i32 %.06586, 1
  %22 = icmp slt i32 %21, %19
  br i1 %22, label %.preheader83, label %.preheader82, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader83, %.lr.ph
  %.06285 = phi i32 [ %28, %.lr.ph ], [ 0, %.preheader83 ]
  %.16484 = phi i32 [ %29, %.lr.ph ], [ %.06387, %.preheader83 ]
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr @ans, align 4, !tbaa !5
  %26 = add nsw i32 %25, %24
  store i32 %26, ptr @ans, align 4, !tbaa !5
  %27 = load i32, ptr @S, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %27, i32 noundef %.16484, i32 noundef %24)
  %28 = add nuw nsw i32 %.06285, 1
  %29 = add nsw i32 %.16484, 1
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !12

.preheader81:                                     ; preds = %.preheader81.lr.ph, %._crit_edge91
  %32 = phi i32 [ %39, %._crit_edge91 ], [ %19, %.preheader81.lr.ph ]
  %33 = phi i32 [ %40, %._crit_edge91 ], [ %20, %.preheader81.lr.ph ]
  %.05994 = phi i32 [ %.160.lcssa, %._crit_edge91 ], [ 0, %.preheader81.lr.ph ]
  %.06193 = phi i32 [ %41, %._crit_edge91 ], [ 0, %.preheader81.lr.ph ]
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %.lr.ph90, label %._crit_edge91

.preheader80:                                     ; preds = %._crit_edge91, %.preheader83.lr.ph, %.preheader81.lr.ph
  %35 = phi i32 [ %20, %.preheader81.lr.ph ], [ %6, %.preheader83.lr.ph ], [ %40, %._crit_edge91 ]
  %36 = phi i32 [ %19, %.preheader81.lr.ph ], [ %5, %.preheader83.lr.ph ], [ %39, %._crit_edge91 ]
  %37 = icmp sgt i32 %36, 1
  br i1 %37, label %.preheader78.lr.ph, label %.preheader74

.preheader78.lr.ph:                               ; preds = %.preheader80
  %38 = icmp sgt i32 %35, 0
  br i1 %38, label %.preheader78, label %.preheader

._crit_edge91.loopexit:                           ; preds = %.lr.ph90
  %.pre132 = load i32, ptr %1, align 4, !tbaa !5
  br label %._crit_edge91

._crit_edge91:                                    ; preds = %._crit_edge91.loopexit, %.preheader81
  %39 = phi i32 [ %32, %.preheader81 ], [ %.pre132, %._crit_edge91.loopexit ]
  %40 = phi i32 [ %33, %.preheader81 ], [ %50, %._crit_edge91.loopexit ]
  %.160.lcssa = phi i32 [ %.05994, %.preheader81 ], [ %49, %._crit_edge91.loopexit ]
  %41 = add nuw nsw i32 %.06193, 1
  %42 = icmp slt i32 %41, %39
  br i1 %42, label %.preheader81, label %.preheader80, !llvm.loop !13

.lr.ph90:                                         ; preds = %.preheader81, %.lr.ph90
  %.05889 = phi i32 [ %48, %.lr.ph90 ], [ 0, %.preheader81 ]
  %.16088 = phi i32 [ %49, %.lr.ph90 ], [ %.05994, %.preheader81 ]
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = load i32, ptr @ans, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr @ans, align 4, !tbaa !5
  %47 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %.16088, i32 noundef %47, i32 noundef %44)
  %48 = add nuw nsw i32 %.05889, 1
  %49 = add nsw i32 %.16088, 1
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = icmp slt i32 %48, %50
  br i1 %51, label %.lr.ph90, label %._crit_edge91.loopexit, !llvm.loop !14

.loopexit79.loopexit:                             ; preds = %.lr.ph97
  %.pre133 = load i32, ptr %1, align 4, !tbaa !5
  br label %.loopexit79

.loopexit79:                                      ; preds = %.loopexit79.loopexit, %.preheader78
  %52 = phi i32 [ %56, %.preheader78 ], [ %.pre133, %.loopexit79.loopexit ]
  %53 = phi i32 [ %57, %.preheader78 ], [ %78, %.loopexit79.loopexit ]
  %.156.lcssa = phi i32 [ %.05599, %.preheader78 ], [ %75, %.loopexit79.loopexit ]
  %54 = add nuw nsw i32 %58, 1
  %55 = icmp slt i32 %54, %52
  br i1 %55, label %.preheader78, label %.preheader77, !llvm.loop !15

.preheader78:                                     ; preds = %.preheader78.lr.ph, %.loopexit79
  %56 = phi i32 [ %52, %.loopexit79 ], [ %36, %.preheader78.lr.ph ]
  %57 = phi i32 [ %53, %.loopexit79 ], [ %35, %.preheader78.lr.ph ]
  %58 = phi i32 [ %54, %.loopexit79 ], [ 1, %.preheader78.lr.ph ]
  %.05599 = phi i32 [ %.156.lcssa, %.loopexit79 ], [ 0, %.preheader78.lr.ph ]
  %59 = icmp sgt i32 %57, 0
  br i1 %59, label %.lr.ph97, label %.loopexit79

.preheader77:                                     ; preds = %.loopexit79
  %60 = icmp sgt i32 %52, 1
  br i1 %60, label %.preheader75.lr.ph, label %.preheader74

.preheader75.lr.ph:                               ; preds = %.preheader77
  %61 = icmp sgt i32 %53, 0
  br i1 %61, label %.preheader75, label %.preheader

.lr.ph97:                                         ; preds = %.preheader78, %.lr.ph97
  %.05496 = phi i32 [ %74, %.lr.ph97 ], [ 0, %.preheader78 ]
  %.15695 = phi i32 [ %75, %.lr.ph97 ], [ %.05599, %.preheader78 ]
  %62 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = load i32, ptr @ans, align 4, !tbaa !5
  %65 = add nsw i32 %64, %63
  store i32 %65, ptr @ans, align 4, !tbaa !5
  %66 = load i32, ptr @N, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %67
  store i32 -1, ptr %68, align 4, !tbaa !5
  %69 = load i32, ptr @S, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %69, i32 noundef %66, i32 noundef %63)
  %70 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %70, i32 noundef %.15695, i32 noundef 1061109567)
  %71 = load i32, ptr @N, align 4, !tbaa !5
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = add nsw i32 %72, %.15695
  call void @_Z7addEdgeiii(i32 noundef %71, i32 noundef %73, i32 noundef 1061109567)
  %74 = add nuw nsw i32 %.05496, 1
  %75 = add nsw i32 %.15695, 1
  %76 = load i32, ptr @N, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr @N, align 4, !tbaa !5
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = icmp slt i32 %74, %78
  br i1 %79, label %.lr.ph97, label %.loopexit79.loopexit, !llvm.loop !16

.loopexit76.loopexit:                             ; preds = %.lr.ph102
  %.pre134 = load i32, ptr %1, align 4, !tbaa !5
  br label %.loopexit76

.loopexit76:                                      ; preds = %.loopexit76.loopexit, %.preheader75
  %80 = phi i32 [ %84, %.preheader75 ], [ %.pre134, %.loopexit76.loopexit ]
  %81 = phi i32 [ %85, %.preheader75 ], [ %108, %.loopexit76.loopexit ]
  %.152.lcssa = phi i32 [ %.051104, %.preheader75 ], [ %105, %.loopexit76.loopexit ]
  %82 = add nuw nsw i32 %86, 1
  %83 = icmp slt i32 %82, %80
  br i1 %83, label %.preheader75, label %.preheader74, !llvm.loop !17

.preheader75:                                     ; preds = %.preheader75.lr.ph, %.loopexit76
  %84 = phi i32 [ %80, %.loopexit76 ], [ %52, %.preheader75.lr.ph ]
  %85 = phi i32 [ %81, %.loopexit76 ], [ %53, %.preheader75.lr.ph ]
  %86 = phi i32 [ %82, %.loopexit76 ], [ 1, %.preheader75.lr.ph ]
  %.051104 = phi i32 [ %.152.lcssa, %.loopexit76 ], [ 0, %.preheader75.lr.ph ]
  %87 = icmp sgt i32 %85, 0
  br i1 %87, label %.lr.ph102, label %.loopexit76

.preheader74:                                     ; preds = %.loopexit76, %.preheader80, %.preheader77
  %88 = phi i32 [ %53, %.preheader77 ], [ %35, %.preheader80 ], [ %81, %.loopexit76 ]
  %89 = phi i32 [ %52, %.preheader77 ], [ %36, %.preheader80 ], [ %80, %.loopexit76 ]
  %90 = icmp sgt i32 %89, 0
  %91 = icmp sgt i32 %88, 1
  %or.cond = select i1 %90, i1 %91, i1 false
  br i1 %or.cond, label %.preheader73, label %.preheader

.lr.ph102:                                        ; preds = %.preheader75, %.lr.ph102
  %.050101 = phi i32 [ %104, %.lr.ph102 ], [ 0, %.preheader75 ]
  %.152100 = phi i32 [ %105, %.lr.ph102 ], [ %.051104, %.preheader75 ]
  %92 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %93 = load i32, ptr %3, align 4, !tbaa !5
  %94 = load i32, ptr @ans, align 4, !tbaa !5
  %95 = add nsw i32 %94, %93
  store i32 %95, ptr @ans, align 4, !tbaa !5
  %96 = load i32, ptr @N, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %97
  store i32 -1, ptr %98, align 4, !tbaa !5
  %99 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %96, i32 noundef %99, i32 noundef %93)
  %100 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %.152100, i32 noundef %100, i32 noundef 1061109567)
  %101 = load i32, ptr %2, align 4, !tbaa !5
  %102 = add nsw i32 %101, %.152100
  %103 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %102, i32 noundef %103, i32 noundef 1061109567)
  %104 = add nuw nsw i32 %.050101, 1
  %105 = add nsw i32 %.152100, 1
  %106 = load i32, ptr @N, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr @N, align 4, !tbaa !5
  %108 = load i32, ptr %2, align 4, !tbaa !5
  %109 = icmp slt i32 %104, %108
  br i1 %109, label %.lr.ph102, label %.loopexit76.loopexit, !llvm.loop !18

.preheader73:                                     ; preds = %.preheader74, %._crit_edge107
  %110 = phi i32 [ %115, %._crit_edge107 ], [ %89, %.preheader74 ]
  %111 = phi i32 [ %116, %._crit_edge107 ], [ %88, %.preheader74 ]
  %.047110 = phi i32 [ %118, %._crit_edge107 ], [ 0, %.preheader74 ]
  %.049109 = phi i32 [ %117, %._crit_edge107 ], [ 0, %.preheader74 ]
  %112 = icmp sgt i32 %111, 1
  br i1 %112, label %.lr.ph106, label %._crit_edge107

.preheader72:                                     ; preds = %._crit_edge107
  %113 = icmp sgt i32 %115, 0
  %114 = icmp sgt i32 %116, 1
  %or.cond171 = and i1 %113, %114
  br i1 %or.cond171, label %.preheader71, label %.preheader

._crit_edge107.loopexit:                          ; preds = %.lr.ph106
  %.pre135 = load i32, ptr %1, align 4, !tbaa !5
  br label %._crit_edge107

._crit_edge107:                                   ; preds = %._crit_edge107.loopexit, %.preheader73
  %115 = phi i32 [ %110, %.preheader73 ], [ %.pre135, %._crit_edge107.loopexit ]
  %116 = phi i32 [ %111, %.preheader73 ], [ %135, %._crit_edge107.loopexit ]
  %.148.lcssa = phi i32 [ %.047110, %.preheader73 ], [ %131, %._crit_edge107.loopexit ]
  %117 = add nuw nsw i32 %.049109, 1
  %118 = add nsw i32 %.148.lcssa, 1
  %119 = icmp slt i32 %117, %115
  br i1 %119, label %.preheader73, label %.preheader72, !llvm.loop !19

.lr.ph106:                                        ; preds = %.preheader73, %.lr.ph106
  %120 = phi i32 [ %134, %.lr.ph106 ], [ 1, %.preheader73 ]
  %.148105 = phi i32 [ %131, %.lr.ph106 ], [ %.047110, %.preheader73 ]
  %121 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %122 = load i32, ptr %3, align 4, !tbaa !5
  %123 = load i32, ptr @ans, align 4, !tbaa !5
  %124 = add nsw i32 %123, %122
  store i32 %124, ptr @ans, align 4, !tbaa !5
  %125 = load i32, ptr @N, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %126
  store i32 -1, ptr %127, align 4, !tbaa !5
  %128 = load i32, ptr @S, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %128, i32 noundef %125, i32 noundef %122)
  %129 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %129, i32 noundef %.148105, i32 noundef 1061109567)
  %130 = load i32, ptr @N, align 4, !tbaa !5
  %131 = add nsw i32 %.148105, 1
  call void @_Z7addEdgeiii(i32 noundef %130, i32 noundef %131, i32 noundef 1061109567)
  %132 = load i32, ptr @N, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr @N, align 4, !tbaa !5
  %134 = add nuw nsw i32 %120, 1
  %135 = load i32, ptr %2, align 4, !tbaa !5
  %136 = icmp slt i32 %134, %135
  br i1 %136, label %.lr.ph106, label %._crit_edge107.loopexit, !llvm.loop !20

.preheader71:                                     ; preds = %.preheader72, %._crit_edge113
  %137 = phi i32 [ %141, %._crit_edge113 ], [ %115, %.preheader72 ]
  %138 = phi i32 [ %142, %._crit_edge113 ], [ %116, %.preheader72 ]
  %.044116 = phi i32 [ %144, %._crit_edge113 ], [ 0, %.preheader72 ]
  %.045115 = phi i32 [ %143, %._crit_edge113 ], [ 0, %.preheader72 ]
  %139 = icmp sgt i32 %138, 1
  br i1 %139, label %.lr.ph112, label %._crit_edge113

.preheader:                                       ; preds = %._crit_edge113, %0, %.preheader82, %.preheader78.lr.ph, %.preheader75.lr.ph, %.preheader74, %.preheader72
  %140 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %140, label %.lr.ph119, label %._crit_edge120

._crit_edge113.loopexit:                          ; preds = %.lr.ph112
  %.pre136 = load i32, ptr %1, align 4, !tbaa !5
  br label %._crit_edge113

._crit_edge113:                                   ; preds = %._crit_edge113.loopexit, %.preheader71
  %141 = phi i32 [ %137, %.preheader71 ], [ %.pre136, %._crit_edge113.loopexit ]
  %142 = phi i32 [ %138, %.preheader71 ], [ %161, %._crit_edge113.loopexit ]
  %.1.lcssa = phi i32 [ %.044116, %.preheader71 ], [ %156, %._crit_edge113.loopexit ]
  %143 = add nuw nsw i32 %.045115, 1
  %144 = add nsw i32 %.1.lcssa, 1
  %145 = icmp slt i32 %143, %141
  br i1 %145, label %.preheader71, label %.preheader, !llvm.loop !21

.lr.ph112:                                        ; preds = %.preheader71, %.lr.ph112
  %146 = phi i32 [ %160, %.lr.ph112 ], [ 1, %.preheader71 ]
  %.1111 = phi i32 [ %156, %.lr.ph112 ], [ %.044116, %.preheader71 ]
  %147 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %148 = load i32, ptr %3, align 4, !tbaa !5
  %149 = load i32, ptr @ans, align 4, !tbaa !5
  %150 = add nsw i32 %149, %148
  store i32 %150, ptr @ans, align 4, !tbaa !5
  %151 = load i32, ptr @N, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [50003 x i32], ptr @lnk, i64 0, i64 %152
  store i32 -1, ptr %153, align 4, !tbaa !5
  %154 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %151, i32 noundef %154, i32 noundef %148)
  %155 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %.1111, i32 noundef %155, i32 noundef 1061109567)
  %156 = add nsw i32 %.1111, 1
  %157 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %156, i32 noundef %157, i32 noundef 1061109567)
  %158 = load i32, ptr @N, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr @N, align 4, !tbaa !5
  %160 = add nuw nsw i32 %146, 1
  %161 = load i32, ptr %2, align 4, !tbaa !5
  %162 = icmp slt i32 %160, %161
  br i1 %162, label %.lr.ph112, label %._crit_edge113.loopexit, !llvm.loop !22

.loopexit:                                        ; preds = %.lr.ph118, %.lr.ph119
  %163 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %163, label %.lr.ph119, label %._crit_edge120, !llvm.loop !23

.lr.ph119:                                        ; preds = %.preheader, %.loopexit
  %164 = load i32, ptr @N, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = shl nsw i64 %165, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @cur, ptr nonnull align 16 @lnk, i64 %166, i1 false)
  %167 = load i32, ptr @S, align 4, !tbaa !5
  %168 = call noundef i32 @_Z3dfsii(i32 noundef %167, i32 noundef 1061109567)
  %169 = icmp sgt i32 %168, 0
  br i1 %169, label %.lr.ph118, label %.loopexit

.lr.ph118:                                        ; preds = %.lr.ph119, %.lr.ph118
  %170 = phi i32 [ %174, %.lr.ph118 ], [ %168, %.lr.ph119 ]
  %171 = load i32, ptr @ans, align 4, !tbaa !5
  %172 = sub nsw i32 %171, %170
  store i32 %172, ptr @ans, align 4, !tbaa !5
  %173 = load i32, ptr @S, align 4, !tbaa !5
  %174 = call noundef i32 @_Z3dfsii(i32 noundef %173, i32 noundef 1061109567)
  %175 = icmp sgt i32 %174, 0
  br i1 %175, label %.lr.ph118, label %.loopexit, !llvm.loop !24

._crit_edge120:                                   ; preds = %.loopexit, %.preheader
  %176 = load i32, ptr @ans, align 4, !tbaa !5
  %177 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %176)
  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
  ret i32 0
}

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #6 = { 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 #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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unswitch.partial.disable"}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !11}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !11}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10, !11}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}


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