; LLVM IR from lzyrapx/Competitive-Programming :: LibreOJ/101（dinic）.ll (Z3dfsii)

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

@e = external dso_local global [8000010 x %struct.edge], align 16
@T = external dso_local global i32, align 4
@dis = external dso_local global [1000005 x i32], align 16
@cur = external dso_local global [1000005 x i32], align 16

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3dfsii(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load i32, ptr @T, align 4, !tbaa !5
  %13 = icmp eq i32 %11, %12
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %15, ptr %3, align 4
  br label %113

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [1000005 x i32], ptr @cur, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr %7, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %95, %16
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 2, ptr %8, align 4
  br label %101

25:                                               ; preds = %21
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.edge, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %90

32:                                               ; preds = %25
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.edge, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1000005 x i32], ptr @dis, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1000005 x i32], ptr @dis, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  %46 = icmp eq i32 %40, %45
  br i1 %46, label %47, label %90

47:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.edge, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = sub nsw i32 %53, %54
  store i32 %55, ptr %10, align 4, !tbaa !5
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %57
  %59 = getelementptr inbounds %struct.edge, ptr %58, i32 0, i32 2
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %59)
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = call noundef i32 @_Z3dfsii(i32 noundef %52, i32 noundef %61)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  store i32 %62, ptr %9, align 4, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = add nsw i32 %64, %63
  store i32 %65, ptr %6, align 4, !tbaa !5
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.edge, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 4, !tbaa !9
  %72 = sub nsw i32 %71, %66
  store i32 %72, ptr %70, align 4, !tbaa !9
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = xor i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.edge, ptr %77, i32 0, i32 2
  %79 = load i32, ptr %78, align 4, !tbaa !9
  %80 = add nsw i32 %79, %73
  store i32 %80, ptr %78, align 4, !tbaa !9
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = load i32, ptr %5, align 4, !tbaa !5
  %83 = icmp eq i32 %81, %82
  br i1 %83, label %84, label %86

84:                                               ; preds = %47
  %85 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %85, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %87

86:                                               ; preds = %47
  store i32 0, ptr %8, align 4
  br label %87

87:                                               ; preds = %86, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %88 = load i32, ptr %8, align 4
  switch i32 %88, label %101 [
    i32 0, label %89
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89, %32, %25
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [1000005 x i32], ptr @cur, i64 0, i64 %93
  store i32 %91, ptr %94, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %90
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %97
  %99 = getelementptr inbounds %struct.edge, ptr %98, i32 0, i32 1
  %100 = load i32, ptr %99, align 4, !tbaa !12
  store i32 %100, ptr %7, align 4, !tbaa !5
  br label %21, !llvm.loop !13

101:                                              ; preds = %87, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %102 = load i32, ptr %8, align 4
  switch i32 %102, label %112 [
    i32 2, label %103
  ]

103:                                              ; preds = %101
  %104 = load i32, ptr %6, align 4, !tbaa !5
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %110

106:                                              ; preds = %103
  %107 = load i32, ptr %4, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [1000005 x i32], ptr @dis, i64 0, i64 %108
  store i32 -1, ptr %109, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %106, %103
  %111 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %111, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %112

112:                                              ; preds = %110, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %113

113:                                              ; preds = %112, %14
  %114 = load i32, ptr %3, align 4
  ret i32 %114
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 8}
!10 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 0}
!12 = !{!10, !6, i64 4}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@e = external dso_local global [8000010 x %struct.edge], align 16
@T = external dso_local local_unnamed_addr global i32, align 4
@dis = external dso_local local_unnamed_addr global [1000005 x i32], align 16
@cur = external dso_local local_unnamed_addr global [1000005 x i32], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z3dfsii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = load i32, ptr @T, align 4, !tbaa !5
  %5 = icmp eq i32 %4, %0
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %2
  %7 = sext i32 %0 to i64
  %8 = getelementptr inbounds [1000005 x i32], ptr @cur, i64 0, i64 %7
  %.03245 = load i32, ptr %8, align 4, !tbaa !5
  %.not46 = icmp eq i32 %.03245, 0
  br i1 %.not46, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %9 = getelementptr inbounds [1000005 x i32], ptr @dis, i64 0, i64 %7
  br label %10

10:                                               ; preds = %.lr.ph, %36
  %.03248 = phi i32 [ %.03245, %.lr.ph ], [ %.032, %36 ]
  %.03347 = phi i32 [ 0, %.lr.ph ], [ %.134, %36 ]
  %11 = sext i32 %.03248 to i64
  %12 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %11
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %.not38 = icmp eq i32 %14, 0
  br i1 %.not38, label %36, label %15

15:                                               ; preds = %10
  %16 = load i32, ptr %12, align 4, !tbaa !11
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1000005 x i32], ptr @dis, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = load i32, ptr %9, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  %22 = icmp eq i32 %19, %21
  br i1 %22, label %23, label %36

23:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %24 = sub nsw i32 %1, %.03347
  store i32 %24, ptr %3, align 4, !tbaa !5
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = call noundef i32 @_Z3dfsii(i32 noundef %16, i32 noundef %26)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  %28 = add nsw i32 %27, %.03347
  %29 = load i32, ptr %13, align 4, !tbaa !9
  %30 = sub nsw i32 %29, %27
  store i32 %30, ptr %13, align 4, !tbaa !9
  %31 = xor i32 %.03248, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [8000010 x %struct.edge], ptr @e, i64 0, i64 %32, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = add nsw i32 %34, %27
  store i32 %35, ptr %33, align 4, !tbaa !9
  %.not39 = icmp eq i32 %28, %1
  br i1 %.not39, label %.loopexit, label %36

36:                                               ; preds = %23, %15, %10
  %.134 = phi i32 [ %28, %23 ], [ %.03347, %15 ], [ %.03347, %10 ]
  store i32 %.03248, ptr %8, align 4, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %12, i64 4
  %.032 = load i32, ptr %37, align 4, !tbaa !5
  %.not = icmp eq i32 %.032, 0
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !12

._crit_edge:                                      ; preds = %36
  %.not40 = icmp eq i32 %.134, 0
  br i1 %.not40, label %.loopexit, label %38

38:                                               ; preds = %._crit_edge
  %39 = getelementptr inbounds [1000005 x i32], ptr @dis, i64 0, i64 %7
  store i32 -1, ptr %39, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %23, %6, %38, %._crit_edge, %2
  %.5 = phi i32 [ %1, %2 ], [ %.134, %38 ], [ 0, %._crit_edge ], [ 0, %6 ], [ %1, %23 ]
  ret i32 %.5
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 8}
!10 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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