; LLVM IR from kazunetakahashi/atcoder :: 2018/0512_ARC097 (E)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%class.BIT = type { i32, ptr }

@c = external dso_local global [4020 x i8], align 16
@a = external dso_local global [4020 x i32], align 16
@cost = external dso_local global [2 x [2010 x [2010 x i32]]], align 16
@DP = external dso_local global [2010 x [2010 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [2 x %class.BIT], align 16
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %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 i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %35, %0
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = mul nsw i32 2, %22
  %24 = icmp slt i32 %21, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %38

26:                                               ; preds = %20
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [4020 x i8], ptr @c, i64 0, i64 %28
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %29)
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [4020 x i32], ptr @a, i64 0, i64 %32
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 4 dereferenceable(4) %33)
  br label %35

35:                                               ; preds = %26
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %3, align 4, !tbaa !5
  br label %20, !llvm.loop !9

38:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #8
  store ptr %4, ptr %5, align 8
  %39 = load i32, ptr %2, align 4, !tbaa !5
  invoke void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %39)
          to label %40 unwind label %61

40:                                               ; preds = %38
  %41 = getelementptr inbounds %class.BIT, ptr %4, i64 1
  store ptr %41, ptr %5, align 8
  %42 = load i32, ptr %2, align 4, !tbaa !5
  invoke void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16) %41, i32 noundef %42)
          to label %43 unwind label %61

43:                                               ; preds = %40
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = mul nsw i32 2, %44
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr @c, i64 %46
  invoke void @_ZSt7reverseIPcEvT_S1_(ptr noundef @c, ptr noundef %47)
          to label %48 unwind label %72

48:                                               ; preds = %43
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = mul nsw i32 2, %49
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr @a, i64 %51
  invoke void @_ZSt7reverseIPiEvT_S1_(ptr noundef @a, ptr noundef %52)
          to label %53 unwind label %72

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 -1, ptr %8, align 4, !tbaa !5
  invoke void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @cost, ptr noundef getelementptr inbounds (i32, ptr @cost, i64 8080200), ptr noundef nonnull align 4 dereferenceable(4) %8)
          to label %54 unwind label %76

54:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %176, %54
  %56 = load i32, ptr %9, align 4, !tbaa !5
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = mul nsw i32 2, %57
  %59 = icmp slt i32 %56, %58
  br i1 %59, label %80, label %60

60:                                               ; preds = %55
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %180

61:                                               ; preds = %40, %38
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %6, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %7, align 4
  %65 = load ptr, ptr %5, align 8
  %66 = icmp eq ptr %4, %65
  br i1 %66, label %71, label %67

67:                                               ; preds = %67, %61
  %68 = phi ptr [ %65, %61 ], [ %69, %67 ]
  %69 = getelementptr inbounds %class.BIT, ptr %68, i64 -1
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %69) #8
  %70 = icmp eq ptr %69, %4
  br i1 %70, label %71, label %67

71:                                               ; preds = %67, %61
  br label %354

72:                                               ; preds = %335, %326, %48, %43
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %6, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %7, align 4
  br label %346

76:                                               ; preds = %53
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %6, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %346

80:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %81 = load i32, ptr %9, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [4020 x i8], ptr @c, i64 0, i64 %82
  %84 = load i8, ptr %83, align 1, !tbaa !11
  %85 = sext i8 %84 to i32
  %86 = icmp eq i32 %85, 66
  %87 = zext i1 %86 to i32
  store i32 %87, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [4020 x i32], ptr @a, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  store i32 %91, ptr %12, align 4, !tbaa !5
  %92 = load i32, ptr %11, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [2 x %class.BIT], ptr %4, i64 0, i64 %93
  %95 = load i32, ptr %12, align 4, !tbaa !5
  invoke void @_ZN3BIT3addEi(ptr noundef nonnull align 8 dereferenceable(16) %94, i32 noundef %95)
          to label %96 unwind label %105

96:                                               ; preds = %80
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = icmp eq i32 %97, 0
  br i1 %98, label %99, label %139

99:                                               ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %131, %99
  %101 = load i32, ptr %13, align 4, !tbaa !5
  %102 = load i32, ptr %2, align 4, !tbaa !5
  %103 = icmp sle i32 %101, %102
  br i1 %103, label %109, label %104

104:                                              ; preds = %100
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %138

105:                                              ; preds = %80
  %106 = landingpad { ptr, i32 }
          cleanup
  %107 = extractvalue { ptr, i32 } %106, 0
  store ptr %107, ptr %6, align 8
  %108 = extractvalue { ptr, i32 } %106, 1
  store i32 %108, ptr %7, align 4
  br label %179

109:                                              ; preds = %100
  %110 = getelementptr inbounds [2 x %class.BIT], ptr %4, i64 0, i64 0
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = sub nsw i32 %111, 1
  %113 = invoke noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %110, i32 noundef %112)
          to label %114 unwind label %134

114:                                              ; preds = %109
  %115 = getelementptr inbounds [2 x %class.BIT], ptr %4, i64 0, i64 1
  %116 = load i32, ptr %13, align 4, !tbaa !5
  %117 = invoke noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %115, i32 noundef %116)
          to label %118 unwind label %134

118:                                              ; preds = %114
  %119 = add nsw i64 %113, %117
  %120 = trunc i64 %119 to i32
  %121 = load i32, ptr %11, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [2 x [2010 x [2010 x i32]]], ptr @cost, i64 0, i64 %122
  %124 = load i32, ptr %12, align 4, !tbaa !5
  %125 = sub nsw i32 %124, 1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [2010 x [2010 x i32]], ptr %123, i64 0, i64 %126
  %128 = load i32, ptr %13, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [2010 x i32], ptr %127, i64 0, i64 %129
  store i32 %120, ptr %130, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %118
  %132 = load i32, ptr %13, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %13, align 4, !tbaa !5
  br label %100, !llvm.loop !12

134:                                              ; preds = %114, %109
  %135 = landingpad { ptr, i32 }
          cleanup
  %136 = extractvalue { ptr, i32 } %135, 0
  store ptr %136, ptr %6, align 8
  %137 = extractvalue { ptr, i32 } %135, 1
  store i32 %137, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %179

138:                                              ; preds = %104
  br label %175

139:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %140

140:                                              ; preds = %167, %139
  %141 = load i32, ptr %14, align 4, !tbaa !5
  %142 = load i32, ptr %2, align 4, !tbaa !5
  %143 = icmp sle i32 %141, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %140
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %174

145:                                              ; preds = %140
  %146 = getelementptr inbounds [2 x %class.BIT], ptr %4, i64 0, i64 1
  %147 = load i32, ptr %12, align 4, !tbaa !5
  %148 = sub nsw i32 %147, 1
  %149 = invoke noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %146, i32 noundef %148)
          to label %150 unwind label %170

150:                                              ; preds = %145
  %151 = getelementptr inbounds [2 x %class.BIT], ptr %4, i64 0, i64 0
  %152 = load i32, ptr %14, align 4, !tbaa !5
  %153 = invoke noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %151, i32 noundef %152)
          to label %154 unwind label %170

154:                                              ; preds = %150
  %155 = add nsw i64 %149, %153
  %156 = trunc i64 %155 to i32
  %157 = load i32, ptr %11, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [2 x [2010 x [2010 x i32]]], ptr @cost, i64 0, i64 %158
  %160 = load i32, ptr %14, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [2010 x [2010 x i32]], ptr %159, i64 0, i64 %161
  %163 = load i32, ptr %12, align 4, !tbaa !5
  %164 = sub nsw i32 %163, 1
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [2010 x i32], ptr %162, i64 0, i64 %165
  store i32 %156, ptr %166, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %154
  %168 = load i32, ptr %14, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %14, align 4, !tbaa !5
  br label %140, !llvm.loop !13

170:                                              ; preds = %150, %145
  %171 = landingpad { ptr, i32 }
          cleanup
  %172 = extractvalue { ptr, i32 } %171, 0
  store ptr %172, ptr %6, align 8
  %173 = extractvalue { ptr, i32 } %171, 1
  store i32 %173, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %179

174:                                              ; preds = %144
  br label %175

175:                                              ; preds = %174, %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %176

176:                                              ; preds = %175
  %177 = load i32, ptr %9, align 4, !tbaa !5
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %9, align 4, !tbaa !5
  br label %55, !llvm.loop !14

179:                                              ; preds = %170, %134, %105
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %346

180:                                              ; preds = %60
  store i32 0, ptr @DP, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %181

181:                                              ; preds = %323, %180
  %182 = load i32, ptr %15, align 4, !tbaa !5
  %183 = load i32, ptr %2, align 4, !tbaa !5
  %184 = icmp sle i32 %182, %183
  br i1 %184, label %186, label %185

185:                                              ; preds = %181
  store i32 14, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %326

186:                                              ; preds = %181
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %187

187:                                              ; preds = %318, %186
  %188 = load i32, ptr %16, align 4, !tbaa !5
  %189 = load i32, ptr %2, align 4, !tbaa !5
  %190 = icmp sle i32 %188, %189
  br i1 %190, label %192, label %191

191:                                              ; preds = %187
  store i32 17, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %322

192:                                              ; preds = %187
  %193 = load i32, ptr %15, align 4, !tbaa !5
  %194 = icmp eq i32 %193, 0
  br i1 %194, label %195, label %205

195:                                              ; preds = %192
  %196 = load i32, ptr %16, align 4, !tbaa !5
  %197 = icmp eq i32 %196, 0
  br i1 %197, label %198, label %205

198:                                              ; preds = %195
  %199 = load i32, ptr %15, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %200
  %202 = load i32, ptr %16, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [2010 x i32], ptr %201, i64 0, i64 %203
  store i32 0, ptr %204, align 4, !tbaa !5
  br label %318

205:                                              ; preds = %195, %192
  %206 = load i32, ptr %15, align 4, !tbaa !5
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %207
  %209 = load i32, ptr %16, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [2010 x i32], ptr %208, i64 0, i64 %210
  store i32 1000000007, ptr %211, align 4, !tbaa !5
  %212 = load i32, ptr %15, align 4, !tbaa !5
  %213 = icmp sgt i32 %212, 0
  br i1 %213, label %214, label %264

214:                                              ; preds = %205
  %215 = load i32, ptr %15, align 4, !tbaa !5
  %216 = sub nsw i32 %215, 1
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [2010 x [2010 x i32]], ptr @cost, i64 0, i64 %217
  %219 = load i32, ptr %16, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [2010 x i32], ptr %218, i64 0, i64 %220
  %222 = load i32, ptr %221, align 4, !tbaa !5
  %223 = icmp sge i32 %222, 0
  br i1 %223, label %224, label %225

224:                                              ; preds = %214
  br label %227

225:                                              ; preds = %214
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 142, ptr noundef @__PRETTY_FUNCTION__.main) #9
  unreachable

226:                                              ; No predecessors!
  br label %227

227:                                              ; preds = %226, %224
  %228 = load i32, ptr %15, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %229
  %231 = load i32, ptr %16, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [2010 x i32], ptr %230, i64 0, i64 %232
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %234 = load i32, ptr %15, align 4, !tbaa !5
  %235 = sub nsw i32 %234, 1
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %236
  %238 = load i32, ptr %16, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [2010 x i32], ptr %237, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = load i32, ptr %15, align 4, !tbaa !5
  %243 = sub nsw i32 %242, 1
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [2010 x [2010 x i32]], ptr @cost, i64 0, i64 %244
  %246 = load i32, ptr %16, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [2010 x i32], ptr %245, i64 0, i64 %247
  %249 = load i32, ptr %248, align 4, !tbaa !5
  %250 = add nsw i32 %241, %249
  store i32 %250, ptr %17, align 4, !tbaa !5
  %251 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %233, ptr noundef nonnull align 4 dereferenceable(4) %17)
          to label %252 unwind label %260

252:                                              ; preds = %227
  %253 = load i32, ptr %251, align 4, !tbaa !5
  %254 = load i32, ptr %15, align 4, !tbaa !5
  %255 = sext i32 %254 to i64
  %256 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %255
  %257 = load i32, ptr %16, align 4, !tbaa !5
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [2010 x i32], ptr %256, i64 0, i64 %258
  store i32 %253, ptr %259, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %264

