; LLVM IR from Dev-XYS/Algorithms :: Cut-Vertex (main)

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

@V = external dso_local global [100000 x %struct.vertex], align 16
@ivc = external dso_local global i32, align 4
@iec = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

; 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 @_Z3geti(i32 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @ivc, ptr noundef @iec)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %20, %0
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load i32, ptr @iec, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %9
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z8add_edgeii(i32 noundef %16, i32 noundef %17)
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z8add_edgeii(i32 noundef %18, i32 noundef %19)
  br label %20

20:                                               ; preds = %14
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %4, align 4, !tbaa !5
  br label %9, !llvm.loop !9

23:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %39, %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr @ivc, align 4, !tbaa !5
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %42

29:                                               ; preds = %24
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.vertex, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %29
  %37 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z3geti(i32 noundef %37)
  br label %38

38:                                               ; preds = %36, %29
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %5, align 4, !tbaa !5
  br label %24, !llvm.loop !14

42:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %61, %42
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr @ivc, align 4, !tbaa !5
  %46 = icmp sle i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %64

48:                                               ; preds = %43
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.vertex, ptr %51, i32 0, i32 3
  %53 = load i8, ptr %52, align 4, !tbaa !15, !range !16, !noundef !17
  %54 = trunc i8 %53 to i1
  %55 = zext i1 %54 to i32
  %56 = icmp eq i32 %55, 1
  br i1 %56, label %57, label %60

57:                                               ; preds = %48
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %6, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %57, %48
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %7, align 4, !tbaa !5
  br label %43, !llvm.loop !18

64:                                               ; preds = %47
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %65)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %67 = load i32, ptr %1, align 4
  ret i32 %67
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

declare i32 @printf(ptr noundef, ...) #4

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress norecurse 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 #4 = { "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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 4}
!12 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !6, i64 8, !13, i64 12}
!13 = !{!"bool", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = !{!12, !13, i64 12}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !10}


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

@V = external dso_local local_unnamed_addr global [100000 x %struct.vertex], align 16
@ivc = external dso_local global i32, align 4
@iec = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

; 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 @_Z3geti(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @ivc, ptr noundef nonnull @iec)
  %4 = load i32, ptr @iec, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.preheader16

.preheader16:                                     ; preds = %.lr.ph, %0
  %6 = load i32, ptr @ivc, align 4, !tbaa !5
  %.not18 = icmp slt i32 %6, 1
  br i1 %.not18, label %._crit_edge, label %.lr.ph20

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01417 = phi i32 [ %12, %.lr.ph ], [ 0, %0 ]
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z8add_edgeii(i32 noundef %8, i32 noundef %9)
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z8add_edgeii(i32 noundef %10, i32 noundef %11)
  %12 = add nuw nsw i32 %.01417, 1
  %13 = load i32, ptr @iec, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %.lr.ph, label %.preheader16, !llvm.loop !9

.preheader:                                       ; preds = %23
  %.not1521 = icmp slt i32 %24, 1
  br i1 %.not1521, label %._crit_edge, label %.lr.ph24.preheader

.lr.ph24.preheader:                               ; preds = %.preheader
  %15 = zext nneg i32 %24 to i64
  %xtraiter = and i64 %15, 3
  %16 = icmp ult i32 %24, 4
  br i1 %16, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph24.preheader.new

.lr.ph24.preheader.new:                           ; preds = %.lr.ph24.preheader
  %unroll_iter = and i64 %15, 2147483644
  br label %.lr.ph24

.lr.ph20:                                         ; preds = %.preheader16, %23
  %17 = phi i32 [ %24, %23 ], [ %6, %.preheader16 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %23 ], [ 1, %.preheader16 ]
  %18 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %indvars.iv, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %.lr.ph20
  %22 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_Z3geti(i32 noundef %22)
  %.pre = load i32, ptr @ivc, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %.lr.ph20, %21
  %24 = phi i32 [ %17, %.lr.ph20 ], [ %.pre, %21 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = sext i32 %24 to i64
  %.not.not = icmp slt i64 %indvars.iv, %25
  br i1 %.not.not, label %.lr.ph20, label %.preheader, !llvm.loop !14

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph24, %.lr.ph24.preheader
  %spec.select.lcssa.ph = phi i32 [ poison, %.lr.ph24.preheader ], [ %spec.select.3, %.lr.ph24 ]
  %indvars.iv28.unr = phi i64 [ 1, %.lr.ph24.preheader ], [ %indvars.iv.next29.3, %.lr.ph24 ]
  %.01222.unr = phi i32 [ 0, %.lr.ph24.preheader ], [ %spec.select.3, %.lr.ph24 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph24.epil

.lr.ph24.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph24.epil
  %indvars.iv28.epil = phi i64 [ %indvars.iv.next29.epil, %.lr.ph24.epil ], [ %indvars.iv28.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01222.epil = phi i32 [ %spec.select.epil, %.lr.ph24.epil ], [ %.01222.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph24.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %26 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %indvars.iv28.epil, i32 3
  %27 = load i8, ptr %26, align 4, !tbaa !15, !range !16, !noundef !17
  %28 = zext nneg i8 %27 to i32
  %spec.select.epil = add nuw nsw i32 %.01222.epil, %28
  %indvars.iv.next29.epil = add nuw nsw i64 %indvars.iv28.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph24.epil, !llvm.loop !18

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph24.epil, %.preheader16, %.preheader
  %.012.lcssa = phi i32 [ 0, %.preheader ], [ 0, %.preheader16 ], [ %spec.select.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select.epil, %.lr.ph24.epil ]
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.012.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0

.lr.ph24:                                         ; preds = %.lr.ph24, %.lr.ph24.preheader.new
  %indvars.iv28 = phi i64 [ 1, %.lr.ph24.preheader.new ], [ %indvars.iv.next29.3, %.lr.ph24 ]
  %.01222 = phi i32 [ 0, %.lr.ph24.preheader.new ], [ %spec.select.3, %.lr.ph24 ]
  %niter = phi i64 [ 0, %.lr.ph24.preheader.new ], [ %niter.next.3, %.lr.ph24 ]
  %30 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %indvars.iv28, i32 3
  %31 = load i8, ptr %30, align 4, !tbaa !15, !range !16, !noundef !17
  %32 = zext nneg i8 %31 to i32
  %spec.select = add nuw nsw i32 %.01222, %32
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %33 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %indvars.iv.next29, i32 3
  %34 = load i8, ptr %33, align 4, !tbaa !15, !range !16, !noundef !17
  %35 = zext nneg i8 %34 to i32
  %spec.select.1 = add nuw nsw i32 %spec.select, %35
  %indvars.iv.next29.1 = add nuw nsw i64 %indvars.iv28, 2
  %36 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %indvars.iv.next29.1, i32 3
  %37 = load i8, ptr %36, align 4, !tbaa !15, !range !16, !noundef !17
  %38 = zext nneg i8 %37 to i32
  %spec.select.2 = add nuw nsw i32 %spec.select.1, %38
  %indvars.iv.next29.2 = add nuw nsw i64 %indvars.iv28, 3
  %39 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %indvars.iv.next29.2, i32 3
  %40 = load i8, ptr %39, align 4, !tbaa !15, !range !16, !noundef !17
  %41 = zext nneg i8 %40 to i32
  %spec.select.3 = add nuw nsw i32 %spec.select.2, %41
  %indvars.iv.next29.3 = add nuw nsw i64 %indvars.iv28, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph24, !llvm.loop !20
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress norecurse 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 #4 = { nofree nounwind "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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 4}
!12 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !6, i64 8, !13, i64 12}
!13 = !{!"bool", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = !{!12, !13, i64 12}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}
!20 = distinct !{!20, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass