; LLVM IR from xirc/cp-algorithm :: spoj/koicost/main.ll (Z5solvev)

; 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.__gnu_cxx::__normal_iterator" = type { ptr }
%struct.DSU = type { i32, %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl" }
%"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl" = type { %"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.edge = type { i32, i32, i32 }
%"struct.DSU::node" = type { i32, i32, i32 }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@edges = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvev() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %2 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.DSU, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %12 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %13 = alloca %struct.edge, align 4
  %14 = alloca %"struct.DSU::node", align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca { i64, i32 }, align 8
  %18 = alloca %"struct.DSU::node", align 4
  %19 = alloca { i64, i32 }, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #6
  %24 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %1, i32 0, i32 0
  store ptr %23, ptr %24, align 8
  %25 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #6
  %26 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %2, i32 0, i32 0
  store ptr %25, ptr %26, align 8
  %27 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %1, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8
  %29 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %2, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %28, ptr %30)
  %31 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #6
  %32 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  store ptr %31, ptr %32, align 8
  %33 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #6
  %34 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  store ptr %33, ptr %34, align 8
  %35 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8
  %37 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8
  call void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %36, ptr %38)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %53, %0
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = load i32, ptr @M, align 4, !tbaa !9
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %56

44:                                               ; preds = %39
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %46) #6
  %48 = getelementptr inbounds %struct.edge, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = load i64, ptr %5, align 8, !tbaa !5
  %52 = add nsw i64 %51, %50
  store i64 %52, ptr %5, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %44
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %6, align 4, !tbaa !9
  br label %39, !llvm.loop !13

56:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #6
  %57 = load i32, ptr @N, align 4, !tbaa !9
  call void @_ZN3DSUC2Ei(ptr noundef nonnull align 8 dereferenceable(32) %7, i32 noundef %57)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store ptr @edges, ptr %10, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %58 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #6
  %59 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  store ptr %58, ptr %59, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %60 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #6
  %61 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %60, ptr %61, align 8
  br label %62

62:                                               ; preds = %122, %56
  %63 = call noundef zeroext i1 @_ZN9__gnu_cxxneIP4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12) #6
  br i1 %63, label %65, label %64

64:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %126

65:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #6
  %66 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS1_SaIS1_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %66, i64 12, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #6
  %67 = getelementptr inbounds %struct.edge, ptr %13, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !18
  %69 = invoke { i64, i32 } @_ZN3DSU8find_setEi(ptr noundef nonnull align 8 dereferenceable(32) %7, i32 noundef %68)
          to label %70 unwind label %104

70:                                               ; preds = %65
  store { i64, i32 } %69, ptr %17, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %17, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #6
  %71 = getelementptr inbounds %struct.edge, ptr %13, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !19
  %73 = invoke { i64, i32 } @_ZN3DSU8find_setEi(ptr noundef nonnull align 8 dereferenceable(32) %7, i32 noundef %72)
          to label %74 unwind label %108

74:                                               ; preds = %70
  store { i64, i32 } %73, ptr %19, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 8 %19, i64 12, i1 false)
  %75 = getelementptr inbounds %"struct.DSU::node", ptr %14, i32 0, i32 0
  %76 = load i32, ptr %75, align 4, !tbaa !20
  %77 = getelementptr inbounds %"struct.DSU::node", ptr %18, i32 0, i32 0
  %78 = load i32, ptr %77, align 4, !tbaa !20
  %79 = icmp ne i32 %76, %78
  br i1 %79, label %80, label %116

80:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %81 = getelementptr inbounds %"struct.DSU::node", ptr %14, i32 0, i32 2
  %82 = load i32, ptr %81, align 4, !tbaa !22
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %"struct.DSU::node", ptr %18, i32 0, i32 2
  %85 = load i32, ptr %84, align 4, !tbaa !22
  %86 = sext i32 %85 to i64
  %87 = mul nsw i64 %83, %86
  store i64 %87, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %88 = load i64, ptr %5, align 8, !tbaa !5
  %89 = load i64, ptr %8, align 8, !tbaa !5
  %90 = sub nsw i64 %88, %89
  store i64 %90, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %91 = load i64, ptr %20, align 8, !tbaa !5
  %92 = load i64, ptr %21, align 8, !tbaa !5
  %93 = mul nsw i64 %91, %92
  %94 = srem i64 %93, 1000000000
  store i64 %94, ptr %22, align 8, !tbaa !5
  %95 = load i64, ptr %9, align 8, !tbaa !5
  %96 = load i64, ptr %22, align 8, !tbaa !5
  %97 = add nsw i64 %95, %96
  %98 = srem i64 %97, 1000000000
  store i64 %98, ptr %9, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.edge, ptr %13, i32 0, i32 0
  %100 = load i32, ptr %99, align 4, !tbaa !18
  %101 = getelementptr inbounds %struct.edge, ptr %13, i32 0, i32 1
  %102 = load i32, ptr %101, align 4, !tbaa !19
  invoke void @_ZN3DSU9union_setEii(ptr noundef nonnull align 8 dereferenceable(32) %7, i32 noundef %100, i32 noundef %102)
          to label %103 unwind label %112

103:                                              ; preds = %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  br label %116

104:                                              ; preds = %65
  %105 = landingpad { ptr, i32 }
          cleanup
  %106 = extractvalue { ptr, i32 } %105, 0
  store ptr %106, ptr %15, align 8
  %107 = extractvalue { ptr, i32 } %105, 1
  store i32 %107, ptr %16, align 4
  br label %125

108:                                              ; preds = %70
  %109 = landingpad { ptr, i32 }
          cleanup
  %110 = extractvalue { ptr, i32 } %109, 0
  store ptr %110, ptr %15, align 8
  %111 = extractvalue { ptr, i32 } %109, 1
  store i32 %111, ptr %16, align 4
  br label %124

112:                                              ; preds = %80
  %113 = landingpad { ptr, i32 }
          cleanup
  %114 = extractvalue { ptr, i32 } %113, 0
  store ptr %114, ptr %15, align 8
  %115 = extractvalue { ptr, i32 } %113, 1
  store i32 %115, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  br label %124

116:                                              ; preds = %103, %74
  %117 = getelementptr inbounds %struct.edge, ptr %13, i32 0, i32 2
  %118 = load i32, ptr %117, align 4, !tbaa !11
  %119 = sext i32 %118 to i64
  %120 = load i64, ptr %8, align 8, !tbaa !5
  %121 = add nsw i64 %120, %119
  store i64 %121, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #6
  br label %122

122:                                              ; preds = %116
  %123 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS1_SaIS1_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #6
  br label %62

124:                                              ; preds = %112, %108
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #6
  br label %125

125:                                              ; preds = %124, %104
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 12, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @_ZN3DSUD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %128

126:                                              ; preds = %64
  %127 = load i64, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @_ZN3DSUD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret i64 %127

128:                                              ; preds = %125
  %129 = load ptr, ptr %15, align 8
  %130 = load i32, ptr %16, align 4
  %131 = insertvalue { ptr, i32 } poison, ptr %129, 0
  %132 = insertvalue { ptr, i32 } %131, i32 %130, 1
  resume { ptr, i32 } %132
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) #1

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) #1

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3DSUC2Ei(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) unnamed_addr #0 align 2

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZN3DSU8find_setEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3DSU9union_setEii(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3DSUD2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 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 = { 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 #2 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS4edge", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9}
!18 = !{!12, !10, i64 0}
!19 = !{!12, !10, i64 4}
!20 = !{!21, !10, i64 0}
!21 = !{!"_ZTSN3DSU4nodeE", !10, i64 0, !10, i64 4, !10, i64 8}
!22 = !{!21, !10, i64 8}


; 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 }
%struct.DSU = type { i32, %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl" }
%"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl" = type { %"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DSU::node, std::allocator<DSU::node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@N = external dso_local local_unnamed_addr global i32, align 4
@M = external dso_local local_unnamed_addr global i32, align 4
@edges = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i64 -999999999, 1000000000) i64 @_Z5solvev() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %struct.DSU, align 8
  %2 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = tail call ptr @_ZNSt6vectorI4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #5
  %5 = tail call ptr @_ZNSt6vectorI4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #5
  tail call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %4, ptr %5)
  %6 = tail call ptr @_ZNSt6vectorI4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #5
  %7 = tail call ptr @_ZNSt6vectorI4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #5
  tail call void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %6, ptr %7)
  %8 = load i32, ptr @M, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.0.lcssa = phi i64 [ 0, %0 ], [ %18, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #5
  %10 = load i32, ptr @N, align 4, !tbaa !5
  call void @_ZN3DSUC2Ei(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %11 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #5
  store ptr %11, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %12 = call ptr @_ZNSt6vectorI4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @edges) #5
  store ptr %12, ptr %3, align 8
  %13 = call noundef zeroext i1 @_ZN9__gnu_cxxneIP4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  br i1 %13, label %.lr.ph44, label %._crit_edge45

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %.040 = phi i64 [ %18, %.lr.ph ], [ 0, %0 ]
  %14 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %indvars.iv) #5
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = add nsw i64 %.040, %17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr @M, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %indvars.iv.next, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge45:                                    ; preds = %43, %._crit_edge
  %.029.lcssa = phi i64 [ 0, %._crit_edge ], [ %.1, %43 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @_ZN3DSUD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #5
  ret i64 %.029.lcssa

.lr.ph44:                                         ; preds = %._crit_edge, %43
  %.02842 = phi i64 [ %45, %43 ], [ 0, %._crit_edge ]
  %.02941 = phi i64 [ %.1, %43 ], [ 0, %._crit_edge ]
  %22 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS1_SaIS1_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %.sroa.011.0.copyload = load i32, ptr %22, align 4, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %22, i64 4
  %.sroa.6.0.copyload = load i32, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !5
  %.sroa.8.0..sroa_idx = getelementptr inbounds i8, ptr %22, i64 8
  %.sroa.8.0.copyload = load i32, ptr %.sroa.8.0..sroa_idx, align 4, !tbaa !5
  %23 = invoke { i64, i32 } @_ZN3DSU8find_setEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %.sroa.011.0.copyload)
          to label %24 unwind label %37

24:                                               ; preds = %.lr.ph44
  %.fca.1.extract5 = extractvalue { i64, i32 } %23, 1
  %25 = invoke { i64, i32 } @_ZN3DSU8find_setEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %.sroa.6.0.copyload)
          to label %26 unwind label %39

26:                                               ; preds = %24
  %.fca.0.extract4 = extractvalue { i64, i32 } %23, 0
  %.fca.0.extract = extractvalue { i64, i32 } %25, 0
  %.sroa.09.0.extract.trunc = trunc i64 %.fca.0.extract4 to i32
  %.sroa.03.0.extract.trunc = trunc i64 %.fca.0.extract to i32
  %.not = icmp eq i32 %.sroa.09.0.extract.trunc, %.sroa.03.0.extract.trunc
  br i1 %.not, label %43, label %27

27:                                               ; preds = %26
  invoke void @_ZN3DSU9union_setEii(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %.sroa.011.0.copyload, i32 noundef %.sroa.6.0.copyload)
          to label %28 unwind label %41

28:                                               ; preds = %27
  %29 = sext i32 %.fca.1.extract5 to i64
  %.fca.1.extract = extractvalue { i64, i32 } %25, 1
  %30 = sext i32 %.fca.1.extract to i64
  %31 = sub nsw i64 %.0.lcssa, %.02842
  %32 = mul i64 %31, %29
  %33 = mul i64 %32, %30
  %34 = srem i64 %33, 1000000000
  %35 = add nsw i64 %34, %.02941
  %36 = srem i64 %35, 1000000000
  br label %43

37:                                               ; preds = %.lr.ph44
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %48

39:                                               ; preds = %24
  %40 = landingpad { ptr, i32 }
          cleanup
  br label %48

41:                                               ; preds = %27
  %42 = landingpad { ptr, i32 }
          cleanup
  br label %48

43:                                               ; preds = %28, %26
  %.1 = phi i64 [ %36, %28 ], [ %.02941, %26 ]
  %44 = sext i32 %.sroa.8.0.copyload to i64
  %45 = add nsw i64 %.02842, %44
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS1_SaIS1_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %47 = call noundef zeroext i1 @_ZN9__gnu_cxxneIP4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  br i1 %47, label %.lr.ph44, label %._crit_edge45

48:                                               ; preds = %39, %41, %37
  %.pn.pn = phi { ptr, i32 } [ %38, %37 ], [ %42, %41 ], [ %40, %39 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @_ZN3DSUD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #5
  resume { ptr, i32 } %.pn.pn
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) local_unnamed_addr #1

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIP4edgeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) local_unnamed_addr #1

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3DSUC2Ei(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZN3DSU8find_setEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3DSU9union_setEii(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3DSUD2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 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 = { 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 #2 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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