260:                                              ; preds = %227
  %261 = landingpad { ptr, i32 }
          cleanup
  %262 = extractvalue { ptr, i32 } %261, 0
  store ptr %262, ptr %6, align 8
  %263 = extractvalue { ptr, i32 } %261, 1
  store i32 %263, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %321

264:                                              ; preds = %252, %205
  %265 = load i32, ptr %16, align 4, !tbaa !5
  %266 = icmp sgt i32 %265, 0
  br i1 %266, label %267, label %317

267:                                              ; preds = %264
  %268 = load i32, ptr %15, align 4, !tbaa !5
  %269 = sext i32 %268 to i64
  %270 = getelementptr inbounds [2010 x [2010 x i32]], ptr getelementptr inbounds ([2 x [2010 x [2010 x i32]]], ptr @cost, i64 0, i64 1), i64 0, i64 %269
  %271 = load i32, ptr %16, align 4, !tbaa !5
  %272 = sub nsw i32 %271, 1
  %273 = sext i32 %272 to i64
  %274 = getelementptr inbounds [2010 x i32], ptr %270, i64 0, i64 %273
  %275 = load i32, ptr %274, align 4, !tbaa !5
  %276 = icmp sge i32 %275, 0
  br i1 %276, label %277, label %278

277:                                              ; preds = %267
  br label %280

278:                                              ; preds = %267
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 147, ptr noundef @__PRETTY_FUNCTION__.main) #9
  unreachable

279:                                              ; No predecessors!
  br label %280

280:                                              ; preds = %279, %277
  %281 = load i32, ptr %15, align 4, !tbaa !5
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %282
  %284 = load i32, ptr %16, align 4, !tbaa !5
  %285 = sext i32 %284 to i64
  %286 = getelementptr inbounds [2010 x i32], ptr %283, i64 0, i64 %285
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  %287 = load i32, ptr %15, align 4, !tbaa !5
  %288 = sext i32 %287 to i64
  %289 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %288
  %290 = load i32, ptr %16, align 4, !tbaa !5
  %291 = sub nsw i32 %290, 1
  %292 = sext i32 %291 to i64
  %293 = getelementptr inbounds [2010 x i32], ptr %289, i64 0, i64 %292
  %294 = load i32, ptr %293, align 4, !tbaa !5
  %295 = load i32, ptr %15, align 4, !tbaa !5
  %296 = sext i32 %295 to i64
  %297 = getelementptr inbounds [2010 x [2010 x i32]], ptr getelementptr inbounds ([2 x [2010 x [2010 x i32]]], ptr @cost, i64 0, i64 1), i64 0, i64 %296
  %298 = load i32, ptr %16, align 4, !tbaa !5
  %299 = sub nsw i32 %298, 1
  %300 = sext i32 %299 to i64
  %301 = getelementptr inbounds [2010 x i32], ptr %297, i64 0, i64 %300
  %302 = load i32, ptr %301, align 4, !tbaa !5
  %303 = add nsw i32 %294, %302
  store i32 %303, ptr %18, align 4, !tbaa !5
  %304 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %286, ptr noundef nonnull align 4 dereferenceable(4) %18)
          to label %305 unwind label %313

305:                                              ; preds = %280
  %306 = load i32, ptr %304, align 4, !tbaa !5
  %307 = load i32, ptr %15, align 4, !tbaa !5
  %308 = sext i32 %307 to i64
  %309 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %308
  %310 = load i32, ptr %16, align 4, !tbaa !5
  %311 = sext i32 %310 to i64
  %312 = getelementptr inbounds [2010 x i32], ptr %309, i64 0, i64 %311
  store i32 %306, ptr %312, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %317

313:                                              ; preds = %280
  %314 = landingpad { ptr, i32 }
          cleanup
  %315 = extractvalue { ptr, i32 } %314, 0
  store ptr %315, ptr %6, align 8
  %316 = extractvalue { ptr, i32 } %314, 1
  store i32 %316, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %321

317:                                              ; preds = %305, %264
  br label %318

318:                                              ; preds = %317, %198
  %319 = load i32, ptr %16, align 4, !tbaa !5
  %320 = add nsw i32 %319, 1
  store i32 %320, ptr %16, align 4, !tbaa !5
  br label %187, !llvm.loop !15

321:                                              ; preds = %313, %260
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %346

322:                                              ; preds = %191
  br label %323

323:                                              ; preds = %322
  %324 = load i32, ptr %15, align 4, !tbaa !5
  %325 = add nsw i32 %324, 1
  store i32 %325, ptr %15, align 4, !tbaa !5
  br label %181, !llvm.loop !16

326:                                              ; preds = %185
  %327 = load i32, ptr %2, align 4, !tbaa !5
  %328 = sext i32 %327 to i64
  %329 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %328
  %330 = load i32, ptr %2, align 4, !tbaa !5
  %331 = sext i32 %330 to i64
  %332 = getelementptr inbounds [2010 x i32], ptr %329, i64 0, i64 %331
  %333 = load i32, ptr %332, align 4, !tbaa !5
  %334 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %333)
          to label %335 unwind label %72

335:                                              ; preds = %326
  %336 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %334, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %337 unwind label %72

337:                                              ; preds = %335
  store i32 0, ptr %1, align 4
  store i32 1, ptr %10, align 4
  %338 = getelementptr inbounds [2 x %class.BIT], ptr %4, i32 0, i32 0
  %339 = getelementptr inbounds %class.BIT, ptr %338, i64 2
  br label %340

340:                                              ; preds = %340, %337
  %341 = phi ptr [ %339, %337 ], [ %342, %340 ]
  %342 = getelementptr inbounds %class.BIT, ptr %341, i64 -1
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %342) #8
  %343 = icmp eq ptr %342, %338
  br i1 %343, label %344, label %340

344:                                              ; preds = %340
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  %345 = load i32, ptr %1, align 4
  ret i32 %345

346:                                              ; preds = %321, %179, %76, %72
  %347 = getelementptr inbounds [2 x %class.BIT], ptr %4, i32 0, i32 0
  %348 = getelementptr inbounds %class.BIT, ptr %347, i64 2
  br label %349

349:                                              ; preds = %349, %346
  %350 = phi ptr [ %348, %346 ], [ %351, %349 ]
  %351 = getelementptr inbounds %class.BIT, ptr %350, i64 -1
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %351) #8
  %352 = icmp eq ptr %351, %347
  br i1 %352, label %353, label %349

353:                                              ; preds = %349
  br label %354

354:                                              ; preds = %353, %71
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %355

355:                                              ; preds = %354
  %356 = load ptr, ptr %6, align 8
  %357 = load i32, ptr %7, align 4
  %358 = insertvalue { ptr, i32 } poison, ptr %356, 0
  %359 = insertvalue { ptr, i32 } %358, i32 %357, 1
  resume { ptr, i32 } %359
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BIT3addEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #4 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #6

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%class.BIT = type { i32, ptr }

@c = external dso_local global [4020 x i8], align 16
@a = external dso_local global [4020 x i32], align 16
@cost = external dso_local global [2 x [2010 x [2010 x i32]]], align 16
@DP = external dso_local global [2010 x [2010 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca [2 x %class.BIT], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa87 = phi i32 [ %7, %0 ], [ %15, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #8
  call void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.lcssa87)
  %9 = getelementptr inbounds i8, ptr %2, i64 16
  %10 = load i32, ptr %1, align 4, !tbaa !5
  invoke void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16) %9, i32 noundef %10)
          to label %19 unwind label %.loopexit.loopexit112

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %11 = getelementptr inbounds [4020 x i8], ptr @c, i64 0, i64 %indvars.iv
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %11)
  %13 = getelementptr inbounds [4020 x i32], ptr @a, i64 0, i64 %indvars.iv
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = shl nsw i32 %15, 1
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !9

19:                                               ; preds = %._crit_edge
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = shl nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr @c, i64 %22
  invoke void @_ZSt7reverseIPcEvT_S1_(ptr noundef nonnull @c, ptr noundef nonnull %23)
          to label %24 unwind label %35

24:                                               ; preds = %19
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = shl nsw i32 %25, 1
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr @a, i64 %27
  invoke void @_ZSt7reverseIPiEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %28)
          to label %29 unwind label %35

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  store i32 -1, ptr %3, align 4, !tbaa !5
  invoke void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @cost, ptr noundef nonnull getelementptr inbounds (i8, ptr @cost, i64 32320800), ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %30 unwind label %37

30:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph97, label %._crit_edge98

._crit_edge98:                                    ; preds = %.loopexit81, %30
  %33 = phi i32 [ %31, %30 ], [ %72, %.loopexit81 ]
  store i32 0, ptr @DP, align 16, !tbaa !5
  %.not103 = icmp slt i32 %33, 0
  br i1 %.not103, label %._crit_edge106, label %.preheader

.loopexit.loopexit112:                            ; preds = %._crit_edge
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit

35:                                               ; preds = %131, %._crit_edge106, %24, %19
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.loopexit

37:                                               ; preds = %29
  %38 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  br label %.loopexit.loopexit

.lr.ph97:                                         ; preds = %30, %.loopexit81
  %indvars.iv122 = phi i64 [ %indvars.iv.next123, %.loopexit81 ], [ 0, %30 ]
  %39 = getelementptr inbounds [4020 x i8], ptr @c, i64 0, i64 %indvars.iv122
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = icmp eq i8 %40, 66
  %42 = getelementptr inbounds [4020 x i32], ptr @a, i64 0, i64 %indvars.iv122
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = zext i1 %41 to i64
  %45 = getelementptr inbounds [2 x %class.BIT], ptr %2, i64 0, i64 %44
  invoke void @_ZN3BIT3addEi(ptr noundef nonnull align 8 dereferenceable(16) %45, i32 noundef %43)
          to label %46 unwind label %52

46:                                               ; preds = %.lr.ph97
  %47 = load i32, ptr %1, align 4, !tbaa !5
  %.not7792 = icmp slt i32 %47, 0
  br i1 %41, label %.preheader80, label %.preheader82

.preheader82:                                     ; preds = %46
  br i1 %.not7792, label %.loopexit81, label %.lr.ph91

.lr.ph91:                                         ; preds = %.preheader82
  %48 = add nsw i32 %43, -1
  %49 = sext i32 %48 to i64
  br label %54

.preheader80:                                     ; preds = %46
  br i1 %.not7792, label %.loopexit81, label %.lr.ph94

.lr.ph94:                                         ; preds = %.preheader80
  %50 = add nsw i32 %43, -1
  %51 = sext i32 %50 to i64
  br label %63

52:                                               ; preds = %.lr.ph97
  %53 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.loopexit

54:                                               ; preds = %.lr.ph91, %54
  %indvars.iv116 = phi i64 [ 0, %.lr.ph91 ], [ %indvars.iv.next117, %54 ]
  %55 = call noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %48)
  %56 = trunc nuw nsw i64 %indvars.iv116 to i32
  %57 = call noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %9, i32 noundef %56)
  %58 = add nsw i64 %57, %55
  %59 = trunc i64 %58 to i32
  %60 = getelementptr inbounds [2 x [2010 x [2010 x i32]]], ptr @cost, i64 0, i64 %44, i64 %49, i64 %indvars.iv116
  store i32 %59, ptr %60, align 4, !tbaa !5
  %indvars.iv.next117 = add nuw nsw i64 %indvars.iv116, 1
  %61 = load i32, ptr %1, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %.not78.not = icmp slt i64 %indvars.iv116, %62
  br i1 %.not78.not, label %54, label %.loopexit81, !llvm.loop !12

63:                                               ; preds = %.lr.ph94, %63
  %indvars.iv119 = phi i64 [ 0, %.lr.ph94 ], [ %indvars.iv.next120, %63 ]
  %64 = call noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %9, i32 noundef %50)
  %65 = trunc nuw nsw i64 %indvars.iv119 to i32
  %66 = call noundef i64 @_ZN3BIT3sumEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %65)
  %67 = add nsw i64 %66, %64
  %68 = trunc i64 %67 to i32
  %69 = getelementptr inbounds [2 x [2010 x [2010 x i32]]], ptr @cost, i64 0, i64 %44, i64 %indvars.iv119, i64 %51
  store i32 %68, ptr %69, align 4, !tbaa !5
  %indvars.iv.next120 = add nuw nsw i64 %indvars.iv119, 1
  %70 = load i32, ptr %1, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %.not77.not = icmp slt i64 %indvars.iv119, %71
  br i1 %.not77.not, label %63, label %.loopexit81, !llvm.loop !13

.loopexit81:                                      ; preds = %54, %63, %.preheader82, %.preheader80
  %72 = phi i32 [ %47, %.preheader82 ], [ %47, %.preheader80 ], [ %70, %63 ], [ %61, %54 ]
  %indvars.iv.next123 = add nuw nsw i64 %indvars.iv122, 1
  %73 = shl nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = icmp slt i64 %indvars.iv.next123, %74
  br i1 %75, label %.lr.ph97, label %._crit_edge98, !llvm.loop !14

.preheader:                                       ; preds = %._crit_edge98, %._crit_edge102
  %76 = phi i32 [ %107, %._crit_edge102 ], [ %33, %._crit_edge98 ]
  %.061104 = phi i32 [ %108, %._crit_edge102 ], [ 0, %._crit_edge98 ]
  %.not7299 = icmp slt i32 %76, 0
  br i1 %.not7299, label %._crit_edge102, label %.lr.ph101

.lr.ph101:                                        ; preds = %.preheader
  %77 = zext nneg i32 %.061104 to i64
  %.not73 = icmp eq i32 %.061104, 0
  %78 = add nsw i32 %.061104, -1
  %79 = zext nneg i32 %78 to i64
  br i1 %.not73, label %90, label %.lr.ph101.split.preheader

.lr.ph101.split.preheader:                        ; preds = %.lr.ph101
  %80 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %77, i64 0
  store i32 1000000007, ptr %80, align 8, !tbaa !5
  %81 = getelementptr inbounds [2010 x [2010 x i32]], ptr @cost, i64 0, i64 %79, i64 0
  %82 = load i32, ptr %81, align 8, !tbaa !5
  %83 = icmp sgt i32 %82, -1
  br i1 %83, label %84, label %.loopexit129

84:                                               ; preds = %.lr.ph101.split.preheader
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  %85 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %79, i64 0
  %86 = load i32, ptr %85, align 8, !tbaa !5
  %87 = add nsw i32 %86, %82
  store i32 %87, ptr %4, align 4, !tbaa !5
  %88 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %80, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %89 = load i32, ptr %88, align 4, !tbaa !5
  store i32 %89, ptr %80, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  %.not72.not.peel = icmp sgt i32 %.pre, 0
  br i1 %.not72.not.peel, label %.lr.ph101.split.peel.next, label %._crit_edge102

90:                                               ; preds = %.lr.ph101
  store i32 0, ptr @DP, align 16, !tbaa !5
  %.not72.us.not.peel.not = icmp eq i32 %76, 0
  br i1 %.not72.us.not.peel.not, label %._crit_edge102, label %.lr.ph101.split.us.peel.next

.lr.ph101.split.us.peel.next:                     ; preds = %90, %96
  %indvars.iv132 = phi i64 [ %indvars.iv.next133, %96 ], [ 1, %90 ]
  %91 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %77, i64 %indvars.iv132
  store i32 1000000007, ptr %91, align 4, !tbaa !5
  %92 = add nsw i64 %indvars.iv132, -1
  %93 = getelementptr inbounds [2010 x [2010 x i32]], ptr getelementptr inbounds (i8, ptr @cost, i64 16160400), i64 0, i64 %77, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = icmp sgt i32 %94, -1
  br i1 %95, label %96, label %.split.us

96:                                               ; preds = %.lr.ph101.split.us.peel.next
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %97 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %77, i64 %92
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = add nsw i32 %98, %94
  store i32 %99, ptr %5, align 4, !tbaa !5
  %100 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %91, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %101 = load i32, ptr %100, align 4, !tbaa !5
  store i32 %101, ptr %91, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  %.pre141 = load i32, ptr %1, align 4, !tbaa !5
  %indvars.iv.next133 = add nuw nsw i64 %indvars.iv132, 1
  %102 = sext i32 %.pre141 to i64
  %.not72.us.not = icmp slt i64 %indvars.iv132, %102
  br i1 %.not72.us.not, label %.lr.ph101.split.us.peel.next, label %._crit_edge102, !llvm.loop !15

._crit_edge106:                                   ; preds = %._crit_edge102, %._crit_edge98
  %.lcssa = phi i32 [ %33, %._crit_edge98 ], [ %107, %._crit_edge102 ]
  %103 = sext i32 %.lcssa to i64
  %104 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %103, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %105)
          to label %131 unwind label %35

._crit_edge102:                                   ; preds = %123, %96, %84, %90, %.preheader
  %107 = phi i32 [ %76, %.preheader ], [ 0, %90 ], [ %.pre, %84 ], [ %.pre141, %96 ], [ %129, %123 ]
  %108 = add i32 %.061104, 1
  %.not = icmp sgt i32 %108, %107
  br i1 %.not, label %._crit_edge106, label %.preheader, !llvm.loop !17

.lr.ph101.split.peel.next:                        ; preds = %84, %123
  %indvars.iv125 = phi i64 [ %indvars.iv.next126, %123 ], [ 1, %84 ]
  %109 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %77, i64 %indvars.iv125
  store i32 1000000007, ptr %109, align 4, !tbaa !5
  %110 = getelementptr inbounds [2010 x [2010 x i32]], ptr @cost, i64 0, i64 %79, i64 %indvars.iv125
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = icmp sgt i32 %111, -1
  br i1 %112, label %113, label %.loopexit129

.loopexit129:                                     ; preds = %.lr.ph101.split.preheader, %.lr.ph101.split.peel.next
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 142, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #9
  unreachable

113:                                              ; preds = %.lr.ph101.split.peel.next
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  %114 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %79, i64 %indvars.iv125
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = add nsw i32 %115, %111
  store i32 %116, ptr %4, align 4, !tbaa !5
  %117 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %109, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %118 = load i32, ptr %117, align 4, !tbaa !5
  store i32 %118, ptr %109, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  %119 = add nsw i64 %indvars.iv125, -1
  %120 = getelementptr inbounds [2010 x [2010 x i32]], ptr getelementptr inbounds (i8, ptr @cost, i64 16160400), i64 0, i64 %77, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = icmp sgt i32 %121, -1
  br i1 %122, label %123, label %.split.us

.split.us:                                        ; preds = %113, %.lr.ph101.split.us.peel.next
  call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 147, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #9
  unreachable

123:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %124 = getelementptr inbounds [2010 x [2010 x i32]], ptr @DP, i64 0, i64 %77, i64 %119
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = add nsw i32 %125, %121
  store i32 %126, ptr %5, align 4, !tbaa !5
  %127 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %109, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %128 = load i32, ptr %127, align 4, !tbaa !5
  store i32 %128, ptr %109, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  %indvars.iv.next126 = add nuw nsw i64 %indvars.iv125, 1
  %129 = load i32, ptr %1, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %.not72.not = icmp slt i64 %indvars.iv125, %130
  br i1 %.not72.not, label %.lr.ph101.split.peel.next, label %._crit_edge102, !llvm.loop !19

131:                                              ; preds = %._crit_edge106
  %132 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %106, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %133 unwind label %35

133:                                              ; preds = %131
  %134 = getelementptr inbounds i8, ptr %2, i64 16
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %134) #8
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0

.loopexit.loopexit:                               ; preds = %52, %37, %35
  %.pn = phi { ptr, i32 } [ %53, %52 ], [ %36, %35 ], [ %38, %37 ]
  %135 = getelementptr inbounds i8, ptr %2, i64 16
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %135) #8
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit112, %.loopexit.loopexit
  %.pn.pn = phi { ptr, i32 } [ %.pn, %.loopexit.loopexit ], [ %34, %.loopexit.loopexit112 ]
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  resume { ptr, i32 } %.pn.pn
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BIT3addEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #6

; 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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = { noreturn 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 #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 }
attributes #9 = { noreturn 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !16}
!16 = !{!"llvm.loop.peeled.count", i32 1}
!17 = distinct !{!17, !10, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = distinct !{!19, !10, !16}


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