; LLVM IR from upupming/algorithm :: CCCC-GPLT/L2-001. 紧急救援  (main)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@c1 = external dso_local global i32, align 4
@c2 = external dso_local global i32, align 4
@dis = external dso_local global [510 x i32], align 16
@weight = external dso_local global [510 x i32], align 16
@e = external dso_local global [510 x [510 x i32]], align 16
@num = external dso_local global [510 x i32], align 16
@w = external dso_local global [510 x i32], align 16
@pre = external dso_local global [510 x i32], align 16
@visit = external dso_local global [510 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@_ZL3inf = external hidden constant i32, align 4
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 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
  store i32 0, ptr %1, align 4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n, ptr noundef @m, ptr noundef @c1, ptr noundef @c2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %24, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %27

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %22)
  br label %24

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

27:                                               ; preds = %18
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @e, ptr noundef getelementptr inbounds (i32, ptr @e, i64 260100), ptr noundef nonnull align 4 dereferenceable(4) @_ZL3inf)
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @dis, ptr noundef getelementptr inbounds (i32, ptr @dis, i64 510), ptr noundef nonnull align 4 dereferenceable(4) @_ZL3inf)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %49, %27
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = load i32, ptr @m, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %52

33:                                               ; preds = %28
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %37
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [510 x i32], ptr %38, i64 0, i64 %40
  store i32 %35, ptr %41, align 4, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %44
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [510 x i32], ptr %45, i64 0, i64 %47
  store i32 %42, ptr %48, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %33
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %6, align 4, !tbaa !5
  br label %28, !llvm.loop !11

52:                                               ; preds = %32
  %53 = load i32, ptr @c1, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %54
  store i32 0, ptr %55, align 4, !tbaa !5
  %56 = load i32, ptr @c1, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = load i32, ptr @c1, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %61
  store i32 %59, ptr %62, align 4, !tbaa !5
  %63 = load i32, ptr @c1, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %64
  store i32 1, ptr %65, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %262, %52
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 8, ptr %8, align 4
  br label %265

71:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 -1, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 99999999, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %99, %71
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %102

77:                                               ; preds = %72
  %78 = load i32, ptr %11, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !12, !range !14, !noundef !15
  %82 = trunc i8 %81 to i1
  %83 = zext i1 %82 to i32
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %98

85:                                               ; preds = %77
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = load i32, ptr %10, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %92, label %98

92:                                               ; preds = %85
  %93 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %93, ptr %9, align 4, !tbaa !5
  %94 = load i32, ptr %11, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  store i32 %97, ptr %10, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %92, %85, %77
  br label %99

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

102:                                              ; preds = %76
  %103 = load i32, ptr %9, align 4, !tbaa !5
  %104 = icmp eq i32 %103, -1
  br i1 %104, label %105, label %106

105:                                              ; preds = %102
  store i32 8, ptr %8, align 4
  br label %259

106:                                              ; preds = %102
  %107 = load i32, ptr %9, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %108
  store i8 1, ptr %109, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %255, %106
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = load i32, ptr @n, align 4, !tbaa !5
  %113 = icmp slt i32 %111, %112
  br i1 %113, label %115, label %114

114:                                              ; preds = %110
  store i32 14, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %258

115:                                              ; preds = %110
  %116 = load i32, ptr %12, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %117
  %119 = load i8, ptr %118, align 1, !tbaa !12, !range !14, !noundef !15
  %120 = trunc i8 %119 to i1
  %121 = zext i1 %120 to i32
  %122 = icmp eq i32 %121, 0
  br i1 %122, label %123, label %254

123:                                              ; preds = %115
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %125
  %127 = load i32, ptr %12, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [510 x i32], ptr %126, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = icmp ne i32 %130, 99999999
  br i1 %131, label %132, label %254

132:                                              ; preds = %123
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = load i32, ptr %9, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %138
  %140 = load i32, ptr %12, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [510 x i32], ptr %139, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = add nsw i32 %136, %143
  %145 = load i32, ptr %12, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = icmp slt i32 %144, %148
  br i1 %149, label %150, label %189

150:                                              ; preds = %132
  %151 = load i32, ptr %9, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = load i32, ptr %9, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %156
  %158 = load i32, ptr %12, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [510 x i32], ptr %157, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = add nsw i32 %154, %161
  %163 = load i32, ptr %12, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %164
  store i32 %162, ptr %165, align 4, !tbaa !5
  %166 = load i32, ptr %9, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = load i32, ptr %12, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %171
  store i32 %169, ptr %172, align 4, !tbaa !5
  %173 = load i32, ptr %9, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = load i32, ptr %12, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = add nsw i32 %176, %180
  %182 = load i32, ptr %12, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %183
  store i32 %181, ptr %184, align 4, !tbaa !5
  %185 = load i32, ptr %9, align 4, !tbaa !5
  %186 = load i32, ptr %12, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [510 x i32], ptr @pre, i64 0, i64 %187
  store i32 %185, ptr %188, align 4, !tbaa !5
  br label %253

189:                                              ; preds = %132
  %190 = load i32, ptr %9, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %191
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %194 = load i32, ptr %9, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %195
  %197 = load i32, ptr %12, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [510 x i32], ptr %196, i64 0, i64 %198
  %200 = load i32, ptr %199, align 4, !tbaa !5
  %201 = add nsw i32 %193, %200
  %202 = load i32, ptr %12, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %203
  %205 = load i32, ptr %204, align 4, !tbaa !5
  %206 = icmp eq i32 %201, %205
  br i1 %206, label %207, label %252

207:                                              ; preds = %189
  %208 = load i32, ptr %12, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !5
  %212 = load i32, ptr %9, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %213
  %215 = load i32, ptr %214, align 4, !tbaa !5
  %216 = add nsw i32 %211, %215
  %217 = load i32, ptr %12, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %218
  store i32 %216, ptr %219, align 4, !tbaa !5
  %220 = load i32, ptr %9, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %221
  %223 = load i32, ptr %222, align 4, !tbaa !5
  %224 = load i32, ptr %12, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %225
  %227 = load i32, ptr %226, align 4, !tbaa !5
  %228 = add nsw i32 %223, %227
  %229 = load i32, ptr %12, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !5
  %233 = icmp sgt i32 %228, %232
  br i1 %233, label %234, label %251

234:                                              ; preds = %207
  %235 = load i32, ptr %9, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %236
  %238 = load i32, ptr %237, align 4, !tbaa !5
  %239 = load i32, ptr %12, align 4, !tbaa !5
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %240
  %242 = load i32, ptr %241, align 4, !tbaa !5
  %243 = add nsw i32 %238, %242
  %244 = load i32, ptr %12, align 4, !tbaa !5
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %245
  store i32 %243, ptr %246, align 4, !tbaa !5
  %247 = load i32, ptr %9, align 4, !tbaa !5
  %248 = load i32, ptr %12, align 4, !tbaa !5
  %249 = sext i32 %248 to i64
  %250 = getelementptr inbounds [510 x i32], ptr @pre, i64 0, i64 %249
  store i32 %247, ptr %250, align 4, !tbaa !5
  br label %251

251:                                              ; preds = %234, %207
  br label %252

252:                                              ; preds = %251, %189
  br label %253

253:                                              ; preds = %252, %150
  br label %254

254:                                              ; preds = %253, %123, %115
  br label %255

255:                                              ; preds = %254
  %256 = load i32, ptr %12, align 4, !tbaa !5
  %257 = add nsw i32 %256, 1
  store i32 %257, ptr %12, align 4, !tbaa !5
  br label %110, !llvm.loop !17

258:                                              ; preds = %114
  store i32 0, ptr %8, align 4
  br label %259

259:                                              ; preds = %258, %105
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %260 = load i32, ptr %8, align 4
  switch i32 %260, label %265 [
    i32 0, label %261
  ]

261:                                              ; preds = %259
  br label %262

262:                                              ; preds = %261
  %263 = load i32, ptr %7, align 4, !tbaa !5
  %264 = add nsw i32 %263, 1
  store i32 %264, ptr %7, align 4, !tbaa !5
  br label %66, !llvm.loop !18

265:                                              ; preds = %259, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %266

266:                                              ; preds = %265
  %267 = load i32, ptr @c2, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %268
  %270 = load i32, ptr %269, align 4, !tbaa !5
  %271 = load i32, ptr @c2, align 4, !tbaa !5
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %272
  %274 = load i32, ptr %273, align 4, !tbaa !5
  %275 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %270, i32 noundef %274)
  %276 = load i32, ptr @c2, align 4, !tbaa !5
  call void @_Z9printPathi(i32 noundef %276)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  %277 = load i32, ptr %1, align 4
  ret i32 %277
}

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

; 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 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 void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "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 norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@c1 = external dso_local global i32, align 4
@c2 = external dso_local global i32, align 4
@dis = external dso_local global [510 x i32], align 16
@weight = external dso_local global [510 x i32], align 16
@e = external dso_local global [510 x [510 x i32]], align 16
@num = external dso_local local_unnamed_addr global [510 x i32], align 16
@w = external dso_local local_unnamed_addr global [510 x i32], align 16
@pre = external dso_local local_unnamed_addr global [510 x i32], align 16
@visit = external dso_local local_unnamed_addr global [510 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@_ZL3inf = external hidden constant i32, align 4
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @c1, ptr noundef nonnull @c2)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  tail call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @e, ptr noundef nonnull getelementptr inbounds (i8, ptr @e, i64 1040400), ptr noundef nonnull align 4 dereferenceable(4) @_ZL3inf)
  tail call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @dis, ptr noundef nonnull getelementptr inbounds (i8, ptr @dis, i64 2040), ptr noundef nonnull align 4 dereferenceable(4) @_ZL3inf)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %7 = load i32, ptr @m, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph72, label %._crit_edge73

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %9 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %indvars.iv
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %9)
  %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
  %13 = icmp slt i64 %indvars.iv.next, %12
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge73:                                    ; preds = %.lr.ph72, %._crit_edge
  %14 = load i32, ptr @c1, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %15
  store i32 0, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %15
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %15
  store i32 %18, ptr %19, align 4, !tbaa !5
  %20 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %15
  store i32 1, ptr %20, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.preheader.us.preheader, label %.critedge

.preheader.us.preheader:                          ; preds = %._crit_edge73
  %wide.trip.count107 = zext nneg i32 %21 to i64
  %xtraiter = and i64 %wide.trip.count107, 1
  %23 = icmp eq i32 %21, 1
  %unroll_iter = and i64 %wide.trip.count107, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph77.us.preheader

.lr.ph77.us.preheader:                            ; preds = %._crit_edge82.us, %.preheader.us.preheader
  %.05883.us = phi i32 [ %92, %._crit_edge82.us ], [ 0, %.preheader.us.preheader ]
  br i1 %23, label %._crit_edge78.us.unr-lcssa, label %.lr.ph77.us

._crit_edge78.us.unr-lcssa:                       ; preds = %91, %.lr.ph77.us.preheader
  %.156.us.lcssa.ph = phi i32 [ poison, %.lr.ph77.us.preheader ], [ %.156.us.1, %91 ]
  %indvars.iv101.unr = phi i64 [ 0, %.lr.ph77.us.preheader ], [ %indvars.iv.next102.1, %91 ]
  %.05475.us.unr = phi i32 [ 99999999, %.lr.ph77.us.preheader ], [ %.1.us.1, %91 ]
  %.05574.us.unr = phi i32 [ -1, %.lr.ph77.us.preheader ], [ %.156.us.1, %91 ]
  br i1 %lcmp.mod.not, label %._crit_edge78.us, label %.lr.ph77.us.epil

.lr.ph77.us.epil:                                 ; preds = %._crit_edge78.us.unr-lcssa
  %24 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv101.unr
  %25 = load i8, ptr %24, align 1, !tbaa !11, !range !13, !noundef !14
  %26 = icmp eq i8 %25, 0
  br i1 %26, label %27, label %._crit_edge78.us

27:                                               ; preds = %.lr.ph77.us.epil
  %28 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %indvars.iv101.unr
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp slt i32 %29, %.05475.us.unr
  %31 = trunc nuw nsw i64 %indvars.iv101.unr to i32
  %spec.select.us.epil = select i1 %30, i32 %31, i32 %.05574.us.unr
  br label %._crit_edge78.us

._crit_edge78.us:                                 ; preds = %.lr.ph77.us.epil, %27, %._crit_edge78.us.unr-lcssa
  %.156.us.lcssa = phi i32 [ %.156.us.lcssa.ph, %._crit_edge78.us.unr-lcssa ], [ %.05574.us.unr, %.lr.ph77.us.epil ], [ %spec.select.us.epil, %27 ]
  %.not67.us = icmp eq i32 %.156.us.lcssa, -1
  br i1 %.not67.us, label %.critedge, label %.lr.ph81.us

.lr.ph81.us:                                      ; preds = %._crit_edge78.us
  %32 = sext i32 %.156.us.lcssa to i64
  %33 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %32
  store i8 1, ptr %33, align 1, !tbaa !11
  %34 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %32
  %35 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %32
  %36 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %32
  br label %37

37:                                               ; preds = %.lr.ph81.us, %74
  %indvars.iv104 = phi i64 [ 0, %.lr.ph81.us ], [ %indvars.iv.next105, %74 ]
  %38 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv104
  %39 = load i8, ptr %38, align 1, !tbaa !11, !range !13, !noundef !14
  %40 = icmp eq i8 %39, 0
  br i1 %40, label %41, label %74

41:                                               ; preds = %37
  %42 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %32, i64 %indvars.iv104
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %.not.us = icmp eq i32 %43, 99999999
  br i1 %.not.us, label %74, label %44

44:                                               ; preds = %41
  %45 = load i32, ptr %34, align 4, !tbaa !5
  %46 = add nsw i32 %45, %43
  %47 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %indvars.iv104
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp slt i32 %46, %48
  br i1 %49, label %65, label %50

50:                                               ; preds = %44
  %51 = icmp eq i32 %46, %48
  br i1 %51, label %52, label %74

52:                                               ; preds = %50
  %53 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %indvars.iv104
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = load i32, ptr %35, align 4, !tbaa !5
  %56 = add nsw i32 %55, %54
  store i32 %56, ptr %53, align 4, !tbaa !5
  %57 = load i32, ptr %36, align 4, !tbaa !5
  %58 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %indvars.iv104
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add nsw i32 %59, %57
  %61 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %indvars.iv104
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = icmp sgt i32 %60, %62
  br i1 %63, label %64, label %74

64:                                               ; preds = %52
  store i32 %60, ptr %61, align 4, !tbaa !5
  br label %.sink.split

65:                                               ; preds = %44
  store i32 %46, ptr %47, align 4, !tbaa !5
  %66 = load i32, ptr %35, align 4, !tbaa !5
  %67 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %indvars.iv104
  store i32 %66, ptr %67, align 4, !tbaa !5
  %68 = load i32, ptr %36, align 4, !tbaa !5
  %69 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %indvars.iv104
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = add nsw i32 %70, %68
  %72 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %indvars.iv104
  store i32 %71, ptr %72, align 4, !tbaa !5
  br label %.sink.split

.sink.split:                                      ; preds = %64, %65
  %73 = getelementptr inbounds [510 x i32], ptr @pre, i64 0, i64 %indvars.iv104
  store i32 %.156.us.lcssa, ptr %73, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %.sink.split, %52, %50, %41, %37
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 1
  %exitcond108.not = icmp eq i64 %indvars.iv.next105, %wide.trip.count107
  br i1 %exitcond108.not, label %._crit_edge82.us, label %37, !llvm.loop !15

.lr.ph77.us:                                      ; preds = %.lr.ph77.us.preheader, %91
  %indvars.iv101 = phi i64 [ %indvars.iv.next102.1, %91 ], [ 0, %.lr.ph77.us.preheader ]
  %.05475.us = phi i32 [ %.1.us.1, %91 ], [ 99999999, %.lr.ph77.us.preheader ]
  %.05574.us = phi i32 [ %.156.us.1, %91 ], [ -1, %.lr.ph77.us.preheader ]
  %niter = phi i64 [ %niter.next.1, %91 ], [ 0, %.lr.ph77.us.preheader ]
  %75 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv101
  %76 = load i8, ptr %75, align 2, !tbaa !11, !range !13, !noundef !14
  %77 = icmp eq i8 %76, 0
  br i1 %77, label %78, label %.lr.ph77.us.1

78:                                               ; preds = %.lr.ph77.us
  %79 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %indvars.iv101
  %80 = load i32, ptr %79, align 8, !tbaa !5
  %81 = icmp slt i32 %80, %.05475.us
  %82 = trunc nuw nsw i64 %indvars.iv101 to i32
  %spec.select.us = select i1 %81, i32 %82, i32 %.05574.us
  %spec.select68.us = call i32 @llvm.smin.i32(i32 %80, i32 %.05475.us)
  br label %.lr.ph77.us.1

.lr.ph77.us.1:                                    ; preds = %78, %.lr.ph77.us
  %.156.us = phi i32 [ %.05574.us, %.lr.ph77.us ], [ %spec.select.us, %78 ]
  %.1.us = phi i32 [ %.05475.us, %.lr.ph77.us ], [ %spec.select68.us, %78 ]
  %indvars.iv.next102 = or disjoint i64 %indvars.iv101, 1
  %83 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv.next102
  %84 = load i8, ptr %83, align 1, !tbaa !11, !range !13, !noundef !14
  %85 = icmp eq i8 %84, 0
  br i1 %85, label %86, label %91

86:                                               ; preds = %.lr.ph77.us.1
  %87 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %indvars.iv.next102
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = icmp slt i32 %88, %.1.us
  %90 = trunc nuw nsw i64 %indvars.iv.next102 to i32
  %spec.select.us.1 = select i1 %89, i32 %90, i32 %.156.us
  %spec.select68.us.1 = call i32 @llvm.smin.i32(i32 %88, i32 %.1.us)
  br label %91

91:                                               ; preds = %86, %.lr.ph77.us.1
  %.156.us.1 = phi i32 [ %.156.us, %.lr.ph77.us.1 ], [ %spec.select.us.1, %86 ]
  %.1.us.1 = phi i32 [ %.1.us, %.lr.ph77.us.1 ], [ %spec.select68.us.1, %86 ]
  %indvars.iv.next102.1 = add nuw nsw i64 %indvars.iv101, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge78.us.unr-lcssa, label %.lr.ph77.us, !llvm.loop !16

._crit_edge82.us:                                 ; preds = %74
  %92 = add nuw nsw i32 %.05883.us, 1
  %exitcond109.not = icmp eq i32 %92, %21
  br i1 %exitcond109.not, label %.critedge, label %.lr.ph77.us.preheader, !llvm.loop !17

.lr.ph72:                                         ; preds = %._crit_edge, %.lr.ph72
  %.05970 = phi i32 [ %101, %.lr.ph72 ], [ 0, %._crit_edge ]
  %93 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %94 = load i32, ptr %3, align 4, !tbaa !5
  %95 = load i32, ptr %1, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = load i32, ptr %2, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %96, i64 %98
  store i32 %94, ptr %99, align 4, !tbaa !5
  %100 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %98, i64 %96
  store i32 %94, ptr %100, align 4, !tbaa !5
  %101 = add nuw nsw i32 %.05970, 1
  %102 = load i32, ptr @m, align 4, !tbaa !5
  %103 = icmp slt i32 %101, %102
  br i1 %103, label %.lr.ph72, label %._crit_edge73, !llvm.loop !18

.critedge:                                        ; preds = %._crit_edge82.us, %._crit_edge78.us, %._crit_edge73
  %104 = load i32, ptr @c2, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %105
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %107, i32 noundef %109)
  %111 = load i32, ptr @c2, align 4, !tbaa !5
  call void @_Z9printPathi(i32 noundef %111)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) 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 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 void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5

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 = { 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 #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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