; LLVM IR from vmartinv/eldiego :: flow/konig.ll (Z9dinic_bfsv)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl" }
%"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl" = type { %"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.Edge = type { i32, i32, i64, i64 }

@nodes = external dso_local global i32, align 4
@src = external dso_local global i32, align 4
@dest = external dso_local global i32, align 4
@dist = external dso_local global [2200 x i32], align 16
@q = external dso_local global [2200 x i32], align 16
@g = external dso_local global [2200 x %"class.std::vector"], 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI4EdgeSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; 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 zeroext i1 @_Z9dinic_bfsv() #2 {
  %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 ptr, align 8
  %8 = alloca i32, align 4
  %9 = load i32, ptr @nodes, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i32, ptr @dist, i64 %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 -1, ptr %1, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @dist, ptr noundef %11, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  %12 = load i32, ptr @src, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %13
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  %15 = load i32, ptr @src, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %16 to i64
  %19 = getelementptr inbounds [2200 x i32], ptr @q, i64 0, i64 %18
  store i32 %15, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %81, %0
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [2200 x i32], ptr @q, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  store i32 %29, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %77, %25
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2200 x %"class.std::vector"], ptr @g, i64 0, i64 %33
  %35 = call noundef i64 @_ZNKSt6vectorI4EdgeSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %34) #4
  %36 = trunc i64 %35 to i32
  %37 = icmp slt i32 %31, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %30
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %80

39:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [2200 x %"class.std::vector"], ptr @g, i64 0, i64 %41
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorI4EdgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %42, i64 noundef %44) #4
  store ptr %45, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.Edge, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !11
  store i32 %48, ptr %8, align 4, !tbaa !5
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp slt i32 %52, 0
  br i1 %53, label %54, label %76

54:                                               ; preds = %39
  %55 = load ptr, ptr %7, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.Edge, ptr %55, i32 0, i32 2
  %57 = load i64, ptr %56, align 8, !tbaa !14
  %58 = load ptr, ptr %7, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.Edge, ptr %58, i32 0, i32 3
  %60 = load i64, ptr %59, align 8, !tbaa !15
  %61 = icmp slt i64 %57, %60
  br i1 %61, label %62, label %76

62:                                               ; preds = %54
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = load i32, ptr %8, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %69
  store i32 %67, ptr %70, align 4, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %2, align 4, !tbaa !5
  %74 = sext i32 %72 to i64
  %75 = getelementptr inbounds [2200 x i32], ptr @q, i64 0, i64 %74
  store i32 %71, ptr %75, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %62, %54, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %6, align 4, !tbaa !5
  br label %30, !llvm.loop !16

80:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %3, align 4, !tbaa !5
  br label %20, !llvm.loop !18

84:                                               ; preds = %24
  %85 = load i32, ptr @dest, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = icmp sge i32 %88, 0
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i1 %89
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorI4EdgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

attributes #0 = { 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 = { 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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 16}
!13 = !{!"long long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!12, !13, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl" }
%"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl" = type { %"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Edge, std::allocator<Edge>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@nodes = external dso_local local_unnamed_addr global i32, align 4
@src = external dso_local local_unnamed_addr global i32, align 4
@dest = external dso_local local_unnamed_addr global i32, align 4
@dist = external dso_local global [2200 x i32], align 16
@q = external dso_local local_unnamed_addr global [2200 x i32], align 16
@g = external dso_local global [2200 x %"class.std::vector"], 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI4EdgeSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; 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 uwtable
define dso_local noundef zeroext i1 @_Z9dinic_bfsv() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = load i32, ptr @nodes, align 4, !tbaa !5
  %3 = sext i32 %2 to i64
  %4 = getelementptr inbounds i32, ptr @dist, i64 %3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  store i32 -1, ptr %1, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @dist, ptr noundef nonnull %4, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %5 = load i32, ptr @src, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %6
  store i32 0, ptr %7, align 4, !tbaa !5
  store i32 %5, ptr @q, align 16, !tbaa !5
  br label %14

8:                                                ; preds = %._crit_edge
  %9 = load i32, ptr @dest, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, -1
  ret i1 %13

14:                                               ; preds = %0, %._crit_edge
  %indvars.iv24 = phi i64 [ 0, %0 ], [ %indvars.iv.next25, %._crit_edge ]
  %.022 = phi i32 [ 1, %0 ], [ %.1.lcssa, %._crit_edge ]
  %15 = getelementptr inbounds [2200 x i32], ptr @q, i64 0, i64 %indvars.iv24
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [2200 x %"class.std::vector"], ptr @g, i64 0, i64 %17
  %19 = call noundef i64 @_ZNKSt6vectorI4EdgeSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #4
  %20 = trunc i64 %19 to i32
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %14
  %22 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %17
  br label %25

._crit_edge:                                      ; preds = %44, %14
  %.1.lcssa = phi i32 [ %.022, %14 ], [ %.2, %44 ]
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %23 = sext i32 %.1.lcssa to i64
  %24 = icmp slt i64 %indvars.iv.next25, %23
  br i1 %24, label %14, label %8, !llvm.loop !9

25:                                               ; preds = %.lr.ph, %44
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %44 ]
  %.120 = phi i32 [ %.022, %.lr.ph ], [ %.2, %44 ]
  %26 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorI4EdgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %indvars.iv) #4
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2200 x i32], ptr @dist, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %32, label %44

32:                                               ; preds = %25
  %33 = getelementptr inbounds i8, ptr %26, i64 8
  %34 = load i64, ptr %33, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %26, i64 16
  %36 = load i64, ptr %35, align 8, !tbaa !15
  %37 = icmp slt i64 %34, %36
  br i1 %37, label %38, label %44

38:                                               ; preds = %32
  %39 = load i32, ptr %22, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %29, align 4, !tbaa !5
  %41 = add nsw i32 %.120, 1
  %42 = sext i32 %.120 to i64
  %43 = getelementptr inbounds [2200 x i32], ptr @q, i64 0, i64 %42
  store i32 %27, ptr %43, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %38, %32, %25
  %.2 = phi i32 [ %41, %38 ], [ %.120, %32 ], [ %.120, %25 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %45 = call noundef i64 @_ZNKSt6vectorI4EdgeSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #4
  %sext = shl i64 %45, 32
  %46 = ashr exact i64 %sext, 32
  %47 = icmp slt i64 %indvars.iv.next, %46
  br i1 %47, label %25, label %._crit_edge, !llvm.loop !16
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorI4EdgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 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 = { 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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 16}
!13 = !{!"long long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!12, !13, i64 16}
!16 = distinct !{!16, !10}


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