; LLVM IR from VastoLorde95/Competitive-Programming :: Hackerrank/Week of Code/Week 12/Favorite Sequence (fav)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@present = external dso_local global [1000001 x i32], align 16
@indegree = external dso_local global [1000001 x i32], align 16
@cur = external dso_local global i32, align 4
@nxt = external dso_local global i32, align 4
@adj_list = external dso_local global [1000001 x %"class.std::vector"], align 16
@q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  br label %8

8:                                                ; preds = %40, %0
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @n, align 4, !tbaa !5
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %41

12:                                               ; preds = %8
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @k)
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @cur)
  %15 = load i32, ptr @cur, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1000001 x i32], ptr @present, i64 0, i64 %16
  store i32 1, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %37, %12
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @k, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @nxt)
  %25 = load i32, ptr @nxt, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %27, align 4, !tbaa !5
  %30 = load i32, ptr @cur, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %31
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %32, ptr noundef nonnull align 4 dereferenceable(4) @nxt)
  %33 = load i32, ptr @nxt, align 4, !tbaa !5
  store i32 %33, ptr @cur, align 4, !tbaa !5
  %34 = load i32, ptr @cur, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1000001 x i32], ptr @present, i64 0, i64 %35
  store i32 1, ptr %36, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %23
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !9

40:                                               ; preds = %22
  br label %8, !llvm.loop !11

41:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %62, %41
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = icmp sle i32 %43, 1000000
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %42
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1000001 x i32], ptr @present, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %61

52:                                               ; preds = %46
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %61

58:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = sub nsw i32 0, %59
  store i32 %60, ptr %4, align 4, !tbaa !5
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %61

61:                                               ; preds = %58, %52, %46
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !5
  br label %42, !llvm.loop !12

65:                                               ; preds = %45
  br label %66

66:                                               ; preds = %120, %65
  %67 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %68 = xor i1 %67, true
  br i1 %68, label %69, label %121

69:                                               ; preds = %66
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = sub nsw i32 0, %71
  store i32 %72, ptr @cur, align 4, !tbaa !5
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %73 = load i32, ptr @cur, align 4, !tbaa !5
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %73)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %117, %69
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = load i32, ptr @cur, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %79
  %81 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %80) #5
  %82 = icmp ult i64 %77, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %120

84:                                               ; preds = %75
  %85 = load i32, ptr @cur, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %86
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %87, i64 noundef %89) #5
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = add nsw i32 %94, -1
  store i32 %95, ptr %93, align 4, !tbaa !5
  %96 = load i32, ptr @cur, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %97
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %98, i64 noundef %100) #5
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = icmp eq i32 %105, 0
  br i1 %106, label %107, label %116

107:                                              ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %108 = load i32, ptr @cur, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %109
  %111 = load i32, ptr %5, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %110, i64 noundef %112) #5
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = sub nsw i32 0, %114
  store i32 %115, ptr %6, align 4, !tbaa !5
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %116

116:                                              ; preds = %107, %84
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %5, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %5, align 4, !tbaa !5
  br label %75, !llvm.loop !13

120:                                              ; preds = %83
  br label %66, !llvm.loop !14

121:                                              ; preds = %66
  %122 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %123 = load i32, ptr %1, align 4
  ret i32 %123
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #4 align 2

attributes #0 = { 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 #1 = { "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 = { 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 #4 = { 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 #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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@present = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@indegree = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@cur = external dso_local global i32, align 4
@nxt = external dso_local global i32, align 4
@adj_list = external dso_local global [1000001 x %"class.std::vector"], align 16
@q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @n, align 4, !tbaa !5
  %.not20 = icmp eq i32 %4, 0
  br i1 %.not20, label %.preheader17.preheader, label %.lr.ph21

.preheader17.preheader:                           ; preds = %.loopexit18, %0
  br label %.preheader17

.loopexit18:                                      ; preds = %.lr.ph, %.lr.ph21
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = add nsw i32 %6, -1
  store i32 %7, ptr @n, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.preheader17.preheader, label %.lr.ph21, !llvm.loop !9

