; LLVM IR from tangjz/acm-icpc :: codechef/MAY18 (STMINCUT)

; 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
@a = external dso_local global [1001 x [1001 x i32]], align 16
@dsu = external dso_local global [1001 x i32], align 16
@dis = external dso_local global [1001 x i32], align 16
@ans = external dso_local global i64, align 8
@e = external dso_local global [1000001 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z9dsu_queryii(i32 noundef, i32 noundef) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 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)
  br label %11

11:                                               ; preds = %140, %0
  %12 = load i32, ptr @t, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr @t, align 4, !tbaa !5
  %14 = icmp ne i32 %12, 0
  br i1 %14, label %15, label %143

15:                                               ; preds = %11
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  store i64 0, ptr @ans, align 8, !tbaa !9
  store i32 0, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %94, %15
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 4, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  br label %97

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [1001 x i32], ptr @dsu, i64 0, i64 %24
  store i32 -1, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %27
  store i32 1061109567, ptr %28, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %90, %22
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 7, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #9
  br label %93

34:                                               ; preds = %29
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %36
  %38 = getelementptr inbounds [1001 x i32], ptr %37, i64 0, i64 0
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %41)
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = icmp sle i32 %43, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %34
  br label %90

47:                                               ; preds = %34
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %49
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1001 x i32], ptr %50, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %56
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1001 x i32], ptr %57, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sub nsw i32 %54, %61
  %63 = call i32 @llvm.abs.i32(i32 %62, i1 true)
  %64 = sext i32 %63 to i64
  %65 = load i64, ptr @ans, align 8, !tbaa !9
  %66 = add nsw i64 %65, %64
  store i64 %66, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #9
  %67 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 0
  %68 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %68, ptr %67, align 4, !tbaa !11
  %69 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 1
  %70 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %70, ptr %69, align 4, !tbaa !13
  %71 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 2
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %73
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1001 x i32], ptr %74, i64 0, i64 %76
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %79
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1001 x i32], ptr %80, i64 0, i64 %82
  %84 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %77, ptr noundef nonnull align 4 dereferenceable(4) %83)
  %85 = load i32, ptr %84, align 4, !tbaa !5
  store i32 %85, ptr %71, align 4, !tbaa !14
  %86 = load i32, ptr @m, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr @m, align 4, !tbaa !5
  %88 = sext i32 %86 to i64
  %89 = getelementptr inbounds [1000001 x %struct.Edge], ptr @e, i64 0, i64 %88
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %89, ptr align 4 %5, i64 12, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #9
  br label %90

90:                                               ; preds = %47, %46
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %4, align 4, !tbaa !5
  br label %29, !llvm.loop !16

93:                                               ; preds = %33
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %2, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !18

97:                                               ; preds = %21
  %98 = load i32, ptr @m, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds %struct.Edge, ptr @e, i64 %99
  call void @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef @e, ptr noundef %100)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %137, %97
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = load i32, ptr @m, align 4, !tbaa !5
  %104 = icmp slt i32 %102, %103
  br i1 %104, label %106, label %105

105:                                              ; preds = %101
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  br label %140

106:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [1000001 x %struct.Edge], ptr @e, i64 0, i64 %108
  %110 = getelementptr inbounds %struct.Edge, ptr %109, i32 0, i32 0
  %111 = load i32, ptr %110, align 4, !tbaa !11
  store i32 %111, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [1000001 x %struct.Edge], ptr @e, i64 0, i64 %113
  %115 = getelementptr inbounds %struct.Edge, ptr %114, i32 0, i32 1
  %116 = load i32, ptr %115, align 4, !tbaa !13
  store i32 %116, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  %117 = load i32, ptr %6, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1000001 x %struct.Edge], ptr @e, i64 0, i64 %118
  %120 = getelementptr inbounds %struct.Edge, ptr %119, i32 0, i32 2
  %121 = load i32, ptr %120, align 4, !tbaa !14
  store i32 %121, ptr %9, align 4, !tbaa !5
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = call noundef zeroext i1 @_Z9dsu_mergeiii(i32 noundef %122, i32 noundef %123, i32 noundef %124)
  br i1 %125, label %136, label %126

126:                                              ; preds = %106
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = load i32, ptr %8, align 4, !tbaa !5
  %129 = call noundef i32 @_Z9dsu_queryii(i32 noundef %127, i32 noundef %128)
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = sub nsw i32 %129, %130
  %132 = shl i32 %131, 1
  %133 = sext i32 %132 to i64
  %134 = load i64, ptr @ans, align 8, !tbaa !9
  %135 = add nsw i64 %134, %133
  store i64 %135, ptr @ans, align 8, !tbaa !9
  br label %136

136:                                              ; preds = %126, %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #9
  br label %137

137:                                              ; preds = %136
  %138 = load i32, ptr %6, align 4, !tbaa !5
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %6, align 4, !tbaa !5
  br label %101, !llvm.loop !19

140:                                              ; preds = %105
  %141 = load i64, ptr @ans, align 8, !tbaa !9
  %142 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %141)
  br label %11, !llvm.loop !20

143:                                              ; preds = %11
  ret i32 0
}

declare i32 @__isoc99_scanf(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 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)) #6

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { 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 #9 = { nounwind }

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

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


; 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 local_unnamed_addr global i32, align 4
@a = external dso_local global [1001 x [1001 x i32]], align 16
@dsu = external dso_local local_unnamed_addr global [1001 x i32], align 16
@dis = external dso_local local_unnamed_addr global [1001 x i32], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@e = external dso_local global [1000001 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z9dsu_queryii(i32 noundef, 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
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not43 = icmp eq i32 %2, 0
  br i1 %.not43, label %._crit_edge46, label %.lr.ph45

.lr.ph45:                                         ; preds = %0, %._crit_edge42
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  store i64 0, ptr @ans, align 8, !tbaa !9
  store i32 0, ptr @m, align 4, !tbaa !5
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph37.split, label %._crit_edge38

._crit_edge38.loopexit:                           ; preds = %._crit_edge
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %._crit_edge38

._crit_edge38:                                    ; preds = %._crit_edge38.loopexit, %.lr.ph45
  %7 = phi i32 [ %.pre, %._crit_edge38.loopexit ], [ 0, %.lr.ph45 ]
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds %struct.Edge, ptr @e, i64 %8
  tail call void @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef nonnull @e, ptr noundef nonnull %9)
  %10 = load i32, ptr @m, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph41, label %._crit_edge42

.lr.ph37.split:                                   ; preds = %.lr.ph45, %._crit_edge
  %12 = phi i32 [ %18, %._crit_edge ], [ %5, %.lr.ph45 ]
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %._crit_edge ], [ 0, %.lr.ph45 ]
  %13 = getelementptr inbounds [1001 x i32], ptr @dsu, i64 0, i64 %indvars.iv51
  store i32 -1, ptr %13, align 4, !tbaa !5
  %14 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %indvars.iv51
  store i32 1061109567, ptr %14, align 4, !tbaa !5
  %15 = icmp sgt i32 %12, 0
  br i1 %15, label %.lr.ph, label %.lr.ph37.split.._crit_edge_crit_edge

.lr.ph37.split.._crit_edge_crit_edge:             ; preds = %.lr.ph37.split
  %.pre57 = sext i32 %12 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph37.split
  %16 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %indvars.iv51
  %17 = trunc nuw nsw i64 %indvars.iv51 to i32
  br label %20

._crit_edge:                                      ; preds = %40, %.lr.ph37.split.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre57, %.lr.ph37.split.._crit_edge_crit_edge ], [ %42, %40 ]
  %18 = phi i32 [ %12, %.lr.ph37.split.._crit_edge_crit_edge ], [ %41, %40 ]
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %19 = icmp slt i64 %indvars.iv.next52, %.pre-phi
  br i1 %19, label %.lr.ph37.split, label %._crit_edge38.loopexit, !llvm.loop !11

20:                                               ; preds = %.lr.ph, %40
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %40 ]
  %21 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv
  %22 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %21)
  %.not33 = icmp ugt i64 %indvars.iv51, %indvars.iv
  br i1 %.not33, label %23, label %40

23:                                               ; preds = %20
  %24 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %indvars.iv51, i64 %indvars.iv
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %indvars.iv, i64 %indvars.iv51
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = sub nsw i32 %25, %27
  %29 = tail call i32 @llvm.abs.i32(i32 %28, i1 true)
  %30 = zext nneg i32 %29 to i64
  %31 = load i64, ptr @ans, align 8, !tbaa !9
  %32 = add nsw i64 %31, %30
  store i64 %32, ptr @ans, align 8, !tbaa !9
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %24, ptr noundef nonnull align 4 dereferenceable(4) %26)
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = load i32, ptr @m, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr @m, align 4, !tbaa !5
  %37 = sext i32 %35 to i64
  %38 = getelementptr inbounds [1000001 x %struct.Edge], ptr @e, i64 0, i64 %37
  store i32 %17, ptr %38, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %38, i64 4
  %39 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %39, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %38, i64 8
  store i32 %34, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %20, %23
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %20, label %._crit_edge, !llvm.loop !14

._crit_edge42:                                    ; preds = %62, %._crit_edge38
  %44 = load i64, ptr @ans, align 8, !tbaa !9
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %44)
  %46 = load i32, ptr @t, align 4, !tbaa !5
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %46, 0
  br i1 %.not, label %._crit_edge46, label %.lr.ph45, !llvm.loop !15

.lr.ph41:                                         ; preds = %._crit_edge38, %62
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %62 ], [ 0, %._crit_edge38 ]
  %48 = getelementptr inbounds [1000001 x %struct.Edge], ptr @e, i64 0, i64 %indvars.iv54
  %49 = load i32, ptr %48, align 4, !tbaa !16
  %50 = getelementptr inbounds i8, ptr %48, i64 4
  %51 = load i32, ptr %50, align 4, !tbaa !18
  %52 = getelementptr inbounds i8, ptr %48, i64 8
  %53 = load i32, ptr %52, align 4, !tbaa !19
  %54 = tail call noundef zeroext i1 @_Z9dsu_mergeiii(i32 noundef %49, i32 noundef %51, i32 noundef %53)
  br i1 %54, label %62, label %55

55:                                               ; preds = %.lr.ph41
  %56 = tail call noundef i32 @_Z9dsu_queryii(i32 noundef %49, i32 noundef %51)
  %57 = sub nsw i32 %56, %53
  %58 = shl i32 %57, 1
  %59 = sext i32 %58 to i64
  %60 = load i64, ptr @ans, align 8, !tbaa !9
  %61 = add nsw i64 %60, %59
  store i64 %61, ptr @ans, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %55, %.lr.ph41
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %63 = load i32, ptr @m, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = icmp slt i64 %indvars.iv.next55, %64
  br i1 %65, label %.lr.ph41, label %._crit_edge42, !llvm.loop !20

._crit_edge46:                                    ; preds = %._crit_edge42, %0
  ret i32 0
}

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

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

; 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 #5

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

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

attributes #0 = { mustprogress 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 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 #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" }

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

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


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