; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (1087)

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

%struct.AC = type { [10 x i32], i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@trie = external dso_local global [50 x %struct.AC], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@l = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@que = external dso_local global [1666623 x i32], align 16
@pre = external dso_local global [1666623 x [2 x i32]], align 16
@ans = external dso_local global [1666623 x i32], align 16
@len = external dso_local global i32, align 4
@f = external dso_local global [50 x [1010 x [33 x i8]]], align 16
@flag = external dso_local global i8, align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

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

declare i32 @__isoc99_scanf(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: mustprogress nounwind uwtable
declare dso_local void @_Z5buildv() #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2SDiii(i32 noundef, i32 noundef, i32 noundef) #4

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %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
  store i32 0, ptr %1, align 4
  br label %18

18:                                               ; preds = %310, %0
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %21, label %311

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %22 = load i32, ptr @m, align 4, !tbaa !5
  %23 = shl i32 1, %22
  store i32 %23, ptr %2, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @trie, i8 0, i64 2600, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %31, %21
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr @m, align 4, !tbaa !5
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %34

29:                                               ; preds = %24
  %30 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z6inserti(i32 noundef %30)
  br label %31

31:                                               ; preds = %29
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %3, align 4, !tbaa !5
  br label %24, !llvm.loop !9

34:                                               ; preds = %28
  call void @_Z5buildv()
  call void @llvm.memset.p0.i64(ptr align 16 @f, i8 0, i64 1666500, i1 false)
  store i8 0, ptr @flag, align 1, !tbaa !11
  store i32 0, ptr @r, align 4, !tbaa !5
  store i32 0, ptr @l, align 4, !tbaa !5
  store i8 1, ptr @f, align 16, !tbaa !11
  %35 = call noundef i32 @_Z2SDiii(i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %36 = load i32, ptr @r, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr @r, align 4, !tbaa !5
  %38 = sext i32 %36 to i64
  %39 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %38
  store i32 %35, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %268, %34
  %41 = load i32, ptr @l, align 4, !tbaa !5
  %42 = load i32, ptr @r, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %44, label %269

44:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %45 = load i32, ptr @l, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %46
  call void @_Z2DSRKiRiS1_S1_(ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %255, %44
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = icmp slt i32 %49, 10
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i32 9, ptr %8, align 4
  br label %258

52:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %53 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %53, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = mul nsw i32 %54, 10
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = add nsw i32 %55, %56
  %58 = load i32, ptr @n, align 4, !tbaa !5
  %59 = srem i32 %57, %58
  store i32 %59, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %60 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %60, ptr %11, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %77, %52
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %75

64:                                               ; preds = %61
  %65 = load i32, ptr %9, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %66
  %68 = getelementptr inbounds %struct.AC, ptr %67, i32 0, i32 0
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [10 x i32], ptr %68, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 0
  %74 = xor i1 %73, true
  br label %75

75:                                               ; preds = %64, %61
  %76 = phi i1 [ false, %61 ], [ %74, %64 ]
  br i1 %76, label %77, label %83

77:                                               ; preds = %75
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.AC, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !13
  store i32 %82, ptr %9, align 4, !tbaa !5
  br label %61, !llvm.loop !15

83:                                               ; preds = %75
  %84 = load i32, ptr %9, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.AC, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [10 x i32], ptr %87, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %102

93:                                               ; preds = %83
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.AC, ptr %96, i32 0, i32 0
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [10 x i32], ptr %97, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  store i32 %101, ptr %9, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %93, %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %103 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %103, ptr %12, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %122, %102
  %105 = load i32, ptr %12, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.AC, ptr %107, i32 0, i32 3
  %109 = load i32, ptr %108, align 4, !tbaa !16
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %112, label %111

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

112:                                              ; preds = %104
  %113 = load i32, ptr %12, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %114
  %116 = getelementptr inbounds %struct.AC, ptr %115, i32 0, i32 3
  %117 = load i32, ptr %116, align 4, !tbaa !16
  %118 = sub nsw i32 %117, 1
  %119 = shl i32 1, %118
  %120 = load i32, ptr %11, align 4, !tbaa !5
  %121 = or i32 %120, %119
  store i32 %121, ptr %11, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %112
  %123 = load i32, ptr %12, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %124
  %126 = getelementptr inbounds %struct.AC, ptr %125, i32 0, i32 2
  %127 = load i32, ptr %126, align 4, !tbaa !17
  store i32 %127, ptr %12, align 4, !tbaa !5
  br label %104, !llvm.loop !18

128:                                              ; preds = %111
  %129 = load i32, ptr %10, align 4, !tbaa !5
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %154, label %131

131:                                              ; preds = %128
  %132 = load i32, ptr %11, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  %134 = load i32, ptr %2, align 4, !tbaa !5
  %135 = icmp eq i32 %133, %134
  br i1 %135, label %136, label %154

136:                                              ; preds = %131
  %137 = load i32, ptr @l, align 4, !tbaa !5
  %138 = load i32, ptr @r, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %139
  %141 = getelementptr inbounds [2 x i32], ptr %140, i64 0, i64 0
  store i32 %137, ptr %141, align 8, !tbaa !5
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = load i32, ptr @r, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %144
  %146 = getelementptr inbounds [2 x i32], ptr %145, i64 0, i64 1
  store i32 %142, ptr %146, align 4, !tbaa !5
  %147 = load i32, ptr %9, align 4, !tbaa !5
  %148 = load i32, ptr %10, align 4, !tbaa !5
  %149 = load i32, ptr %11, align 4, !tbaa !5
  %150 = call noundef i32 @_Z2SDiii(i32 noundef %147, i32 noundef %148, i32 noundef %149)
  %151 = load i32, ptr @r, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %152
  store i32 %150, ptr %153, align 4, !tbaa !5
  store i8 1, ptr @flag, align 1, !tbaa !11
  store i32 9, ptr %8, align 4
  br label %252

154:                                              ; preds = %131, %128
  %155 = load i32, ptr %9, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [50 x [1010 x [33 x i8]]], ptr @f, i64 0, i64 %156
  %158 = load i32, ptr %10, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [1010 x [33 x i8]], ptr %157, i64 0, i64 %159
  %161 = load i32, ptr %11, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [33 x i8], ptr %160, i64 0, i64 %162
  %164 = load i8, ptr %163, align 1, !tbaa !11, !range !19, !noundef !20
  %165 = trunc i8 %164 to i1
  br i1 %165, label %194, label %166

166:                                              ; preds = %154
  %167 = load i32, ptr @l, align 4, !tbaa !5
  %168 = load i32, ptr @r, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %169
  %171 = getelementptr inbounds [2 x i32], ptr %170, i64 0, i64 0
  store i32 %167, ptr %171, align 8, !tbaa !5
  %172 = load i32, ptr %7, align 4, !tbaa !5
  %173 = load i32, ptr @r, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %174
  %176 = getelementptr inbounds [2 x i32], ptr %175, i64 0, i64 1
  store i32 %172, ptr %176, align 4, !tbaa !5
  %177 = load i32, ptr %9, align 4, !tbaa !5
  %178 = load i32, ptr %10, align 4, !tbaa !5
  %179 = load i32, ptr %11, align 4, !tbaa !5
  %180 = call noundef i32 @_Z2SDiii(i32 noundef %177, i32 noundef %178, i32 noundef %179)
  %181 = load i32, ptr @r, align 4, !tbaa !5
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr @r, align 4, !tbaa !5
  %183 = sext i32 %181 to i64
  %184 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %183
  store i32 %180, ptr %184, align 4, !tbaa !5
  %185 = load i32, ptr %9, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [50 x [1010 x [33 x i8]]], ptr @f, i64 0, i64 %186
  %188 = load i32, ptr %10, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [1010 x [33 x i8]], ptr %187, i64 0, i64 %189
  %191 = load i32, ptr %11, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [33 x i8], ptr %190, i64 0, i64 %192
  store i8 1, ptr %193, align 1, !tbaa !11
  br label %194

194:                                              ; preds = %166, %154
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %195 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %195, ptr %13, align 4, !tbaa !5
  br label %196

196:                                              ; preds = %245, %194
  %197 = load i32, ptr %13, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %198
  %200 = getelementptr inbounds %struct.AC, ptr %199, i32 0, i32 3
  %201 = load i32, ptr %200, align 4, !tbaa !16
  %202 = icmp ne i32 %201, 0
  br i1 %202, label %204, label %203

203:                                              ; preds = %196
  store i32 17, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %251

204:                                              ; preds = %196
  %205 = load i32, ptr %13, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [50 x [1010 x [33 x i8]]], ptr @f, i64 0, i64 %206
  %208 = load i32, ptr %10, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [1010 x [33 x i8]], ptr %207, i64 0, i64 %209
  %211 = load i32, ptr %11, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [33 x i8], ptr %210, i64 0, i64 %212
  %214 = load i8, ptr %213, align 1, !tbaa !11, !range !19, !noundef !20
  %215 = trunc i8 %214 to i1
  br i1 %215, label %244, label %216

216:                                              ; preds = %204
  %217 = load i32, ptr @l, align 4, !tbaa !5
  %218 = load i32, ptr @r, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %219
  %221 = getelementptr inbounds [2 x i32], ptr %220, i64 0, i64 0
  store i32 %217, ptr %221, align 8, !tbaa !5
  %222 = load i32, ptr %7, align 4, !tbaa !5
  %223 = load i32, ptr @r, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %224
  %226 = getelementptr inbounds [2 x i32], ptr %225, i64 0, i64 1
  store i32 %222, ptr %226, align 4, !tbaa !5
  %227 = load i32, ptr %13, align 4, !tbaa !5
  %228 = load i32, ptr %10, align 4, !tbaa !5
  %229 = load i32, ptr %11, align 4, !tbaa !5
  %230 = call noundef i32 @_Z2SDiii(i32 noundef %227, i32 noundef %228, i32 noundef %229)
  %231 = load i32, ptr @r, align 4, !tbaa !5
  %232 = add nsw i32 %231, 1
  store i32 %232, ptr @r, align 4, !tbaa !5
  %233 = sext i32 %231 to i64
  %234 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %233
  store i32 %230, ptr %234, align 4, !tbaa !5
  %235 = load i32, ptr %13, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [50 x [1010 x [33 x i8]]], ptr @f, i64 0, i64 %236
  %238 = load i32, ptr %10, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [1010 x [33 x i8]], ptr %237, i64 0, i64 %239
  %241 = load i32, ptr %11, align 4, !tbaa !5
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [33 x i8], ptr %240, i64 0, i64 %242
  store i8 1, ptr %243, align 1, !tbaa !11
  br label %244

244:                                              ; preds = %216, %204
  br label %245

245:                                              ; preds = %244
  %246 = load i32, ptr %13, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %247
  %249 = getelementptr inbounds %struct.AC, ptr %248, i32 0, i32 2
  %250 = load i32, ptr %249, align 4, !tbaa !17
  store i32 %250, ptr %13, align 4, !tbaa !5
  br label %196, !llvm.loop !21

251:                                              ; preds = %203
  store i32 0, ptr %8, align 4
  br label %252

252:                                              ; preds = %251, %136
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  %253 = load i32, ptr %8, align 4
  switch i32 %253, label %258 [
    i32 0, label %254
  ]

254:                                              ; preds = %252
  br label %255

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

258:                                              ; preds = %252, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %259

259:                                              ; preds = %258
  %260 = load i8, ptr @flag, align 1, !tbaa !11, !range !19, !noundef !20
  %261 = trunc i8 %260 to i1
  br i1 %261, label %262, label %263

262:                                              ; preds = %259
  store i32 8, ptr %8, align 4
  br label %266

263:                                              ; preds = %259
  %264 = load i32, ptr @l, align 4, !tbaa !5
  %265 = add nsw i32 %264, 1
  store i32 %265, ptr @l, align 4, !tbaa !5
  store i32 0, ptr %8, align 4
  br label %266

266:                                              ; preds = %263, %262
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  %267 = load i32, ptr %8, align 4
  switch i32 %267, label %312 [
    i32 0, label %268
    i32 8, label %269
  ]

268:                                              ; preds = %266
  br label %40, !llvm.loop !23

269:                                              ; preds = %266, %40
  %270 = load i8, ptr @flag, align 1, !tbaa !11, !range !19, !noundef !20
  %271 = trunc i8 %270 to i1
  br i1 %271, label %272, label %308

272:                                              ; preds = %269
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr @len, align 4, !tbaa !5
  br label %273

273:                                              ; preds = %276, %272
  %274 = load i32, ptr @r, align 4, !tbaa !5
  %275 = icmp sgt i32 %274, 0
  br i1 %275, label %276, label %291

276:                                              ; preds = %273
  %277 = load i32, ptr @r, align 4, !tbaa !5
  %278 = sext i32 %277 to i64
  %279 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %278
  %280 = getelementptr inbounds [2 x i32], ptr %279, i64 0, i64 1
  %281 = load i32, ptr %280, align 4, !tbaa !5
  %282 = load i32, ptr @len, align 4, !tbaa !5
  %283 = add nsw i32 %282, 1
  store i32 %283, ptr @len, align 4, !tbaa !5
  %284 = sext i32 %282 to i64
  %285 = getelementptr inbounds [1666623 x i32], ptr @ans, i64 0, i64 %284
  store i32 %281, ptr %285, align 4, !tbaa !5
  %286 = load i32, ptr @r, align 4, !tbaa !5
  %287 = sext i32 %286 to i64
  %288 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %287
  %289 = getelementptr inbounds [2 x i32], ptr %288, i64 0, i64 0
  %290 = load i32, ptr %289, align 8, !tbaa !5
  store i32 %290, ptr @r, align 4, !tbaa !5
  br label %273, !llvm.loop !24

291:                                              ; preds = %273
  %292 = load i32, ptr @len, align 4, !tbaa !5
  %293 = sub nsw i32 %292, 1
  store i32 %293, ptr %14, align 4, !tbaa !5
  br label %294

294:                                              ; preds = %303, %291
  %295 = load i32, ptr %14, align 4, !tbaa !5
  %296 = icmp sge i32 %295, 0
  br i1 %296, label %297, label %306

297:                                              ; preds = %294
  %298 = load i32, ptr %14, align 4, !tbaa !5
  %299 = sext i32 %298 to i64
  %300 = getelementptr inbounds [1666623 x i32], ptr @ans, i64 0, i64 %299
  %301 = load i32, ptr %300, align 4, !tbaa !5
  %302 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %301)
  br label %303

303:                                              ; preds = %297
  %304 = load i32, ptr %14, align 4, !tbaa !5
  %305 = add nsw i32 %304, -1
  store i32 %305, ptr %14, align 4, !tbaa !5
  br label %294, !llvm.loop !25

306:                                              ; preds = %294
  %307 = call i32 @putchar(i32 noundef 10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %310

308:                                              ; preds = %269
  %309 = call i32 @puts(ptr noundef @.str.2)
  br label %310

310:                                              ; preds = %308, %306
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %18, !llvm.loop !26

311:                                              ; preds = %18
  ret i32 0

312:                                              ; preds = %266
  unreachable
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #6

declare i32 @puts(ptr noundef) #3

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

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

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

%struct.AC = type { [10 x i32], i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@trie = external dso_local local_unnamed_addr global [50 x %struct.AC], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@l = external dso_local local_unnamed_addr global i32, align 4
@r = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [1666623 x i32], align 16
@pre = external dso_local local_unnamed_addr global [1666623 x [2 x i32]], align 16
@ans = external dso_local local_unnamed_addr global [1666623 x i32], align 16
@len = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local local_unnamed_addr global [50 x [1010 x [33 x i8]]], align 16
@flag = external dso_local local_unnamed_addr global i8, align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) 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: mustprogress nounwind uwtable
declare dso_local void @_Z5buildv() local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2SDiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = icmp eq i32 %4, 2
  br i1 %5, label %.lr.ph110, label %._crit_edge111

.lr.ph110:                                        ; preds = %0, %131
  %6 = load i32, ptr @m, align 4, !tbaa !5
  %7 = shl nuw i32 1, %6
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(2600) @trie, i8 0, i64 2600, i1 false)
  %.not79 = icmp slt i32 %6, 1
  br i1 %.not79, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph110
  call void @_Z5buildv()
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1666500) @f, i8 0, i64 1666500, i1 false)
  store i8 0, ptr @flag, align 1, !tbaa !9
  store i32 0, ptr @r, align 4, !tbaa !5
  store i32 0, ptr @l, align 4, !tbaa !5
  store i8 1, ptr @f, align 16, !tbaa !9
  %8 = call noundef i32 @_Z2SDiii(i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %9 = load i32, ptr @r, align 4, !tbaa !5
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr @r, align 4, !tbaa !5
  %11 = sext i32 %9 to i64
  %12 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %11
  store i32 %8, ptr %12, align 4, !tbaa !5
  %13 = load i32, ptr @l, align 4, !tbaa !5
  %.not = icmp sgt i32 %13, %9
  br i1 %.not, label %._crit_edge..loopexit77_crit_edge, label %.lr.ph100

._crit_edge..loopexit77_crit_edge:                ; preds = %._crit_edge
  %.pre125 = load i8, ptr @flag, align 1, !tbaa !9, !range !11
  br label %.loopexit77

.lr.ph:                                           ; preds = %.lr.ph110, %.lr.ph
  %.080 = phi i32 [ %14, %.lr.ph ], [ 1, %.lr.ph110 ]
  call void @_Z6inserti(i32 noundef %.080)
  %14 = add nuw nsw i32 %.080, 1
  %15 = load i32, ptr @m, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.080, %15
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !12

.lr.ph100:                                        ; preds = %._crit_edge, %103
  %16 = phi i32 [ %105, %103 ], [ %13, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %17
  call void @_Z2DSRKiRiS1_S1_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %19

19:                                               ; preds = %.lr.ph100, %._crit_edge97
  %indvars.iv = phi i64 [ 0, %.lr.ph100 ], [ %indvars.iv.next, %._crit_edge97 ]
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = mul nsw i32 %20, 10
  %22 = trunc nuw nsw i64 %indvars.iv to i32
  %23 = add nsw i32 %21, %22
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = srem i32 %23, %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %.06081 = load i32, ptr %1, align 4, !tbaa !5
  %.not6682 = icmp eq i32 %.06081, 0
  br i1 %.not6682, label %.critedge, label %.lr.ph85

27:                                               ; preds = %.lr.ph85
  %28 = getelementptr inbounds i8, ptr %30, i64 40
  %.060 = load i32, ptr %28, align 4, !tbaa !5
  %.not66 = icmp eq i32 %.060, 0
  br i1 %.not66, label %.critedge, label %.lr.ph85, !llvm.loop !14

.lr.ph85:                                         ; preds = %19, %27
  %.06083 = phi i32 [ %.060, %27 ], [ %.06081, %19 ]
  %29 = sext i32 %.06083 to i64
  %30 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %29
  %31 = getelementptr inbounds [10 x i32], ptr %30, i64 0, i64 %indvars.iv
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.not67 = icmp eq i32 %32, 0
  br i1 %.not67, label %27, label %.critedge

.critedge:                                        ; preds = %.lr.ph85, %27, %19
  %.060.lcssa = phi i32 [ 0, %19 ], [ 0, %27 ], [ %.06083, %.lr.ph85 ]
  %33 = sext i32 %.060.lcssa to i64
  %34 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %33
  %35 = getelementptr inbounds [10 x i32], ptr %34, i64 0, i64 %indvars.iv
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %.not68 = icmp eq i32 %36, 0
  %spec.select = select i1 %.not68, i32 %.060.lcssa, i32 %36
  %37 = sext i32 %spec.select to i64
  %38 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %37, i32 3
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %.not6988 = icmp eq i32 %39, 0
  br i1 %.not6988, label %._crit_edge91, label %.lr.ph90

._crit_edge91:                                    ; preds = %.lr.ph90, %.critedge
  %.059.lcssa = phi i32 [ %26, %.critedge ], [ %46, %.lr.ph90 ]
  %.not70 = icmp eq i32 %25, 0
  %40 = add nsw i32 %.059.lcssa, 1
  %41 = icmp eq i32 %40, %7
  %or.cond = select i1 %.not70, i1 %41, i1 false
  br i1 %or.cond, label %.loopexit.thread, label %61

.lr.ph90:                                         ; preds = %.critedge, %.lr.ph90
  %42 = phi i32 [ %51, %.lr.ph90 ], [ %39, %.critedge ]
  %43 = phi i64 [ %49, %.lr.ph90 ], [ %37, %.critedge ]
  %.05989 = phi i32 [ %46, %.lr.ph90 ], [ %26, %.critedge ]
  %44 = add nsw i32 %42, -1
  %45 = shl nuw i32 1, %44
  %46 = or i32 %45, %.05989
  %47 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %43, i32 2
  %48 = load i32, ptr %47, align 4, !tbaa !17
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %49, i32 3
  %51 = load i32, ptr %50, align 4, !tbaa !15
  %.not69 = icmp eq i32 %51, 0
  br i1 %.not69, label %._crit_edge91, label %.lr.ph90, !llvm.loop !18

.loopexit.thread:                                 ; preds = %._crit_edge91
  %52 = load i32, ptr @l, align 4, !tbaa !5
  %53 = load i32, ptr @r, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %54
  store i32 %52, ptr %55, align 8, !tbaa !5
  %56 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %54, i64 1
  store i32 %22, ptr %56, align 4, !tbaa !5
  %57 = call noundef i32 @_Z2SDiii(i32 noundef %spec.select, i32 noundef 0, i32 noundef %.059.lcssa)
  %58 = load i32, ptr @r, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %59
  store i32 %57, ptr %60, align 4, !tbaa !5
  store i8 1, ptr @flag, align 1, !tbaa !9
  br label %.thread

61:                                               ; preds = %._crit_edge91
  %62 = sext i32 %25 to i64
  %63 = sext i32 %.059.lcssa to i64
  %64 = getelementptr inbounds [50 x [1010 x [33 x i8]]], ptr @f, i64 0, i64 %37, i64 %62, i64 %63
  %65 = load i8, ptr %64, align 1, !tbaa !9, !range !11, !noundef !19
  %66 = trunc nuw i8 %65 to i1
  br i1 %66, label %78, label %67

67:                                               ; preds = %61
  %68 = load i32, ptr @l, align 4, !tbaa !5
  %69 = load i32, ptr @r, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %70
  store i32 %68, ptr %71, align 8, !tbaa !5
  %72 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %70, i64 1
  store i32 %22, ptr %72, align 4, !tbaa !5
  %73 = call noundef i32 @_Z2SDiii(i32 noundef %spec.select, i32 noundef %25, i32 noundef %.059.lcssa)
  %74 = load i32, ptr @r, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr @r, align 4, !tbaa !5
  %76 = sext i32 %74 to i64
  %77 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %76
  store i32 %73, ptr %77, align 4, !tbaa !5
  store i8 1, ptr %64, align 1, !tbaa !9
  %.pre = load i32, ptr %38, align 4, !tbaa !15
  br label %78

78:                                               ; preds = %67, %61
  %79 = phi i32 [ %.pre, %67 ], [ %39, %61 ]
  %.not7193 = icmp eq i32 %79, 0
  br i1 %.not7193, label %._crit_edge97, label %.lr.ph96

.lr.ph96:                                         ; preds = %78, %95
  %80 = phi i64 [ %98, %95 ], [ %37, %78 ]
  %.05794 = phi i32 [ %97, %95 ], [ %spec.select, %78 ]
  %81 = getelementptr inbounds [50 x [1010 x [33 x i8]]], ptr @f, i64 0, i64 %80, i64 %62, i64 %63
  %82 = load i8, ptr %81, align 1, !tbaa !9, !range !11, !noundef !19
  %83 = trunc nuw i8 %82 to i1
  br i1 %83, label %95, label %84

84:                                               ; preds = %.lr.ph96
  %85 = load i32, ptr @l, align 4, !tbaa !5
  %86 = load i32, ptr @r, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %87
  store i32 %85, ptr %88, align 8, !tbaa !5
  %89 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %87, i64 1
  store i32 %22, ptr %89, align 4, !tbaa !5
  %90 = call noundef i32 @_Z2SDiii(i32 noundef %.05794, i32 noundef %25, i32 noundef %.059.lcssa)
  %91 = load i32, ptr @r, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr @r, align 4, !tbaa !5
  %93 = sext i32 %91 to i64
  %94 = getelementptr inbounds [1666623 x i32], ptr @que, i64 0, i64 %93
  store i32 %90, ptr %94, align 4, !tbaa !5
  store i8 1, ptr %81, align 1, !tbaa !9
  br label %95

95:                                               ; preds = %.lr.ph96, %84
  %96 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %80, i32 2
  %97 = load i32, ptr %96, align 4, !tbaa !17
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [50 x %struct.AC], ptr @trie, i64 0, i64 %98, i32 3
  %100 = load i32, ptr %99, align 4, !tbaa !15
  %.not71 = icmp eq i32 %100, 0
  br i1 %.not71, label %._crit_edge97, label %.lr.ph96, !llvm.loop !20

._crit_edge97:                                    ; preds = %95, %78
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
  br i1 %exitcond.not, label %.loopexit, label %19, !llvm.loop !21

.loopexit:                                        ; preds = %._crit_edge97
  %.pre124 = load i8, ptr @flag, align 1, !tbaa !9, !range !11
  %101 = trunc nuw i8 %.pre124 to i1
  br i1 %101, label %.thread, label %103

.thread:                                          ; preds = %.loopexit, %.loopexit.thread
  %102 = phi i8 [ 1, %.loopexit.thread ], [ %.pre124, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  br label %.loopexit77

103:                                              ; preds = %.loopexit
  %104 = load i32, ptr @l, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr @l, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %106 = load i32, ptr @r, align 4, !tbaa !5
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %.lr.ph100, label %.loopexit77

.loopexit77:                                      ; preds = %103, %._crit_edge..loopexit77_crit_edge, %.thread
  %108 = phi i8 [ %.pre125, %._crit_edge..loopexit77_crit_edge ], [ %102, %.thread ], [ %.pre124, %103 ]
  %109 = trunc nuw i8 %108 to i1
  br i1 %109, label %110, label %129

110:                                              ; preds = %.loopexit77
  store i32 0, ptr @len, align 4, !tbaa !5
  %.pr = load i32, ptr @r, align 4, !tbaa !5
  %111 = icmp sgt i32 %.pr, 0
  br i1 %111, label %.lr.ph102, label %._crit_edge108

.lr.ph102:                                        ; preds = %110, %.lr.ph102
  %indvars.iv118 = phi i64 [ %indvars.iv.next119, %.lr.ph102 ], [ 0, %110 ]
  %112 = phi i32 [ %118, %.lr.ph102 ], [ %.pr, %110 ]
  %113 = zext nneg i32 %112 to i64
  %114 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %113, i64 1
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %indvars.iv.next119 = add nuw nsw i64 %indvars.iv118, 1
  %116 = getelementptr inbounds [1666623 x i32], ptr @ans, i64 0, i64 %indvars.iv118
  store i32 %115, ptr %116, align 4, !tbaa !5
  %117 = getelementptr inbounds [1666623 x [2 x i32]], ptr @pre, i64 0, i64 %113
  %118 = load i32, ptr %117, align 8, !tbaa !5
  %119 = icmp sgt i32 %118, 0
  br i1 %119, label %.lr.ph102, label %120, !llvm.loop !22

120:                                              ; preds = %.lr.ph102
  %121 = trunc nuw i64 %indvars.iv.next119 to i32
  store i32 %121, ptr @len, align 4, !tbaa !5
  store i32 %118, ptr @r, align 4, !tbaa !5
  %122 = icmp sgt i32 %121, 0
  br i1 %122, label %.lr.ph107.preheader, label %._crit_edge108

.lr.ph107.preheader:                              ; preds = %120
  %123 = and i64 %indvars.iv.next119, 2147483647
  br label %.lr.ph107

.lr.ph107:                                        ; preds = %.lr.ph107.preheader, %.lr.ph107
  %indvars.iv121 = phi i64 [ %123, %.lr.ph107.preheader ], [ %indvars.iv.next122, %.lr.ph107 ]
  %indvars.iv.next122 = add nsw i64 %indvars.iv121, -1
  %124 = getelementptr inbounds [1666623 x i32], ptr @ans, i64 0, i64 %indvars.iv.next122
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %125)
  %127 = icmp ugt i64 %indvars.iv121, 1
  br i1 %127, label %.lr.ph107, label %._crit_edge108, !llvm.loop !23

._crit_edge108:                                   ; preds = %.lr.ph107, %110, %120
  %128 = call i32 @putchar(i32 noundef 10)
  br label %131

129:                                              ; preds = %.loopexit77
  %130 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %131

131:                                              ; preds = %129, %._crit_edge108
  %132 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %133 = icmp eq i32 %132, 2
  br i1 %133, label %.lr.ph110, label %._crit_edge111, !llvm.loop !24

._crit_edge111:                                   ; preds = %131, %0
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

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

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

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


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