; LLVM IR from NishkarshRaj/Design-and-Analysis-of-Algorithms :: graphs/DFS.ll (ZN5Graph4isSCEv)

; 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.Graph = type { i32, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, ptr noundef) #0 align 2

; 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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Graph12getTransposeEv(ptr dead_on_unwind noalias writable sret(%class.Graph) align 8, ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5GraphD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5Graph4isSCEv(ptr noundef nonnull align 8 dereferenceable(16) %0) #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %class.Graph, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8
  %15 = getelementptr inbounds %class.Graph, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = call ptr @llvm.stacksave.p0()
  store ptr %18, ptr %4, align 8
  %19 = alloca i8, i64 %17, align 16
  store i64 %17, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !12
  br label %20

20:                                               ; preds = %30, %1
  %21 = load i32, ptr %6, align 4, !tbaa !12
  %22 = getelementptr inbounds %class.Graph, ptr %14, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = icmp slt i32 %21, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %33

26:                                               ; preds = %20
  %27 = load i32, ptr %6, align 4, !tbaa !12
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %19, i64 %28
  store i8 0, ptr %29, align 1, !tbaa !13
  br label %30

30:                                               ; preds = %26
  %31 = load i32, ptr %6, align 4, !tbaa !12
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %6, align 4, !tbaa !12
  br label %20, !llvm.loop !15

33:                                               ; preds = %25
  call void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(16) %14, i32 noundef 0, ptr noundef %19)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %34

34:                                               ; preds = %50, %33
  %35 = load i32, ptr %7, align 4, !tbaa !12
  %36 = getelementptr inbounds %class.Graph, ptr %14, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !9
  %38 = icmp slt i32 %35, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %34
  store i32 5, ptr %8, align 4
  br label %53

40:                                               ; preds = %34
  %41 = load i32, ptr %7, align 4, !tbaa !12
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i8, ptr %19, i64 %42
  %44 = load i8, ptr %43, align 1, !tbaa !13, !range !17, !noundef !18
  %45 = trunc i8 %44 to i1
  %46 = zext i1 %45 to i32
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %40
  store i1 false, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %53

49:                                               ; preds = %40
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %7, align 4, !tbaa !12
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %7, align 4, !tbaa !12
  br label %34, !llvm.loop !19

53:                                               ; preds = %48, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %54 = load i32, ptr %8, align 4
  switch i32 %54, label %98 [
    i32 5, label %55
  ]

55:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @_ZN5Graph12getTransposeEv(ptr dead_on_unwind writable sret(%class.Graph) align 8 %9, ptr noundef nonnull align 8 dereferenceable(16) %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !12
  br label %56

56:                                               ; preds = %66, %55
  %57 = load i32, ptr %10, align 4, !tbaa !12
  %58 = getelementptr inbounds %class.Graph, ptr %14, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !9
  %60 = icmp slt i32 %57, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %56
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %69

62:                                               ; preds = %56
  %63 = load i32, ptr %10, align 4, !tbaa !12
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %19, i64 %64
  store i8 0, ptr %65, align 1, !tbaa !13
  br label %66

66:                                               ; preds = %62
  %67 = load i32, ptr %10, align 4, !tbaa !12
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %10, align 4, !tbaa !12
  br label %56, !llvm.loop !20

69:                                               ; preds = %61
  invoke void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(16) %9, i32 noundef 0, ptr noundef %19)
          to label %70 unwind label %77

70:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !12
  br label %71

71:                                               ; preds = %91, %70
  %72 = load i32, ptr %13, align 4, !tbaa !12
  %73 = getelementptr inbounds %class.Graph, ptr %14, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !9
  %75 = icmp slt i32 %72, %74
  br i1 %75, label %81, label %76

76:                                               ; preds = %71
  store i32 11, ptr %8, align 4
  br label %94

77:                                               ; preds = %69
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %11, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %12, align 4
  call void @_ZN5GraphD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %101

81:                                               ; preds = %71
  %82 = load i32, ptr %13, align 4, !tbaa !12
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i8, ptr %19, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !13, !range !17, !noundef !18
  %86 = trunc i8 %85 to i1
  %87 = zext i1 %86 to i32
  %88 = icmp eq i32 %87, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %81
  store i1 false, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %94

90:                                               ; preds = %81
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %13, align 4, !tbaa !12
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %13, align 4, !tbaa !12
  br label %71, !llvm.loop !21

94:                                               ; preds = %89, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  %95 = load i32, ptr %8, align 4
  switch i32 %95, label %97 [
    i32 11, label %96
  ]

96:                                               ; preds = %94
  store i1 true, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %97

97:                                               ; preds = %96, %94
  call void @_ZN5GraphD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %98

98:                                               ; preds = %97, %53
  %99 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %99)
  %100 = load i1, ptr %2, align 1
  ret i1 %100

101:                                              ; preds = %77
  %102 = load ptr, ptr %11, align 8
  %103 = load i32, ptr %12, align 4
  %104 = insertvalue { ptr, i32 } poison, ptr %102, 0
  %105 = insertvalue { ptr, i32 } %104, i32 %103, 1
  resume { ptr, i32 } %105
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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 = { 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 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS5Graph", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !16}


; 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.Graph = type { i32, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, ptr noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Graph12getTransposeEv(ptr dead_on_unwind noalias writable sret(%class.Graph) align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5GraphD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5Graph4isSCEv(ptr noundef nonnull align 8 dereferenceable(16) %0) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %class.Graph, align 8
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = zext i32 %3 to i64
  %5 = alloca i8, i64 %4, align 16
  %6 = icmp sgt i32 %3, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %1
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %5, i8 0, i64 %4, i1 false), !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %1
  call void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 0, ptr noundef nonnull %5)
  %7 = load i32, ptr %0, align 8, !tbaa !5
  %.not29 = icmp sgt i32 %7, 0
  br i1 %.not29, label %.lr.ph32.preheader, label %.critedge

.lr.ph32.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %.lr.ph32

8:                                                ; preds = %.lr.ph32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %.lr.ph32, !llvm.loop !13

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %8
  %indvars.iv = phi i64 [ 0, %.lr.ph32.preheader ], [ %indvars.iv.next, %8 ]
  %9 = getelementptr inbounds i8, ptr %5, i64 %indvars.iv
  %10 = load i8, ptr %9, align 1, !tbaa !11, !range !15, !noundef !16
  %11 = icmp eq i8 %10, 0
  br i1 %11, label %.loopexit, label %8

.critedge:                                        ; preds = %8, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  call void @_ZN5Graph12getTransposeEv(ptr dead_on_unwind nonnull writable sret(%class.Graph) align 8 %2, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %12 = load i32, ptr %0, align 8, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph34.preheader, label %._crit_edge35

.lr.ph34.preheader:                               ; preds = %.critedge
  %14 = zext nneg i32 %12 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %5, i8 0, i64 %14, i1 false), !tbaa !11
  br label %._crit_edge35

._crit_edge35:                                    ; preds = %.lr.ph34.preheader, %.critedge
  invoke void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef 0, ptr noundef nonnull %5)
          to label %.preheader unwind label %19

.preheader:                                       ; preds = %._crit_edge35
  %15 = load i32, ptr %0, align 8, !tbaa !5
  %.not2536 = icmp slt i32 %15, 1
  br i1 %.not2536, label %.critedge27, label %.lr.ph39.preheader

.lr.ph39.preheader:                               ; preds = %.preheader
  %16 = zext nneg i32 %15 to i64
  %wide.trip.count49 = zext nneg i32 %15 to i64
  %17 = load i8, ptr %5, align 16, !tbaa !11, !range !15, !noundef !16
  %18 = icmp eq i8 %17, 0
  br i1 %18, label %.critedge27, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph39.preheader, %.lr.ph39
  %indvars.iv4751 = phi i64 [ %indvars.iv.next48, %.lr.ph39 ], [ 0, %.lr.ph39.preheader ]
  %indvars.iv.next48 = add nuw nsw i64 %indvars.iv4751, 1
  %exitcond50 = icmp eq i64 %indvars.iv.next48, %wide.trip.count49
  br i1 %exitcond50, label %.critedge27.loopexit, label %.lr.ph39, !llvm.loop !17

19:                                               ; preds = %._crit_edge35
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5GraphD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  resume { ptr, i32 } %20

.lr.ph39:                                         ; preds = %.lr.ph
  %21 = getelementptr inbounds i8, ptr %5, i64 %indvars.iv.next48
  %22 = load i8, ptr %21, align 1, !tbaa !11, !range !15, !noundef !16
  %23 = icmp eq i8 %22, 0
  br i1 %23, label %.critedge27.loopexit, label %.lr.ph, !llvm.loop !17

.critedge27.loopexit:                             ; preds = %.lr.ph39, %.lr.ph
  %.not25.le = icmp uge i64 %indvars.iv.next48, %16
  br label %.critedge27

.critedge27:                                      ; preds = %.critedge27.loopexit, %.lr.ph39.preheader, %.preheader
  %.not25.lcssa = phi i1 [ true, %.preheader ], [ false, %.lr.ph39.preheader ], [ %.not25.le, %.critedge27.loopexit ]
  call void @_ZN5GraphD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph32, %.critedge27
  %.3 = phi i1 [ %.not25.lcssa, %.critedge27 ], [ false, %.lr.ph32 ]
  ret i1 %.3
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_ZTS5Graph", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !14}


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