; LLVM IR from reyadussalahin/problem-solving :: string/hashing/codeforces/F835D (Solution)

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

@memo = external dso_local global [5004 x [5004 x i32]], align 16
@maxk = external dso_local global [5004 x [5004 x i32]], align 16
@cnt = external dso_local global [5004 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [5004 x i8], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %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
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 5004, ptr %2) #5
  %21 = getelementptr inbounds [5004 x i8], ptr %2, i64 0, i64 0
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %23 = getelementptr inbounds [5004 x i8], ptr %2, i64 0, i64 0
  %24 = call i64 @strlen(ptr noundef %23) #6
  %25 = trunc i64 %24 to i32
  store i32 %25, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %84, %0
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %87

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 47, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 1, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %32 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %32, ptr %10, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %80, %31
  %34 = load i32, ptr %10, align 4, !tbaa !5
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %83

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %39 = load i32, ptr %10, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [5004 x i8], ptr %2, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = sext i8 %42 to i32
  %44 = sub nsw i32 %43, 97
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %11, align 4, !tbaa !5
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = load i64, ptr %8, align 8, !tbaa !9
  %48 = mul nsw i64 %46, %47
  %49 = load i32, ptr %11, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = add nsw i64 %48, %50
  %52 = srem i64 %51, 1000000007
  store i64 %52, ptr %6, align 8, !tbaa !9
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = load i64, ptr %9, align 8, !tbaa !9
  %57 = mul nsw i64 %55, %56
  %58 = add nsw i64 %53, %57
  %59 = srem i64 %58, 1000000007
  store i64 %59, ptr %7, align 8, !tbaa !9
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = load i64, ptr %8, align 8, !tbaa !9
  %62 = mul nsw i64 %60, %61
  %63 = srem i64 %62, 1000000007
  store i64 %63, ptr %9, align 8, !tbaa !9
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = trunc i64 %64 to i32
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %67
  %69 = load i32, ptr %10, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [5004 x i32], ptr %68, i64 0, i64 %70
  store i32 %65, ptr %71, align 4, !tbaa !5
  %72 = load i64, ptr %7, align 8, !tbaa !9
  %73 = trunc i64 %72 to i32
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %75
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [5004 x i32], ptr %76, i64 0, i64 %78
  store i32 %73, ptr %79, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %80

80:                                               ; preds = %38
  %81 = load i32, ptr %10, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %10, align 4, !tbaa !5
  br label %33, !llvm.loop !12

83:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %4, align 4, !tbaa !5
  br label %26, !llvm.loop !14

87:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %241, %87
  %89 = load i32, ptr %12, align 4, !tbaa !5
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = icmp sle i32 %89, %90
  br i1 %91, label %93, label %92

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

93:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %94 = load i32, ptr %13, align 4, !tbaa !5
  %95 = load i32, ptr %12, align 4, !tbaa !5
  %96 = add nsw i32 %94, %95
  %97 = sub nsw i32 %96, 1
  store i32 %97, ptr %14, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %235, %93
  %99 = load i32, ptr %14, align 4, !tbaa !5
  %100 = load i32, ptr %3, align 4, !tbaa !5
  %101 = icmp slt i32 %99, %100
  br i1 %101, label %103, label %102

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

103:                                              ; preds = %98
  %104 = load i32, ptr %13, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %105
  %107 = load i32, ptr %14, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [5004 x i32], ptr %106, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = load i32, ptr %14, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %112
  %114 = load i32, ptr %13, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [5004 x i32], ptr %113, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = icmp eq i32 %110, %117
  br i1 %118, label %119, label %234

119:                                              ; preds = %103
  %120 = load i32, ptr %13, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %121
  %123 = load i32, ptr %14, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [5004 x i32], ptr %122, i64 0, i64 %124
  store i32 1, ptr %125, align 4, !tbaa !5
  %126 = load i32, ptr %12, align 4, !tbaa !5
  %127 = and i32 %126, 1
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %176

129:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %130 = load i32, ptr %13, align 4, !tbaa !5
  %131 = load i32, ptr %14, align 4, !tbaa !5
  %132 = add nsw i32 %130, %131
  %133 = sdiv i32 %132, 2
  store i32 %133, ptr %15, align 4, !tbaa !5
  %134 = load i32, ptr %13, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %135
  %137 = load i32, ptr %15, align 4, !tbaa !5
  %138 = sub nsw i32 %137, 1
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [5004 x i32], ptr %136, i64 0, i64 %139
  %141 = load i32, ptr %140, align 4, !tbaa !5
  %142 = load i32, ptr %15, align 4, !tbaa !5
  %143 = add nsw i32 %142, 1
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %144
  %146 = load i32, ptr %14, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [5004 x i32], ptr %145, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = icmp eq i32 %141, %149
  br i1 %150, label %151, label %175

151:                                              ; preds = %129
  %152 = load i32, ptr %13, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %153
  %155 = load i32, ptr %14, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [5004 x i32], ptr %154, i64 0, i64 %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %158 = load i32, ptr %15, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %160
  %162 = load i32, ptr %14, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [5004 x i32], ptr %161, i64 0, i64 %163
  %165 = load i32, ptr %164, align 4, !tbaa !5
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %16, align 4, !tbaa !5
  %167 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %157, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %168 = load i32, ptr %167, align 4, !tbaa !5
  %169 = load i32, ptr %13, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %170
  %172 = load i32, ptr %14, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [5004 x i32], ptr %171, i64 0, i64 %173
  store i32 %168, ptr %174, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %175

175:                                              ; preds = %151, %129
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %222

176:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %177 = load i32, ptr %13, align 4, !tbaa !5
  %178 = load i32, ptr %14, align 4, !tbaa !5
  %179 = add nsw i32 %177, %178
  %180 = sdiv i32 %179, 2
  store i32 %180, ptr %17, align 4, !tbaa !5
  %181 = load i32, ptr %13, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %182
  %184 = load i32, ptr %17, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [5004 x i32], ptr %183, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  %188 = load i32, ptr %17, align 4, !tbaa !5
  %189 = add nsw i32 %188, 1
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %190
  %192 = load i32, ptr %14, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [5004 x i32], ptr %191, i64 0, i64 %193
  %195 = load i32, ptr %194, align 4, !tbaa !5
  %196 = icmp eq i32 %187, %195
  br i1 %196, label %197, label %221

197:                                              ; preds = %176
  %198 = load i32, ptr %13, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %199
  %201 = load i32, ptr %14, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [5004 x i32], ptr %200, i64 0, i64 %202
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %204 = load i32, ptr %17, align 4, !tbaa !5
  %205 = add nsw i32 %204, 1
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %206
  %208 = load i32, ptr %14, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [5004 x i32], ptr %207, i64 0, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !5
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %18, align 4, !tbaa !5
  %213 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %203, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %214 = load i32, ptr %213, align 4, !tbaa !5
  %215 = load i32, ptr %13, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %216
  %218 = load i32, ptr %14, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [5004 x i32], ptr %217, i64 0, i64 %219
  store i32 %214, ptr %220, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %221

221:                                              ; preds = %197, %176
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %222

222:                                              ; preds = %221, %175
  %223 = load i32, ptr %13, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %224
  %226 = load i32, ptr %14, align 4, !tbaa !5
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [5004 x i32], ptr %225, i64 0, i64 %227
  %229 = load i32, ptr %228, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !5
  %233 = add nsw i32 %232, 1
  store i32 %233, ptr %231, align 4, !tbaa !5
  br label %234

234:                                              ; preds = %222, %103
  br label %235

235:                                              ; preds = %234
  %236 = load i32, ptr %13, align 4, !tbaa !5
  %237 = add nsw i32 %236, 1
  store i32 %237, ptr %13, align 4, !tbaa !5
  %238 = load i32, ptr %14, align 4, !tbaa !5
  %239 = add nsw i32 %238, 1
  store i32 %239, ptr %14, align 4, !tbaa !5
  br label %98, !llvm.loop !15

240:                                              ; preds = %102
  br label %241

241:                                              ; preds = %240
  %242 = load i32, ptr %12, align 4, !tbaa !5
  %243 = add nsw i32 %242, 1
  store i32 %243, ptr %12, align 4, !tbaa !5
  br label %88, !llvm.loop !16

244:                                              ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %245 = load i32, ptr %3, align 4, !tbaa !5
  %246 = sub nsw i32 %245, 1
  store i32 %246, ptr %19, align 4, !tbaa !5
  br label %247

247:                                              ; preds = %262, %244
  %248 = load i32, ptr %19, align 4, !tbaa !5
  %249 = icmp sgt i32 %248, 0
  br i1 %249, label %251, label %250

250:                                              ; preds = %247
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %265

251:                                              ; preds = %247
  %252 = load i32, ptr %19, align 4, !tbaa !5
  %253 = add nsw i32 %252, 1
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %254
  %256 = load i32, ptr %255, align 4, !tbaa !5
  %257 = load i32, ptr %19, align 4, !tbaa !5
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %258
  %260 = load i32, ptr %259, align 4, !tbaa !5
  %261 = add nsw i32 %260, %256
  store i32 %261, ptr %259, align 4, !tbaa !5
  br label %262

262:                                              ; preds = %251
  %263 = load i32, ptr %19, align 4, !tbaa !5
  %264 = add nsw i32 %263, -1
  store i32 %264, ptr %19, align 4, !tbaa !5
  br label %247, !llvm.loop !17

265:                                              ; preds = %250
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  store i32 1, ptr %20, align 4, !tbaa !5
  br label %266

266:                                              ; preds = %277, %265
  %267 = load i32, ptr %20, align 4, !tbaa !5
  %268 = load i32, ptr %3, align 4, !tbaa !5
  %269 = icmp sle i32 %267, %268
  br i1 %269, label %271, label %270

270:                                              ; preds = %266
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %280

271:                                              ; preds = %266
  %272 = load i32, ptr %20, align 4, !tbaa !5
  %273 = sext i32 %272 to i64
  %274 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %273
  %275 = load i32, ptr %274, align 4, !tbaa !5
  %276 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %275)
  br label %277

277:                                              ; preds = %271
  %278 = load i32, ptr %20, align 4, !tbaa !5
  %279 = add nsw i32 %278, 1
  store i32 %279, ptr %20, align 4, !tbaa !5
  br label %266, !llvm.loop !18

280:                                              ; preds = %270
  %281 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 5004, ptr %2) #5
  %282 = load i32, ptr %1, align 4
  ret i32 %282
}

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

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

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

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

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

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

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


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

@memo = external dso_local local_unnamed_addr global [5004 x [5004 x i32]], align 16
@maxk = external dso_local global [5004 x [5004 x i32]], align 16
@cnt = external dso_local local_unnamed_addr global [5004 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [5004 x i8], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 5004, ptr nonnull %1) #5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  %6 = trunc i64 %5 to i32
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader88.preheader, label %._crit_edge106

.preheader88.preheader:                           ; preds = %0
  %wide.trip.count113 = and i64 %5, 2147483647
  br label %.preheader88

.preheader88:                                     ; preds = %.preheader88.preheader, %8
  %indvars.iv = phi i64 [ 0, %.preheader88.preheader ], [ %indvars.iv.next, %8 ]
  br label %9

8:                                                ; preds = %9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond114.not = icmp eq i64 %indvars.iv.next, %wide.trip.count113
  br i1 %exitcond114.not, label %.lr.ph, label %.preheader88, !llvm.loop !5

9:                                                ; preds = %.preheader88, %9
  %indvars.iv109 = phi i64 [ %indvars.iv, %.preheader88 ], [ %indvars.iv.next110, %9 ]
  %.08091 = phi i64 [ 1, %.preheader88 ], [ %21, %9 ]
  %.08190 = phi i64 [ 0, %.preheader88 ], [ %16, %9 ]
  %.08289 = phi i64 [ 0, %.preheader88 ], [ %19, %9 ]
  %10 = getelementptr inbounds [5004 x i8], ptr %1, i64 0, i64 %indvars.iv109
  %11 = load i8, ptr %10, align 1, !tbaa !7
  %12 = sext i8 %11 to i64
  %13 = add nsw i64 %12, -96
  %14 = mul nsw i64 %.08190, 47
  %15 = add nsw i64 %13, %14
  %16 = srem i64 %15, 1000000007
  %17 = mul nsw i64 %13, %.08091
  %18 = add nsw i64 %17, %.08289
  %19 = srem i64 %18, 1000000007
  %20 = mul nsw i64 %.08091, 47
  %21 = srem i64 %20, 1000000007
  %22 = trunc nsw i64 %16 to i32
  %23 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv, i64 %indvars.iv109
  store i32 %22, ptr %23, align 4, !tbaa !10
  %24 = trunc nsw i64 %19 to i32
  %25 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv109, i64 %indvars.iv
  store i32 %24, ptr %25, align 4, !tbaa !10
  %indvars.iv.next110 = add nuw nsw i64 %indvars.iv109, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next110, %wide.trip.count113
  br i1 %exitcond.not, label %8, label %9, !llvm.loop !12

.preheader86:                                     ; preds = %._crit_edge
  %.not151 = icmp eq i32 %6, 1
  br i1 %.not151, label %.lr.ph105.preheader, label %.lr.ph102.preheader

.lr.ph102.preheader:                              ; preds = %.preheader86
  %26 = and i64 %5, 2147483647
  %.phi.trans.insert = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %26
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !10
  br label %.lr.ph102

.lr.ph:                                           ; preds = %8, %._crit_edge
  %indvars.iv124 = phi i32 [ %indvars.iv.next125, %._crit_edge ], [ %6, %8 ]
  %indvars.iv115 = phi i32 [ %indvars.iv.next116, %._crit_edge ], [ 0, %8 ]
  %.07899 = phi i32 [ %60, %._crit_edge ], [ 1, %8 ]
  %27 = sext i32 %indvars.iv115 to i64
  %28 = and i32 %.07899, 1
  %.not85 = icmp eq i32 %28, 0
  %wide.trip.count135 = zext i32 %indvars.iv124 to i64
  br i1 %.not85, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %59
  %indvars.iv130 = phi i64 [ %indvars.iv.next131, %59 ], [ 0, %.lr.ph ]
  %indvars.iv128 = phi i64 [ %indvars.iv.next129, %59 ], [ %27, %.lr.ph ]
  %29 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv130, i64 %indvars.iv128
  %30 = load i32, ptr %29, align 4, !tbaa !10
  %31 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv128, i64 %indvars.iv130
  %32 = load i32, ptr %31, align 4, !tbaa !10
  %33 = icmp eq i32 %30, %32
  br i1 %33, label %34, label %59

34:                                               ; preds = %.lr.ph.split.us
  %35 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %indvars.iv130, i64 %indvars.iv128
  store i32 1, ptr %35, align 4, !tbaa !10
  %36 = add nsw i64 %indvars.iv128, %indvars.iv130
  %37 = trunc nsw i64 %36 to i32
  %38 = sdiv i32 %37, 2
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv130, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !10
  %42 = add nsw i32 %38, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %43, i64 %indvars.iv128
  %45 = load i32, ptr %44, align 4, !tbaa !10
  %46 = icmp eq i32 %41, %45
  br i1 %46, label %47, label %53

47:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %48 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %43, i64 %indvars.iv128
  %49 = load i32, ptr %48, align 4, !tbaa !10
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %3, align 4, !tbaa !10
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %35, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %52 = load i32, ptr %51, align 4, !tbaa !10
  store i32 %52, ptr %35, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  br label %53

53:                                               ; preds = %47, %34
  %54 = phi i32 [ %52, %47 ], [ 1, %34 ]
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !10
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %56, align 4, !tbaa !10
  br label %59

59:                                               ; preds = %53, %.lr.ph.split.us
  %indvars.iv.next131 = add nuw nsw i64 %indvars.iv130, 1
  %indvars.iv.next129 = add nsw i64 %indvars.iv128, 1
  %exitcond136.not = icmp eq i64 %indvars.iv.next131, %wide.trip.count135
  br i1 %exitcond136.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !13

._crit_edge:                                      ; preds = %92, %59
  %60 = add i32 %.07899, 1
  %.not = icmp sgt i32 %60, %6
  %indvars.iv.next116 = add i32 %indvars.iv115, 1
  %indvars.iv.next125 = add i32 %indvars.iv124, -1
  br i1 %.not, label %.preheader86, label %.lr.ph, !llvm.loop !14

