; LLVM IR from tangjz/acm-icpc :: codeforces/gym (101206G)

; 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"

%struct.Edge = type { i32, i32, i32 }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_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.std::pair" = type { i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@lnk = external dso_local global [4001 x i32], align 16
@dis = external dso_local global [4001 x i32], align 16
@ans = external dso_local global i32, align 4
@e = external dso_local global [8003 x %struct.Edge], align 16
@vis = external dso_local global [4001 x i8], align 16
@Q = external dso_local global %"class.std::priority_queue", align 8
@Hash = external dso_local global %"class.std::map", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.std::map", align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.Edge, align 4
  %14 = alloca %struct.Edge, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %"struct.std::pair", align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca %"struct.std::pair", align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %243, %0
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = load i32, ptr @t, align 4, !tbaa !5
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  br label %246

34:                                               ; preds = %29
  store i32 0, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %4) #9
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 48, i1 false)
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %4) #9
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE4swapERS7_(ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull align 8 dereferenceable(48) @Hash) #9
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %4) #9
  call void @llvm.lifetime.end.p0(i64 48, ptr %4) #9
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #9
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %87, %34
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr @m, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #9
  br label %90

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %12)
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = call noundef i32 @_Z5getIDii(i32 noundef %43, i32 noundef %44)
  store i32 %45, ptr %10, align 4, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = call noundef i32 @_Z5getIDii(i32 noundef %46, i32 noundef %47)
  store i32 %48, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #9
  %49 = getelementptr inbounds %struct.Edge, ptr %13, i32 0, i32 0
  %50 = load i32, ptr %10, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  store i32 %53, ptr %49, align 4, !tbaa !9
  %54 = getelementptr inbounds %struct.Edge, ptr %13, i32 0, i32 1
  %55 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %55, ptr %54, align 4, !tbaa !11
  %56 = getelementptr inbounds %struct.Edge, ptr %13, i32 0, i32 2
  %57 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %57, ptr %56, align 4, !tbaa !12
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = shl i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %60
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %61, ptr align 4 %13, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #9
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = shl i32 %62, 1
  %64 = load i32, ptr %10, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %65
  store i32 %63, ptr %66, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #9
  %67 = getelementptr inbounds %struct.Edge, ptr %14, i32 0, i32 0
  %68 = load i32, ptr %11, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  store i32 %71, ptr %67, align 4, !tbaa !9
  %72 = getelementptr inbounds %struct.Edge, ptr %14, i32 0, i32 1
  %73 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %73, ptr %72, align 4, !tbaa !11
  %74 = getelementptr inbounds %struct.Edge, ptr %14, i32 0, i32 2
  %75 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %75, ptr %74, align 4, !tbaa !12
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = shl i32 %76, 1
  %78 = or i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %79
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %80, ptr align 4 %14, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #9
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = shl i32 %81, 1
  %83 = or i32 %82, 1
  %84 = load i32, ptr %11, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %85
  store i32 %83, ptr %86, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  br label %87

87:                                               ; preds = %41
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %5, align 4, !tbaa !5
  br label %36, !llvm.loop !14

90:                                               ; preds = %40
  store i32 1061109567, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %230, %90
  %92 = load i32, ptr %15, align 4, !tbaa !5
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  br label %233

96:                                               ; preds = %91
  br label %97

97:                                               ; preds = %101, %96
  %98 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %99 = xor i1 %98, true
  br i1 %99, label %100, label %102

100:                                              ; preds = %97
  br label %101

101:                                              ; preds = %100
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br label %97, !llvm.loop !16

102:                                              ; preds = %97
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = mul i64 %104, 1
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 %105, i1 false)
  %106 = load i32, ptr @n, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = mul i64 %107, 4
  call void @llvm.memset.p0.i64(ptr align 16 @dis, i8 63, i64 %108, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  %109 = load i32, ptr %15, align 4, !tbaa !5
  %110 = shl i32 %109, 1
  %111 = or i32 %110, 1
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %112
  %114 = getelementptr inbounds %struct.Edge, ptr %113, i32 0, i32 1
  %115 = load i32, ptr %114, align 4, !tbaa !11
  store i32 %115, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  %116 = load i32, ptr %15, align 4, !tbaa !5
  %117 = shl i32 %116, 1
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %118
  %120 = getelementptr inbounds %struct.Edge, ptr %119, i32 0, i32 1
  %121 = load i32, ptr %120, align 4, !tbaa !11
  store i32 %121, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  %122 = load i32, ptr %15, align 4, !tbaa !5
  %123 = shl i32 %122, 1
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %124
  %126 = getelementptr inbounds %struct.Edge, ptr %125, i32 0, i32 2
  %127 = load i32, ptr %126, align 4, !tbaa !12
  store i32 %127, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #9
  %128 = load i32, ptr %16, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %129
  store i32 0, ptr %130, align 4, !tbaa !5
  store i32 0, ptr %20, align 4, !tbaa !5
  %131 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %20, ptr noundef nonnull align 4 dereferenceable(4) %16)
  store i64 %131, ptr %19, align 4
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %19)
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #9
  br label %132

132:                                              ; preds = %220, %218, %102
  %133 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %134 = xor i1 %133, true
  br i1 %134, label %135, label %221

135:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #9
  %136 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %137 = getelementptr inbounds %"struct.std::pair", ptr %136, i32 0, i32 1
  %138 = load i32, ptr %137, align 4, !tbaa !17
  store i32 %138, ptr %21, align 4, !tbaa !5
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %139 = load i32, ptr %21, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [4001 x i8], ptr @vis, i64 0, i64 %140
  %142 = load i8, ptr %141, align 1, !tbaa !19, !range !21, !noundef !22
  %143 = trunc i8 %142 to i1
  br i1 %143, label %144, label %145

144:                                              ; preds = %135
  store i32 14, ptr %3, align 4
  br label %218, !llvm.loop !23

145:                                              ; preds = %135
  %146 = load i32, ptr %21, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [4001 x i8], ptr @vis, i64 0, i64 %147
  store i8 1, ptr %148, align 1, !tbaa !19
  %149 = load i32, ptr %21, align 4, !tbaa !5
  %150 = load i32, ptr %17, align 4, !tbaa !5
  %151 = icmp eq i32 %149, %150
  br i1 %151, label %161, label %152

152:                                              ; preds = %145
  %153 = load i32, ptr %21, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !5
  %157 = load i32, ptr %18, align 4, !tbaa !5
  %158 = add nsw i32 %156, %157
  %159 = load i32, ptr @ans, align 4, !tbaa !5
  %160 = icmp sge i32 %158, %159
  br i1 %160, label %161, label %162

161:                                              ; preds = %152, %145
  store i32 15, ptr %3, align 4
  br label %218

162:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #9
  %163 = load i32, ptr %21, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !5
  store i32 %166, ptr %22, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %211, %162
  %168 = load i32, ptr %22, align 4, !tbaa !5
  %169 = icmp ne i32 %168, -1
  br i1 %169, label %171, label %170

170:                                              ; preds = %167
  store i32 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #9
  br label %217

171:                                              ; preds = %167
  %172 = load i32, ptr %22, align 4, !tbaa !5
  %173 = ashr i32 %172, 1
  %174 = load i32, ptr %15, align 4, !tbaa !5
  %175 = icmp eq i32 %173, %174
  br i1 %175, label %176, label %177

176:                                              ; preds = %171
  br label %211

177:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #9
  %178 = load i32, ptr %22, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %179
  %181 = getelementptr inbounds %struct.Edge, ptr %180, i32 0, i32 1
  %182 = load i32, ptr %181, align 4, !tbaa !11
  store i32 %182, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #9
  %183 = load i32, ptr %21, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !5
  %187 = load i32, ptr %22, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %188
  %190 = getelementptr inbounds %struct.Edge, ptr %189, i32 0, i32 2
  %191 = load i32, ptr %190, align 4, !tbaa !12
  %192 = add nsw i32 %186, %191
  store i32 %192, ptr %24, align 4, !tbaa !5
  %193 = load i32, ptr %24, align 4, !tbaa !5
  %194 = load i32, ptr %23, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %195
  %197 = load i32, ptr %196, align 4, !tbaa !5
  %198 = icmp slt i32 %193, %197
  br i1 %198, label %199, label %210

199:                                              ; preds = %177
  %200 = load i32, ptr %24, align 4, !tbaa !5
  %201 = load i32, ptr %23, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %202
  store i32 %200, ptr %203, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #9
  %204 = load i32, ptr %23, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %205
  %207 = load i32, ptr %206, align 4, !tbaa !5
  %208 = sub nsw i32 0, %207
  store i32 %208, ptr %26, align 4, !tbaa !5
  %209 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %26, ptr noundef nonnull align 4 dereferenceable(4) %23)
  store i64 %209, ptr %25, align 4
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %25)
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #9
  br label %210

210:                                              ; preds = %199, %177
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #9
  br label %211

211:                                              ; preds = %210, %176
  %212 = load i32, ptr %22, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %213
  %215 = getelementptr inbounds %struct.Edge, ptr %214, i32 0, i32 0
  %216 = load i32, ptr %215, align 4, !tbaa !9
  store i32 %216, ptr %22, align 4, !tbaa !5
  br label %167, !llvm.loop !24

217:                                              ; preds = %170
  store i32 0, ptr %3, align 4
  br label %218

218:                                              ; preds = %217, %161, %144
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #9
  %219 = load i32, ptr %3, align 4
  switch i32 %219, label %247 [
    i32 0, label %220
    i32 14, label %132
    i32 15, label %221
  ]

220:                                              ; preds = %218
  br label %132, !llvm.loop !23

221:                                              ; preds = %218, %132
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #9
  %222 = load i32, ptr %17, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %223
  %225 = load i32, ptr %224, align 4, !tbaa !5
  %226 = load i32, ptr %18, align 4, !tbaa !5
  %227 = add nsw i32 %225, %226
  store i32 %227, ptr %27, align 4, !tbaa !5
  %228 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %27)
  %229 = load i32, ptr %228, align 4, !tbaa !5
  store i32 %229, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  br label %230

230:                                              ; preds = %221
  %231 = load i32, ptr %15, align 4, !tbaa !5
  %232 = add nsw i32 %231, 1
  store i32 %232, ptr %15, align 4, !tbaa !5
  br label %91, !llvm.loop !25

233:                                              ; preds = %95
  %234 = load i32, ptr %2, align 4, !tbaa !5
  %235 = load i32, ptr @ans, align 4, !tbaa !5
  %236 = icmp slt i32 %235, 1061109567
  br i1 %236, label %237, label %239

237:                                              ; preds = %233
  %238 = load i32, ptr @ans, align 4, !tbaa !5
  br label %240

239:                                              ; preds = %233
  br label %240

240:                                              ; preds = %239, %237
  %241 = phi i32 [ %238, %237 ], [ 0, %239 ]
  %242 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %234, i32 noundef %241)
  br label %243

243:                                              ; preds = %240
  %244 = load i32, ptr %2, align 4, !tbaa !5
  %245 = add nsw i32 %244, 1
  store i32 %245, ptr %2, align 4, !tbaa !5
  br label %29, !llvm.loop !26

246:                                              ; preds = %33
  ret i32 0

247:                                              ; preds = %218
  unreachable
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE4swapERS7_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) #0 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z5getIDii(i32 noundef, i32 noundef) #5

; 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) #6

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #7

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

; 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)) #8

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

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


; 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"

%struct.Edge = type { i32, i32, i32 }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_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.std::pair" = type { i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local global i32, align 4
@lnk = external dso_local local_unnamed_addr global [4001 x i32], align 16
@dis = external dso_local local_unnamed_addr global [4001 x i32], align 16
@ans = external dso_local global i32, align 4
@e = external dso_local local_unnamed_addr global [8003 x %struct.Edge], align 16
@vis = external dso_local local_unnamed_addr global [4001 x i8], align 16
@Q = external dso_local global %"class.std::priority_queue", align 8
@Hash = external dso_local global %"class.std::map", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca %"class.std::map", align 8
  %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 i32, align 4
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"struct.std::pair", align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %15 = load i32, ptr @t, align 4, !tbaa !5
  %.not66 = icmp slt i32 %15, 1
  br i1 %.not66, label %._crit_edge70, label %.lr.ph69

._crit_edge70:                                    ; preds = %._crit_edge65.thread, %0
  ret i32 0

.lr.ph69:                                         ; preds = %0, %._crit_edge65.thread
  %.067 = phi i32 [ %49, %._crit_edge65.thread ], [ 1, %0 ]
  store i32 0, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %1) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %1, i8 0, i64 48, i1 false)
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #8
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE4swapERS7_(ptr noundef nonnull align 8 dereferenceable(48) %1, ptr noundef nonnull align 8 dereferenceable(48) @Hash) #8
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #8
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %.lr.ph69
  store i32 1061109567, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge65.thread

._crit_edge:                                      ; preds = %.lr.ph
  store i32 1061109567, ptr @ans, align 4, !tbaa !5
  %19 = icmp sgt i32 %42, 0
  br i1 %19, label %.preheader, label %._crit_edge65.thread

.lr.ph:                                           ; preds = %.lr.ph69, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph69 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = call noundef i32 @_Z5getIDii(i32 noundef %21, i32 noundef %22)
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = call noundef i32 @_Z5getIDii(i32 noundef %24, i32 noundef %25)
  %27 = sext i32 %23 to i64
  %28 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = shl nuw i64 %indvars.iv, 1
  %32 = trunc nuw i64 %31 to i32
  %sext = shl i64 %indvars.iv, 33
  %33 = ashr exact i64 %sext, 32
  %34 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %33
  store i32 %29, ptr %34, align 8, !tbaa !5
  %.sroa.424.0..sroa_idx = getelementptr inbounds i8, ptr %34, i64 4
  store i32 %26, ptr %.sroa.424.0..sroa_idx, align 4, !tbaa !5
  %.sroa.525.0..sroa_idx = getelementptr inbounds i8, ptr %34, i64 8
  store i32 %30, ptr %.sroa.525.0..sroa_idx, align 8, !tbaa !5
  store i32 %32, ptr %28, align 4, !tbaa !5
  %35 = sext i32 %26 to i64
  %36 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = trunc i64 %31 to i32
  %39 = or disjoint i32 %38, 1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %40
  store i32 %37, ptr %41, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %41, i64 4
  store i32 %23, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %41, i64 8
  store i32 %30, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  store i32 %39, ptr %36, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %42 = load i32, ptr @m, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next, %43
  br i1 %44, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader:                                       ; preds = %._crit_edge, %.thread
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %.thread ], [ 0, %._crit_edge ]
  %45 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %45, label %._crit_edge54, label %.lr.ph53

._crit_edge65:                                    ; preds = %.thread
  %46 = icmp slt i32 %.fr, 1061109567
  %spec.select = select i1 %46, i32 %.fr, i32 0
  br label %._crit_edge65.thread

._crit_edge65.thread:                             ; preds = %._crit_edge65, %._crit_edge.thread, %._crit_edge
  %47 = phi i32 [ 0, %._crit_edge ], [ 0, %._crit_edge.thread ], [ %spec.select, %._crit_edge65 ]
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %.067, i32 noundef %47)
  %49 = add nuw nsw i32 %.067, 1
  %50 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.067, %50
  br i1 %.not.not, label %.lr.ph69, label %._crit_edge70, !llvm.loop !11

.lr.ph53:                                         ; preds = %.preheader, %.lr.ph53
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %51 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %51, label %._crit_edge54, label %.lr.ph53, !llvm.loop !12

._crit_edge54:                                    ; preds = %.lr.ph53, %.preheader
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @vis, i8 0, i64 %53, i1 false)
  %54 = shl nsw i64 %53, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @dis, i8 63, i64 %54, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #8
  %55 = shl i64 %indvars.iv72, 33
  %sext75 = ashr exact i64 %55, 32
  %56 = or disjoint i64 %sext75, 1
  %57 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %56, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !13
  store i32 %58, ptr %7, align 4, !tbaa !5
  %indvars.iv72.tr = trunc i64 %indvars.iv72 to i32
  %59 = shl i32 %indvars.iv72.tr, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %60
  %62 = getelementptr inbounds i8, ptr %61, i64 4
  %63 = load i32, ptr %62, align 4, !tbaa !13
  %64 = getelementptr inbounds i8, ptr %61, i64 8
  %65 = load i32, ptr %64, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #8
  %66 = sext i32 %58 to i64
  %67 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %66
  store i32 0, ptr %67, align 4, !tbaa !5
  store i32 0, ptr %9, align 4, !tbaa !5
  %68 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %7)
  store i64 %68, ptr %8, align 8
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  %69 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %69, label %.thread, label %.lr.ph61

.lr.ph61:                                         ; preds = %._crit_edge54, %.loopexit
  %70 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %71 = getelementptr inbounds i8, ptr %70, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !16
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [4001 x i8], ptr @vis, i64 0, i64 %73
  %75 = load i8, ptr %74, align 1, !tbaa !18, !range !20, !noundef !21
  %76 = trunc nuw i8 %75 to i1
  br i1 %76, label %.loopexit, label %77, !llvm.loop !22

77:                                               ; preds = %.lr.ph61
  store i8 1, ptr %74, align 1, !tbaa !18
  %78 = icmp eq i32 %72, %63
  br i1 %78, label %.thread, label %79

79:                                               ; preds = %77
  %80 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %73
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = add nsw i32 %81, %65
  %83 = load i32, ptr @ans, align 4, !tbaa !5
  %.not47 = icmp slt i32 %82, %83
  br i1 %.not47, label %84, label %.thread

84:                                               ; preds = %79
  %85 = getelementptr inbounds [4001 x i32], ptr @lnk, i64 0, i64 %73
  %.04255 = load i32, ptr %85, align 4, !tbaa !5
  %.not4856 = icmp eq i32 %.04255, -1
  br i1 %.not4856, label %.loopexit, label %.lr.ph59

.lr.ph59:                                         ; preds = %84, %106
  %.04257 = phi i32 [ %.042, %106 ], [ %.04255, %84 ]
  %86 = ashr i32 %.04257, 1
  %87 = zext i32 %86 to i64
  %88 = icmp eq i64 %indvars.iv72, %87
  br i1 %88, label %.lr.ph59._crit_edge, label %89

.lr.ph59._crit_edge:                              ; preds = %.lr.ph59
  %.pre = sext i32 %.04257 to i64
  br label %106

89:                                               ; preds = %.lr.ph59
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #8
  %90 = sext i32 %.04257 to i64
  %91 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %90
  %92 = getelementptr inbounds i8, ptr %91, i64 4
  %93 = load i32, ptr %92, align 4, !tbaa !13
  store i32 %93, ptr %10, align 4, !tbaa !5
  %94 = load i32, ptr %80, align 4, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %91, i64 8
  %96 = load i32, ptr %95, align 4, !tbaa !15
  %97 = add nsw i32 %96, %94
  %98 = sext i32 %93 to i64
  %99 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = icmp slt i32 %97, %100
  br i1 %101, label %102, label %105

102:                                              ; preds = %89
  store i32 %97, ptr %99, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #8
  %103 = sub nsw i32 0, %97
  store i32 %103, ptr %12, align 4, !tbaa !5
  %104 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %10)
  store i64 %104, ptr %11, align 8
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #8
  br label %105

105:                                              ; preds = %102, %89
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #8
  br label %106

106:                                              ; preds = %.lr.ph59._crit_edge, %105
  %.pre-phi = phi i64 [ %.pre, %.lr.ph59._crit_edge ], [ %90, %105 ]
  %107 = getelementptr inbounds [8003 x %struct.Edge], ptr @e, i64 0, i64 %.pre-phi
  %.042 = load i32, ptr %107, align 4, !tbaa !5
  %.not48 = icmp eq i32 %.042, -1
  br i1 %.not48, label %.loopexit, label %.lr.ph59, !llvm.loop !23

.loopexit:                                        ; preds = %106, %84, %.lr.ph61
  %108 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %108, label %.thread, label %.lr.ph61

.thread:                                          ; preds = %.loopexit, %79, %77, %._crit_edge54
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #8
  %109 = sext i32 %63 to i64
  %110 = getelementptr inbounds [4001 x i32], ptr @dis, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = add nsw i32 %111, %65
  store i32 %112, ptr %13, align 4, !tbaa !5
  %113 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %.fr = freeze i32 %114
  store i32 %.fr, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #8
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %115 = load i32, ptr @m, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = icmp slt i64 %indvars.iv.next73, %116
  br i1 %117, label %.preheader, label %._crit_edge65, !llvm.loop !24
}

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

; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE4swapERS7_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #0 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z5getIDii(i32 noundef, i32 noundef) local_unnamed_addr #5

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

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

; 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 #7

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

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 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 #2 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { 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 #8 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !6, i64 4}
!14 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!17, !6, i64 4}
!17 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!18 = !{!19, !19, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}


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