; LLVM IR from Dev-XYS/Algorithms :: Hungarian-Algorithm.ll (Z3dfsi)

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

@V = external dso_local global [1010 x %struct.vertex], align 16
@E = external dso_local global [250010 x %struct.edge], align 16
@vis = external dso_local global [1010 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z3dfsi(i32 noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [1010 x i8], ptr @vis, i64 0, i64 %7
  %9 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = trunc i8 %9 to i1
  %11 = zext i1 %10 to i32
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %92

14:                                               ; preds = %1
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1010 x i8], ptr @vis, i64 0, i64 %16
  store i8 1, ptr %17, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.vertex, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !13
  store i32 %22, ptr %4, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %83, %14
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 2, ptr %5, align 4
  br label %89

27:                                               ; preds = %23
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.vertex, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [250010 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 8, !tbaa !16
  %38 = icmp ne i32 %32, %37
  br i1 %38, label %39, label %82

39:                                               ; preds = %27
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [250010 x %struct.edge], ptr @E, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.edge, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !16
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.vertex, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !15
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %63, label %50

50:                                               ; preds = %39
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [250010 x %struct.edge], ptr @E, i64 0, i64 %52
  %54 = getelementptr inbounds %struct.edge, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !16
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %56
  %58 = getelementptr inbounds %struct.vertex, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 4, !tbaa !15
  %60 = call noundef zeroext i1 @_Z3dfsi(i32 noundef %59)
  %61 = zext i1 %60 to i32
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %82

63:                                               ; preds = %50, %39
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [250010 x %struct.edge], ptr @E, i64 0, i64 %65
  %67 = getelementptr inbounds %struct.edge, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !16
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.vertex, ptr %71, i32 0, i32 1
  store i32 %68, ptr %72, align 4, !tbaa !15
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [250010 x %struct.edge], ptr @E, i64 0, i64 %75
  %77 = getelementptr inbounds %struct.edge, ptr %76, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !16
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.vertex, ptr %80, i32 0, i32 1
  store i32 %73, ptr %81, align 4, !tbaa !15
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %89

82:                                               ; preds = %50, %27
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [250010 x %struct.edge], ptr @E, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.edge, ptr %86, i32 0, i32 1
  %88 = load i32, ptr %87, align 4, !tbaa !18
  store i32 %88, ptr %4, align 4, !tbaa !5
  br label %23, !llvm.loop !19

89:                                               ; preds = %63, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %90 = load i32, ptr %5, align 4
  switch i32 %90, label %94 [
    i32 2, label %91
    i32 1, label %92
  ]

91:                                               ; preds = %89
  store i1 false, ptr %2, align 1
  br label %92

92:                                               ; preds = %91, %89, %13
  %93 = load i1, ptr %2, align 1
  ret i1 %93

94:                                               ; preds = %89
  unreachable
}

; 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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 4}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!18 = !{!17, !6, i64 4}
!19 = distinct !{!19, !20}
!20 = !{!"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 }

@V = external dso_local local_unnamed_addr global [1010 x %struct.vertex], align 16
@E = external dso_local local_unnamed_addr global [250010 x %struct.edge], align 16
@vis = external dso_local local_unnamed_addr global [1010 x i8], align 16

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z3dfsi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = sext i32 %0 to i64
  %3 = getelementptr inbounds [1010 x i8], ptr @vis, i64 0, i64 %2
  %4 = load i8, ptr %3, align 1, !tbaa !5, !range !9, !noundef !10
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %1
  store i8 1, ptr %3, align 1, !tbaa !5
  %7 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %2
  %.01421 = load i32, ptr %7, align 8, !tbaa !11
  %.not22.not = icmp eq i32 %.01421, 0
  br i1 %.not22.not, label %.loopexit, label %.lr.ph

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

9:                                                ; preds = %.lr.ph, %23
  %.01423 = phi i32 [ %.01421, %.lr.ph ], [ %.014, %23 ]
  %10 = load i32, ptr %8, align 4, !tbaa !13
  %11 = sext i32 %.01423 to i64
  %12 = getelementptr inbounds [250010 x %struct.edge], ptr @E, i64 0, i64 %11
  %13 = load i32, ptr %12, align 8, !tbaa !15
  %.not18 = icmp eq i32 %10, %13
  br i1 %.not18, label %23, label %14

14:                                               ; preds = %9
  %15 = sext i32 %13 to i64
  %16 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %15, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %split, label %19

19:                                               ; preds = %14
  %20 = tail call noundef zeroext i1 @_Z3dfsi(i32 noundef %17)
  br i1 %20, label %._crit_edge, label %23

._crit_edge:                                      ; preds = %19
  %.pre = load i32, ptr %12, align 8, !tbaa !15
  %.pre25 = sext i32 %.pre to i64
  br label %split

split:                                            ; preds = %14, %._crit_edge
  %.pre-phi = phi i64 [ %.pre25, %._crit_edge ], [ %15, %14 ]
  %21 = phi i32 [ %.pre, %._crit_edge ], [ %13, %14 ]
  store i32 %21, ptr %8, align 4, !tbaa !13
  %22 = getelementptr inbounds [1010 x %struct.vertex], ptr @V, i64 0, i64 %.pre-phi, i32 1
  store i32 %0, ptr %22, align 4, !tbaa !13
  br label %.loopexit

23:                                               ; preds = %9, %19
  %24 = getelementptr inbounds i8, ptr %12, i64 4
  %.014 = load i32, ptr %24, align 4, !tbaa !11
  %.not.not = icmp eq i32 %.014, 0
  br i1 %.not.not, label %.loopexit, label %9, !llvm.loop !17

.loopexit:                                        ; preds = %23, %6, %split, %1
  %.1 = phi i1 [ false, %1 ], [ true, %split ], [ false, %6 ], [ false, %23 ]
  ret i1 %.1
}

attributes #0 = { mustprogress nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"_ZTS6vertex", !12, i64 0, !12, i64 4}
!15 = !{!16, !12, i64 0}
!16 = !{!"_ZTS4edge", !12, i64 0, !12, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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