; LLVM IR from UtkarshPathrabe/Competitive-Coding :: Model Algorithms/Graphs/Euler Circuit in Directed Graph.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, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(24), 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 @_ZN5Graph9transposeEv(ptr dead_on_unwind noalias writable sret(%class.Graph) align 8, ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5Graph4isSCEv(ptr noundef nonnull align 8 dereferenceable(24) %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 i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %class.Graph, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %14 = getelementptr inbounds %class.Graph, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = call noalias noundef nonnull ptr @_Znam(i64 noundef %16) #5
  store ptr %17, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %29, %1
  %19 = load i32, ptr %5, align 4, !tbaa !12
  %20 = getelementptr inbounds %class.Graph, ptr %13, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = icmp slt i32 %19, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %32

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !12
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %25, i64 %27
  store i8 0, ptr %28, align 1, !tbaa !13
  br label %29

29:                                               ; preds = %24
  %30 = load i32, ptr %5, align 4, !tbaa !12
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !12
  br label %18, !llvm.loop !15

32:                                               ; preds = %23
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(24) %13, i32 noundef 0, ptr noundef %33)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !12
  br label %34

34:                                               ; preds = %49, %32
  %35 = load i32, ptr %6, align 4, !tbaa !12
  %36 = getelementptr inbounds %class.Graph, ptr %13, 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 %7, align 4
  br label %52

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

47:                                               ; preds = %40
  store i1 false, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %52

48:                                               ; preds = %40
  br label %49

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

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

54:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #4
  call void @_ZN5Graph9transposeEv(ptr dead_on_unwind writable sret(%class.Graph) align 8 %8, ptr noundef nonnull align 8 dereferenceable(24) %13)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !12
  br label %55

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

60:                                               ; preds = %55
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %69

61:                                               ; preds = %55
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !12
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  store i8 0, ptr %65, align 1, !tbaa !13
  br label %66

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

69:                                               ; preds = %60
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(24) %8, i32 noundef 0, ptr noundef %70)
          to label %71 unwind label %78

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

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

77:                                               ; preds = %72
  store i32 11, ptr %7, align 4
  br label %94

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

82:                                               ; preds = %72
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = load i32, ptr %12, align 4, !tbaa !12
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i8, ptr %83, i64 %85
  %87 = load i8, ptr %86, align 1, !tbaa !13, !range !17, !noundef !18
  %88 = trunc i8 %87 to i1
  br i1 %88, label %90, label %89

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

90:                                               ; preds = %82
  br label %91

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

94:                                               ; preds = %89, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %95 = load i32, ptr %7, 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 %7, align 4
  br label %97

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

98:                                               ; preds = %97, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %99 = load i1, ptr %2, align 1
  ret i1 %99

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #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 = { nobuiltin allocsize(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 #4 = { nounwind }
attributes #5 = { builtin allocsize(0) }

!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, !6, i64 16}
!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, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(24), 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 @_ZN5Graph9transposeEv(ptr dead_on_unwind noalias writable sret(%class.Graph) align 8, ptr noundef nonnull align 8 dereferenceable(24)) 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(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5Graph4isSCEv(ptr noundef nonnull align 8 dereferenceable(24) %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 = sext i32 %3 to i64
  %5 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %4) #5
  %6 = icmp sgt i32 %3, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %1
  %7 = zext nneg i32 %3 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %5, i8 0, i64 %7, i1 false), !tbaa !11
  br label %._crit_edge

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

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

9:                                                ; preds = %.lr.ph37
  %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.ph37, !llvm.loop !13

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

.critedge:                                        ; preds = %9, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #6
  call void @_ZN5Graph9transposeEv(ptr dead_on_unwind nonnull writable sret(%class.Graph) align 8 %2, ptr noundef nonnull align 8 dereferenceable(24) %0)
  %13 = load i32, ptr %0, align 8, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph39.preheader, label %._crit_edge40

.lr.ph39.preheader:                               ; preds = %.critedge
  %15 = zext nneg i32 %13 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %5, i8 0, i64 %15, i1 false), !tbaa !11
  br label %._crit_edge40

._crit_edge40:                                    ; preds = %.lr.ph39.preheader, %.critedge
  invoke void @_ZN5Graph7DFSUtilEiPb(ptr noundef nonnull align 8 dereferenceable(24) %2, i32 noundef 0, ptr noundef nonnull %5)
          to label %.preheader unwind label %20

.preheader:                                       ; preds = %._crit_edge40
  %16 = load i32, ptr %0, align 8, !tbaa !5
  %.not3041 = icmp slt i32 %16, 1
  br i1 %.not3041, label %.critedge32, label %.lr.ph44.preheader

.lr.ph44.preheader:                               ; preds = %.preheader
  %17 = zext nneg i32 %16 to i64
  %wide.trip.count54 = zext nneg i32 %16 to i64
  %18 = load i8, ptr %5, align 1, !tbaa !11, !range !15, !noundef !16
  %19 = trunc nuw i8 %18 to i1
  br i1 %19, label %.lr.ph, label %.critedge32

.lr.ph:                                           ; preds = %.lr.ph44.preheader, %.lr.ph44
  %indvars.iv5256 = phi i64 [ %indvars.iv.next53, %.lr.ph44 ], [ 0, %.lr.ph44.preheader ]
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv5256, 1
  %exitcond55 = icmp eq i64 %indvars.iv.next53, %wide.trip.count54
  br i1 %exitcond55, label %.critedge32.loopexit, label %.lr.ph44, !llvm.loop !17

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

.lr.ph44:                                         ; preds = %.lr.ph
  %22 = getelementptr inbounds i8, ptr %5, i64 %indvars.iv.next53
  %23 = load i8, ptr %22, align 1, !tbaa !11, !range !15, !noundef !16
  %24 = trunc nuw i8 %23 to i1
  br i1 %24, label %.lr.ph, label %.critedge32.loopexit, !llvm.loop !17

.critedge32.loopexit:                             ; preds = %.lr.ph44, %.lr.ph
  %.not30.le = icmp uge i64 %indvars.iv.next53, %17
  br label %.critedge32

.critedge32:                                      ; preds = %.critedge32.loopexit, %.lr.ph44.preheader, %.preheader
  %.not30.lcssa = phi i1 [ true, %.preheader ], [ false, %.lr.ph44.preheader ], [ %.not30.le, %.critedge32.loopexit ]
  call void @_ZN5GraphD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #6
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph37, %.critedge32
  %.3 = phi i1 [ %.not30.lcssa, %.critedge32 ], [ false, %.lr.ph37 ]
  ret i1 %.3
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #3

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

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 = { nobuiltin allocsize(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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { 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, !10, i64 16}
!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,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass