; LLVM IR from tangjz/acm-icpc :: codeforces (533F)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [200001 x i32], align 16
@b = external dso_local global [200001 x i32], align 16
@fir = external dso_local global [27 x i32], align 16
@pos = external dso_local global [27 x i32], align 16
@f = external dso_local global [200001 x i32], align 16
@cnt = external dso_local global i32, align 4
@ans = external dso_local global [200001 x i32], align 16
@buf = external dso_local global [200001 x i8], align 16
@pat = external dso_local global [200001 x i8], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m, ptr noundef @buf, ptr noundef @pat)
  call void @llvm.memset.p0.i64(ptr align 16 @fir, i8 -1, i64 108, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @pos, i8 -1, i64 108, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %51, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @m, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [200001 x i8], ptr @pat, i64 0, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = sub nsw i32 %21, 97
  store i32 %22, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp eq i32 %26, -1
  br i1 %27, label %28, label %36

28:                                               ; preds = %16
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [200001 x i32], ptr @b, i64 0, i64 %30
  store i32 -1, ptr %31, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [27 x i32], ptr @fir, i64 0, i64 %34
  store i32 %32, ptr %35, align 4, !tbaa !5
  br label %46

36:                                               ; preds = %16
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = sub nsw i32 %37, %41
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [200001 x i32], ptr @b, i64 0, i64 %44
  store i32 %42, ptr %45, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %36, %28
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %49
  store i32 %47, ptr %50, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %51

51:                                               ; preds = %46
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !10

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

55:                                               ; preds = %96, %54
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = load i32, ptr @m, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %99

60:                                               ; preds = %55
  br label %61

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

64:                                               ; preds = %61
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [200001 x i32], ptr @b, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = call noundef zeroext i1 @_Z5matchii(i32 noundef %65, i32 noundef %69)
  %71 = xor i1 %70, true
  br label %72

72:                                               ; preds = %64, %61
  %73 = phi i1 [ false, %61 ], [ %71, %64 ]
  br i1 %73, label %74, label %80

74:                                               ; preds = %72
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  store i32 %79, ptr %5, align 4, !tbaa !5
  br label %61, !llvm.loop !12

80:                                               ; preds = %72
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [200001 x i32], ptr @b, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = call noundef zeroext i1 @_Z5matchii(i32 noundef %81, i32 noundef %85)
  br i1 %86, label %87, label %90

87:                                               ; preds = %80
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %5, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %87, %80
  %91 = load i32, ptr %5, align 4, !tbaa !5
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %94
  store i32 %91, ptr %95, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %90
  %97 = load i32, ptr %4, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %4, align 4, !tbaa !5
  br label %55, !llvm.loop !13

99:                                               ; preds = %59
  call void @llvm.memset.p0.i64(ptr align 16 @pos, i8 -1, i64 108, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %192, %99
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = load i32, ptr @n, align 4, !tbaa !5
  %103 = icmp slt i32 %101, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %195

105:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [200001 x i8], ptr @buf, i64 0, i64 %107
  %109 = load i8, ptr %108, align 1, !tbaa !9
  %110 = sext i8 %109 to i32
  %111 = sub nsw i32 %110, 97
  store i32 %111, ptr %8, align 4, !tbaa !5
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = icmp eq i32 %115, -1
  br i1 %116, label %117, label %118

117:                                              ; preds = %105
  br label %125

118:                                              ; preds = %105
  %119 = load i32, ptr %6, align 4, !tbaa !5
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = sub nsw i32 %119, %123
  br label %125

125:                                              ; preds = %118, %117
  %126 = phi i32 [ -1, %117 ], [ %124, %118 ]
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [200001 x i32], ptr @a, i64 0, i64 %128
  store i32 %126, ptr %129, align 4, !tbaa !5
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %132
  store i32 %130, ptr %133, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %148, %125
  %135 = load i32, ptr %7, align 4, !tbaa !5
  %136 = icmp ne i32 %135, 0
  br i1 %136, label %137, label %145

137:                                              ; preds = %134
  %138 = load i32, ptr %7, align 4, !tbaa !5
  %139 = load i32, ptr %6, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [200001 x i32], ptr @a, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = call noundef zeroext i1 @_Z5matchii(i32 noundef %138, i32 noundef %142)
  %144 = xor i1 %143, true
  br label %145

145:                                              ; preds = %137, %134
  %146 = phi i1 [ false, %134 ], [ %144, %137 ]
  br i1 %146, label %147, label %153

147:                                              ; preds = %145
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  store i32 %152, ptr %7, align 4, !tbaa !5
  br label %134, !llvm.loop !14

153:                                              ; preds = %145
  %154 = load i32, ptr %7, align 4, !tbaa !5
  %155 = load i32, ptr %6, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [200001 x i32], ptr @a, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = call noundef zeroext i1 @_Z5matchii(i32 noundef %154, i32 noundef %158)
  br i1 %159, label %160, label %163

160:                                              ; preds = %153
  %161 = load i32, ptr %7, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %7, align 4, !tbaa !5
  br label %163

163:                                              ; preds = %160, %153
  %164 = load i32, ptr %7, align 4, !tbaa !5
  %165 = load i32, ptr @m, align 4, !tbaa !5
  %166 = icmp eq i32 %164, %165
  br i1 %166, label %167, label %191

167:                                              ; preds = %163
  %168 = load i32, ptr %6, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds i8, ptr @buf, i64 %169
  %171 = load i32, ptr @m, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = sub i64 0, %172
  %174 = getelementptr inbounds i8, ptr %170, i64 %173
  %175 = getelementptr inbounds i8, ptr %174, i64 1
  %176 = call noundef zeroext i1 @_Z7hasPermPc(ptr noundef %175)
  br i1 %176, label %177, label %186

177:                                              ; preds = %167
  %178 = load i32, ptr %6, align 4, !tbaa !5
  %179 = load i32, ptr @m, align 4, !tbaa !5
  %180 = sub nsw i32 %178, %179
  %181 = add nsw i32 %180, 1
  %182 = load i32, ptr @cnt, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr @cnt, align 4, !tbaa !5
  %184 = sext i32 %182 to i64
  %185 = getelementptr inbounds [200001 x i32], ptr @ans, i64 0, i64 %184
  store i32 %181, ptr %185, align 4, !tbaa !5
  br label %186

186:                                              ; preds = %177, %167
  %187 = load i32, ptr %7, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %188
  %190 = load i32, ptr %189, align 4, !tbaa !5
  store i32 %190, ptr %7, align 4, !tbaa !5
  br label %191

191:                                              ; preds = %186, %163
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %192

192:                                              ; preds = %191
  %193 = load i32, ptr %6, align 4, !tbaa !5
  %194 = add nsw i32 %193, 1
  store i32 %194, ptr %6, align 4, !tbaa !5
  br label %100, !llvm.loop !15

195:                                              ; preds = %104
  %196 = load i32, ptr @cnt, align 4, !tbaa !5
  %197 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %196)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %198

198:                                              ; preds = %218, %195
  %199 = load i32, ptr %9, align 4, !tbaa !5
  %200 = load i32, ptr @cnt, align 4, !tbaa !5
  %201 = icmp slt i32 %199, %200
  br i1 %201, label %203, label %202

202:                                              ; preds = %198
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %221

203:                                              ; preds = %198
  %204 = load i32, ptr %9, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [200001 x i32], ptr @ans, i64 0, i64 %205
  %207 = load i32, ptr %206, align 4, !tbaa !5
  %208 = add nsw i32 %207, 1
  %209 = load i32, ptr %9, align 4, !tbaa !5
  %210 = load i32, ptr @cnt, align 4, !tbaa !5
  %211 = sub nsw i32 %210, 1
  %212 = icmp eq i32 %209, %211
  %213 = zext i1 %212 to i64
  %214 = getelementptr inbounds [3 x i8], ptr @.str.3, i64 0, i64 %213
  %215 = load i8, ptr %214, align 1, !tbaa !9
  %216 = sext i8 %215 to i32
  %217 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %208, i32 noundef %216)
  br label %218

218:                                              ; preds = %203
  %219 = load i32, ptr %9, align 4, !tbaa !5
  %220 = add nsw i32 %219, 1
  store i32 %220, ptr %9, align 4, !tbaa !5
  br label %198, !llvm.loop !16

221:                                              ; preds = %202
  ret i32 0
}

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5matchii(i32 noundef, i32 noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7hasPermPc(ptr noundef) #4

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

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

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}


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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local local_unnamed_addr global [200001 x i32], align 16
@b = external dso_local local_unnamed_addr global [200001 x i32], align 16
@fir = external dso_local local_unnamed_addr global [27 x i32], align 16
@pos = external dso_local local_unnamed_addr global [27 x i32], align 16
@f = external dso_local local_unnamed_addr global [200001 x i32], align 16
@cnt = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global [200001 x i32], align 16
@buf = external dso_local global [200001 x i8], align 16
@pat = external dso_local global [200001 x i8], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @buf, ptr noundef nonnull @pat)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(108) @fir, i8 -1, i64 108, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(108) @pos, i8 -1, i64 108, i1 false)
  %2 = load i32, ptr @m, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.lr.ph

.preheader63:                                     ; preds = %17
  %.not99 = icmp eq i32 %2, 1
  br i1 %.not99, label %._crit_edge, label %.preheader

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %17 ]
  %4 = getelementptr inbounds [200001 x i8], ptr @pat, i64 0, i64 %indvars.iv
  %5 = load i8, ptr %4, align 1, !tbaa !9
  %6 = sext i8 %5 to i64
  %7 = add nsw i64 %6, -97
  %8 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %9, -1
  br i1 %10, label %11, label %14

11:                                               ; preds = %.lr.ph
  %12 = getelementptr inbounds [27 x i32], ptr @fir, i64 0, i64 %7
  %13 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %13, ptr %12, align 4, !tbaa !5
  br label %17

14:                                               ; preds = %.lr.ph
  %15 = trunc nuw nsw i64 %indvars.iv to i32
  %16 = sub nsw i32 %15, %9
  br label %17

17:                                               ; preds = %14, %11
  %.pre-phi = phi i32 [ %15, %14 ], [ %13, %11 ]
  %.sink = phi i32 [ %16, %14 ], [ -1, %11 ]
  %18 = getelementptr inbounds [200001 x i32], ptr @b, i64 0, i64 %indvars.iv
  store i32 %.sink, ptr %18, align 4
  store i32 %.pre-phi, ptr %8, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader63, label %.lr.ph, !llvm.loop !10

.preheader:                                       ; preds = %.preheader63, %.critedge
  %indvars.iv90 = phi i64 [ %indvars.iv.next91, %.critedge ], [ 1, %.preheader63 ]
  %.05271 = phi i32 [ %spec.select, %.critedge ], [ 0, %.preheader63 ]
  %.not6065 = icmp eq i32 %.05271, 0
  br i1 %.not6065, label %.critedge, label %.lr.ph67

.lr.ph67:                                         ; preds = %.preheader
  %19 = getelementptr inbounds [200001 x i32], ptr @b, i64 0, i64 %indvars.iv90
  br label %22

._crit_edge:                                      ; preds = %.critedge, %0, %.preheader63
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(108) @pos, i8 -1, i64 108, i1 false)
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph83, label %._crit_edge84

22:                                               ; preds = %.lr.ph67, %25
  %.15366 = phi i32 [ %.05271, %.lr.ph67 ], [ %28, %25 ]
  %23 = load i32, ptr %19, align 4, !tbaa !5
  %24 = tail call noundef zeroext i1 @_Z5matchii(i32 noundef %.15366, i32 noundef %23)
  br i1 %24, label %.critedge, label %25

25:                                               ; preds = %22
  %26 = sext i32 %.15366 to i64
  %27 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %.not60 = icmp eq i32 %28, 0
  br i1 %.not60, label %.critedge, label %22, !llvm.loop !12

.critedge:                                        ; preds = %22, %25, %.preheader
  %.153.lcssa = phi i32 [ 0, %.preheader ], [ 0, %25 ], [ %.15366, %22 ]
  %29 = getelementptr inbounds [200001 x i32], ptr @b, i64 0, i64 %indvars.iv90
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = tail call noundef zeroext i1 @_Z5matchii(i32 noundef %.153.lcssa, i32 noundef %30)
  %32 = zext i1 %31 to i32
  %spec.select = add nsw i32 %.153.lcssa, %32
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %33 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %indvars.iv.next91
  store i32 %spec.select, ptr %33, align 4, !tbaa !5
  %34 = load i32, ptr @m, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next91, %35
  br i1 %36, label %.preheader, label %._crit_edge, !llvm.loop !13

._crit_edge84:                                    ; preds = %80, %._crit_edge
  %37 = load i32, ptr @cnt, align 4, !tbaa !5
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %37)
  %39 = load i32, ptr @cnt, align 4, !tbaa !5
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %.lr.ph87, label %._crit_edge88

.lr.ph83:                                         ; preds = %._crit_edge, %80
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %80 ], [ 0, %._crit_edge ]
  %.05081 = phi i32 [ %.3, %80 ], [ 0, %._crit_edge ]
  %41 = getelementptr inbounds [200001 x i8], ptr @buf, i64 0, i64 %indvars.iv93
  %42 = load i8, ptr %41, align 1, !tbaa !9
  %43 = sext i8 %42 to i64
  %44 = add nsw i64 %43, -97
  %45 = getelementptr inbounds [27 x i32], ptr @pos, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = icmp eq i32 %46, -1
  %48 = trunc nuw nsw i64 %indvars.iv93 to i32
  %49 = sub nsw i32 %48, %46
  %spec.select61 = select i1 %47, i32 -1, i32 %49
  %50 = getelementptr inbounds [200001 x i32], ptr @a, i64 0, i64 %indvars.iv93
  store i32 %spec.select61, ptr %50, align 4, !tbaa !5
  store i32 %48, ptr %45, align 4, !tbaa !5
  %.not72 = icmp eq i32 %.05081, 0
  br i1 %.not72, label %.critedge2, label %.lr.ph75

.lr.ph75:                                         ; preds = %.lr.ph83, %53
  %.173 = phi i32 [ %56, %53 ], [ %.05081, %.lr.ph83 ]
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = tail call noundef zeroext i1 @_Z5matchii(i32 noundef %.173, i32 noundef %51)
  br i1 %52, label %.critedge2.loopexit, label %53

53:                                               ; preds = %.lr.ph75
  %54 = sext i32 %.173 to i64
  %55 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %.not = icmp eq i32 %56, 0
  br i1 %.not, label %.critedge2.loopexit, label %.lr.ph75, !llvm.loop !14

.critedge2.loopexit:                              ; preds = %53, %.lr.ph75
  %.1.lcssa.ph = phi i32 [ %.173, %.lr.ph75 ], [ 0, %53 ]
  %.pre = load i32, ptr %50, align 4, !tbaa !5
  br label %.critedge2

.critedge2:                                       ; preds = %.critedge2.loopexit, %.lr.ph83
  %57 = phi i32 [ %spec.select61, %.lr.ph83 ], [ %.pre, %.critedge2.loopexit ]
  %.1.lcssa = phi i32 [ 0, %.lr.ph83 ], [ %.1.lcssa.ph, %.critedge2.loopexit ]
  %58 = tail call noundef zeroext i1 @_Z5matchii(i32 noundef %.1.lcssa, i32 noundef %57)
  %59 = zext i1 %58 to i32
  %spec.select62 = add nsw i32 %.1.lcssa, %59
  %60 = load i32, ptr @m, align 4, !tbaa !5
  %61 = icmp eq i32 %spec.select62, %60
  br i1 %61, label %62, label %80

62:                                               ; preds = %.critedge2
  %63 = sext i32 %spec.select62 to i64
  %64 = sub nsw i64 0, %63
  %65 = getelementptr inbounds i8, ptr %41, i64 %64
  %66 = getelementptr inbounds i8, ptr %65, i64 1
  %67 = tail call noundef zeroext i1 @_Z7hasPermPc(ptr noundef nonnull %66)
  br i1 %67, label %68, label %77

68:                                               ; preds = %62
  %69 = load i32, ptr @m, align 4, !tbaa !5
  %70 = trunc i64 %indvars.iv93 to i32
  %71 = add i32 %70, 1
  %72 = sub i32 %71, %69
  %73 = load i32, ptr @cnt, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr @cnt, align 4, !tbaa !5
  %75 = sext i32 %73 to i64
  %76 = getelementptr inbounds [200001 x i32], ptr @ans, i64 0, i64 %75
  store i32 %72, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %68, %62
  %78 = getelementptr inbounds [200001 x i32], ptr @f, i64 0, i64 %63
  %79 = load i32, ptr %78, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %77, %.critedge2
  %.3 = phi i32 [ %79, %77 ], [ %spec.select62, %.critedge2 ]
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = icmp slt i64 %indvars.iv.next94, %82
  br i1 %83, label %.lr.ph83, label %._crit_edge84, !llvm.loop !15

._crit_edge88:                                    ; preds = %.lr.ph87, %._crit_edge84
  ret i32 0

.lr.ph87:                                         ; preds = %._crit_edge84, %.lr.ph87
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %.lr.ph87 ], [ 0, %._crit_edge84 ]
  %84 = phi i32 [ %96, %.lr.ph87 ], [ %39, %._crit_edge84 ]
  %85 = getelementptr inbounds [200001 x i32], ptr @ans, i64 0, i64 %indvars.iv96
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  %88 = add nsw i32 %84, -1
  %89 = zext i32 %88 to i64
  %90 = icmp eq i64 %indvars.iv96, %89
  %91 = zext i1 %90 to i64
  %92 = getelementptr inbounds [3 x i8], ptr @.str.3, i64 0, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !9
  %94 = sext i8 %93 to i32
  %95 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %87, i32 noundef %94)
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %96 = load i32, ptr @cnt, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = icmp slt i64 %indvars.iv.next97, %97
  br i1 %98, label %.lr.ph87, label %._crit_edge88, !llvm.loop !16
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5matchii(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7hasPermPc(ptr noundef) local_unnamed_addr #3

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

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

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}


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