; LLVM IR from eyangch/competitive-programming :: Codeforces/1626 (e)

; 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<edge, std::allocator<edge>>::_Vector_impl" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl" = type { %"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%struct.edge = type { i64, i64 }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@N = external dso_local global i64, align 8
@ans = external dso_local global [300000 x i64], align 16
@C = external dso_local global [300000 x i8], align 16
@graph = external dso_local global [300000 x %"class.std::vector"], align 16
@active = external dso_local global [300000 x %"class.std::set"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5dfs_exx(i64 noundef, i64 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 @_Z5dfs_ax(i64 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca %struct.edge, align 8
  %7 = alloca %struct.edge, align 8
  %8 = alloca i64, align 8
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca i64, align 8
  %11 = alloca %"struct.std::pair", align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %15 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %16 = getelementptr i8, ptr %15, i64 -24
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %17
  %19 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %18, ptr noundef null)
  %20 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %22

22:                                               ; preds = %31, %0
  %23 = load i64, ptr %2, align 8, !tbaa !8
  %24 = load i64, ptr @N, align 8, !tbaa !8
  %25 = icmp slt i64 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  br label %34

27:                                               ; preds = %22
  %28 = load i64, ptr %2, align 8, !tbaa !8
  %29 = getelementptr inbounds [300000 x i8], ptr @C, i64 0, i64 %28
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERb(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %29)
  br label %31

31:                                               ; preds = %27
  %32 = load i64, ptr %2, align 8, !tbaa !8
  %33 = add nsw i64 %32, 1
  store i64 %33, ptr %2, align 8, !tbaa !8
  br label %22, !llvm.loop !11

34:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %35

35:                                               ; preds = %78, %34
  %36 = load i64, ptr %3, align 8, !tbaa !8
  %37 = load i64, ptr @N, align 8, !tbaa !8
  %38 = sub nsw i64 %37, 1
  %39 = icmp slt i64 %36, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %81

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %44 = load i64, ptr %4, align 8, !tbaa !8
  %45 = add nsw i64 %44, -1
  store i64 %45, ptr %4, align 8, !tbaa !8
  %46 = load i64, ptr %5, align 8, !tbaa !8
  %47 = add nsw i64 %46, -1
  store i64 %47, ptr %5, align 8, !tbaa !8
  %48 = load i64, ptr %4, align 8, !tbaa !8
  %49 = getelementptr inbounds [300000 x %"class.std::vector"], ptr @graph, i64 0, i64 %48
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  %50 = getelementptr inbounds %struct.edge, ptr %6, i32 0, i32 0
  %51 = load i64, ptr %5, align 8, !tbaa !8
  store i64 %51, ptr %50, align 8, !tbaa !13
  %52 = getelementptr inbounds %struct.edge, ptr %6, i32 0, i32 1
  store i64 0, ptr %52, align 8, !tbaa !15
  call void @_ZNSt6vectorI4edgeSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %49, ptr noundef nonnull align 8 dereferenceable(16) %6)
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  %53 = load i64, ptr %5, align 8, !tbaa !8
  %54 = getelementptr inbounds [300000 x %"class.std::vector"], ptr @graph, i64 0, i64 %53
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  %55 = getelementptr inbounds %struct.edge, ptr %7, i32 0, i32 0
  %56 = load i64, ptr %4, align 8, !tbaa !8
  store i64 %56, ptr %55, align 8, !tbaa !13
  %57 = getelementptr inbounds %struct.edge, ptr %7, i32 0, i32 1
  store i64 0, ptr %57, align 8, !tbaa !15
  call void @_ZNSt6vectorI4edgeSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %54, ptr noundef nonnull align 8 dereferenceable(16) %7)
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  %58 = load i64, ptr %4, align 8, !tbaa !8
  %59 = getelementptr inbounds [300000 x %"class.std::set"], ptr @active, i64 0, i64 %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %60 = load i64, ptr %4, align 8, !tbaa !8
  %61 = getelementptr inbounds [300000 x %"class.std::set"], ptr @active, i64 0, i64 %60
  %62 = call noundef i64 @_ZNKSt3setIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %61) #6
  store i64 %62, ptr %8, align 8, !tbaa !8
  %63 = call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %59, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %64 = getelementptr inbounds { ptr, i8 }, ptr %9, i32 0, i32 0
  %65 = extractvalue { ptr, i8 } %63, 0
  store ptr %65, ptr %64, align 8
  %66 = getelementptr inbounds { ptr, i8 }, ptr %9, i32 0, i32 1
  %67 = extractvalue { ptr, i8 } %63, 1
  store i8 %67, ptr %66, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %68 = load i64, ptr %5, align 8, !tbaa !8
  %69 = getelementptr inbounds [300000 x %"class.std::set"], ptr @active, i64 0, i64 %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %70 = load i64, ptr %5, align 8, !tbaa !8
  %71 = getelementptr inbounds [300000 x %"class.std::set"], ptr @active, i64 0, i64 %70
  %72 = call noundef i64 @_ZNKSt3setIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %71) #6
  store i64 %72, ptr %10, align 8, !tbaa !8
  %73 = call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %69, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %74 = getelementptr inbounds { ptr, i8 }, ptr %11, i32 0, i32 0
  %75 = extractvalue { ptr, i8 } %73, 0
  store ptr %75, ptr %74, align 8
  %76 = getelementptr inbounds { ptr, i8 }, ptr %11, i32 0, i32 1
  %77 = extractvalue { ptr, i8 } %73, 1
  store i8 %77, ptr %76, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %78

78:                                               ; preds = %41
  %79 = load i64, ptr %3, align 8, !tbaa !8
  %80 = add nsw i64 %79, 1
  store i64 %80, ptr %3, align 8, !tbaa !8
  br label %35, !llvm.loop !16

81:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store i64 0, ptr %12, align 8, !tbaa !8
  br label %82

82:                                               ; preds = %95, %81
  %83 = load i64, ptr %12, align 8, !tbaa !8
  %84 = load i64, ptr @N, align 8, !tbaa !8
  %85 = icmp slt i64 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %98

87:                                               ; preds = %82
  %88 = load i64, ptr %12, align 8, !tbaa !8
  %89 = getelementptr inbounds [300000 x i8], ptr @C, i64 0, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !17, !range !19, !noundef !20
  %91 = trunc i8 %90 to i1
  br i1 %91, label %92, label %94

92:                                               ; preds = %87
  %93 = load i64, ptr %12, align 8, !tbaa !8
  call void @_Z5dfs_exx(i64 noundef %93, i64 noundef -1)
  br label %94

94:                                               ; preds = %92, %87
  br label %95

95:                                               ; preds = %94
  %96 = load i64, ptr %12, align 8, !tbaa !8
  %97 = add nsw i64 %96, 1
  store i64 %97, ptr %12, align 8, !tbaa !8
  br label %82, !llvm.loop !21

98:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 0, ptr %13, align 8, !tbaa !8
  br label %99

99:                                               ; preds = %114, %98
  %100 = load i64, ptr %13, align 8, !tbaa !8
  %101 = load i64, ptr @N, align 8, !tbaa !8
  %102 = icmp slt i64 %100, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %117

104:                                              ; preds = %99
  %105 = load i64, ptr %13, align 8, !tbaa !8
  %106 = getelementptr inbounds [300000 x i8], ptr @C, i64 0, i64 %105
  %107 = load i8, ptr %106, align 1, !tbaa !17, !range !19, !noundef !20
  %108 = trunc i8 %107 to i1
  br i1 %108, label %109, label %113

109:                                              ; preds = %104
  %110 = load i64, ptr %13, align 8, !tbaa !8
  %111 = getelementptr inbounds [300000 x i64], ptr @ans, i64 0, i64 %110
  store i64 2, ptr %111, align 8, !tbaa !8
  %112 = load i64, ptr %13, align 8, !tbaa !8
  call void @_Z5dfs_ax(i64 noundef %112)
  br label %113

113:                                              ; preds = %109, %104
  br label %114

114:                                              ; preds = %113
  %115 = load i64, ptr %13, align 8, !tbaa !8
  %116 = add nsw i64 %115, 1
  store i64 %116, ptr %13, align 8, !tbaa !8
  br label %99, !llvm.loop !22

117:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store i64 0, ptr %14, align 8, !tbaa !8
  br label %118

118:                                              ; preds = %130, %117
  %119 = load i64, ptr %14, align 8, !tbaa !8
  %120 = load i64, ptr @N, align 8, !tbaa !8
  %121 = icmp slt i64 %119, %120
  br i1 %121, label %123, label %122

122:                                              ; preds = %118
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %133

123:                                              ; preds = %118
  %124 = load i64, ptr %14, align 8, !tbaa !8
  %125 = getelementptr inbounds [300000 x i64], ptr @ans, i64 0, i64 %124
  %126 = load i64, ptr %125, align 8, !tbaa !8
  %127 = icmp sgt i64 %126, 0
  %128 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i1 noundef zeroext %127)
  %129 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %128, i8 noundef signext 32)
  br label %130

130:                                              ; preds = %123
  %131 = load i64, ptr %14, align 8, !tbaa !8
  %132 = add nsw i64 %131, 1
  store i64 %132, ptr %14, align 8, !tbaa !8
  br label %118, !llvm.loop !23

133:                                              ; preds = %122
  %134 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  %135 = load i32, ptr %1, align 4
  ret i32 %135
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #3 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #4

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERb(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt3setIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8), i1 noundef zeroext) #0 align 2

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 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 #3 = { 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 #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 = { inlinehint 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 #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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !9, i64 0}
!14 = !{!"_ZTS4edge", !9, i64 0, !9, i64 8}
!15 = !{!14, !9, i64 8}
!16 = distinct !{!16, !12}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !10, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}


; 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<edge, std::allocator<edge>>::_Vector_impl" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl" = type { %"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%struct.edge = type { i64, i64 }

@N = external dso_local global i64, align 8
@ans = external dso_local local_unnamed_addr global [300000 x i64], align 16
@C = external dso_local global [300000 x i8], align 16
@graph = external dso_local global [300000 x %"class.std::vector"], align 16
@active = external dso_local global [300000 x %"class.std::set"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5dfs_exx(i64 noundef, i64 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 @_Z5dfs_ax(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca %struct.edge, align 8
  %4 = alloca %struct.edge, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %14 = load i64, ptr @N, align 8, !tbaa !8
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

.preheader26:                                     ; preds = %.lr.ph
  %16 = icmp sgt i64 %22, 1
  br i1 %16, label %.lr.ph29, label %.preheader25

.lr.ph29:                                         ; preds = %.preheader26
  %17 = getelementptr inbounds i8, ptr %3, i64 8
  %18 = getelementptr inbounds i8, ptr %4, i64 8
  br label %26

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.02227 = phi i64 [ %21, %.lr.ph ], [ 0, %0 ]
  %19 = getelementptr inbounds [300000 x i8], ptr @C, i64 0, i64 %.02227
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERb(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %19)
  %21 = add nuw nsw i64 %.02227, 1
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %.lr.ph, label %.preheader26, !llvm.loop !11

.preheader25:                                     ; preds = %26, %.preheader26
  %24 = phi i64 [ %22, %.preheader26 ], [ %46, %26 ]
  %25 = icmp sgt i64 %24, 0
  br i1 %25, label %.lr.ph31, label %._crit_edge

26:                                               ; preds = %.lr.ph29, %26
  %.02328 = phi i64 [ 0, %.lr.ph29 ], [ %45, %26 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %29 = load i64, ptr %1, align 8, !tbaa !8
  %30 = add nsw i64 %29, -1
  store i64 %30, ptr %1, align 8, !tbaa !8
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = add nsw i64 %31, -1
  store i64 %32, ptr %2, align 8, !tbaa !8
  %33 = getelementptr inbounds [300000 x %"class.std::vector"], ptr @graph, i64 0, i64 %30
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  store i64 %32, ptr %3, align 8, !tbaa !13
  store i64 0, ptr %17, align 8, !tbaa !15
  call void @_ZNSt6vectorI4edgeSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %33, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [300000 x %"class.std::vector"], ptr @graph, i64 0, i64 %34
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  %36 = load i64, ptr %1, align 8, !tbaa !8
  store i64 %36, ptr %4, align 8, !tbaa !13
  store i64 0, ptr %18, align 8, !tbaa !15
  call void @_ZNSt6vectorI4edgeSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %35, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  %37 = load i64, ptr %1, align 8, !tbaa !8
  %38 = getelementptr inbounds [300000 x %"class.std::set"], ptr @active, i64 0, i64 %37
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %39 = call noundef i64 @_ZNKSt3setIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %38) #6
  store i64 %39, ptr %5, align 8, !tbaa !8
  %40 = call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %38, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  %41 = load i64, ptr %2, align 8, !tbaa !8
  %42 = getelementptr inbounds [300000 x %"class.std::set"], ptr @active, i64 0, i64 %41
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %43 = call noundef i64 @_ZNKSt3setIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %42) #6
  store i64 %43, ptr %6, align 8, !tbaa !8
  %44 = call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %42, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %45 = add nuw nsw i64 %.02328, 1
  %46 = load i64, ptr @N, align 8, !tbaa !8
  %47 = add nsw i64 %46, -1
  %48 = icmp slt i64 %45, %47
  br i1 %48, label %26, label %.preheader25, !llvm.loop !16

.preheader24:                                     ; preds = %55
  %49 = icmp sgt i64 %56, 0
  br i1 %49, label %.lr.ph33, label %._crit_edge

.lr.ph31:                                         ; preds = %.preheader25, %55
  %50 = phi i64 [ %56, %55 ], [ %24, %.preheader25 ]
  %.02130 = phi i64 [ %57, %55 ], [ 0, %.preheader25 ]
  %51 = getelementptr inbounds [300000 x i8], ptr @C, i64 0, i64 %.02130
  %52 = load i8, ptr %51, align 1, !tbaa !17, !range !19, !noundef !20
  %53 = trunc nuw i8 %52 to i1
  br i1 %53, label %54, label %55

54:                                               ; preds = %.lr.ph31
  call void @_Z5dfs_exx(i64 noundef %.02130, i64 noundef -1)
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  br label %55

55:                                               ; preds = %.lr.ph31, %54
  %56 = phi i64 [ %50, %.lr.ph31 ], [ %.pre, %54 ]
  %57 = add nuw nsw i64 %.02130, 1
  %58 = icmp slt i64 %57, %56
  br i1 %58, label %.lr.ph31, label %.preheader24, !llvm.loop !21

.preheader:                                       ; preds = %66
  %59 = icmp sgt i64 %67, 0
  br i1 %59, label %.lr.ph35, label %._crit_edge

.lr.ph33:                                         ; preds = %.preheader24, %66
  %60 = phi i64 [ %67, %66 ], [ %56, %.preheader24 ]
  %.02032 = phi i64 [ %68, %66 ], [ 0, %.preheader24 ]
  %61 = getelementptr inbounds [300000 x i8], ptr @C, i64 0, i64 %.02032
  %62 = load i8, ptr %61, align 1, !tbaa !17, !range !19, !noundef !20
  %63 = trunc nuw i8 %62 to i1
  br i1 %63, label %64, label %66

64:                                               ; preds = %.lr.ph33
  %65 = getelementptr inbounds [300000 x i64], ptr @ans, i64 0, i64 %.02032
  store i64 2, ptr %65, align 8, !tbaa !8
  call void @_Z5dfs_ax(i64 noundef %.02032)
  %.pre36 = load i64, ptr @N, align 8, !tbaa !8
  br label %66

66:                                               ; preds = %.lr.ph33, %64
  %67 = phi i64 [ %60, %.lr.ph33 ], [ %.pre36, %64 ]
  %68 = add nuw nsw i64 %.02032, 1
  %69 = icmp slt i64 %68, %67
  br i1 %69, label %.lr.ph33, label %.preheader, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph35, %0, %.preheader25, %.preheader24, %.preheader
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  ret i32 0

.lr.ph35:                                         ; preds = %.preheader, %.lr.ph35
  %.034 = phi i64 [ %76, %.lr.ph35 ], [ 0, %.preheader ]
  %71 = getelementptr inbounds [300000 x i64], ptr @ans, i64 0, i64 %.034
  %72 = load i64, ptr %71, align 8, !tbaa !8
  %73 = icmp sgt i64 %72, 0
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i1 noundef zeroext %73)
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %74, i8 noundef signext 32)
  %76 = add nuw nsw i64 %.034, 1
  %77 = load i64, ptr @N, align 8, !tbaa !8
  %78 = icmp slt i64 %76, %77
  br i1 %78, label %.lr.ph35, label %._crit_edge, !llvm.loop !23
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #3 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERb(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt3setIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8), i1 noundef zeroext) local_unnamed_addr #0 align 2

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 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 #3 = { 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 #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 = { inlinehint 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 #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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !9, i64 0}
!14 = !{!"_ZTS4edge", !9, i64 0, !9, i64 8}
!15 = !{!14, !9, i64 8}
!16 = distinct !{!16, !12}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !10, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}


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