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

; 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.EDGE = type { i32, i32, i32 }
%struct.Node = type { i32, i32 }
%"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 { i32, i32 }
%"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 i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@G = external dso_local global [100005 x %"class.std::set"], align 16
@val = external dso_local global [100005 x i32], align 16
@limw = external dso_local global i32, align 4
@B = external dso_local global i32, align 4
@ed = external dso_local global [100005 x %struct.EDGE], align 16
@a = external dso_local global [100005 x %struct.Node], align 16
@dgr = external dso_local global [100005 x i32], align 16
@Sum = external dso_local global i32, align 4
@col = external dso_local global [100005 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmp4NodeS_(i64, i64) #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 nounwind uwtable
declare dso_local void @_ZN4EdgeC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4workv() #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2 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)) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8prework2v() #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.Edge, align 4
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca %struct.Edge, align 4
  %10 = alloca %"struct.std::pair", align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 4 dereferenceable(4) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %27, %0
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %30

22:                                               ; preds = %17
  %23 = call noundef i32 @_Z4readv()
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100005 x i32], ptr @val, i64 0, i64 %25
  store i32 %23, ptr %26, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !9

30:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %75, %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr @m, align 4, !tbaa !5
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

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

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %37 = call noundef i32 @_Z4readv()
  store i32 %37, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %38 = call noundef i32 @_Z4readv()
  store i32 %38, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %39 = call noundef i32 @_Z4readv()
  store i32 %39, ptr %6, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = load i32, ptr %5, align 4, !tbaa !5
  call void @_ZN4EdgeC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %7, i32 noundef %43, i32 noundef %44)
  %45 = call { ptr, i8 } @_ZNSt3setI4EdgeSt4lessIS0_ESaIS0_EE6insertEOS0_(ptr noundef nonnull align 8 dereferenceable(48) %42, ptr noundef nonnull align 4 dereferenceable(8) %7)
  %46 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 0
  %47 = extractvalue { ptr, i8 } %45, 0
  store ptr %47, ptr %46, align 8
  %48 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 1
  %49 = extractvalue { ptr, i8 } %45, 1
  store i8 %49, ptr %48, align 8
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = load i32, ptr %4, align 4, !tbaa !5
  call void @_ZN4EdgeC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %9, i32 noundef %53, i32 noundef %54)
  %55 = call { ptr, i8 } @_ZNSt3setI4EdgeSt4lessIS0_ESaIS0_EE6insertEOS0_(ptr noundef nonnull align 8 dereferenceable(48) %52, ptr noundef nonnull align 4 dereferenceable(8) %9)
  %56 = getelementptr inbounds { ptr, i8 }, ptr %10, i32 0, i32 0
  %57 = extractvalue { ptr, i8 } %55, 0
  store ptr %57, ptr %56, align 8
  %58 = getelementptr inbounds { ptr, i8 }, ptr %10, i32 0, i32 1
  %59 = extractvalue { ptr, i8 } %55, 1
  store i8 %59, ptr %58, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100005 x %struct.EDGE], ptr @ed, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.EDGE, ptr %63, i32 0, i32 0
  store i32 %60, ptr %64, align 4, !tbaa !11
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100005 x %struct.EDGE], ptr @ed, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.EDGE, ptr %68, i32 0, i32 1
  store i32 %65, ptr %69, align 4, !tbaa !13
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100005 x %struct.EDGE], ptr @ed, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.EDGE, ptr %73, i32 0, i32 2
  store i32 %70, ptr %74, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %75

75:                                               ; preds = %36
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !15

78:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %98, %78
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = icmp sle i32 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %101

84:                                               ; preds = %79
  %85 = load i32, ptr %11, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100005 x i32], ptr @val, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = load i32, ptr %11, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %90
  %92 = getelementptr inbounds %struct.Node, ptr %91, i32 0, i32 1
  store i32 %88, ptr %92, align 4, !tbaa !16
  %93 = load i32, ptr %11, align 4, !tbaa !5
  %94 = load i32, ptr %11, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.Node, ptr %96, i32 0, i32 0
  store i32 %93, ptr %97, align 8, !tbaa !18
  br label %98

98:                                               ; preds = %84
  %99 = load i32, ptr %11, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %11, align 4, !tbaa !5
  br label %79, !llvm.loop !19

101:                                              ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %114, %101
  %103 = load i32, ptr %12, align 4, !tbaa !5
  %104 = load i32, ptr @n, align 4, !tbaa !5
  %105 = icmp sle i32 %103, %104
  br i1 %105, label %107, label %106

106:                                              ; preds = %102
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %117

107:                                              ; preds = %102
  %108 = load i32, ptr %12, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100005 x i32], ptr @col, i64 0, i64 %109
  store i32 1, ptr %110, align 4, !tbaa !5
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100005 x i32], ptr @dgr, i64 0, i64 %112
  store i32 1061109567, ptr %113, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %107
  %115 = load i32, ptr %12, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %12, align 4, !tbaa !5
  br label %102, !llvm.loop !20

117:                                              ; preds = %106
  %118 = load i32, ptr @n, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds %struct.Node, ptr @a, i64 %119
  %121 = getelementptr inbounds %struct.Node, ptr %120, i64 1
  call void @_ZSt4sortIP4NodePFbS0_S0_EEvT_S4_T0_(ptr noundef getelementptr inbounds (%struct.Node, ptr @a, i64 1), ptr noundef %121, ptr noundef @_Z3cmp4NodeS_)
  %122 = load i32, ptr @k, align 4, !tbaa !5
  %123 = icmp ne i32 %122, 1
  br i1 %123, label %124, label %125

124:                                              ; preds = %117
  call void @_Z8prework2v()
  br label %125

125:                                              ; preds = %124, %117
  %126 = load i32, ptr @k, align 4, !tbaa !5
  %127 = icmp ne i32 %126, 1
  br i1 %127, label %128, label %132

128:                                              ; preds = %125
  %129 = load i32, ptr @n, align 4, !tbaa !5
  %130 = icmp eq i32 %129, 1000
  br i1 %130, label %131, label %132

131:                                              ; preds = %128
  store i32 965, ptr @limw, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %131, %128, %125
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = icmp eq i32 %133, 10000
  br i1 %134, label %135, label %136

135:                                              ; preds = %132
  store i32 1, ptr @B, align 4, !tbaa !5
  br label %137

136:                                              ; preds = %132
  store i32 20, ptr @B, align 4, !tbaa !5
  br label %137

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

138:                                              ; preds = %147, %137
  %139 = load i32, ptr %13, align 4, !tbaa !5
  %140 = load i32, ptr @limw, align 4, !tbaa !5
  %141 = icmp sle i32 %139, %140
  br i1 %141, label %143, label %142

142:                                              ; preds = %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %150

143:                                              ; preds = %138
  %144 = load i32, ptr %13, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [100005 x i32], ptr @dgr, i64 0, i64 %145
  store i32 1061109567, ptr %146, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %143
  %148 = load i32, ptr %13, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %13, align 4, !tbaa !5
  br label %138, !llvm.loop !21

150:                                              ; preds = %142
  call void @_Z4workv()
  %151 = load i32, ptr @Sum, align 4, !tbaa !5
  %152 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, i32 noundef %151)
  %153 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %152, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z4readv() #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP4NodePFbS0_S0_EEvT_S4_T0_(ptr noundef, ptr noundef, ptr noundef) #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #5

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4EDGE", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}
!15 = distinct !{!15, !10}
!16 = !{!17, !6, i64 4}
!17 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4}
!18 = !{!17, !6, i64 0}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !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::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.EDGE = type { i32, i32, i32 }
%struct.Node = type { i32, i32 }
%"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 { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@G = external dso_local global [100005 x %"class.std::set"], align 16
@val = external dso_local local_unnamed_addr global [100005 x i32], align 16
@limw = external dso_local local_unnamed_addr global i32, align 4
@B = external dso_local local_unnamed_addr global i32, align 4
@ed = external dso_local local_unnamed_addr global [100005 x %struct.EDGE], align 16
@a = external dso_local global [100005 x %struct.Node], align 16
@dgr = external dso_local local_unnamed_addr global [100005 x i32], align 16
@Sum = external dso_local local_unnamed_addr global i32, align 4
@col = external dso_local local_unnamed_addr global [100005 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmp4NodeS_(i64, i64) #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 nounwind uwtable
declare dso_local void @_ZN4EdgeC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4workv() local_unnamed_addr #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 #2 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)) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8prework2v() local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca %struct.Edge, align 4
  %2 = alloca %struct.Edge, align 4
  %3 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %4 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(4) @k)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %.not45 = icmp slt i32 %6, 1
  br i1 %.not45, label %.preheader44, label %.lr.ph

.preheader44:                                     ; preds = %.lr.ph, %0
  %7 = phi i32 [ %6, %0 ], [ %11, %.lr.ph ]
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %.not3847 = icmp slt i32 %8, 1
  br i1 %.not3847, label %.preheader43, label %.lr.ph49

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %9 = tail call noundef i32 @_Z4readv()
  %10 = getelementptr inbounds [100005 x i32], ptr @val, i64 0, i64 %indvars.iv
  store i32 %9, ptr %10, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %.not.not = icmp slt i64 %indvars.iv, %12
  br i1 %.not.not, label %.lr.ph, label %.preheader44, !llvm.loop !9

.preheader43.loopexit:                            ; preds = %.lr.ph49
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %.preheader43

.preheader43:                                     ; preds = %.preheader43.loopexit, %.preheader44
  %13 = phi i32 [ %.pre, %.preheader43.loopexit ], [ %7, %.preheader44 ]
  %.not3950 = icmp slt i32 %13, 1
  br i1 %.not3950, label %._crit_edge, label %.lr.ph52.preheader

.lr.ph52.preheader:                               ; preds = %.preheader43
  %14 = add nuw i32 %13, 1
  %wide.trip.count = zext i32 %14 to i64
  %15 = zext nneg i32 %13 to i64
  %min.iters.check = icmp ult i32 %13, 4
  br i1 %min.iters.check, label %.lr.ph52.preheader100, label %vector.ph

