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

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

%struct.Edge = type { i32, i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@a = external dso_local global [1010 x [1010 x i32]], align 16
@fa = external dso_local global [1020100 x i32], align 16
@ans = external dso_local global i32, align 4
@e = external dso_local global [4080400 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = 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 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 @_Z3idxii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) #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 i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %162, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @t, align 4, !tbaa !5
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %17)
  store i32 0, ptr @tot, align 4, !tbaa !5
  store i32 0, ptr @ans, align 4, !tbaa !5
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %99, %16
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %25, label %24

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

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

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

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

31:                                               ; preds = %26
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1010 x i32], ptr %34, i64 0, i64 %36
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %37)
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %41, label %66

41:                                               ; preds = %31
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = call noundef i32 @_Z3idxii(i32 noundef %42, i32 noundef %43)
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = call noundef i32 @_Z3idxii(i32 noundef %46, i32 noundef %47)
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %50
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1010 x i32], ptr %51, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = sub nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %58
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1010 x i32], ptr %59, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sub nsw i32 %55, %63
  %65 = call i32 @llvm.abs.i32(i32 %64, i1 true)
  call void @_Z7addedgeiii(i32 noundef %44, i32 noundef %48, i32 noundef %65)
  br label %66

66:                                               ; preds = %41, %31
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 0
  br i1 %68, label %69, label %94

69:                                               ; preds = %66
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = load i32, ptr %5, align 4, !tbaa !5
  %72 = call noundef i32 @_Z3idxii(i32 noundef %70, i32 noundef %71)
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = sub nsw i32 %74, 1
  %76 = call noundef i32 @_Z3idxii(i32 noundef %73, i32 noundef %75)
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %78
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1010 x i32], ptr %79, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %85
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = sub nsw i32 %87, 1
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [1010 x i32], ptr %86, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sub nsw i32 %83, %91
  %93 = call i32 @llvm.abs.i32(i32 %92, i1 true)
  call void @_Z7addedgeiii(i32 noundef %72, i32 noundef %76, i32 noundef %93)
  br label %94

94:                                               ; preds = %69, %66
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %5, align 4, !tbaa !5
  br label %26, !llvm.loop !9

98:                                               ; preds = %30
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %4, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %4, align 4, !tbaa !5
  br label %20, !llvm.loop !11

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

103:                                              ; preds = %115, %102
  %104 = load i32, ptr %6, align 4, !tbaa !5
  %105 = load i32, ptr @n, align 4, !tbaa !5
  %106 = load i32, ptr @m, align 4, !tbaa !5
  %107 = mul nsw i32 %105, %106
  %108 = icmp slt i32 %104, %107
  br i1 %108, label %110, label %109

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

110:                                              ; preds = %103
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [1020100 x i32], ptr @fa, i64 0, i64 %113
  store i32 %111, ptr %114, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %110
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %6, align 4, !tbaa !5
  br label %103, !llvm.loop !12

118:                                              ; preds = %109
  %119 = load i32, ptr @tot, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds %struct.Edge, ptr @e, i64 %120
  call void @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef @e, ptr noundef %121)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %156, %118
  %123 = load i32, ptr %7, align 4, !tbaa !5
  %124 = load i32, ptr @tot, align 4, !tbaa !5
  %125 = icmp slt i32 %123, %124
  br i1 %125, label %127, label %126

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

127:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %128 = load i32, ptr %7, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [4080400 x %struct.Edge], ptr @e, i64 0, i64 %129
  %131 = getelementptr inbounds %struct.Edge, ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 4, !tbaa !13
  %133 = call noundef i32 @_Z4findi(i32 noundef %132)
  store i32 %133, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %134 = load i32, ptr %7, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [4080400 x %struct.Edge], ptr @e, i64 0, i64 %135
  %137 = getelementptr inbounds %struct.Edge, ptr %136, i32 0, i32 1
  %138 = load i32, ptr %137, align 4, !tbaa !15
  %139 = call noundef i32 @_Z4findi(i32 noundef %138)
  store i32 %139, ptr %9, align 4, !tbaa !5
  %140 = load i32, ptr %8, align 4, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = icmp ne i32 %140, %141
  br i1 %142, label %143, label %155

143:                                              ; preds = %127
  %144 = load i32, ptr %9, align 4, !tbaa !5
  %145 = load i32, ptr %8, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1020100 x i32], ptr @fa, i64 0, i64 %146
  store i32 %144, ptr %147, align 4, !tbaa !5
  %148 = load i32, ptr %7, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [4080400 x %struct.Edge], ptr @e, i64 0, i64 %149
  %151 = getelementptr inbounds %struct.Edge, ptr %150, i32 0, i32 2
  %152 = load i32, ptr %151, align 4, !tbaa !16
  %153 = load i32, ptr @ans, align 4, !tbaa !5
  %154 = add nsw i32 %153, %152
  store i32 %154, ptr @ans, align 4, !tbaa !5
  br label %155

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

156:                                              ; preds = %155
  %157 = load i32, ptr %7, align 4, !tbaa !5
  %158 = add nsw i32 %157, 1
  store i32 %158, ptr %7, align 4, !tbaa !5
  br label %122, !llvm.loop !17

159:                                              ; preds = %126
  %160 = load i32, ptr @ans, align 4, !tbaa !5
  %161 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %160)
  br label %162

162:                                              ; preds = %159
  %163 = load i32, ptr %2, align 4, !tbaa !5
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !18

165:                                              ; preds = %15
  ret i32 0
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef, 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 = { 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 #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 nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind }

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

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

%struct.Edge = type { i32, i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local global [1010 x [1010 x i32]], align 16
@fa = external dso_local local_unnamed_addr global [1020100 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local global [4080400 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = 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 nounwind uwtable
declare dso_local noundef i32 @_Z3idxii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %.not60 = icmp slt i32 %2, 1
  br i1 %.not60, label %._crit_edge64, label %.lr.ph63

._crit_edge64:                                    ; preds = %._crit_edge59, %0
  ret i32 0

.lr.ph63:                                         ; preds = %0, %._crit_edge59
  %.061 = phi i32 [ %85, %._crit_edge59 ], [ 1, %0 ]
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.061)
  store i32 0, ptr @tot, align 4, !tbaa !5
  store i32 0, ptr @ans, align 4, !tbaa !5
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  %.pre84 = load i32, ptr @m, align 4, !tbaa !5
  %7 = icmp sgt i32 %.pre84, 0
  %or.cond = select i1 %6, i1 %7, i1 false
  br i1 %or.cond, label %.preheader, label %.preheader49

.preheader49:                                     ; preds = %._crit_edge, %.lr.ph63
  %8 = phi i32 [ %.pre84, %.lr.ph63 ], [ %49, %._crit_edge ]
  %.lcssa = phi i32 [ %5, %.lr.ph63 ], [ %51, %._crit_edge ]
  %9 = mul nsw i32 %8, %.lcssa
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph54.preheader, label %._crit_edge55

.lr.ph54.preheader:                               ; preds = %.preheader49
  %wide.trip.count = zext nneg i32 %9 to i64
  %min.iters.check = icmp ult i32 %9, 8
  br i1 %min.iters.check, label %.lr.ph54.preheader98, label %vector.ph

.lr.ph54.preheader98:                             ; preds = %middle.block, %.lr.ph54.preheader
  %indvars.iv77.ph = phi i64 [ 0, %.lr.ph54.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph54

vector.ph:                                        ; preds = %.lr.ph54.preheader
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %11 = getelementptr inbounds [1020100 x i32], ptr @fa, i64 0, i64 %index
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store <4 x i32> %vec.ind, ptr %11, align 16, !tbaa !5
  store <4 x i32> %step.add, ptr %12, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %13 = icmp eq i64 %index.next, %n.vec
  br i1 %13, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge55, label %.lr.ph54.preheader98

.preheader:                                       ; preds = %.lr.ph63, %._crit_edge
  %14 = phi i32 [ %49, %._crit_edge ], [ %.pre84, %.lr.ph63 ]
  %15 = phi i32 [ %50, %._crit_edge ], [ %.pre84, %.lr.ph63 ]
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %._crit_edge ], [ 0, %.lr.ph63 ]
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %.not47 = icmp eq i64 %indvars.iv74, 0
  %17 = add nsw i64 %indvars.iv74, -1
  br i1 %.not47, label %31, label %18

18:                                               ; preds = %.lr.ph
  %19 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %indvars.iv74, i64 0
  %20 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %19)
  %21 = trunc nuw nsw i64 %indvars.iv74 to i32
  %22 = tail call noundef i32 @_Z3idxii(i32 noundef %21, i32 noundef 0)
  %23 = trunc nsw i64 %17 to i32
  %24 = tail call noundef i32 @_Z3idxii(i32 noundef %23, i32 noundef 0)
  %25 = load i32, ptr %19, align 8, !tbaa !5
  %26 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %17, i64 0
  %27 = load i32, ptr %26, align 8, !tbaa !5
  %28 = sub nsw i32 %25, %27
  %29 = tail call i32 @llvm.abs.i32(i32 %28, i1 true)
  tail call void @_Z7addedgeiii(i32 noundef %22, i32 noundef %24, i32 noundef %29)
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  %30 = icmp sgt i32 %.pre, 1
  br i1 %30, label %.lr.ph.split.peel.next, label %._crit_edge

31:                                               ; preds = %.lr.ph
  %32 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %.pre83 = load i32, ptr @m, align 4, !tbaa !5
  %33 = icmp sgt i32 %.pre83, 1
  br i1 %33, label %.lr.ph.split.us.peel.next, label %._crit_edge

.lr.ph.split.us.peel.next:                        ; preds = %31, %.lr.ph.split.us.peel.next
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %.lr.ph.split.us.peel.next ], [ 1, %31 ]
  %34 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 0, i64 %indvars.iv70
  %35 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %34)
  %36 = trunc nuw nsw i64 %indvars.iv70 to i32
  %37 = tail call noundef i32 @_Z3idxii(i32 noundef 0, i32 noundef %36)
  %38 = add nsw i64 %indvars.iv70, -1
  %39 = trunc nsw i64 %38 to i32
  %40 = tail call noundef i32 @_Z3idxii(i32 noundef 0, i32 noundef %39)
  %41 = load i32, ptr %34, align 4, !tbaa !5
  %42 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 0, i64 %38
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sub nsw i32 %41, %43
  %45 = tail call i32 @llvm.abs.i32(i32 %44, i1 true)
  tail call void @_Z7addedgeiii(i32 noundef %37, i32 noundef %40, i32 noundef %45)
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %46 = load i32, ptr @m, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = icmp slt i64 %indvars.iv.next71, %47
  br i1 %48, label %.lr.ph.split.us.peel.next, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph.split.peel.next, %.lr.ph.split.us.peel.next, %18, %31, %.preheader
  %49 = phi i32 [ %14, %.preheader ], [ %.pre83, %31 ], [ %.pre, %18 ], [ %46, %.lr.ph.split.us.peel.next ], [ %73, %.lr.ph.split.peel.next ]
  %50 = phi i32 [ %15, %.preheader ], [ %.pre83, %31 ], [ %.pre, %18 ], [ %46, %.lr.ph.split.us.peel.next ], [ %73, %.lr.ph.split.peel.next ]
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %51 = load i32, ptr @n, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = icmp slt i64 %indvars.iv.next75, %52
  br i1 %53, label %.preheader, label %.preheader49, !llvm.loop !15

.lr.ph.split.peel.next:                           ; preds = %18, %.lr.ph.split.peel.next
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.split.peel.next ], [ 1, %18 ]
  %54 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %indvars.iv74, i64 %indvars.iv
  %55 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %54)
  %56 = trunc nuw nsw i64 %indvars.iv to i32
  %57 = tail call noundef i32 @_Z3idxii(i32 noundef %21, i32 noundef %56)
  %58 = tail call noundef i32 @_Z3idxii(i32 noundef %23, i32 noundef %56)
  %59 = load i32, ptr %54, align 4, !tbaa !5
  %60 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %17, i64 %indvars.iv
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sub nsw i32 %59, %61
  %63 = tail call i32 @llvm.abs.i32(i32 %62, i1 true)
  tail call void @_Z7addedgeiii(i32 noundef %57, i32 noundef %58, i32 noundef %63)
  %64 = tail call noundef i32 @_Z3idxii(i32 noundef %21, i32 noundef %56)
  %65 = add nsw i64 %indvars.iv, -1
  %66 = trunc nsw i64 %65 to i32
  %67 = tail call noundef i32 @_Z3idxii(i32 noundef %21, i32 noundef %66)
  %68 = load i32, ptr %54, align 4, !tbaa !5
  %69 = getelementptr inbounds [1010 x [1010 x i32]], ptr @a, i64 0, i64 %indvars.iv74, i64 %65
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sub nsw i32 %68, %70
  %72 = tail call i32 @llvm.abs.i32(i32 %71, i1 true)
  tail call void @_Z7addedgeiii(i32 noundef %64, i32 noundef %67, i32 noundef %72)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %73 = load i32, ptr @m, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = icmp slt i64 %indvars.iv.next, %74
  br i1 %75, label %.lr.ph.split.peel.next, label %._crit_edge, !llvm.loop !17

._crit_edge55:                                    ; preds = %.lr.ph54, %middle.block, %.preheader49
  %76 = load i32, ptr @tot, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.Edge, ptr @e, i64 %77
  tail call void @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef nonnull @e, ptr noundef nonnull %78)
  %79 = load i32, ptr @tot, align 4, !tbaa !5
  %80 = icmp sgt i32 %79, 0
  br i1 %80, label %.lr.ph58, label %._crit_edge59

.lr.ph54:                                         ; preds = %.lr.ph54.preheader98, %.lr.ph54
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %.lr.ph54 ], [ %indvars.iv77.ph, %.lr.ph54.preheader98 ]
  %81 = getelementptr inbounds [1020100 x i32], ptr @fa, i64 0, i64 %indvars.iv77
  %82 = trunc nuw nsw i64 %indvars.iv77 to i32
  store i32 %82, ptr %81, align 4, !tbaa !5
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next78, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge55, label %.lr.ph54, !llvm.loop !18

._crit_edge59:                                    ; preds = %100, %._crit_edge55
  %83 = load i32, ptr @ans, align 4, !tbaa !5
  %84 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %83)
  %85 = add nuw nsw i32 %.061, 1
  %86 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.061, %86
  br i1 %.not.not, label %.lr.ph63, label %._crit_edge64, !llvm.loop !19

.lr.ph58:                                         ; preds = %._crit_edge55, %100
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %100 ], [ 0, %._crit_edge55 ]
  %87 = getelementptr inbounds [4080400 x %struct.Edge], ptr @e, i64 0, i64 %indvars.iv80
  %88 = load i32, ptr %87, align 4, !tbaa !20
  %89 = tail call noundef i32 @_Z4findi(i32 noundef %88)
  %90 = getelementptr inbounds i8, ptr %87, i64 4
  %91 = load i32, ptr %90, align 4, !tbaa !22
  %92 = tail call noundef i32 @_Z4findi(i32 noundef %91)
  %.not46 = icmp eq i32 %89, %92
  br i1 %.not46, label %100, label %93

93:                                               ; preds = %.lr.ph58
  %94 = sext i32 %89 to i64
  %95 = getelementptr inbounds [1020100 x i32], ptr @fa, i64 0, i64 %94
  store i32 %92, ptr %95, align 4, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %87, i64 8
  %97 = load i32, ptr %96, align 4, !tbaa !23
  %98 = load i32, ptr @ans, align 4, !tbaa !5
  %99 = add nsw i32 %98, %97
  store i32 %99, ptr @ans, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %93, %.lr.ph58
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %101 = load i32, ptr @tot, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = icmp slt i64 %indvars.iv.next81, %102
  br i1 %103, label %.lr.ph58, label %._crit_edge59, !llvm.loop !24
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #4

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

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

!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, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !14}
!14 = !{!"llvm.loop.peeled.count", i32 1}
!15 = distinct !{!15, !10, !16}
!16 = !{!"llvm.loop.unswitch.partial.disable"}
!17 = distinct !{!17, !10, !14}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}
!20 = !{!21, !6, i64 0}
!21 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8}
!22 = !{!21, !6, i64 4}
!23 = !{!21, !6, i64 8}
!24 = distinct !{!24, !10}


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