; LLVM IR from reyadussalahin/problem-solving :: ad_hoc/constructive_algorithm/codeforces/F1345D (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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@b = external dso_local global [1024 x [1024 x i8]], align 16
@p = external dso_local global [1048576 x i32], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.main.dx = external hidden unnamed_addr constant [4 x i32], align 16
@__const.main.dy = external hidden unnamed_addr constant [4 x i32], align 16
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z10countBlackv() #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z4okayv() #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7inrangeii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 [4 x i32], align 16
  %8 = alloca [4 x i32], align 16
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %32, %0
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %35

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %28
  %30 = getelementptr inbounds [1024 x i8], ptr %29, i64 0, i64 0
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %30)
  br label %32

32:                                               ; preds = %26
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !9

35:                                               ; preds = %25
  %36 = call noundef zeroext i1 @_Z4okayv()
  br i1 %36, label %37, label %202

37:                                               ; preds = %35
  %38 = call noundef i32 @_Z10countBlackv()
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %42, label %40

40:                                               ; preds = %37
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  br label %205

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %66, %42
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %69

48:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %62, %48
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = load i32, ptr @m, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %65

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = call noundef i32 @_Z5_hashii(i32 noundef %55, i32 noundef %56)
  store i32 %57, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1048576 x i32], ptr @p, i64 0, i64 %60
  store i32 %58, ptr %61, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %62

62:                                               ; preds = %54
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %5, align 4, !tbaa !5
  br label %49, !llvm.loop !11

65:                                               ; preds = %53
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %3, align 4, !tbaa !5
  br label %43, !llvm.loop !12

69:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const.main.dx, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const.main.dy, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %70

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

74:                                               ; preds = %70
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %158

75:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %151, %75
  %77 = load i32, ptr %10, align 4, !tbaa !5
  %78 = load i32, ptr @m, align 4, !tbaa !5
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %76
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %154

81:                                               ; preds = %76
  %82 = load i32, ptr %9, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %83
  %85 = load i32, ptr %10, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1024 x i8], ptr %84, i64 0, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !13
  %89 = sext i8 %88 to i32
  %90 = icmp ne i32 %89, 35
  br i1 %90, label %91, label %92

91:                                               ; preds = %81
  br label %151

92:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %93 = load i32, ptr %9, align 4, !tbaa !5
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = call noundef i32 @_Z5_hashii(i32 noundef %93, i32 noundef %94)
  store i32 %95, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %147, %92
  %97 = load i32, ptr %12, align 4, !tbaa !5
  %98 = icmp slt i32 %97, 4
  br i1 %98, label %100, label %99

99:                                               ; preds = %96
  store i32 17, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %150

100:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %101 = load i32, ptr %9, align 4, !tbaa !5
  %102 = load i32, ptr %12, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [4 x i32], ptr %7, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %101, %105
  store i32 %106, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %107 = load i32, ptr %10, align 4, !tbaa !5
  %108 = load i32, ptr %12, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = add nsw i32 %107, %111
  store i32 %112, ptr %14, align 4, !tbaa !5
  %113 = load i32, ptr %13, align 4, !tbaa !5
  %114 = load i32, ptr %14, align 4, !tbaa !5
  %115 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %113, i32 noundef %114)
  br i1 %115, label %116, label %126

116:                                              ; preds = %100
  %117 = load i32, ptr %13, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %118
  %120 = load i32, ptr %14, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1024 x i8], ptr %119, i64 0, i64 %121
  %123 = load i8, ptr %122, align 1, !tbaa !13
  %124 = sext i8 %123 to i32
  %125 = icmp ne i32 %124, 35
  br i1 %125, label %126, label %127

126:                                              ; preds = %116, %100
  store i32 19, ptr %4, align 4
  br label %144

127:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %128 = load i32, ptr %13, align 4, !tbaa !5
  %129 = load i32, ptr %14, align 4, !tbaa !5
  %130 = call noundef i32 @_Z5_hashii(i32 noundef %128, i32 noundef %129)
  store i32 %130, ptr %15, align 4, !tbaa !5
  %131 = load i32, ptr %11, align 4, !tbaa !5
  %132 = call noundef i32 @_Z4findi(i32 noundef %131)
  %133 = load i32, ptr %15, align 4, !tbaa !5
  %134 = call noundef i32 @_Z4findi(i32 noundef %133)
  %135 = icmp ne i32 %132, %134
  br i1 %135, label %136, label %143

136:                                              ; preds = %127
  %137 = load i32, ptr %15, align 4, !tbaa !5
  %138 = call noundef i32 @_Z4findi(i32 noundef %137)
  %139 = load i32, ptr %11, align 4, !tbaa !5
  %140 = call noundef i32 @_Z4findi(i32 noundef %139)
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1048576 x i32], ptr @p, i64 0, i64 %141
  store i32 %138, ptr %142, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %136, %127
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  store i32 0, ptr %4, align 4
  br label %144

144:                                              ; preds = %143, %126
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  %145 = load i32, ptr %4, align 4
  switch i32 %145, label %207 [
    i32 0, label %146
    i32 19, label %147
  ]

146:                                              ; preds = %144
  br label %147

147:                                              ; preds = %146, %144
  %148 = load i32, ptr %12, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %12, align 4, !tbaa !5
  br label %96, !llvm.loop !14

150:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %151

151:                                              ; preds = %150, %91
  %152 = load i32, ptr %10, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %10, align 4, !tbaa !5
  br label %76, !llvm.loop !15

154:                                              ; preds = %80
  br label %155

155:                                              ; preds = %154
  %156 = load i32, ptr %9, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %9, align 4, !tbaa !5
  br label %70, !llvm.loop !16

158:                                              ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %196, %158
  %160 = load i32, ptr %17, align 4, !tbaa !5
  %161 = load i32, ptr @n, align 4, !tbaa !5
  %162 = icmp slt i32 %160, %161
  br i1 %162, label %164, label %163

163:                                              ; preds = %159
  store i32 20, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %199

164:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %165

165:                                              ; preds = %192, %164
  %166 = load i32, ptr %18, align 4, !tbaa !5
  %167 = load i32, ptr @m, align 4, !tbaa !5
  %168 = icmp slt i32 %166, %167
  br i1 %168, label %170, label %169

169:                                              ; preds = %165
  store i32 23, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %195

170:                                              ; preds = %165
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %171 = load i32, ptr %17, align 4, !tbaa !5
  %172 = load i32, ptr %18, align 4, !tbaa !5
  %173 = call noundef i32 @_Z5_hashii(i32 noundef %171, i32 noundef %172)
  store i32 %173, ptr %19, align 4, !tbaa !5
  %174 = load i32, ptr %17, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %175
  %177 = load i32, ptr %18, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [1024 x i8], ptr %176, i64 0, i64 %178
  %180 = load i8, ptr %179, align 1, !tbaa !13
  %181 = sext i8 %180 to i32
  %182 = icmp eq i32 %181, 35
  br i1 %182, label %183, label %191

183:                                              ; preds = %170
  %184 = load i32, ptr %19, align 4, !tbaa !5
  %185 = call noundef i32 @_Z4findi(i32 noundef %184)
  %186 = load i32, ptr %19, align 4, !tbaa !5
  %187 = icmp eq i32 %185, %186
  br i1 %187, label %188, label %191

188:                                              ; preds = %183
  %189 = load i32, ptr %16, align 4, !tbaa !5
  %190 = add nsw i32 %189, 1
  store i32 %190, ptr %16, align 4, !tbaa !5
  br label %191

191:                                              ; preds = %188, %183, %170
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %192

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

195:                                              ; preds = %169
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %17, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %17, align 4, !tbaa !5
  br label %159, !llvm.loop !18

199:                                              ; preds = %163
  %200 = load i32, ptr %16, align 4, !tbaa !5
  %201 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %200)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  br label %204

202:                                              ; preds = %35
  %203 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %204

204:                                              ; preds = %202, %199
  store i32 0, ptr %1, align 4
  br label %205

205:                                              ; preds = %204, %40
  %206 = load i32, ptr %1, align 4
  ret i32 %206

207:                                              ; preds = %144
  unreachable
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }

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

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


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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@b = external dso_local global [1024 x [1024 x i8]], align 16
@p = external dso_local local_unnamed_addr global [1048576 x i32], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.main.dx = external hidden unnamed_addr constant [4 x i32], align 16
@__const.main.dy = external hidden unnamed_addr constant [4 x i32], align 16
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z10countBlackv() local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z4okayv() local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7inrangeii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %4 = tail call noundef zeroext i1 @_Z4okayv()
  br i1 %4, label %10, label %157

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %5 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %indvars.iv
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %5)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = icmp slt i64 %indvars.iv.next, %8
  br i1 %9, label %.lr.ph, label %._crit_edge, !llvm.loop !9

10:                                               ; preds = %._crit_edge
  %11 = tail call noundef i32 @_Z10countBlackv()
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %16, label %.preheader64

.preheader64:                                     ; preds = %10
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  %14 = load i32, ptr @m, align 4
  %15 = icmp sgt i32 %14, 0
  %or.cond = select i1 %13, i1 %15, i1 false
  br i1 %or.cond, label %.preheader63, label %._crit_edge81

16:                                               ; preds = %10
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %159

.preheader63:                                     ; preds = %.preheader64, %._crit_edge68
  %18 = phi i32 [ %31, %._crit_edge68 ], [ %12, %.preheader64 ]
  %19 = phi i32 [ %32, %._crit_edge68 ], [ %14, %.preheader64 ]
  %.05269 = phi i32 [ %33, %._crit_edge68 ], [ 0, %.preheader64 ]
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph67, label %._crit_edge68

.preheader62:                                     ; preds = %._crit_edge68
  %21 = icmp sgt i32 %31, 0
  br i1 %21, label %.preheader61.lr.ph, label %._crit_edge81

.preheader61.lr.ph:                               ; preds = %.preheader62
  %.pr = load i32, ptr @m, align 4, !tbaa !5
  %22 = icmp sgt i32 %.pr, 0
  br i1 %22, label %.preheader61.preheader, label %._crit_edge81

.preheader61.preheader:                           ; preds = %.preheader61.lr.ph
  %23 = load i32, ptr @__const.main.dx, align 16
  %24 = load i32, ptr @__const.main.dy, align 16
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dx, i64 4), align 4
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dy, i64 4), align 4
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dx, i64 8), align 8
  %28 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dy, i64 8), align 8
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dx, i64 12), align 4
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dy, i64 12), align 4
  br label %.preheader61

._crit_edge68.loopexit:                           ; preds = %.lr.ph67
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge68

._crit_edge68:                                    ; preds = %._crit_edge68.loopexit, %.preheader63
  %31 = phi i32 [ %.pre, %._crit_edge68.loopexit ], [ %18, %.preheader63 ]
  %32 = phi i32 [ %39, %._crit_edge68.loopexit ], [ %19, %.preheader63 ]
  %33 = add nuw nsw i32 %.05269, 1
  %34 = icmp slt i32 %33, %31
  br i1 %34, label %.preheader63, label %.preheader62, !llvm.loop !11

.lr.ph67:                                         ; preds = %.preheader63, %.lr.ph67
  %.05466 = phi i32 [ %38, %.lr.ph67 ], [ 0, %.preheader63 ]
  %35 = tail call noundef i32 @_Z5_hashii(i32 noundef %.05269, i32 noundef %.05466)
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1048576 x i32], ptr @p, i64 0, i64 %36
  store i32 %35, ptr %37, align 4, !tbaa !5
  %38 = add nuw nsw i32 %.05466, 1
  %39 = load i32, ptr @m, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %.lr.ph67, label %._crit_edge68.loopexit, !llvm.loop !13

.preheader61:                                     ; preds = %.preheader61.preheader, %._crit_edge73
  %41 = phi i32 [ %31, %.preheader61.preheader ], [ %56, %._crit_edge73 ]
  %42 = phi i32 [ %.pr, %.preheader61.preheader ], [ %57, %._crit_edge73 ]
  %43 = phi i32 [ %.pr, %.preheader61.preheader ], [ %58, %._crit_edge73 ]
  %indvars.iv93 = phi i64 [ 0, %.preheader61.preheader ], [ %indvars.iv.next94, %._crit_edge73 ]
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.lr.ph72, label %._crit_edge73

.lr.ph72:                                         ; preds = %.preheader61
  %45 = trunc nuw nsw i64 %indvars.iv93 to i32
  %46 = add nsw i32 %23, %45
  %47 = sext i32 %46 to i64
  %48 = add nsw i32 %25, %45
  %49 = sext i32 %48 to i64
  %50 = add nsw i32 %27, %45
  %51 = sext i32 %50 to i64
  %52 = add nsw i32 %29, %45
  %53 = sext i32 %52 to i64
  br label %61

.preheader60:                                     ; preds = %._crit_edge73
  %54 = icmp sgt i32 %56, 0
  %.pr109 = load i32, ptr @m, align 4
  %55 = icmp sgt i32 %.pr109, 0
  %or.cond116 = select i1 %54, i1 %55, i1 false
  br i1 %or.cond116, label %.preheader, label %._crit_edge81

._crit_edge73.loopexit:                           ; preds = %.loopexit
  %.pre103 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge73

._crit_edge73:                                    ; preds = %._crit_edge73.loopexit, %.preheader61
  %56 = phi i32 [ %.pre103, %._crit_edge73.loopexit ], [ %41, %.preheader61 ]
  %57 = phi i32 [ %131, %._crit_edge73.loopexit ], [ %42, %.preheader61 ]
  %58 = phi i32 [ %131, %._crit_edge73.loopexit ], [ %43, %.preheader61 ]
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %59 = sext i32 %56 to i64
  %60 = icmp slt i64 %indvars.iv.next94, %59
  br i1 %60, label %.preheader61, label %.preheader60, !llvm.loop !14

61:                                               ; preds = %.lr.ph72, %.loopexit
  %62 = phi i32 [ %42, %.lr.ph72 ], [ %131, %.loopexit ]
  %indvars.iv90 = phi i64 [ 0, %.lr.ph72 ], [ %indvars.iv.next91, %.loopexit ]
  %63 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %indvars.iv93, i64 %indvars.iv90
  %64 = load i8, ptr %63, align 1, !tbaa !15
  %.not57 = icmp eq i8 %64, 35
  br i1 %.not57, label %65, label %.loopexit

65:                                               ; preds = %61
  %66 = trunc nuw nsw i64 %indvars.iv90 to i32
  %67 = tail call noundef i32 @_Z5_hashii(i32 noundef %45, i32 noundef %66)
  %68 = add nsw i32 %24, %66
  %69 = tail call noundef zeroext i1 @_Z7inrangeii(i32 noundef %46, i32 noundef %68)
  br i1 %69, label %70, label %83

70:                                               ; preds = %65
  %71 = sext i32 %68 to i64
  %72 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %47, i64 %71
  %73 = load i8, ptr %72, align 1, !tbaa !15
  %.not58 = icmp eq i8 %73, 35
  br i1 %.not58, label %74, label %83

74:                                               ; preds = %70
  %75 = tail call noundef i32 @_Z5_hashii(i32 noundef %46, i32 noundef %68)
  %76 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %77 = tail call noundef i32 @_Z4findi(i32 noundef %75)
  %.not59 = icmp eq i32 %76, %77
  br i1 %.not59, label %83, label %78

78:                                               ; preds = %74
  %79 = tail call noundef i32 @_Z4findi(i32 noundef %75)
  %80 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1048576 x i32], ptr @p, i64 0, i64 %81
  store i32 %79, ptr %82, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %74, %78, %65, %70
  %84 = add nsw i32 %26, %66
  %85 = tail call noundef zeroext i1 @_Z7inrangeii(i32 noundef %48, i32 noundef %84)
  br i1 %85, label %86, label %99

86:                                               ; preds = %83
  %87 = sext i32 %84 to i64
  %88 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %49, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !15
  %.not58.1 = icmp eq i8 %89, 35
  br i1 %.not58.1, label %90, label %99

90:                                               ; preds = %86
  %91 = tail call noundef i32 @_Z5_hashii(i32 noundef %48, i32 noundef %84)
  %92 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %93 = tail call noundef i32 @_Z4findi(i32 noundef %91)
  %.not59.1 = icmp eq i32 %92, %93
  br i1 %.not59.1, label %99, label %94

94:                                               ; preds = %90
  %95 = tail call noundef i32 @_Z4findi(i32 noundef %91)
  %96 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1048576 x i32], ptr @p, i64 0, i64 %97
  store i32 %95, ptr %98, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %94, %90, %86, %83
  %100 = add nsw i32 %28, %66
  %101 = tail call noundef zeroext i1 @_Z7inrangeii(i32 noundef %50, i32 noundef %100)
  br i1 %101, label %102, label %115

102:                                              ; preds = %99
  %103 = sext i32 %100 to i64
  %104 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %51, i64 %103
  %105 = load i8, ptr %104, align 1, !tbaa !15
  %.not58.2 = icmp eq i8 %105, 35
  br i1 %.not58.2, label %106, label %115

106:                                              ; preds = %102
  %107 = tail call noundef i32 @_Z5_hashii(i32 noundef %50, i32 noundef %100)
  %108 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %109 = tail call noundef i32 @_Z4findi(i32 noundef %107)
  %.not59.2 = icmp eq i32 %108, %109
  br i1 %.not59.2, label %115, label %110

110:                                              ; preds = %106
  %111 = tail call noundef i32 @_Z4findi(i32 noundef %107)
  %112 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [1048576 x i32], ptr @p, i64 0, i64 %113
  store i32 %111, ptr %114, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %110, %106, %102, %99
  %116 = add nsw i32 %30, %66
  %117 = tail call noundef zeroext i1 @_Z7inrangeii(i32 noundef %52, i32 noundef %116)
  br i1 %117, label %118, label %.loopexit.loopexit

118:                                              ; preds = %115
  %119 = sext i32 %116 to i64
  %120 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %53, i64 %119
  %121 = load i8, ptr %120, align 1, !tbaa !15
  %.not58.3 = icmp eq i8 %121, 35
  br i1 %.not58.3, label %122, label %.loopexit.loopexit

122:                                              ; preds = %118
  %123 = tail call noundef i32 @_Z5_hashii(i32 noundef %52, i32 noundef %116)
  %124 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %125 = tail call noundef i32 @_Z4findi(i32 noundef %123)
  %.not59.3 = icmp eq i32 %124, %125
  br i1 %.not59.3, label %.loopexit.loopexit, label %126

126:                                              ; preds = %122
  %127 = tail call noundef i32 @_Z4findi(i32 noundef %123)
  %128 = tail call noundef i32 @_Z4findi(i32 noundef %67)
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [1048576 x i32], ptr @p, i64 0, i64 %129
  store i32 %127, ptr %130, align 4, !tbaa !5
  br label %.loopexit.loopexit

.loopexit.loopexit:                               ; preds = %126, %122, %118, %115
  %.pre102 = load i32, ptr @m, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %61
  %131 = phi i32 [ %.pre102, %.loopexit.loopexit ], [ %62, %61 ]
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %132 = sext i32 %131 to i64
  %133 = icmp slt i64 %indvars.iv.next91, %132
  br i1 %133, label %61, label %._crit_edge73.loopexit, !llvm.loop !16

.preheader:                                       ; preds = %.preheader60, %._crit_edge78
  %134 = phi i32 [ %139, %._crit_edge78 ], [ %56, %.preheader60 ]
  %135 = phi i32 [ %140, %._crit_edge78 ], [ %.pr109, %.preheader60 ]
  %indvars.iv99 = phi i64 [ %indvars.iv.next100, %._crit_edge78 ], [ 0, %.preheader60 ]
  %.05079 = phi i32 [ %.1.lcssa, %._crit_edge78 ], [ 0, %.preheader60 ]
  %136 = icmp sgt i32 %135, 0
  br i1 %136, label %.lr.ph77, label %._crit_edge78

.lr.ph77:                                         ; preds = %.preheader
  %137 = trunc nuw nsw i64 %indvars.iv99 to i32
  br label %143

._crit_edge81:                                    ; preds = %._crit_edge78, %.preheader61.lr.ph, %.preheader64, %.preheader62, %.preheader60
  %.050.lcssa = phi i32 [ 0, %.preheader60 ], [ 0, %.preheader62 ], [ 0, %.preheader64 ], [ 0, %.preheader61.lr.ph ], [ %.1.lcssa, %._crit_edge78 ]
  %138 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.050.lcssa)
  br label %159

._crit_edge78.loopexit:                           ; preds = %153
  %.pre104 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge78

._crit_edge78:                                    ; preds = %._crit_edge78.loopexit, %.preheader
  %139 = phi i32 [ %134, %.preheader ], [ %.pre104, %._crit_edge78.loopexit ]
  %140 = phi i32 [ %135, %.preheader ], [ %154, %._crit_edge78.loopexit ]
  %.1.lcssa = phi i32 [ %.05079, %.preheader ], [ %.2, %._crit_edge78.loopexit ]
  %indvars.iv.next100 = add nuw nsw i64 %indvars.iv99, 1
  %141 = sext i32 %139 to i64
  %142 = icmp slt i64 %indvars.iv.next100, %141
  br i1 %142, label %.preheader, label %._crit_edge81, !llvm.loop !17

143:                                              ; preds = %.lr.ph77, %153
  %indvars.iv96 = phi i64 [ 0, %.lr.ph77 ], [ %indvars.iv.next97, %153 ]
  %.175 = phi i32 [ %.05079, %.lr.ph77 ], [ %.2, %153 ]
  %144 = trunc nuw nsw i64 %indvars.iv96 to i32
  %145 = tail call noundef i32 @_Z5_hashii(i32 noundef %137, i32 noundef %144)
  %146 = getelementptr inbounds [1024 x [1024 x i8]], ptr @b, i64 0, i64 %indvars.iv99, i64 %indvars.iv96
  %147 = load i8, ptr %146, align 1, !tbaa !15
  %148 = icmp eq i8 %147, 35
  br i1 %148, label %149, label %153

149:                                              ; preds = %143
  %150 = tail call noundef i32 @_Z4findi(i32 noundef %145)
  %151 = icmp eq i32 %150, %145
  %152 = zext i1 %151 to i32
  %spec.select = add nsw i32 %.175, %152
  br label %153

153:                                              ; preds = %149, %143
  %.2 = phi i32 [ %.175, %143 ], [ %spec.select, %149 ]
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %154 = load i32, ptr @m, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = icmp slt i64 %indvars.iv.next97, %155
  br i1 %156, label %143, label %._crit_edge78.loopexit, !llvm.loop !18

157:                                              ; preds = %._crit_edge
  %158 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %159

159:                                              ; preds = %._crit_edge81, %157, %16
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(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 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 #2 = { 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 #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" }

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

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


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