; LLVM IR from upupming/algorithm :: AdvancedLevel_C++/1003. Emergency (25)  (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
@e = external dso_local global [510 x [510 x i32]], align 16
@weight = external dso_local global [510 x i32], align 16
@dis = external dso_local global [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
@visit = external dso_local global [510 x i8], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZL3inf = external hidden constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

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

28:                                               ; preds = %48, %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) #4
  br label %51

33:                                               ; preds = %28
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load i32, ptr %4, 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 %3, 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 %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %43
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [510 x i32], ptr %44, i64 0, i64 %46
  store i32 %35, ptr %47, align 4, !tbaa !5
  br label %48

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

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

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

69:                                               ; preds = %65
  store i32 8, ptr %8, align 4
  br label %256

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

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

75:                                               ; preds = %71
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %101

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

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

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

97:                                               ; preds = %91, %84, %76
  br label %98

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

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

104:                                              ; preds = %101
  store i32 8, ptr %8, align 4
  br label %250

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

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

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

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

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

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

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

184:                                              ; preds = %131
  %185 = load i32, ptr %9, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = load i32, ptr %9, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %190
  %192 = load i32, ptr %12, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [510 x i32], ptr %191, i64 0, i64 %193
  %195 = load i32, ptr %194, align 4, !tbaa !5
  %196 = add nsw i32 %188, %195
  %197 = load i32, ptr %12, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [510 x i32], ptr @dis, i64 0, i64 %198
  %200 = load i32, ptr %199, align 4, !tbaa !5
  %201 = icmp eq i32 %196, %200
  br i1 %201, label %202, label %243

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

229:                                              ; preds = %202
  %230 = load i32, ptr %9, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %231
  %233 = load i32, ptr %232, align 4, !tbaa !5
  %234 = load i32, ptr %12, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [510 x i32], ptr @weight, i64 0, i64 %235
  %237 = load i32, ptr %236, align 4, !tbaa !5
  %238 = add nsw i32 %233, %237
  %239 = load i32, ptr %12, align 4, !tbaa !5
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %240
  store i32 %238, ptr %241, align 4, !tbaa !5
  br label %242

242:                                              ; preds = %229, %202
  br label %243

243:                                              ; preds = %242, %184
  br label %244

244:                                              ; preds = %243, %149
  br label %245

245:                                              ; preds = %244, %122, %114
  br label %246

246:                                              ; preds = %245
  %247 = load i32, ptr %12, align 4, !tbaa !5
  %248 = add nsw i32 %247, 1
  store i32 %248, ptr %12, align 4, !tbaa !5
  br label %109, !llvm.loop !17

249:                                              ; preds = %113
  store i32 0, ptr %8, align 4
  br label %250

250:                                              ; preds = %249, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %251 = load i32, ptr %8, align 4
  switch i32 %251, label %256 [
    i32 0, label %252
  ]

252:                                              ; preds = %250
  br label %253

253:                                              ; preds = %252
  %254 = load i32, ptr %7, align 4, !tbaa !5
  %255 = add nsw i32 %254, 1
  store i32 %255, ptr %7, align 4, !tbaa !5
  br label %65, !llvm.loop !18

256:                                              ; preds = %250, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %257

257:                                              ; preds = %256
  %258 = load i32, ptr @c2, align 4, !tbaa !5
  %259 = sext i32 %258 to i64
  %260 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %259
  %261 = load i32, ptr %260, align 4, !tbaa !5
  %262 = load i32, ptr @c2, align 4, !tbaa !5
  %263 = sext i32 %262 to i64
  %264 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %263
  %265 = load i32, ptr %264, align 4, !tbaa !5
  %266 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %261, i32 noundef %265)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %267 = load i32, ptr %1, align 4
  ret i32 %267
}

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) #2

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

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

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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
@e = external dso_local global [510 x [510 x i32]], align 16
@weight = external dso_local global [510 x i32], align 16
@dis = external dso_local global [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
@visit = external dso_local local_unnamed_addr global [510 x i8], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZL3inf = external hidden constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %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, 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) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %7 = load i32, ptr @m, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph68, label %._crit_edge69

.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.1, 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_edge69:                                    ; preds = %.lr.ph68, %._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_edge69
  %wide.trip.count103 = zext nneg i32 %21 to i64
  %xtraiter = and i64 %wide.trip.count103, 1
  %23 = icmp eq i32 %21, 1
  %unroll_iter = and i64 %wide.trip.count103, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph73.us.preheader

.lr.ph73.us.preheader:                            ; preds = %._crit_edge78.us, %.preheader.us.preheader
  %.05479.us = phi i32 [ %91, %._crit_edge78.us ], [ 0, %.preheader.us.preheader ]
  br i1 %23, label %._crit_edge74.us.unr-lcssa, label %.lr.ph73.us

._crit_edge74.us.unr-lcssa:                       ; preds = %90, %.lr.ph73.us.preheader
  %.152.us.lcssa.ph = phi i32 [ poison, %.lr.ph73.us.preheader ], [ %.152.us.1, %90 ]
  %indvars.iv97.unr = phi i64 [ 0, %.lr.ph73.us.preheader ], [ %indvars.iv.next98.1, %90 ]
  %.05071.us.unr = phi i32 [ 99999999, %.lr.ph73.us.preheader ], [ %.1.us.1, %90 ]
  %.05170.us.unr = phi i32 [ -1, %.lr.ph73.us.preheader ], [ %.152.us.1, %90 ]
  br i1 %lcmp.mod.not, label %._crit_edge74.us, label %.lr.ph73.us.epil

.lr.ph73.us.epil:                                 ; preds = %._crit_edge74.us.unr-lcssa
  %24 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv97.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_edge74.us

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

._crit_edge74.us:                                 ; preds = %.lr.ph73.us.epil, %27, %._crit_edge74.us.unr-lcssa
  %.152.us.lcssa = phi i32 [ %.152.us.lcssa.ph, %._crit_edge74.us.unr-lcssa ], [ %.05170.us.unr, %.lr.ph73.us.epil ], [ %spec.select.us.epil, %27 ]
  %.not63.us = icmp eq i32 %.152.us.lcssa, -1
  br i1 %.not63.us, label %.critedge, label %.lr.ph77.us

.lr.ph77.us:                                      ; preds = %._crit_edge74.us
  %32 = sext i32 %.152.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.ph77.us, %73
  %indvars.iv100 = phi i64 [ 0, %.lr.ph77.us ], [ %indvars.iv.next101, %73 ]
  %38 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv100
  %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 %73

41:                                               ; preds = %37
  %42 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %32, i64 %indvars.iv100
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %.not.us = icmp eq i32 %43, 99999999
  br i1 %.not.us, label %73, 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.iv100
  %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 %73

52:                                               ; preds = %50
  %53 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %indvars.iv100
  %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.iv100
  %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.iv100
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = icmp sgt i32 %60, %62
  br i1 %63, label %64, label %73

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

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.iv100
  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.iv100
  %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.iv100
  store i32 %71, ptr %72, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %65, %64, %52, %50, %41, %37
  %indvars.iv.next101 = add nuw nsw i64 %indvars.iv100, 1
  %exitcond104.not = icmp eq i64 %indvars.iv.next101, %wide.trip.count103
  br i1 %exitcond104.not, label %._crit_edge78.us, label %37, !llvm.loop !15

.lr.ph73.us:                                      ; preds = %.lr.ph73.us.preheader, %90
  %indvars.iv97 = phi i64 [ %indvars.iv.next98.1, %90 ], [ 0, %.lr.ph73.us.preheader ]
  %.05071.us = phi i32 [ %.1.us.1, %90 ], [ 99999999, %.lr.ph73.us.preheader ]
  %.05170.us = phi i32 [ %.152.us.1, %90 ], [ -1, %.lr.ph73.us.preheader ]
  %niter = phi i64 [ %niter.next.1, %90 ], [ 0, %.lr.ph73.us.preheader ]
  %74 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv97
  %75 = load i8, ptr %74, align 2, !tbaa !11, !range !13, !noundef !14
  %76 = icmp eq i8 %75, 0
  br i1 %76, label %77, label %.lr.ph73.us.1

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

.lr.ph73.us.1:                                    ; preds = %77, %.lr.ph73.us
  %.152.us = phi i32 [ %.05170.us, %.lr.ph73.us ], [ %spec.select.us, %77 ]
  %.1.us = phi i32 [ %.05071.us, %.lr.ph73.us ], [ %spec.select64.us, %77 ]
  %indvars.iv.next98 = or disjoint i64 %indvars.iv97, 1
  %82 = getelementptr inbounds [510 x i8], ptr @visit, i64 0, i64 %indvars.iv.next98
  %83 = load i8, ptr %82, align 1, !tbaa !11, !range !13, !noundef !14
  %84 = icmp eq i8 %83, 0
  br i1 %84, label %85, label %90

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

90:                                               ; preds = %85, %.lr.ph73.us.1
  %.152.us.1 = phi i32 [ %.152.us, %.lr.ph73.us.1 ], [ %spec.select.us.1, %85 ]
  %.1.us.1 = phi i32 [ %.1.us, %.lr.ph73.us.1 ], [ %spec.select64.us.1, %85 ]
  %indvars.iv.next98.1 = add nuw nsw i64 %indvars.iv97, 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_edge74.us.unr-lcssa, label %.lr.ph73.us, !llvm.loop !16

._crit_edge78.us:                                 ; preds = %73
  %91 = add nuw nsw i32 %.05479.us, 1
  %exitcond105.not = icmp eq i32 %91, %21
  br i1 %exitcond105.not, label %.critedge, label %.lr.ph73.us.preheader, !llvm.loop !17

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

.critedge:                                        ; preds = %._crit_edge78.us, %._crit_edge74.us, %._crit_edge69
  %103 = load i32, ptr @c2, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [510 x i32], ptr @num, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = getelementptr inbounds [510 x i32], ptr @w, i64 0, i64 %104
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %106, i32 noundef %108)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  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) #2

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

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

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

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

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