.lr.ph.split:                                     ; preds = %.lr.ph, %92
  %indvars.iv119 = phi i64 [ %indvars.iv.next120, %92 ], [ 0, %.lr.ph ]
  %indvars.iv117 = phi i64 [ %indvars.iv.next118, %92 ], [ %27, %.lr.ph ]
  %61 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv119, i64 %indvars.iv117
  %62 = load i32, ptr %61, align 4, !tbaa !10
  %63 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv117, i64 %indvars.iv119
  %64 = load i32, ptr %63, align 4, !tbaa !10
  %65 = icmp eq i32 %62, %64
  br i1 %65, label %66, label %92

66:                                               ; preds = %.lr.ph.split
  %67 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %indvars.iv119, i64 %indvars.iv117
  store i32 1, ptr %67, align 4, !tbaa !10
  %68 = add nsw i64 %indvars.iv117, %indvars.iv119
  %69 = trunc nsw i64 %68 to i32
  %70 = sdiv i32 %69, 2
  %71 = add nsw i32 %70, -1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %indvars.iv119, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !10
  %75 = add nsw i32 %70, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [5004 x [5004 x i32]], ptr @memo, i64 0, i64 %76, i64 %indvars.iv117
  %78 = load i32, ptr %77, align 4, !tbaa !10
  %79 = icmp eq i32 %74, %78
  br i1 %79, label %80, label %86

80:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %81 = getelementptr inbounds [5004 x [5004 x i32]], ptr @maxk, i64 0, i64 %76, i64 %indvars.iv117
  %82 = load i32, ptr %81, align 4, !tbaa !10
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %2, align 4, !tbaa !10
  %84 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %67, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %85 = load i32, ptr %84, align 4, !tbaa !10
  store i32 %85, ptr %67, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  br label %86

86:                                               ; preds = %66, %80
  %87 = phi i32 [ 1, %66 ], [ %85, %80 ]
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !10
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %89, align 4, !tbaa !10
  br label %92

92:                                               ; preds = %.lr.ph.split, %86
  %indvars.iv.next120 = add nuw nsw i64 %indvars.iv119, 1
  %indvars.iv.next118 = add nsw i64 %indvars.iv117, 1
  %exitcond127.not = icmp eq i64 %indvars.iv.next120, %wide.trip.count135
  br i1 %exitcond127.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !13

.lr.ph105.preheader:                              ; preds = %.lr.ph102, %.preheader86
  %93 = add nuw nsw i64 %5, 1
  %wide.trip.count143 = and i64 %93, 4294967295
  br label %.lr.ph105

.lr.ph102:                                        ; preds = %.lr.ph102.preheader, %.lr.ph102
  %94 = phi i32 [ %.pre, %.lr.ph102.preheader ], [ %97, %.lr.ph102 ]
  %indvars.iv137 = phi i64 [ %26, %.lr.ph102.preheader ], [ %indvars.iv.next138, %.lr.ph102 ]
  %indvars.iv.next138 = add nsw i64 %indvars.iv137, -1
  %95 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %indvars.iv.next138
  %96 = load i32, ptr %95, align 4, !tbaa !10
  %97 = add nsw i32 %96, %94
  store i32 %97, ptr %95, align 4, !tbaa !10
  %98 = icmp ugt i64 %indvars.iv137, 2
  br i1 %98, label %.lr.ph102, label %.lr.ph105.preheader, !llvm.loop !15

._crit_edge106:                                   ; preds = %.lr.ph105, %0
  %99 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  call void @llvm.lifetime.end.p0(i64 5004, ptr nonnull %1) #5
  ret i32 0

.lr.ph105:                                        ; preds = %.lr.ph105.preheader, %.lr.ph105
  %indvars.iv140 = phi i64 [ 1, %.lr.ph105.preheader ], [ %indvars.iv.next141, %.lr.ph105 ]
  %100 = getelementptr inbounds [5004 x i32], ptr @cnt, i64 0, i64 %indvars.iv140
  %101 = load i32, ptr %100, align 4, !tbaa !10
  %102 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %101)
  %indvars.iv.next141 = add nuw nsw i64 %indvars.iv140, 1
  %exitcond144.not = icmp eq i64 %indvars.iv.next141, %wide.trip.count143
  br i1 %exitcond144.not, label %._crit_edge106, label %.lr.ph105, !llvm.loop !16
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

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

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

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

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = distinct !{!12, !6}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}
!15 = distinct !{!15, !6}
!16 = distinct !{!16, !6}


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