; LLVM IR from div-bargali/Data-Structures-and-Algorithms :: C++/Algorithms/Graph-Algorithms/Number_of_Islands.ll (Z3DFSPA5_iiiPA5_b)

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

@_ZZ3DFSPA5_iiiPA5_bE6rowNbr = external hidden global [8 x i32], align 16
@_ZZ3DFSPA5_iiiPA5_bE6colNbr = external hidden global [8 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

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

17:                                               ; preds = %54, %4
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = icmp slt i32 %18, 8
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %57

21:                                               ; preds = %17
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [8 x i32], ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = add nsw i32 %23, %27
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [8 x i32], ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = add nsw i32 %29, %33
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %22, i32 noundef %28, i32 noundef %34, ptr noundef %35)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %53

38:                                               ; preds = %21
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [8 x i32], ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = add nsw i32 %40, %44
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [8 x i32], ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = add nsw i32 %46, %50
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %39, i32 noundef %45, i32 noundef %51, ptr noundef %52)
  br label %53

53:                                               ; preds = %38, %21
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %9, align 4, !tbaa !9
  br label %17, !llvm.loop !13

57:                                               ; preds = %20
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@_ZZ3DFSPA5_iiiPA5_bE6rowNbr = external hidden local_unnamed_addr global [8 x i32], align 16
@_ZZ3DFSPA5_iiiPA5_bE6colNbr = external hidden local_unnamed_addr global [8 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %90, %4
  %.tr18 = phi i32 [ %1, %4 ], [ %92, %90 ]
  %.tr19 = phi i32 [ %2, %4 ], [ %94, %90 ]
  %5 = sext i32 %.tr18 to i64
  %6 = sext i32 %.tr19 to i64
  %7 = getelementptr inbounds [5 x i8], ptr %3, i64 %5, i64 %6
  store i8 1, ptr %7, align 1, !tbaa !5
  %8 = load i32, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, align 16, !tbaa !9
  %9 = add nsw i32 %8, %.tr18
  %10 = load i32, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, align 16, !tbaa !9
  %11 = add nsw i32 %10, %.tr19
  %12 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %9, i32 noundef %11, ptr noundef %3)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %18, label %13

13:                                               ; preds = %tailrecurse
  %14 = load i32, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, align 16, !tbaa !9
  %15 = add nsw i32 %14, %.tr18
  %16 = load i32, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, align 16, !tbaa !9
  %17 = add nsw i32 %16, %.tr19
  tail call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %15, i32 noundef %17, ptr noundef nonnull %3)
  br label %18

18:                                               ; preds = %tailrecurse, %13
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 4), align 4, !tbaa !9
  %20 = add nsw i32 %19, %.tr18
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 4), align 4, !tbaa !9
  %22 = add nsw i32 %21, %.tr19
  %23 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %20, i32 noundef %22, ptr noundef nonnull %3)
  %.not.1 = icmp eq i32 %23, 0
  br i1 %.not.1, label %29, label %24

24:                                               ; preds = %18
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 4), align 4, !tbaa !9
  %26 = add nsw i32 %25, %.tr18
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 4), align 4, !tbaa !9
  %28 = add nsw i32 %27, %.tr19
  tail call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %26, i32 noundef %28, ptr noundef nonnull %3)
  br label %29

29:                                               ; preds = %24, %18
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 8), align 8, !tbaa !9
  %31 = add nsw i32 %30, %.tr18
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 8), align 8, !tbaa !9
  %33 = add nsw i32 %32, %.tr19
  %34 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %31, i32 noundef %33, ptr noundef nonnull %3)
  %.not.2 = icmp eq i32 %34, 0
  br i1 %.not.2, label %40, label %35

35:                                               ; preds = %29
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 8), align 8, !tbaa !9
  %37 = add nsw i32 %36, %.tr18
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 8), align 8, !tbaa !9
  %39 = add nsw i32 %38, %.tr19
  tail call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %37, i32 noundef %39, ptr noundef nonnull %3)
  br label %40

40:                                               ; preds = %35, %29
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 12), align 4, !tbaa !9
  %42 = add nsw i32 %41, %.tr18
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 12), align 4, !tbaa !9
  %44 = add nsw i32 %43, %.tr19
  %45 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %42, i32 noundef %44, ptr noundef nonnull %3)
  %.not.3 = icmp eq i32 %45, 0
  br i1 %.not.3, label %51, label %46

46:                                               ; preds = %40
  %47 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 12), align 4, !tbaa !9
  %48 = add nsw i32 %47, %.tr18
  %49 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 12), align 4, !tbaa !9
  %50 = add nsw i32 %49, %.tr19
  tail call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %48, i32 noundef %50, ptr noundef nonnull %3)
  br label %51

51:                                               ; preds = %46, %40
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 16), align 16, !tbaa !9
  %53 = add nsw i32 %52, %.tr18
  %54 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 16), align 16, !tbaa !9
  %55 = add nsw i32 %54, %.tr19
  %56 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %53, i32 noundef %55, ptr noundef nonnull %3)
  %.not.4 = icmp eq i32 %56, 0
  br i1 %.not.4, label %62, label %57

57:                                               ; preds = %51
  %58 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 16), align 16, !tbaa !9
  %59 = add nsw i32 %58, %.tr18
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 16), align 16, !tbaa !9
  %61 = add nsw i32 %60, %.tr19
  tail call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %59, i32 noundef %61, ptr noundef nonnull %3)
  br label %62

62:                                               ; preds = %57, %51
  %63 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 20), align 4, !tbaa !9
  %64 = add nsw i32 %63, %.tr18
  %65 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 20), align 4, !tbaa !9
  %66 = add nsw i32 %65, %.tr19
  %67 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %64, i32 noundef %66, ptr noundef nonnull %3)
  %.not.5 = icmp eq i32 %67, 0
  br i1 %.not.5, label %73, label %68

68:                                               ; preds = %62
  %69 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 20), align 4, !tbaa !9
  %70 = add nsw i32 %69, %.tr18
  %71 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 20), align 4, !tbaa !9
  %72 = add nsw i32 %71, %.tr19
  tail call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %70, i32 noundef %72, ptr noundef nonnull %3)
  br label %73

73:                                               ; preds = %68, %62
  %74 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 24), align 8, !tbaa !9
  %75 = add nsw i32 %74, %.tr18
  %76 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 24), align 8, !tbaa !9
  %77 = add nsw i32 %76, %.tr19
  %78 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %75, i32 noundef %77, ptr noundef nonnull %3)
  %.not.6 = icmp eq i32 %78, 0
  br i1 %.not.6, label %84, label %79

79:                                               ; preds = %73
  %80 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 24), align 8, !tbaa !9
  %81 = add nsw i32 %80, %.tr18
  %82 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 24), align 8, !tbaa !9
  %83 = add nsw i32 %82, %.tr19
  tail call void @_Z3DFSPA5_iiiPA5_b(ptr noundef %0, i32 noundef %81, i32 noundef %83, ptr noundef nonnull %3)
  br label %84

84:                                               ; preds = %79, %73
  %85 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 28), align 4, !tbaa !9
  %86 = add nsw i32 %85, %.tr18
  %87 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 28), align 4, !tbaa !9
  %88 = add nsw i32 %87, %.tr19
  %89 = tail call noundef i32 @_Z6isSafePA5_iiiPA5_b(ptr noundef %0, i32 noundef %86, i32 noundef %88, ptr noundef nonnull %3)
  %.not.7 = icmp eq i32 %89, 0
  br i1 %.not.7, label %95, label %90

90:                                               ; preds = %84
  %91 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6rowNbr, i64 28), align 4, !tbaa !9
  %92 = add nsw i32 %91, %.tr18
  %93 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ3DFSPA5_iiiPA5_bE6colNbr, i64 28), align 4, !tbaa !9
  %94 = add nsw i32 %93, %.tr19
  br label %tailrecurse

95:                                               ; preds = %84
  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" }

!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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass