; LLVM IR from Tunghohin/Competitive_Coding :: Daimayuan/225.ll (Z5dfs_2xx)

; 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 { i64, i64, i64 }

@max_flow = external dso_local global [100010 x i64], align 16
@max_up = external dso_local global [100010 x i64], align 16
@dp = external dso_local global [100010 x i64], align 16
@e = external dso_local global [200020 x %struct.edge], align 16
@head = external dso_local global [100010 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z8inv_edgex(i64 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5dfs_2xx(i64 noundef %0, i64 noundef %1) #3 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds [100010 x i64], ptr @head, i64 0, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !5
  store i64 %13, ptr %6, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %34, %2
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %39

18:                                               ; preds = %14
  %19 = load i64, ptr %6, align 8, !tbaa !5
  %20 = load i64, ptr %4, align 8, !tbaa !5
  %21 = call noundef i64 @_Z8inv_edgex(i64 noundef %20)
  %22 = icmp eq i64 %19, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  br label %34

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %25 = load i64, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.edge, ptr %26, i32 0, i32 0
  %28 = load i64, ptr %27, align 8, !tbaa !9
  store i64 %28, ptr %7, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds [100010 x i64], ptr @max_flow, i64 0, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = load i64, ptr %5, align 8, !tbaa !5
  %33 = add nsw i64 %32, %31
  store i64 %33, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %34

34:                                               ; preds = %24, %23
  %35 = load i64, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.edge, ptr %36, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !11
  store i64 %38, ptr %6, align 8, !tbaa !5
  br label %14, !llvm.loop !12

39:                                               ; preds = %17
  %40 = load i64, ptr %3, align 8, !tbaa !5
  %41 = icmp eq i64 %40, 1
  br i1 %41, label %42, label %46

42:                                               ; preds = %39
  %43 = load i64, ptr %5, align 8, !tbaa !5
  %44 = load i64, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds [100010 x i64], ptr @dp, i64 0, i64 %44
  store i64 %43, ptr %45, align 8, !tbaa !5
  br label %87

46:                                               ; preds = %39
  %47 = load i64, ptr %4, align 8, !tbaa !5
  %48 = call noundef i64 @_Z8inv_edgex(i64 noundef %47)
  %49 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.edge, ptr %49, i32 0, i32 0
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = icmp eq i64 %51, 1
  br i1 %52, label %53, label %60

53:                                               ; preds = %46
  %54 = load i64, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %54
  %56 = getelementptr inbounds %struct.edge, ptr %55, i32 0, i32 2
  %57 = load i64, ptr %56, align 8, !tbaa !14
  %58 = load i64, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds [100010 x i64], ptr @max_up, i64 0, i64 %58
  store i64 %57, ptr %59, align 8, !tbaa !5
  br label %79

60:                                               ; preds = %46
  %61 = load i64, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.edge, ptr %62, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %64 = load i64, ptr %4, align 8, !tbaa !5
  %65 = call noundef i64 @_Z8inv_edgex(i64 noundef %64)
  %66 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %65
  %67 = getelementptr inbounds %struct.edge, ptr %66, i32 0, i32 0
  %68 = load i64, ptr %67, align 8, !tbaa !9
  %69 = getelementptr inbounds [100010 x i64], ptr @dp, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !5
  %71 = load i64, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds [100010 x i64], ptr @max_flow, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !5
  %74 = sub nsw i64 %70, %73
  store i64 %74, ptr %8, align 8, !tbaa !5
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %63, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %77 = load i64, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds [100010 x i64], ptr @max_up, i64 0, i64 %77
  store i64 %76, ptr %78, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %79

79:                                               ; preds = %60, %53
  %80 = load i64, ptr %5, align 8, !tbaa !5
  %81 = load i64, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds [100010 x i64], ptr @max_up, i64 0, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !5
  %84 = add nsw i64 %80, %83
  %85 = load i64, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds [100010 x i64], ptr @dp, i64 0, i64 %85
  store i64 %84, ptr %86, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %79, %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %88 = load i64, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds [100010 x i64], ptr @head, i64 0, i64 %88
  %90 = load i64, ptr %89, align 8, !tbaa !5
  store i64 %90, ptr %9, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %108, %87
  %92 = load i64, ptr %9, align 8, !tbaa !5
  %93 = icmp ne i64 %92, 0
  br i1 %93, label %95, label %94

94:                                               ; preds = %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %113

95:                                               ; preds = %91
  %96 = load i64, ptr %9, align 8, !tbaa !5
  %97 = load i64, ptr %4, align 8, !tbaa !5
  %98 = call noundef i64 @_Z8inv_edgex(i64 noundef %97)
  %99 = icmp eq i64 %96, %98
  br i1 %99, label %100, label %101

100:                                              ; preds = %95
  br label %108

101:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %102 = load i64, ptr %9, align 8, !tbaa !5
  %103 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %102
  %104 = getelementptr inbounds %struct.edge, ptr %103, i32 0, i32 0
  %105 = load i64, ptr %104, align 8, !tbaa !9
  store i64 %105, ptr %10, align 8, !tbaa !5
  %106 = load i64, ptr %10, align 8, !tbaa !5
  %107 = load i64, ptr %9, align 8, !tbaa !5
  call void @_Z5dfs_2xx(i64 noundef %106, i64 noundef %107)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %108

108:                                              ; preds = %101, %100
  %109 = load i64, ptr %9, align 8, !tbaa !5
  %110 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.edge, ptr %110, i32 0, i32 1
  %112 = load i64, ptr %111, align 8, !tbaa !11
  store i64 %112, ptr %9, align 8, !tbaa !5
  br label %91, !llvm.loop !15

113:                                              ; preds = %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

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 = { 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 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 = { 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 = !{!"long long", !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 8, !6, i64 16}
!11 = !{!10, !6, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16}
!15 = distinct !{!15, !13}


; 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 { i64, i64, i64 }

@max_flow = external dso_local local_unnamed_addr global [100010 x i64], align 16
@max_up = external dso_local local_unnamed_addr global [100010 x i64], align 16
@dp = external dso_local local_unnamed_addr global [100010 x i64], align 16
@e = external dso_local global [200020 x %struct.edge], align 16
@head = external dso_local local_unnamed_addr global [100010 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z8inv_edgex(i64 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z5dfs_2xx(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i64, align 8
  %4 = getelementptr inbounds [100010 x i64], ptr @head, i64 0, i64 %0
  %.03034 = load i64, ptr %4, align 8, !tbaa !5
  %.not35 = icmp eq i64 %.03034, 0
  br i1 %.not35, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %14, %2
  %.0.lcssa = phi i64 [ 0, %2 ], [ %.1, %14 ]
  %5 = icmp eq i64 %0, 1
  br i1 %5, label %16, label %17

.lr.ph:                                           ; preds = %2, %14
  %.03037 = phi i64 [ %.030, %14 ], [ %.03034, %2 ]
  %.036 = phi i64 [ %.1, %14 ], [ 0, %2 ]
  %6 = tail call noundef i64 @_Z8inv_edgex(i64 noundef %1)
  %7 = icmp eq i64 %.03037, %6
  br i1 %7, label %14, label %8

8:                                                ; preds = %.lr.ph
  %9 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %.03037
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds [100010 x i64], ptr @max_flow, i64 0, i64 %10
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = add nsw i64 %12, %.036
  br label %14

14:                                               ; preds = %.lr.ph, %8
  %.1 = phi i64 [ %.036, %.lr.ph ], [ %13, %8 ]
  %15 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %.03037, i32 1
  %.030 = load i64, ptr %15, align 8, !tbaa !5
  %.not = icmp eq i64 %.030, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

16:                                               ; preds = %._crit_edge
  store i64 %.0.lcssa, ptr getelementptr inbounds (i8, ptr @dp, i64 8), align 8, !tbaa !5
  br label %40

17:                                               ; preds = %._crit_edge
  %18 = tail call noundef i64 @_Z8inv_edgex(i64 noundef %1)
  %19 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %18
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = icmp eq i64 %20, 1
  %22 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %1, i32 2
  br i1 %21, label %23, label %25

23:                                               ; preds = %17
  %24 = load i64, ptr %22, align 8, !tbaa !13
  br label %36

25:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %26 = tail call noundef i64 @_Z8inv_edgex(i64 noundef %1)
  %27 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds [100010 x i64], ptr @dp, i64 0, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds [100010 x i64], ptr @max_flow, i64 0, i64 %0
  %32 = load i64, ptr %31, align 8, !tbaa !5
  %33 = sub nsw i64 %30, %32
  store i64 %33, ptr %3, align 8, !tbaa !5
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %22, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %35 = load i64, ptr %34, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %36

36:                                               ; preds = %25, %23
  %.sink = phi i64 [ %24, %23 ], [ %35, %25 ]
  %37 = getelementptr inbounds [100010 x i64], ptr @max_up, i64 0, i64 %0
  store i64 %.sink, ptr %37, align 8
  %38 = add nsw i64 %.sink, %.0.lcssa
  %39 = getelementptr inbounds [100010 x i64], ptr @dp, i64 0, i64 %0
  store i64 %38, ptr %39, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %36, %16
  %.02938 = load i64, ptr %4, align 8, !tbaa !5
  %.not3339 = icmp eq i64 %.02938, 0
  br i1 %.not3339, label %._crit_edge43, label %.lr.ph42

._crit_edge43:                                    ; preds = %46, %40
  ret void

.lr.ph42:                                         ; preds = %40, %46
  %.02940 = phi i64 [ %.029, %46 ], [ %.02938, %40 ]
  %41 = call noundef i64 @_Z8inv_edgex(i64 noundef %1)
  %42 = icmp eq i64 %.02940, %41
  br i1 %42, label %46, label %43

43:                                               ; preds = %.lr.ph42
  %44 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %.02940
  %45 = load i64, ptr %44, align 8, !tbaa !9
  call void @_Z5dfs_2xx(i64 noundef %45, i64 noundef %.02940)
  br label %46

46:                                               ; preds = %.lr.ph42, %43
  %47 = getelementptr inbounds [200020 x %struct.edge], ptr @e, i64 0, i64 %.02940, i32 1
  %.029 = load i64, ptr %47, align 8, !tbaa !5
  %.not33 = icmp eq i64 %.029, 0
  br i1 %.not33, label %._crit_edge43, label %.lr.ph42, !llvm.loop !14
}

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"long long", !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 8, !6, i64 16}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !6, i64 16}
!14 = distinct !{!14, !12}


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