.lr.ph21:                                         ; preds = %0, %.loopexit18
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @k)
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @cur)
  %10 = load i32, ptr @cur, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [1000001 x i32], ptr @present, i64 0, i64 %11
  store i32 1, ptr %12, align 4, !tbaa !5
  %13 = load i32, ptr @k, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 1
  br i1 %14, label %.lr.ph, label %.loopexit18

.lr.ph:                                           ; preds = %.lr.ph21, %.lr.ph
  %.01419 = phi i32 [ %27, %.lr.ph ], [ 1, %.lr.ph21 ]
  %15 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @nxt)
  %16 = load i32, ptr @nxt, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %18, align 4, !tbaa !5
  %21 = load i32, ptr @cur, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %22
  tail call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 4 dereferenceable(4) @nxt)
  %24 = load i32, ptr @nxt, align 4, !tbaa !5
  store i32 %24, ptr @cur, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1000001 x i32], ptr @present, i64 0, i64 %25
  store i32 1, ptr %26, align 4, !tbaa !5
  %27 = add nuw nsw i32 %.01419, 1
  %28 = load i32, ptr @k, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %.lr.ph, label %.loopexit18, !llvm.loop !11

.preheader:                                       ; preds = %40
  %30 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  br i1 %30, label %._crit_edge, label %.lr.ph25

.preheader17:                                     ; preds = %.preheader17.preheader, %40
  %indvars.iv = phi i64 [ %indvars.iv.next, %40 ], [ 0, %.preheader17.preheader ]
  %31 = getelementptr inbounds [1000001 x i32], ptr @present, i64 0, i64 %indvars.iv
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.not16 = icmp eq i32 %32, 0
  br i1 %.not16, label %40, label %33

33:                                               ; preds = %.preheader17
  %34 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %indvars.iv
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %38 = trunc i64 %indvars.iv to i32
  %39 = sub i32 0, %38
  store i32 %39, ptr %1, align 4, !tbaa !5
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  br label %40

40:                                               ; preds = %.preheader17, %33, %37
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1000001
  br i1 %exitcond.not, label %.preheader, label %.preheader17, !llvm.loop !12

.loopexit:                                        ; preds = %76, %.lr.ph25
  %41 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  br i1 %41, label %._crit_edge, label %.lr.ph25, !llvm.loop !13

.lr.ph25:                                         ; preds = %.preheader, %.loopexit
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sub nsw i32 0, %43
  store i32 %44, ptr @cur, align 4, !tbaa !5
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %45 = load i32, ptr @cur, align 4, !tbaa !5
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %45)
  %47 = load i32, ptr @cur, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %48
  %50 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %49) #5
  %.not26 = icmp eq i64 %50, 0
  br i1 %.not26, label %.loopexit, label %.lr.ph24

.lr.ph24:                                         ; preds = %.lr.ph25, %76
  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %76 ], [ 0, %.lr.ph25 ]
  %51 = load i32, ptr @cur, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %52
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %indvars.iv28) #5
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = add nsw i32 %58, -1
  store i32 %59, ptr %57, align 4, !tbaa !5
  %60 = load i32, ptr @cur, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %61
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %indvars.iv28) #5
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1000001 x i32], ptr @indegree, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %76

69:                                               ; preds = %.lr.ph24
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %70 = load i32, ptr @cur, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %71
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %72, i64 noundef %indvars.iv28) #5
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sub nsw i32 0, %74
  store i32 %75, ptr %2, align 4, !tbaa !5
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  br label %76

76:                                               ; preds = %.lr.ph24, %69
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %77 = load i32, ptr @cur, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %78
  %80 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %79) #5
  %81 = icmp ugt i64 %80, %indvars.iv.next29
  br i1 %81, label %.lr.ph24, label %.loopexit, !llvm.loop !14

._crit_edge:                                      ; preds = %.loopexit, %.preheader
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  ret i32 0
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 align 2

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass