; LLVM IR from Dev-XYS/Algorithms :: 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.vertex = type { i32, i32 }
%struct.edge = type { i32, i32, i32 }

@V = external dso_local global [100000 x %struct.vertex], align 16
@E = external dso_local global [100000 x %struct.edge], align 16
@sink = external dso_local global i32, align 4

; 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
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load i32, ptr @sink, align 4, !tbaa !5
  %12 = icmp eq i32 %10, %11
  br i1 %12, label %13, label %15

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

15:                                               ; 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
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %17
  %19 = getelementptr inbounds %struct.vertex, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !9
  store i32 %20, ptr %7, align 4, !tbaa !5
  br label %21

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

24:                                               ; preds = %21
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br label %28

28:                                               ; preds = %24, %21
  %29 = phi i1 [ false, %21 ], [ %27, %24 ]
  br i1 %29, label %31, label %30

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

31:                                               ; preds = %28
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %33
  %35 = getelementptr inbounds %struct.vertex, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.edge, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.vertex, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = add nsw i32 %45, 1
  %47 = icmp eq i32 %36, %46
  br i1 %47, label %48, label %89

48:                                               ; preds = %31
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.edge, ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !14
  %54 = icmp sgt i32 %53, 0
  br i1 %54, label %55, label %89

55:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %57
  %59 = getelementptr inbounds %struct.edge, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 4, !tbaa !12
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.edge, ptr %63, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sub nsw i32 %65, %66
  store i32 %67, ptr %9, align 4, !tbaa !5
  %68 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %64, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = call noundef i32 @_Z3dfsii(i32 noundef %60, i32 noundef %69)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  store i32 %70, ptr %8, align 4, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %73
  %75 = getelementptr inbounds %struct.edge, ptr %74, i32 0, i32 2
  %76 = load i32, ptr %75, align 4, !tbaa !14
  %77 = sub nsw i32 %76, %71
  store i32 %77, ptr %75, align 4, !tbaa !14
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = xor i32 %79, 1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %81
  %83 = getelementptr inbounds %struct.edge, ptr %82, i32 0, i32 2
  %84 = load i32, ptr %83, align 4, !tbaa !14
  %85 = add nsw i32 %84, %78
  store i32 %85, ptr %83, align 4, !tbaa !14
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = add nsw i32 %87, %86
  store i32 %88, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %89

89:                                               ; preds = %55, %48, %31
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.edge, ptr %93, i32 0, i32 1
  %95 = load i32, ptr %94, align 4, !tbaa !15
  store i32 %95, ptr %7, align 4, !tbaa !5
  br label %21, !llvm.loop !16

96:                                               ; preds = %30
  %97 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %97, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %98

98:                                               ; preds = %96, %13
  %99 = load i32, ptr %3, align 4
  ret i32 %99
}

; 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 0}
!10 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = !{!13, !6, i64 8}
!15 = !{!13, !6, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"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.vertex = type { i32, i32 }
%struct.edge = type { i32, i32, i32 }

@V = external dso_local local_unnamed_addr global [100000 x %struct.vertex], align 16
@E = external dso_local global [100000 x %struct.edge], align 16
@sink = external dso_local local_unnamed_addr global i32, align 4

; 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 @sink, 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 [100000 x %struct.vertex], ptr @V, i64 0, i64 %7
  %.02226 = load i32, ptr %8, align 8, !tbaa !5
  %9 = icmp ne i32 %.02226, 0
  %10 = icmp sgt i32 %1, 0
  %11 = and i1 %9, %10
  br i1 %11, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %6
  %12 = getelementptr inbounds i8, ptr %8, i64 4
  br label %13

13:                                               ; preds = %.lr.ph, %40
  %.02228 = phi i32 [ %.02226, %.lr.ph ], [ %.022, %40 ]
  %.02327 = phi i32 [ 0, %.lr.ph ], [ %.1, %40 ]
  %14 = load i32, ptr %12, align 4, !tbaa !9
  %15 = sext i32 %.02228 to i64
  %16 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %18, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  %22 = icmp eq i32 %14, %21
  br i1 %22, label %23, label %40

23:                                               ; preds = %13
  %24 = getelementptr inbounds i8, ptr %16, i64 8
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %27, label %40

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %28 = sub nsw i32 %1, %.02327
  store i32 %28, ptr %3, align 4, !tbaa !5
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %24, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = call noundef i32 @_Z3dfsii(i32 noundef %17, i32 noundef %30)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  %32 = load i32, ptr %24, align 4, !tbaa !13
  %33 = sub nsw i32 %32, %31
  store i32 %33, ptr %24, align 4, !tbaa !13
  %34 = xor i32 %.02228, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %35, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !13
  %38 = add nsw i32 %37, %31
  store i32 %38, ptr %36, align 4, !tbaa !13
  %39 = add nsw i32 %31, %.02327
  br label %40

40:                                               ; preds = %13, %23, %27
  %.1 = phi i32 [ %39, %27 ], [ %.02327, %23 ], [ %.02327, %13 ]
  %41 = getelementptr inbounds i8, ptr %16, i64 4
  %.022 = load i32, ptr %41, align 4, !tbaa !5
  %42 = icmp ne i32 %.022, 0
  %43 = icmp slt i32 %.1, %1
  %44 = select i1 %42, i1 %43, i1 false
  br i1 %44, label %13, label %.loopexit, !llvm.loop !14

.loopexit:                                        ; preds = %40, %6, %2
  %.0 = phi i32 [ %1, %2 ], [ 0, %6 ], [ %.1, %40 ]
  ret i32 %.0
}

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


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