.lr.ph52.preheader100:                            ; preds = %middle.block, %.lr.ph52.preheader
  %indvars.iv65.ph = phi i64 [ 1, %.lr.ph52.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph52

vector.ph:                                        ; preds = %.lr.ph52.preheader
  %n.vec = and i64 %15, 2147483644
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i32> [ <i32 1, i32 2>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <2 x i32> %vec.ind, <i32 2, i32 2>
  %offset.idx = or disjoint i64 %index, 1
  %16 = or disjoint i64 %index, 3
  %17 = getelementptr inbounds [100005 x i32], ptr @val, i64 0, i64 %offset.idx
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %wide.load = load <2 x i32>, ptr %17, align 4, !tbaa !5
  %wide.load84 = load <2 x i32>, ptr %18, align 4, !tbaa !5
  %19 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %offset.idx
  %20 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %16
  %interleaved.vec = shufflevector <2 x i32> %vec.ind, <2 x i32> %wide.load, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x i32> %interleaved.vec, ptr %19, align 8, !tbaa !5
  %interleaved.vec85 = shufflevector <2 x i32> %step.add, <2 x i32> %wide.load84, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x i32> %interleaved.vec85, ptr %20, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i32> %vec.ind, <i32 4, i32 4>
  %21 = icmp eq i64 %index.next, %n.vec
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %15
  br i1 %cmp.n, label %.preheader, label %.lr.ph52.preheader100

.lr.ph49:                                         ; preds = %.preheader44, %.lr.ph49
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %.lr.ph49 ], [ 1, %.preheader44 ]
  %22 = call noundef i32 @_Z4readv()
  %23 = call noundef i32 @_Z4readv()
  %24 = call noundef i32 @_Z4readv()
  %25 = sext i32 %22 to i64
  %26 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %25
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  call void @_ZN4EdgeC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %1, i32 noundef %24, i32 noundef %23)
  %27 = call { ptr, i8 } @_ZNSt3setI4EdgeSt4lessIS0_ESaIS0_EE6insertEOS0_(ptr noundef nonnull align 8 dereferenceable(48) %26, ptr noundef nonnull align 4 dereferenceable(8) %1)
  %28 = sext i32 %23 to i64
  %29 = getelementptr inbounds [100005 x %"class.std::set"], ptr @G, i64 0, i64 %28
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  call void @_ZN4EdgeC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef %24, i32 noundef %22)
  %30 = call { ptr, i8 } @_ZNSt3setI4EdgeSt4lessIS0_ESaIS0_EE6insertEOS0_(ptr noundef nonnull align 8 dereferenceable(48) %29, ptr noundef nonnull align 4 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %31 = getelementptr inbounds [100005 x %struct.EDGE], ptr @ed, i64 0, i64 %indvars.iv62
  store i32 %22, ptr %31, align 4, !tbaa !14
  %32 = getelementptr inbounds i8, ptr %31, i64 4
  store i32 %23, ptr %32, align 4, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %31, i64 8
  store i32 %24, ptr %33, align 4, !tbaa !17
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %34 = load i32, ptr @m, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %.not38.not = icmp slt i64 %indvars.iv62, %35
  br i1 %.not38.not, label %.lr.ph49, label %.preheader43.loopexit, !llvm.loop !18

.preheader:                                       ; preds = %.lr.ph52, %middle.block
  br i1 %.not3950, label %._crit_edge, label %.lr.ph55.preheader

.lr.ph55.preheader:                               ; preds = %.preheader
  %36 = zext nneg i32 %13 to i64
  %37 = shl nuw nsw i64 %36, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @dgr, i64 4), i8 63, i64 %37, i1 false), !tbaa !5
  %38 = add nuw i32 %13, 1
  %wide.trip.count71 = zext i32 %38 to i64
  %39 = zext nneg i32 %13 to i64
  %min.iters.check88 = icmp ult i32 %13, 8
  br i1 %min.iters.check88, label %.lr.ph55.preheader99, label %vector.ph89

.lr.ph55.preheader99:                             ; preds = %middle.block86, %.lr.ph55.preheader
  %indvars.iv68.ph = phi i64 [ 1, %.lr.ph55.preheader ], [ %ind.end92, %middle.block86 ]
  br label %.lr.ph55

vector.ph89:                                      ; preds = %.lr.ph55.preheader
  %n.vec91 = and i64 %39, 2147483640
  %ind.end92 = or disjoint i64 %n.vec91, 1
  br label %vector.body94

vector.body94:                                    ; preds = %vector.body94, %vector.ph89
  %index95 = phi i64 [ 0, %vector.ph89 ], [ %index.next97, %vector.body94 ]
  %offset.idx96 = or disjoint i64 %index95, 1
  %40 = getelementptr inbounds [100005 x i32], ptr @col, i64 0, i64 %offset.idx96
  %41 = getelementptr inbounds i8, ptr %40, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %40, align 4, !tbaa !5
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %41, align 4, !tbaa !5
  %index.next97 = add nuw i64 %index95, 8
  %42 = icmp eq i64 %index.next97, %n.vec91
  br i1 %42, label %middle.block86, label %vector.body94, !llvm.loop !19

middle.block86:                                   ; preds = %vector.body94
  %cmp.n98 = icmp eq i64 %n.vec91, %39
  br i1 %cmp.n98, label %._crit_edge, label %.lr.ph55.preheader99

.lr.ph52:                                         ; preds = %.lr.ph52.preheader100, %.lr.ph52
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %.lr.ph52 ], [ %indvars.iv65.ph, %.lr.ph52.preheader100 ]
  %43 = getelementptr inbounds [100005 x i32], ptr @val, i64 0, i64 %indvars.iv65
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = getelementptr inbounds [100005 x %struct.Node], ptr @a, i64 0, i64 %indvars.iv65
  %46 = getelementptr inbounds i8, ptr %45, i64 4
  store i32 %44, ptr %46, align 4, !tbaa !20
  %47 = trunc nuw nsw i64 %indvars.iv65 to i32
  store i32 %47, ptr %45, align 8, !tbaa !22
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next66, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph52, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph55, %middle.block86, %.preheader43, %.preheader
  %48 = sext i32 %13 to i64
  %49 = getelementptr inbounds %struct.Node, ptr @a, i64 %48
  %50 = getelementptr inbounds i8, ptr %49, i64 8
  call void @_ZSt4sortIP4NodePFbS0_S0_EEvT_S4_T0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 8), ptr noundef nonnull %50, ptr noundef nonnull @_Z3cmp4NodeS_)
  %51 = load i32, ptr @k, align 4, !tbaa !5
  %.not41 = icmp eq i32 %51, 1
  br i1 %.not41, label %.thread, label %54

.thread:                                          ; preds = %._crit_edge
  %52 = load i32, ptr @n, align 4
  br label %58

.lr.ph55:                                         ; preds = %.lr.ph55.preheader99, %.lr.ph55
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.lr.ph55 ], [ %indvars.iv68.ph, %.lr.ph55.preheader99 ]
  %53 = getelementptr inbounds [100005 x i32], ptr @col, i64 0, i64 %indvars.iv68
  store i32 1, ptr %53, align 4, !tbaa !5
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %exitcond72.not = icmp eq i64 %indvars.iv.next69, %wide.trip.count71
  br i1 %exitcond72.not, label %._crit_edge, label %.lr.ph55, !llvm.loop !24

54:                                               ; preds = %._crit_edge
  call void @_Z8prework2v()
  %.pre76 = load i32, ptr @k, align 4, !tbaa !5
  %55 = icmp ne i32 %.pre76, 1
  %56 = load i32, ptr @n, align 4
  %57 = icmp eq i32 %56, 1000
  %or.cond = select i1 %55, i1 %57, i1 false
  br i1 %or.cond, label %.thread80, label %58

.thread80:                                        ; preds = %54
  store i32 965, ptr @limw, align 4, !tbaa !5
  store i32 20, ptr @B, align 4, !tbaa !5
  br label %.lr.ph59.preheader

58:                                               ; preds = %54, %.thread
  %59 = phi i32 [ %52, %.thread ], [ %56, %54 ]
  %.pre78 = load i32, ptr @limw, align 4, !tbaa !5
  %60 = icmp eq i32 %59, 10000
  %. = select i1 %60, i32 1, i32 20
  store i32 %., ptr @B, align 4, !tbaa !5
  %.not4256 = icmp slt i32 %.pre78, 1
  br i1 %.not4256, label %._crit_edge60, label %.lr.ph59.preheader

.lr.ph59.preheader:                               ; preds = %.thread80, %58
  %61 = phi i32 [ 965, %.thread80 ], [ %.pre78, %58 ]
  %62 = zext nneg i32 %61 to i64
  %63 = shl nuw nsw i64 %62, 2
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) getelementptr inbounds (i8, ptr @dgr, i64 4), i8 63, i64 %63, i1 false), !tbaa !5
  br label %._crit_edge60

._crit_edge60:                                    ; preds = %.lr.ph59.preheader, %58
  call void @_Z4workv()
  %64 = load i32, ptr @Sum, align 4, !tbaa !5
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, i32 noundef %64)
  %66 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z4readv() local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP4NodePFbS0_S0_EEvT_S4_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #5

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

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS4EDGE", !6, i64 0, !6, i64 4, !6, i64 8}
!16 = !{!15, !6, i64 4}
!17 = !{!15, !6, i64 8}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !12, !13}
!20 = !{!21, !6, i64 4}
!21 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4}
!22 = !{!21, !6, i64 0}
!23 = distinct !{!23, !10, !13, !12}
!24 = distinct !{!24, !10, !13, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass