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

@V = external dso_local global [2010 x %struct.vertex], align 16
@E = external dso_local global [4000000 x %struct.edge], align 16
@dfn = external dso_local global i32, align 4
@col = external dso_local global i32, align 4
@S = external dso_local global [2010 x i32], align 16
@sp = external dso_local global i32, align 4
@ins = external dso_local global [2010 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3DFSi(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = load i32, ptr @sp, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr @sp, align 4, !tbaa !5
  %8 = sext i32 %6 to i64
  %9 = getelementptr inbounds [2010 x i32], ptr @S, i64 0, i64 %8
  store i32 %5, ptr %9, align 4, !tbaa !5
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [2010 x i8], ptr @ins, i64 0, i64 %11
  store i8 1, ptr %12, align 1, !tbaa !9
  %13 = load i32, ptr @dfn, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr @dfn, align 4, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %16
  %18 = getelementptr inbounds %struct.vertex, ptr %17, i32 0, i32 2
  store i32 %13, ptr %18, align 8, !tbaa !11
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.vertex, ptr %21, i32 0, i32 1
  store i32 %13, ptr %22, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.vertex, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 16, !tbaa !14
  store i32 %27, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %92, %1
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %28
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [4000000 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 !15
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.vertex, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !13
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %43, label %49

43:                                               ; preds = %32
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [4000000 x %struct.edge], ptr @E, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.edge, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !15
  call void @_Z3DFSi(i32 noundef %48)
  br label %49

49:                                               ; preds = %43, %32
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [4000000 x %struct.edge], ptr @E, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.edge, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !15
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [2010 x i8], ptr @ins, i64 0, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !9, !range !17, !noundef !18
  %58 = trunc i8 %57 to i1
  %59 = zext i1 %58 to i32
  %60 = icmp eq i32 %59, 1
  br i1 %60, label %61, label %91

61:                                               ; preds = %49
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [4000000 x %struct.edge], ptr @E, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.edge, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 8, !tbaa !15
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.vertex, ptr %68, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !11
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.vertex, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !11
  %76 = icmp slt i32 %70, %75
  br i1 %76, label %77, label %91

77:                                               ; preds = %61
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [4000000 x %struct.edge], ptr @E, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.edge, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 8, !tbaa !15
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %83
  %85 = getelementptr inbounds %struct.vertex, ptr %84, i32 0, i32 2
  %86 = load i32, ptr %85, align 8, !tbaa !11
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %88
  %90 = getelementptr inbounds %struct.vertex, ptr %89, i32 0, i32 2
  store i32 %86, ptr %90, align 8, !tbaa !11
  br label %91

91:                                               ; preds = %77, %61, %49
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %3, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [4000000 x %struct.edge], ptr @E, i64 0, i64 %94
  %96 = getelementptr inbounds %struct.edge, ptr %95, i32 0, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !19
  store i32 %97, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !20

98:                                               ; preds = %31
  %99 = load i32, ptr %2, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %100
  %102 = getelementptr inbounds %struct.vertex, ptr %101, i32 0, i32 2
  %103 = load i32, ptr %102, align 8, !tbaa !11
  %104 = load i32, ptr %2, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %105
  %107 = getelementptr inbounds %struct.vertex, ptr %106, i32 0, i32 1
  %108 = load i32, ptr %107, align 4, !tbaa !13
  %109 = icmp eq i32 %103, %108
  br i1 %109, label %110, label %132

110:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  br label %111

111:                                              ; preds = %125, %110
  %112 = load i32, ptr @sp, align 4, !tbaa !5
  %113 = add nsw i32 %112, -1
  store i32 %113, ptr @sp, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [2010 x i32], ptr @S, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  store i32 %116, ptr %4, align 4, !tbaa !5
  %117 = load i32, ptr %4, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2010 x i8], ptr @ins, i64 0, i64 %118
  store i8 0, ptr %119, align 1, !tbaa !9
  %120 = load i32, ptr @col, align 4, !tbaa !5
  %121 = load i32, ptr %4, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %122
  %124 = getelementptr inbounds %struct.vertex, ptr %123, i32 0, i32 3
  store i32 %120, ptr %124, align 4, !tbaa !22
  br label %125

125:                                              ; preds = %111
  %126 = load i32, ptr %4, align 4, !tbaa !5
  %127 = load i32, ptr %2, align 4, !tbaa !5
  %128 = icmp ne i32 %126, %127
  br i1 %128, label %111, label %129, !llvm.loop !23

129:                                              ; preds = %125
  %130 = load i32, ptr @col, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr @col, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %132

132:                                              ; preds = %129, %98
  ret void
}

; 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 = !{!12, !6, i64 8}
!12 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!16, !6, i64 4}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !6, i64 12}
!23 = distinct !{!23, !21}


; 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, i32, i32 }
%struct.edge = type { i32, i32 }

@V = external dso_local local_unnamed_addr global [2010 x %struct.vertex], align 16
@E = external dso_local local_unnamed_addr global [4000000 x %struct.edge], align 16
@dfn = external dso_local local_unnamed_addr global i32, align 4
@col = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local local_unnamed_addr global [2010 x i32], align 16
@sp = external dso_local local_unnamed_addr global i32, align 4
@ins = external dso_local local_unnamed_addr global [2010 x i8], align 16

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z3DFSi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @sp, align 4, !tbaa !5
  %3 = add nsw i32 %2, 1
  store i32 %3, ptr @sp, align 4, !tbaa !5
  %4 = sext i32 %2 to i64
  %5 = getelementptr inbounds [2010 x i32], ptr @S, i64 0, i64 %4
  store i32 %0, ptr %5, align 4, !tbaa !5
  %6 = sext i32 %0 to i64
  %7 = getelementptr inbounds [2010 x i8], ptr @ins, i64 0, i64 %6
  store i8 1, ptr %7, align 1, !tbaa !9
  %8 = load i32, ptr @dfn, align 4, !tbaa !5
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr @dfn, align 4, !tbaa !5
  %10 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %6
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  store i32 %8, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %10, i64 4
  store i32 %8, ptr %12, align 4, !tbaa !13
  %.022 = load i32, ptr %10, align 16, !tbaa !5
  %.not23 = icmp eq i32 %.022, 0
  br i1 %.not23, label %.preheader, label %.lr.ph

._crit_edge:                                      ; preds = %34
  %.pre27 = load i32, ptr %11, align 8, !tbaa !11
  %.pre28 = load i32, ptr %12, align 4, !tbaa !13
  %13 = icmp eq i32 %.pre27, %.pre28
  br i1 %13, label %.preheader, label %45

.preheader:                                       ; preds = %1, %._crit_edge
  %14 = load i32, ptr @col, align 4, !tbaa !5
  %sp.promoted = load i32, ptr @sp, align 4, !tbaa !5
  %15 = sext i32 %sp.promoted to i64
  br label %36

.lr.ph:                                           ; preds = %1, %34
  %.024 = phi i32 [ %.0, %34 ], [ %.022, %1 ]
  %16 = sext i32 %.024 to i64
  %17 = getelementptr inbounds [4000000 x %struct.edge], ptr @E, i64 0, i64 %16
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %19, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %.lr.ph
  tail call void @_Z3DFSi(i32 noundef %18)
  %.pre = load i32, ptr %17, align 8, !tbaa !14
  %.pre29 = sext i32 %.pre to i64
  br label %24

24:                                               ; preds = %23, %.lr.ph
  %.pre-phi = phi i64 [ %.pre29, %23 ], [ %19, %.lr.ph ]
  %25 = getelementptr inbounds [2010 x i8], ptr @ins, i64 0, i64 %.pre-phi
  %26 = load i8, ptr %25, align 1, !tbaa !9, !range !16, !noundef !17
  %27 = trunc nuw i8 %26 to i1
  br i1 %27, label %28, label %34

28:                                               ; preds = %24
  %29 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %.pre-phi, i32 2
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = load i32, ptr %11, align 8, !tbaa !11
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %28
  store i32 %30, ptr %11, align 8, !tbaa !11
  br label %34

34:                                               ; preds = %24, %28, %33
  %35 = getelementptr inbounds i8, ptr %17, i64 4
  %.0 = load i32, ptr %35, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

36:                                               ; preds = %.preheader, %36
  %indvars.iv = phi i64 [ %15, %.preheader ], [ %indvars.iv.next, %36 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %37 = getelementptr inbounds [2010 x i32], ptr @S, i64 0, i64 %indvars.iv.next
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2010 x i8], ptr @ins, i64 0, i64 %39
  store i8 0, ptr %40, align 1, !tbaa !9
  %41 = getelementptr inbounds [2010 x %struct.vertex], ptr @V, i64 0, i64 %39, i32 3
  store i32 %14, ptr %41, align 4, !tbaa !20
  %.not21 = icmp eq i32 %38, %0
  br i1 %.not21, label %42, label %36, !llvm.loop !21

42:                                               ; preds = %36
  %43 = trunc nsw i64 %indvars.iv.next to i32
  store i32 %43, ptr @sp, align 4, !tbaa !5
  %44 = add nsw i32 %14, 1
  store i32 %44, ptr @col, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %42, %._crit_edge
  ret void
}

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 = !{!"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 = !{!12, !6, i64 8}
!12 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = !{!12, !6, i64 4}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !6, i64 12}
!21 = distinct !{!21, !19}


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