; LLVM IR from ravireddy07/cpp-book :: src/Code-Chef/VBR_Vibrating-Paths.ll (Z4workv)

; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<Edge, Edge, std::_Identity<Edge>, std::less<Edge>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<Edge, Edge, std::_Identity<Edge>, std::less<Edge>>::_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 }
%struct.Node = type { i32, i32 }
%"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::basic_ostream" = type { ptr, %"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 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@G = external dso_local global [100005 x %"class.std::set"], align 16
@B = external dso_local global i32, align 4
@a = external dso_local global [100005 x %struct.Node], align 16
@ans = external dso_local global %"class.std::vector", align 8
@dgr = external dso_local global [100005 x i32], align 16
@col = external dso_local global [100005 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt3setI4EdgeSt4lessIS0_ESaIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorI4EdgeEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 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 nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z6getvali(i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4workv() #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 i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %111, %0
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = load i32, ptr @B, align 4, !tbaa !5
  %20 = add nsw i32 %18, %19
  %21 = sub nsw i32 %20, 1
  %22 = load i32, ptr @B, align 4, !tbaa !5
  %23 = sdiv i32 %21, %22
  %24 = icmp sle i32 %17, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %16
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  br label %114

26:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = sub nsw i32 %27, 1
  %29 = load i32, ptr @B, align 4, !tbaa !5
  %30 = mul nsw i32 %28, %29
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = load i32, ptr @B, align 4, !tbaa !5
  %34 = mul nsw i32 %32, %33
  store i32 %34, ptr %5, align 4, !tbaa !5
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %36 = load i32, ptr %35, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  store i32 %36, ptr %4, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %109, %26
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 -1061109567, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %39 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %39, ptr %8, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %95, %38
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = icmp sle i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 7, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %98

45:                                               ; preds = %40
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %47
  %49 = getelementptr inbounds %struct.Node, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %51
  %53 = call noundef zeroext i1 @_ZNKSt3setI4EdgeSt4lessIS0_ESaIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) %52) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  br i1 %53, label %76, label %54

54:                                               ; preds = %45
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %56
  %58 = getelementptr inbounds %struct.Node, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %60
  %62 = call ptr @_ZNKSt3setI4EdgeSt4lessIS0_ESaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %61) #6
  %63 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %9, i32 0, i32 0
  store ptr %62, ptr %63, align 8
  %64 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorI4EdgeEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #6
  %65 = getelementptr inbounds %struct.Edge, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !13
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.Node, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %70, align 8, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100005 x i32], ptr @dgr, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = icmp slt i32 %66, %74
  br label %76

76:                                               ; preds = %54, %45
  %77 = phi i1 [ false, %45 ], [ %75, %54 ]
  %78 = xor i1 %77, true
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br i1 %78, label %79, label %80

79:                                               ; preds = %76
  br label %95

80:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %81 = load i32, ptr %8, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %82
  %84 = getelementptr inbounds %struct.Node, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !11
  %86 = call noundef i64 @_Z6getvali(i32 noundef %85)
  store i64 %86, ptr %10, align 8, !tbaa !9
  %87 = load i64, ptr %10, align 8, !tbaa !9
  %88 = load i64, ptr %6, align 8, !tbaa !9
  %89 = icmp sgt i64 %87, %88
  br i1 %89, label %90, label %94

90:                                               ; preds = %80
  %91 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %91, ptr %6, align 8, !tbaa !9
  %92 = load i32, ptr %8, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  store i64 %93, ptr %7, align 8, !tbaa !9
  br label %94

94:                                               ; preds = %90, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %95

95:                                               ; preds = %94, %79
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %8, align 4, !tbaa !5
  br label %40, !llvm.loop !15

98:                                               ; preds = %44
  %99 = load i64, ptr %6, align 8, !tbaa !9
  %100 = icmp eq i64 %99, -1061109567
  br i1 %100, label %101, label %102

101:                                              ; preds = %98
  store i32 6, ptr %2, align 4
  br label %107

102:                                              ; preds = %98
  %103 = load i64, ptr %7, align 8, !tbaa !9
  %104 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %103
  %105 = getelementptr inbounds %struct.Node, ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 8, !tbaa !11
  call void @_Z5erasei(i32 noundef %106)
  store i32 0, ptr %2, align 4
  br label %107

107:                                              ; preds = %102, %101
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %108 = load i32, ptr %2, align 4
  switch i32 %108, label %150 [
    i32 0, label %109
    i32 6, label %110
  ]

109:                                              ; preds = %107
  br label %37, !llvm.loop !17

110:                                              ; preds = %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %1, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %1, align 4, !tbaa !5
  br label %16, !llvm.loop !18

114:                                              ; preds = %25
  %115 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @ans) #6
  %116 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %115)
  %117 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %116, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store ptr @ans, ptr %11, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %118 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @ans) #6
  %119 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %118, ptr %119, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %120 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @ans) #6
  %121 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %120, ptr %121, align 8
  br label %122

122:                                              ; preds = %130, %114
  %123 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %13) #6
  br i1 %123, label %125, label %124

124:                                              ; preds = %122
  store i32 10, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %132

125:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %126 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %12) #6
  %127 = load i32, ptr %126, align 4, !tbaa !5
  store i32 %127, ptr %14, align 4, !tbaa !5
  %128 = load i32, ptr %14, align 4, !tbaa !5
  %129 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %128)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %130

130:                                              ; preds = %125
  %131 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %12) #6
  br label %122

132:                                              ; preds = %124
  %133 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %145, %132
  %135 = load i32, ptr %15, align 4, !tbaa !5
  %136 = load i32, ptr @n, align 4, !tbaa !5
  %137 = icmp sle i32 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  store i32 12, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %148

139:                                              ; preds = %134
  %140 = load i32, ptr %15, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [100005 x i32], ptr @col, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %143)
  br label %145

145:                                              ; preds = %139
  %146 = load i32, ptr %15, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %15, align 4, !tbaa !5
  br label %134, !llvm.loop !21

148:                                              ; preds = %138
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.5)
  ret void

150:                                              ; preds = %107
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = { 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 #5 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}
!19 = !{!20, !20, i64 0}
!20 = !{!"any pointer", !7, i64 0}
!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.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<Edge, Edge, std::_Identity<Edge>, std::less<Edge>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<Edge, Edge, std::_Identity<Edge>, std::less<Edge>>::_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 }
%struct.Node = type { i32, i32 }
%"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::basic_ostream" = type { ptr, %"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 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@G = external dso_local global [100005 x %"class.std::set"], align 16
@B = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global [100005 x %struct.Node], align 16
@ans = external dso_local global %"class.std::vector", align 8
@dgr = external dso_local local_unnamed_addr global [100005 x i32], align 16
@col = external dso_local local_unnamed_addr global [100005 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt3setI4EdgeSt4lessIS0_ESaIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; 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 nounwind uwtable
declare dso_local ptr @_ZNKSt3setI4EdgeSt4lessIS0_ESaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorI4EdgeEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 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 nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z6getvali(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4workv() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = load i32, ptr @B, align 4, !tbaa !5
  %7 = add i32 %5, -1
  %8 = add i32 %7, %6
  %9 = sdiv i32 %8, %6
  %.not44 = icmp slt i32 %9, 1
  br i1 %.not44, label %._crit_edge, label %.lr.ph46

._crit_edge:                                      ; preds = %.split43.us, %0
  %10 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @ans) #7
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %10)
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %13 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @ans) #7
  store ptr %13, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %14 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @ans) #7
  store ptr %14, ptr %4, align 8
  %15 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  br i1 %15, label %.lr.ph48, label %._crit_edge49

.lr.ph46:                                         ; preds = %0, %.split43.us
  %indvars.iv = phi i32 [ %indvars.iv.next, %.split43.us ], [ 0, %0 ]
  %16 = phi i32 [ %51, %.split43.us ], [ %6, %0 ]
  %.02345 = phi i32 [ %49, %.split43.us ], [ 1, %0 ]
  %17 = add nsw i32 %.02345, -1
  %18 = mul nsw i32 %16, %17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %19 = mul nsw i32 %16, %.02345
  store i32 %19, ptr %1, align 4, !tbaa !5
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %21 = load i32, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %.not32.not37 = icmp slt i32 %18, %21
  br i1 %.not32.not37, label %.lr.ph.us.preheader, label %.split43.us

.lr.ph.us.preheader:                              ; preds = %.lr.ph46
  %22 = mul i32 %16, %indvars.iv
  %23 = sext i32 %22 to i64
  %wide.trip.count = sext i32 %21 to i64
  br label %.lr.ph.us

24:                                               ; preds = %._crit_edge.us
  %25 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %.229.us
  %26 = load i32, ptr %25, align 8, !tbaa !9
  call void @_Z5erasei(i32 noundef %26)
  br label %.lr.ph.us.backedge

.lr.ph.us:                                        ; preds = %.lr.ph.us.backedge, %.lr.ph.us.preheader
  %indvars.iv55 = phi i64 [ %23, %.lr.ph.us.preheader ], [ %indvars.iv55.be, %.lr.ph.us.backedge ]
  %.02539.us = phi i64 [ -1061109567, %.lr.ph.us.preheader ], [ %.02539.us.be, %.lr.ph.us.backedge ]
  %.02738.us = phi i64 [ 0, %.lr.ph.us.preheader ], [ %.02738.us.be, %.lr.ph.us.backedge ]
  %indvars.iv.next56 = add nsw i64 %indvars.iv55, 1
  %27 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %indvars.iv.next56
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %29
  %31 = call noundef zeroext i1 @_ZNKSt3setI4EdgeSt4lessIS0_ESaIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) %30) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  br i1 %31, label %.critedge.us, label %32

32:                                               ; preds = %.lr.ph.us
  %33 = load i32, ptr %27, align 8, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %34
  %36 = call ptr @_ZNKSt3setI4EdgeSt4lessIS0_ESaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %35) #7
  store ptr %36, ptr %2, align 8
  %37 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorI4EdgeEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = load i32, ptr %27, align 8, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100005 x i32], ptr @dgr, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = icmp slt i32 %38, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br i1 %43, label %44, label %47

44:                                               ; preds = %32
  %45 = call noundef i64 @_Z6getvali(i32 noundef %39)
  %46 = icmp sgt i64 %45, %.02539.us
  %spec.select.us = select i1 %46, i64 %indvars.iv.next56, i64 %.02738.us
  %spec.select33.us = call i64 @llvm.smax.i64(i64 %45, i64 %.02539.us)
  br label %47

.critedge.us:                                     ; preds = %.lr.ph.us
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %47

47:                                               ; preds = %.critedge.us, %44, %32
  %.229.us = phi i64 [ %.02738.us, %32 ], [ %spec.select.us, %44 ], [ %.02738.us, %.critedge.us ]
  %.2.us = phi i64 [ %.02539.us, %32 ], [ %spec.select33.us, %44 ], [ %.02539.us, %.critedge.us ]
  %exitcond.not = icmp eq i64 %indvars.iv.next56, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us, label %.lr.ph.us.backedge

.lr.ph.us.backedge:                               ; preds = %47, %24
  %indvars.iv55.be = phi i64 [ %indvars.iv.next56, %47 ], [ %23, %24 ]
  %.02539.us.be = phi i64 [ %.2.us, %47 ], [ -1061109567, %24 ]
  %.02738.us.be = phi i64 [ %.229.us, %47 ], [ 0, %24 ]
  br label %.lr.ph.us, !llvm.loop !13

._crit_edge.us:                                   ; preds = %47
  %48 = icmp eq i64 %.2.us, -1061109567
  br i1 %48, label %.split43.us, label %24

.split43.us:                                      ; preds = %._crit_edge.us, %.lr.ph46
  %49 = add nuw nsw i32 %.02345, 1
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = load i32, ptr @B, align 4, !tbaa !5
  %52 = add i32 %50, -1
  %53 = add i32 %52, %51
  %54 = sdiv i32 %53, %51
  %.not.not = icmp slt i32 %.02345, %54
  %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
  br i1 %.not.not, label %.lr.ph46, label %._crit_edge, !llvm.loop !15

._crit_edge49:                                    ; preds = %.lr.ph48, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.5)
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %.not3150 = icmp slt i32 %56, 1
  br i1 %.not3150, label %._crit_edge54, label %.lr.ph53

.lr.ph48:                                         ; preds = %._crit_edge, %.lr.ph48
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #7
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %58)
  %60 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #7
  %61 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  br i1 %61, label %.lr.ph48, label %._crit_edge49

._crit_edge54:                                    ; preds = %.lr.ph53, %._crit_edge49
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.5)
  ret void

.lr.ph53:                                         ; preds = %._crit_edge49, %.lr.ph53
  %indvars.iv58 = phi i64 [ %indvars.iv.next59, %.lr.ph53 ], [ 1, %._crit_edge49 ]
  %63 = getelementptr inbounds [100005 x i32], ptr @col, i64 0, i64 %indvars.iv58
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %64)
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %.not31.not = icmp slt i64 %indvars.iv58, %67
  br i1 %.not31.not, label %.lr.ph53, label %._crit_edge54, !llvm.loop !16
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #6

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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = { 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 #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass