; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/图论/一般图最大权匹配.ll (Z5foundRK4edge)

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

@match = external dso_local global [1023 x i32], align 16
@slack = external dso_local global [1023 x i32], align 16
@st = external dso_local global [1023 x i32], align 16
@pa = external dso_local global [1023 x i32], align 16
@S = external dso_local global [1023 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
declare dso_local void @_Z4pushi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7augmentii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7get_lcaii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3addiii(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5foundRK4edge(ptr noundef nonnull align 4 dereferenceable(12) %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %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
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.edge, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [1023 x i32], ptr @st, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !12
  store i32 %14, ptr %4, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.edge, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [1023 x i32], ptr @st, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !12
  store i32 %20, ptr %5, align 4, !tbaa !12
  %21 = load i32, ptr %5, align 4, !tbaa !12
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1023 x i32], ptr @S, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !12
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %26, label %53

26:                                               ; preds = %1
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.edge, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = load i32, ptr %5, align 4, !tbaa !12
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1023 x i32], ptr @pa, i64 0, i64 %31
  store i32 %29, ptr %32, align 4, !tbaa !12
  %33 = load i32, ptr %5, align 4, !tbaa !12
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1023 x i32], ptr @S, i64 0, i64 %34
  store i32 1, ptr %35, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %36 = load i32, ptr %5, align 4, !tbaa !12
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1023 x i32], ptr @match, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !12
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1023 x i32], ptr @st, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !12
  store i32 %42, ptr %6, align 4, !tbaa !12
  %43 = load i32, ptr %6, align 4, !tbaa !12
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1023 x i32], ptr @slack, i64 0, i64 %44
  store i32 0, ptr %45, align 4, !tbaa !12
  %46 = load i32, ptr %5, align 4, !tbaa !12
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1023 x i32], ptr @slack, i64 0, i64 %47
  store i32 0, ptr %48, align 4, !tbaa !12
  %49 = load i32, ptr %6, align 4, !tbaa !12
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1023 x i32], ptr @S, i64 0, i64 %50
  store i32 0, ptr %51, align 4, !tbaa !12
  %52 = load i32, ptr %6, align 4, !tbaa !12
  call void @_Z4pushi(i32 noundef %52)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %79

53:                                               ; preds = %1
  %54 = load i32, ptr %5, align 4, !tbaa !12
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1023 x i32], ptr @S, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !12
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %78

59:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %60 = load i32, ptr %4, align 4, !tbaa !12
  %61 = load i32, ptr %5, align 4, !tbaa !12
  %62 = call noundef i32 @_Z7get_lcaii(i32 noundef %60, i32 noundef %61)
  store i32 %62, ptr %7, align 4, !tbaa !12
  %63 = load i32, ptr %7, align 4, !tbaa !12
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %70, label %65

65:                                               ; preds = %59
  %66 = load i32, ptr %4, align 4, !tbaa !12
  %67 = load i32, ptr %5, align 4, !tbaa !12
  call void @_Z7augmentii(i32 noundef %66, i32 noundef %67)
  %68 = load i32, ptr %5, align 4, !tbaa !12
  %69 = load i32, ptr %4, align 4, !tbaa !12
  call void @_Z7augmentii(i32 noundef %68, i32 noundef %69)
  store i1 true, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %75

70:                                               ; preds = %59
  %71 = load i32, ptr %4, align 4, !tbaa !12
  %72 = load i32, ptr %7, align 4, !tbaa !12
  %73 = load i32, ptr %5, align 4, !tbaa !12
  call void @_Z3addiii(i32 noundef %71, i32 noundef %72, i32 noundef %73)
  br label %74

74:                                               ; preds = %70
  store i32 0, ptr %8, align 4
  br label %75

75:                                               ; preds = %74, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %76 = load i32, ptr %8, align 4
  switch i32 %76, label %80 [
    i32 0, label %77
  ]

77:                                               ; preds = %75
  br label %78

78:                                               ; preds = %77, %53
  br label %79

79:                                               ; preds = %78, %26
  store i1 false, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %80

80:                                               ; preds = %79, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %81 = load i1, ptr %2, align 1
  ret i1 %81
}

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS4edge", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}


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

@match = external dso_local local_unnamed_addr global [1023 x i32], align 16
@slack = external dso_local local_unnamed_addr global [1023 x i32], align 16
@st = external dso_local local_unnamed_addr global [1023 x i32], align 16
@pa = external dso_local local_unnamed_addr global [1023 x i32], align 16
@S = external dso_local local_unnamed_addr global [1023 x i32], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4pushi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7augmentii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7get_lcaii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3addiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5foundRK4edge(ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 4, !tbaa !5
  %3 = sext i32 %2 to i64
  %4 = getelementptr inbounds [1023 x i32], ptr @st, i64 0, i64 %3
  %5 = load i32, ptr %4, align 4, !tbaa !10
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !11
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [1023 x i32], ptr @st, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !10
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [1023 x i32], ptr @S, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !10
  switch i32 %13, label %28 [
    i32 -1, label %14
    i32 0, label %25
  ]

14:                                               ; preds = %1
  %15 = getelementptr inbounds [1023 x i32], ptr @pa, i64 0, i64 %11
  store i32 %2, ptr %15, align 4, !tbaa !10
  store i32 1, ptr %12, align 4, !tbaa !10
  %16 = getelementptr inbounds [1023 x i32], ptr @match, i64 0, i64 %11
  %17 = load i32, ptr %16, align 4, !tbaa !10
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [1023 x i32], ptr @st, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !10
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [1023 x i32], ptr @slack, i64 0, i64 %21
  store i32 0, ptr %22, align 4, !tbaa !10
  %23 = getelementptr inbounds [1023 x i32], ptr @slack, i64 0, i64 %11
  store i32 0, ptr %23, align 4, !tbaa !10
  %24 = getelementptr inbounds [1023 x i32], ptr @S, i64 0, i64 %21
  store i32 0, ptr %24, align 4, !tbaa !10
  tail call void @_Z4pushi(i32 noundef %20)
  br label %28

25:                                               ; preds = %1
  %26 = tail call noundef i32 @_Z7get_lcaii(i32 noundef %5, i32 noundef %10)
  %.not.not = icmp eq i32 %26, 0
  br i1 %.not.not, label %.thread, label %27

.thread:                                          ; preds = %25
  tail call void @_Z7augmentii(i32 noundef %5, i32 noundef %10)
  tail call void @_Z7augmentii(i32 noundef %10, i32 noundef %5)
  br label %28

27:                                               ; preds = %25
  tail call void @_Z3addiii(i32 noundef %5, i32 noundef %26, i32 noundef %10)
  br label %28

28:                                               ; preds = %14, %1, %27, %.thread
  %.1 = phi i1 [ true, %.thread ], [ false, %27 ], [ false, %1 ], [ false, %14 ]
  ret i1 %.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 = { 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" }

!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, !7, i64 0}
!6 = !{!"_ZTS4edge", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !7, i64 4}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass