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

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

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@pre = external dso_local global [1000001 x i32], align 16
@suf = external dso_local global [1000001 x i32], align 16
@que = external dso_local global [1000001 x i32], align 16
@scc = external dso_local global [1000001 x i32], align 16
@f = external dso_local global [1000001 x i32], align 16
@e = external dso_local global [3000003 x %struct.Edge], align 16
@vis = external dso_local global [1000001 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs1i(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 uwtable
declare dso_local void @_Z4dfs2i(i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs3i(i32 noundef) #0

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

; 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 %struct.Edge, 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 @n, ptr noundef @m)
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = mul i64 %18, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @pre, i64 1), i8 -1, i64 %19, i1 false)
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = mul i64 %21, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @suf, i64 1), i8 -1, i64 %22, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %64, %0
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = load i32, ptr @m, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %67

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %30 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 0
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  store i32 %34, ptr %30, align 4, !tbaa !9
  %35 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 1
  %36 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %36, ptr %35, align 4, !tbaa !11
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = shl i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %39
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %40, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = shl i32 %41, 1
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %44
  store i32 %42, ptr %45, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %46 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 0
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1000001 x i32], ptr @suf, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  store i32 %50, ptr %46, align 4, !tbaa !9
  %51 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 1
  %52 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %52, ptr %51, align 4, !tbaa !11
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = shl i32 %53, 1
  %55 = or i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %56
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %57, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = shl i32 %58, 1
  %60 = or i32 %59, 1
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1000001 x i32], ptr @suf, i64 0, i64 %62
  store i32 %60, ptr %63, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %64

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

67:                                               ; preds = %27
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = mul i64 %69, 1
  call void @llvm.memset.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %70, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %85, %67
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = load i32, ptr @n, align 4, !tbaa !5
  %74 = icmp sle i32 %72, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %88

76:                                               ; preds = %71
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !15, !range !17, !noundef !18
  %81 = trunc i8 %80 to i1
  br i1 %81, label %84, label %82

82:                                               ; preds = %76
  %83 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z4dfs1i(i32 noundef %83)
  br label %84

84:                                               ; preds = %82, %76
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %7, align 4, !tbaa !5
  br label %71, !llvm.loop !19

88:                                               ; preds = %75
  store i32 0, ptr @tot, align 4, !tbaa !5
  %89 = load i32, ptr @n, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = mul i64 %90, 1
  call void @llvm.memset.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %91, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %92 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %92, ptr %8, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %114, %88
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = icmp sge i32 %94, 1
  br i1 %95, label %97, label %96

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

97:                                               ; preds = %93
  %98 = load i32, ptr %8, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %102
  %104 = load i8, ptr %103, align 1, !tbaa !15, !range !17, !noundef !18
  %105 = trunc i8 %104 to i1
  br i1 %105, label %113, label %106

106:                                              ; preds = %97
  %107 = load i32, ptr @tot, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr @tot, align 4, !tbaa !5
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  call void @_Z4dfs2i(i32 noundef %112)
  br label %113

113:                                              ; preds = %106, %97
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = add nsw i32 %115, -1
  store i32 %116, ptr %8, align 4, !tbaa !5
  br label %93, !llvm.loop !20

117:                                              ; preds = %96
  %118 = load i32, ptr @m, align 4, !tbaa !5
  %119 = shl i32 %118, 1
  store i32 %119, ptr @m, align 4, !tbaa !5
  %120 = load i32, ptr @n, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = mul i64 %121, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @pre, i64 1), i8 -1, i64 %122, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %177, %117
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = load i32, ptr @n, align 4, !tbaa !5
  %126 = icmp sle i32 %124, %125
  br i1 %126, label %128, label %127

127:                                              ; preds = %123
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %180

128:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1000001 x i32], ptr @scc, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  store i32 %132, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1000001 x i32], ptr @suf, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  store i32 %136, ptr %12, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %170, %128
  %138 = load i32, ptr %12, align 4, !tbaa !5
  %139 = icmp ne i32 %138, -1
  br i1 %139, label %141, label %140

140:                                              ; preds = %137
  store i32 14, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %176

141:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %142 = load i32, ptr %12, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %143
  %145 = getelementptr inbounds %struct.Edge, ptr %144, i32 0, i32 1
  %146 = load i32, ptr %145, align 4, !tbaa !11
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1000001 x i32], ptr @scc, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  store i32 %149, ptr %13, align 4, !tbaa !5
  %150 = load i32, ptr %13, align 4, !tbaa !5
  %151 = load i32, ptr %11, align 4, !tbaa !5
  %152 = icmp ne i32 %150, %151
  br i1 %152, label %153, label %169

153:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %154 = getelementptr inbounds %struct.Edge, ptr %14, i32 0, i32 0
  %155 = load i32, ptr %13, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  store i32 %158, ptr %154, align 4, !tbaa !9
  %159 = getelementptr inbounds %struct.Edge, ptr %14, i32 0, i32 1
  %160 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %160, ptr %159, align 4, !tbaa !11
  %161 = load i32, ptr @m, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %162
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %163, ptr align 4 %14, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  %164 = load i32, ptr @m, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr @m, align 4, !tbaa !5
  %166 = load i32, ptr %13, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %167
  store i32 %164, ptr %168, align 4, !tbaa !5
  br label %169

169:                                              ; preds = %153, %141
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %170

170:                                              ; preds = %169
  %171 = load i32, ptr %12, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %172
  %174 = getelementptr inbounds %struct.Edge, ptr %173, i32 0, i32 0
  %175 = load i32, ptr %174, align 8, !tbaa !9
  store i32 %175, ptr %12, align 4, !tbaa !5
  br label %137, !llvm.loop !21

176:                                              ; preds = %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %177

177:                                              ; preds = %176
  %178 = load i32, ptr %9, align 4, !tbaa !5
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %9, align 4, !tbaa !5
  br label %123, !llvm.loop !22

180:                                              ; preds = %127
  store i32 0, ptr @m, align 4, !tbaa !5
  %181 = load i32, ptr @tot, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = mul i64 %182, 1
  call void @llvm.memset.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %183, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %184

184:                                              ; preds = %203, %180
  %185 = load i32, ptr %15, align 4, !tbaa !5
  %186 = load i32, ptr @tot, align 4, !tbaa !5
  %187 = icmp sle i32 %185, %186
  br i1 %187, label %189, label %188

188:                                              ; preds = %184
  store i32 17, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %206

189:                                              ; preds = %184
  %190 = load i32, ptr %15, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %191
  %193 = load i8, ptr %192, align 1, !tbaa !15, !range !17, !noundef !18
  %194 = trunc i8 %193 to i1
  br i1 %194, label %197, label %195

195:                                              ; preds = %189
  %196 = load i32, ptr %15, align 4, !tbaa !5
  call void @_Z4dfs3i(i32 noundef %196)
  br label %197

197:                                              ; preds = %195, %189
  %198 = load i32, ptr %15, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %199
  %201 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @m, ptr noundef nonnull align 4 dereferenceable(4) %200)
  %202 = load i32, ptr %201, align 4, !tbaa !5
  store i32 %202, ptr @m, align 4, !tbaa !5
  br label %203

203:                                              ; preds = %197
  %204 = load i32, ptr %15, align 4, !tbaa !5
  %205 = add nsw i32 %204, 1
  store i32 %205, ptr %15, align 4, !tbaa !5
  br label %184, !llvm.loop !23

206:                                              ; preds = %188
  %207 = load i32, ptr @m, align 4, !tbaa !5
  %208 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %207)
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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

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 = { inlinehint 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: write) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }

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

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


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

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@suf = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@que = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@scc = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@f = external dso_local global [1000001 x i32], align 16
@e = external dso_local local_unnamed_addr global [3000003 x %struct.Edge], align 16
@vis = external dso_local local_unnamed_addr global [1000001 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs1i(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 uwtable
declare dso_local void @_Z4dfs2i(i32 noundef) local_unnamed_addr #0

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

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

; 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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = shl nsw i64 %5, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @pre, i64 4), i8 -1, i64 %6, i1 false)
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @suf, i64 4), i8 -1, i64 %6, i1 false)
  %7 = load i32, ptr @m, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  %.pre94 = sext i32 %.pre to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.pre-phi = phi i64 [ %.pre94, %._crit_edge.loopexit ], [ %5, %0 ]
  %9 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %4, %0 ]
  call void @llvm.memset.p0.i64(ptr nonnull align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %.pre-phi, i1 false)
  %.not47 = icmp slt i32 %9, 1
  br i1 %.not47, label %._crit_edge51.thread, label %.lr.ph50

._crit_edge51.thread:                             ; preds = %._crit_edge
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr nonnull align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %.pre-phi, i1 false)
  br label %._crit_edge55

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = shl nuw i64 %indvars.iv, 1
  %17 = trunc nuw i64 %16 to i32
  %sext = shl i64 %indvars.iv, 33
  %18 = ashr exact i64 %sext, 32
  %19 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %18
  store i32 %14, ptr %19, align 16, !tbaa !5
  %.sroa.428.0..sroa_idx = getelementptr inbounds i8, ptr %19, i64 4
  store i32 %15, ptr %.sroa.428.0..sroa_idx, align 4, !tbaa !5
  store i32 %17, ptr %13, align 4, !tbaa !5
  %20 = sext i32 %15 to i64
  %21 = getelementptr inbounds [1000001 x i32], ptr @suf, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = trunc i64 %16 to i32
  %24 = or disjoint i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %25
  store i32 %22, ptr %26, align 8, !tbaa !5
  %.sroa.426.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 4
  store i32 %11, ptr %.sroa.426.0..sroa_idx, align 4, !tbaa !5
  store i32 %24, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next, %28
  br i1 %29, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !9

._crit_edge51:                                    ; preds = %38
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr nonnull align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %40, i1 false)
  %30 = icmp sgt i32 %39, 0
  br i1 %30, label %.lr.ph54.preheader, label %._crit_edge55

.lr.ph54.preheader:                               ; preds = %._crit_edge51
  %31 = zext nneg i32 %39 to i64
  br label %.lr.ph54

.lr.ph50:                                         ; preds = %._crit_edge, %38
  %32 = phi i32 [ %39, %38 ], [ %9, %._crit_edge ]
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %38 ], [ 1, %._crit_edge ]
  %33 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %indvars.iv80
  %34 = load i8, ptr %33, align 1, !tbaa !11, !range !13, !noundef !14
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %38, label %36

36:                                               ; preds = %.lr.ph50
  %37 = trunc nuw nsw i64 %indvars.iv80 to i32
  call void @_Z4dfs1i(i32 noundef %37)
  %.pre92 = load i32, ptr @n, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %.lr.ph50, %36
  %39 = phi i32 [ %32, %.lr.ph50 ], [ %.pre92, %36 ]
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %40 = sext i32 %39 to i64
  %.not.not = icmp slt i64 %indvars.iv80, %40
  br i1 %.not.not, label %.lr.ph50, label %._crit_edge51, !llvm.loop !15

._crit_edge55.loopexit:                           ; preds = %55
  %.pre93 = load i32, ptr @n, align 4, !tbaa !5
  %.pre96 = sext i32 %.pre93 to i64
  br label %._crit_edge55

._crit_edge55:                                    ; preds = %._crit_edge51.thread, %._crit_edge55.loopexit, %._crit_edge51
  %.pre-phi97 = phi i64 [ %.pre96, %._crit_edge55.loopexit ], [ %40, %._crit_edge51 ], [ %.pre-phi, %._crit_edge51.thread ]
  %41 = phi i32 [ %.pre93, %._crit_edge55.loopexit ], [ %39, %._crit_edge51 ], [ %9, %._crit_edge51.thread ]
  %42 = load i32, ptr @m, align 4, !tbaa !5
  %43 = shl nsw i64 %.pre-phi97, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @pre, i64 4), i8 -1, i64 %43, i1 false)
  %.not4267 = icmp slt i32 %41, 1
  br i1 %.not4267, label %._crit_edge72, label %.lr.ph71.preheader

.lr.ph71.preheader:                               ; preds = %._crit_edge55
  %44 = shl i32 %42, 1
  %45 = add nuw i32 %41, 1
  %wide.trip.count = zext i32 %45 to i64
  br label %.lr.ph71

.lr.ph54:                                         ; preds = %.lr.ph54.preheader, %55
  %indvars.iv83 = phi i64 [ %31, %.lr.ph54.preheader ], [ %indvars.iv.next84, %55 ]
  %46 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %indvars.iv83
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11, !range !13, !noundef !14
  %51 = trunc nuw i8 %50 to i1
  br i1 %51, label %55, label %52

52:                                               ; preds = %.lr.ph54
  %53 = load i32, ptr @tot, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr @tot, align 4, !tbaa !5
  call void @_Z4dfs2i(i32 noundef %47)
  br label %55

55:                                               ; preds = %.lr.ph54, %52
  %indvars.iv.next84 = add nsw i64 %indvars.iv83, -1
  %56 = icmp sgt i64 %indvars.iv83, 1
  br i1 %56, label %.lr.ph54, label %._crit_edge55.loopexit, !llvm.loop !16

._crit_edge72:                                    ; preds = %._crit_edge61, %._crit_edge55
  store i32 0, ptr @m, align 4, !tbaa !5
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %58, i1 false)
  %.not4373 = icmp slt i32 %57, 1
  br i1 %.not4373, label %._crit_edge77, label %.lr.ph76

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %._crit_edge61
  %indvars.iv86 = phi i64 [ 1, %.lr.ph71.preheader ], [ %indvars.iv.next87, %._crit_edge61 ]
  %m.promoted6668 = phi i32 [ %44, %.lr.ph71.preheader ], [ %m.promoted65, %._crit_edge61 ]
  %59 = getelementptr inbounds [1000001 x i32], ptr @scc, i64 0, i64 %indvars.iv86
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = getelementptr inbounds [1000001 x i32], ptr @suf, i64 0, i64 %indvars.iv86
  %.03856 = load i32, ptr %61, align 4, !tbaa !5
  %.not4457 = icmp eq i32 %.03856, -1
  br i1 %.not4457, label %._crit_edge61, label %.lr.ph60

._crit_edge61:                                    ; preds = %77, %.lr.ph71
  %m.promoted65 = phi i32 [ %m.promoted6668, %.lr.ph71 ], [ %m.promoted63, %77 ]
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next87, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge72, label %.lr.ph71, !llvm.loop !17

.lr.ph60:                                         ; preds = %.lr.ph71, %77
  %m.promoted64 = phi i32 [ %m.promoted63, %77 ], [ %m.promoted6668, %.lr.ph71 ]
  %.03858 = phi i32 [ %.038, %77 ], [ %.03856, %.lr.ph71 ]
  %62 = phi i32 [ %78, %77 ], [ %m.promoted6668, %.lr.ph71 ]
  %63 = sext i32 %.03858 to i64
  %64 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %63
  %65 = getelementptr inbounds i8, ptr %64, i64 4
  %66 = load i32, ptr %65, align 4, !tbaa !18
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1000001 x i32], ptr @scc, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %.not45 = icmp eq i32 %69, %60
  br i1 %.not45, label %77, label %70

70:                                               ; preds = %.lr.ph60
  %71 = sext i32 %69 to i64
  %72 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = sext i32 %62 to i64
  %75 = getelementptr inbounds [3000003 x %struct.Edge], ptr @e, i64 0, i64 %74
  store i32 %73, ptr %75, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %75, i64 4
  store i32 %60, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %76 = add nsw i32 %62, 1
  store i32 %62, ptr %72, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %70, %.lr.ph60
  %m.promoted63 = phi i32 [ %76, %70 ], [ %m.promoted64, %.lr.ph60 ]
  %78 = phi i32 [ %76, %70 ], [ %62, %.lr.ph60 ]
  %.038 = load i32, ptr %64, align 8, !tbaa !5
  %.not44 = icmp eq i32 %.038, -1
  br i1 %.not44, label %._crit_edge61, label %.lr.ph60, !llvm.loop !20

._crit_edge77:                                    ; preds = %86, %._crit_edge72
  %79 = phi i32 [ 0, %._crit_edge72 ], [ %89, %86 ]
  %80 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %79)
  ret i32 0

.lr.ph76:                                         ; preds = %._crit_edge72, %86
  %indvars.iv89 = phi i64 [ %indvars.iv.next90, %86 ], [ 1, %._crit_edge72 ]
  %81 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %indvars.iv89
  %82 = load i8, ptr %81, align 1, !tbaa !11, !range !13, !noundef !14
  %83 = trunc nuw i8 %82 to i1
  br i1 %83, label %86, label %84

84:                                               ; preds = %.lr.ph76
  %85 = trunc nuw nsw i64 %indvars.iv89 to i32
  call void @_Z4dfs3i(i32 noundef %85)
  br label %86

86:                                               ; preds = %84, %.lr.ph76
  %87 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv89
  %88 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @m, ptr noundef nonnull align 4 dereferenceable(4) %87)
  %89 = load i32, ptr %88, align 4, !tbaa !5
  store i32 %89, ptr @m, align 4, !tbaa !5
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  %90 = load i32, ptr @tot, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %.not43.not = icmp slt i64 %indvars.iv89, %91
  br i1 %.not43.not, label %.lr.ph76, label %._crit_edge77, !llvm.loop !21
}

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

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

; 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 = { inlinehint 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{!19, !6, i64 4}
!19 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}


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