; LLVM IR from tangjz/acm-icpc :: self_training/2015-09-24 (H)

; 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
@e = external dso_local global [2 x [51 x [51 x i32]]], align 16
@match = external dso_local global [2 x [51 x i32]], align 16
@work = external dso_local global [2 x [51 x i32]], align 16
@tim = external dso_local global [2 x [51 x i32]], align 16
@total = external dso_local global i32, align 4
@cur_e = external dso_local global ptr, align 8
@cur_match = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2KMv() #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: 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 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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %224, %0
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %20

17:                                               ; preds = %14
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br label %20

20:                                               ; preds = %17, %14
  %21 = phi i1 [ false, %14 ], [ %19, %17 ]
  br i1 %21, label %23, label %22

22:                                               ; preds = %20
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %227

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

24:                                               ; preds = %60, %23
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 2
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %56, %28
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %34, label %33

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

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %52, %34
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = icmp sle i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %55

40:                                               ; preds = %35
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2 x [51 x [51 x i32]]], ptr @e, i64 0, i64 %42
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [51 x [51 x i32]], ptr %43, i64 0, i64 %45
  %47 = getelementptr inbounds [51 x i32], ptr %46, i64 0, i64 0
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %50)
  br label %52

52:                                               ; preds = %40
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %6, align 4, !tbaa !5
  br label %35, !llvm.loop !9

55:                                               ; preds = %39
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %5, align 4, !tbaa !5
  br label %29, !llvm.loop !11

59:                                               ; preds = %33
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !5
  br label %24, !llvm.loop !12

63:                                               ; preds = %27
  store ptr @e, ptr @cur_e, align 8, !tbaa !13
  store ptr @match, ptr @cur_match, align 8, !tbaa !13
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = mul i64 %65, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @match, i64 1), i8 0, i64 %66, i1 false)
  call void @_Z2KMv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %93, %63
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = icmp sle i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %96

72:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %73 = load ptr, ptr @cur_match, align 8, !tbaa !13
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %73, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  store i32 %77, ptr %8, align 4, !tbaa !5
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [51 x i32], ptr @work, i64 0, i64 %80
  store i32 %78, ptr %81, align 4, !tbaa !5
  %82 = load ptr, ptr @cur_e, align 8, !tbaa !13
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [51 x i32], ptr %82, i64 %84
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [51 x i32], ptr %85, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = load i32, ptr %8, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %91
  store i32 %89, ptr %92, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %93

93:                                               ; preds = %72
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %7, align 4, !tbaa !5
  br label %67, !llvm.loop !15

96:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %140, %96
  %98 = load i32, ptr %9, align 4, !tbaa !5
  %99 = load i32, ptr @n, align 4, !tbaa !5
  %100 = icmp sle i32 %98, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %97
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %143

102:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %136, %102
  %104 = load i32, ptr %10, align 4, !tbaa !5
  %105 = load i32, ptr @n, align 4, !tbaa !5
  %106 = icmp sle i32 %104, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %103
  store i32 20, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %139

108:                                              ; preds = %103
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [51 x [51 x i32]], ptr getelementptr inbounds ([2 x [51 x [51 x i32]]], ptr @e, i64 0, i64 1), i64 0, i64 %110
  %112 = load i32, ptr %10, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [51 x i32], ptr %111, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %117
  %119 = load ptr, ptr @cur_match, align 8, !tbaa !13
  %120 = load i32, ptr %10, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr %119, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %124
  %126 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %118, ptr noundef nonnull align 4 dereferenceable(4) %125)
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = add nsw i32 %115, %127
  %129 = load ptr, ptr @cur_e, align 8, !tbaa !13
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [51 x i32], ptr %129, i64 %131
  %133 = load i32, ptr %10, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [51 x i32], ptr %132, i64 0, i64 %134
  store i32 %128, ptr %135, align 4, !tbaa !5
  br label %136

136:                                              ; preds = %108
  %137 = load i32, ptr %10, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %10, align 4, !tbaa !5
  br label %103, !llvm.loop !16

139:                                              ; preds = %107
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %9, align 4, !tbaa !5
  br label %97, !llvm.loop !17

143:                                              ; preds = %101
  store ptr getelementptr inbounds ([2 x [51 x i32]], ptr @match, i64 0, i64 1), ptr @cur_match, align 8, !tbaa !13
  %144 = load i32, ptr @n, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = mul i64 %145, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr getelementptr inbounds ([2 x [51 x i32]], ptr @match, i64 0, i64 1), i64 1), i8 0, i64 %146, i1 false)
  call void @_Z2KMv()
  store i32 0, ptr @total, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %192, %143
  %148 = load i32, ptr %11, align 4, !tbaa !5
  %149 = load i32, ptr @n, align 4, !tbaa !5
  %150 = icmp sle i32 %148, %149
  br i1 %150, label %152, label %151

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

152:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %153 = load ptr, ptr @cur_match, align 8, !tbaa !13
  %154 = load i32, ptr %11, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds i32, ptr %153, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  store i32 %157, ptr %12, align 4, !tbaa !5
  %158 = load i32, ptr %11, align 4, !tbaa !5
  %159 = load i32, ptr %12, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds ([2 x [51 x i32]], ptr @work, i64 0, i64 1), i64 0, i64 %160
  store i32 %158, ptr %161, align 4, !tbaa !5
  %162 = load ptr, ptr @cur_e, align 8, !tbaa !13
  %163 = load i32, ptr %12, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [51 x i32], ptr %162, i64 %164
  %166 = load i32, ptr %11, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [51 x i32], ptr %165, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = load i32, ptr %12, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds ([2 x [51 x i32]], ptr @tim, i64 0, i64 1), i64 0, i64 %171
  store i32 %169, ptr %172, align 4, !tbaa !5
  %173 = load i32, ptr %12, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds ([2 x [51 x i32]], ptr @tim, i64 0, i64 1), i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = load i32, ptr %12, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = sub nsw i32 %176, %180
  %182 = load i32, ptr %12, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [51 x [51 x i32]], ptr getelementptr inbounds ([2 x [51 x [51 x i32]]], ptr @e, i64 0, i64 1), i64 0, i64 %183
  %185 = load i32, ptr %11, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [51 x i32], ptr %184, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = sub nsw i32 %181, %188
  %190 = load i32, ptr @total, align 4, !tbaa !5
  %191 = add nsw i32 %190, %189
  store i32 %191, ptr @total, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %192

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

195:                                              ; preds = %151
  %196 = load i32, ptr %2, 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 %13) #6
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %198

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

202:                                              ; preds = %198
  store i32 26, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %221

203:                                              ; preds = %198
  %204 = load i32, ptr %13, align 4, !tbaa !5
  %205 = load i32, ptr %13, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [51 x i32], ptr @work, i64 0, i64 %206
  %208 = load i32, ptr %207, align 4, !tbaa !5
  %209 = load i32, ptr %13, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds ([2 x [51 x i32]], ptr @work, i64 0, i64 1), i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = load i32, ptr %13, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds ([2 x [51 x i32]], ptr @tim, i64 0, i64 1), i64 0, i64 %214
  %216 = load i32, ptr %215, align 4, !tbaa !5
  %217 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %204, i32 noundef %208, i32 noundef %212, i32 noundef %216)
  br label %218

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

221:                                              ; preds = %202
  %222 = load i32, ptr @total, align 4, !tbaa !5
  %223 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %222)
  br label %224

224:                                              ; preds = %221
  %225 = load i32, ptr %2, align 4, !tbaa !5
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !20

227:                                              ; preds = %22
  ret i32 0
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #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 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !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
@e = external dso_local global [2 x [51 x [51 x i32]]], align 16
@match = external dso_local global [2 x [51 x i32]], align 16
@work = external dso_local local_unnamed_addr global [2 x [51 x i32]], align 16
@tim = external dso_local global [2 x [51 x i32]], align 16
@total = external dso_local local_unnamed_addr global i32, align 4
@cur_e = external dso_local local_unnamed_addr global ptr, align 8
@cur_match = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2KMv() local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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)
  %2 = icmp eq i32 %1, 1
  %3 = load i32, ptr @n, align 4
  %4 = icmp ne i32 %3, 0
  %5 = select i1 %2, i1 %4, i1 false
  br i1 %5, label %.preheader66, label %._crit_edge95

.preheader66:                                     ; preds = %0, %._crit_edge93
  %6 = phi i32 [ %105, %._crit_edge93 ], [ %3, %0 ]
  %.04794 = phi i32 [ %102, %._crit_edge93 ], [ 1, %0 ]
  %7 = icmp slt i32 %6, 1
  br i1 %7, label %.split.us, label %.preheader

._crit_edge95:                                    ; preds = %._crit_edge93, %0
  ret i32 0

.split.us:                                        ; preds = %._crit_edge.1, %._crit_edge71, %.preheader66
  %8 = phi i32 [ %6, %.preheader66 ], [ %26, %._crit_edge71 ], [ %25, %._crit_edge.1 ]
  store ptr @e, ptr @cur_e, align 8, !tbaa !5
  store ptr @match, ptr @cur_match, align 8, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %9, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @match, i64 4), i8 0, i64 %10, i1 false)
  tail call void @_Z2KMv()
  %11 = load i32, ptr @n, align 4, !tbaa !9
  %.not73 = icmp slt i32 %11, 1
  br i1 %.not73, label %._crit_edge83, label %.lr.ph76

.lr.ph76:                                         ; preds = %.split.us
  %12 = load ptr, ptr @cur_match, align 8, !tbaa !5
  %13 = load ptr, ptr @cur_e, align 8, !tbaa !5
  %14 = zext nneg i32 %11 to i64
  %xtraiter = and i64 %14, 1
  %15 = icmp eq i32 %11, 1
  br i1 %15, label %.preheader65.unr-lcssa, label %.lr.ph76.new

.lr.ph76.new:                                     ; preds = %.lr.ph76
  %unroll_iter = and i64 %14, 2147483646
  br label %40

.preheader:                                       ; preds = %.preheader66, %._crit_edge
  %16 = phi i32 [ %26, %._crit_edge ], [ %6, %.preheader66 ]
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %._crit_edge ], [ 1, %.preheader66 ]
  %.not6067 = icmp slt i32 %16, 1
  br i1 %.not6067, label %.preheader.._crit_edge_crit_edge, label %.lr.ph

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre126 = sext i32 %16 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %17 = getelementptr inbounds [2 x [51 x [51 x i32]]], ptr @e, i64 0, i64 0, i64 %indvars.iv101
  br label %27

._crit_edge71:                                    ; preds = %._crit_edge
  %.not5969.1 = icmp slt i32 %26, 1
  br i1 %.not5969.1, label %.split.us, label %.preheader.1

.preheader.1:                                     ; preds = %._crit_edge71, %._crit_edge.1
  %18 = phi i32 [ %25, %._crit_edge.1 ], [ %26, %._crit_edge71 ]
  %indvars.iv101.1 = phi i64 [ %indvars.iv.next102.1, %._crit_edge.1 ], [ 1, %._crit_edge71 ]
  %.not6067.1 = icmp slt i32 %18, 1
  br i1 %.not6067.1, label %.preheader.1.._crit_edge.1_crit_edge, label %.lr.ph.1

.preheader.1.._crit_edge.1_crit_edge:             ; preds = %.preheader.1
  %.pre124 = sext i32 %18 to i64
  br label %._crit_edge.1

.lr.ph.1:                                         ; preds = %.preheader.1
  %19 = getelementptr inbounds [2 x [51 x [51 x i32]]], ptr @e, i64 0, i64 1, i64 %indvars.iv101.1
  br label %20

20:                                               ; preds = %20, %.lr.ph.1
  %indvars.iv.1 = phi i64 [ 1, %.lr.ph.1 ], [ %indvars.iv.next.1, %20 ]
  %21 = getelementptr inbounds i32, ptr %19, i64 %indvars.iv.1
  %22 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %21)
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.1, 1
  %23 = load i32, ptr @n, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %.not60.not.1 = icmp slt i64 %indvars.iv.1, %24
  br i1 %.not60.not.1, label %20, label %._crit_edge.1, !llvm.loop !11

._crit_edge.1:                                    ; preds = %20, %.preheader.1.._crit_edge.1_crit_edge
  %.pre-phi125 = phi i64 [ %.pre124, %.preheader.1.._crit_edge.1_crit_edge ], [ %24, %20 ]
  %25 = phi i32 [ %18, %.preheader.1.._crit_edge.1_crit_edge ], [ %23, %20 ]
  %indvars.iv.next102.1 = add nuw nsw i64 %indvars.iv101.1, 1
  %.not59.not.1 = icmp slt i64 %indvars.iv101.1, %.pre-phi125
  br i1 %.not59.not.1, label %.preheader.1, label %.split.us, !llvm.loop !13

._crit_edge:                                      ; preds = %27, %.preheader.._crit_edge_crit_edge
  %.pre-phi127 = phi i64 [ %.pre126, %.preheader.._crit_edge_crit_edge ], [ %31, %27 ]
  %26 = phi i32 [ %16, %.preheader.._crit_edge_crit_edge ], [ %30, %27 ]
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %.not59.not = icmp slt i64 %indvars.iv101, %.pre-phi127
  br i1 %.not59.not, label %.preheader, label %._crit_edge71, !llvm.loop !13

27:                                               ; preds = %.lr.ph, %27
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %27 ]
  %28 = getelementptr inbounds i32, ptr %17, i64 %indvars.iv
  %29 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %28)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr @n, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %.not60.not = icmp slt i64 %indvars.iv, %31
  br i1 %.not60.not, label %27, label %._crit_edge, !llvm.loop !11

.preheader65.unr-lcssa:                           ; preds = %40, %.lr.ph76
  %indvars.iv107.unr = phi i64 [ 1, %.lr.ph76 ], [ %indvars.iv.next108.1, %40 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader65, label %.preheader65.epilog-lcssa

.preheader65.epilog-lcssa:                        ; preds = %.preheader65.unr-lcssa
  %32 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv107.unr
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [51 x i32], ptr @work, i64 0, i64 %34
  %36 = trunc nuw nsw i64 %indvars.iv107.unr to i32
  store i32 %36, ptr %35, align 4, !tbaa !9
  %37 = getelementptr inbounds [51 x i32], ptr %13, i64 %34, i64 %indvars.iv107.unr
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %34
  store i32 %38, ptr %39, align 4, !tbaa !9
  br label %.preheader65

.preheader65:                                     ; preds = %.preheader65.unr-lcssa, %.preheader65.epilog-lcssa
  br i1 %.not73, label %._crit_edge83, label %.preheader63

40:                                               ; preds = %40, %.lr.ph76.new
  %indvars.iv107 = phi i64 [ 1, %.lr.ph76.new ], [ %indvars.iv.next108.1, %40 ]
  %niter = phi i64 [ 0, %.lr.ph76.new ], [ %niter.next.1, %40 ]
  %41 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv107
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [51 x i32], ptr @work, i64 0, i64 %43
  %45 = trunc nuw nsw i64 %indvars.iv107 to i32
  store i32 %45, ptr %44, align 4, !tbaa !9
  %46 = getelementptr inbounds [51 x i32], ptr %13, i64 %43, i64 %indvars.iv107
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %43
  store i32 %47, ptr %48, align 4, !tbaa !9
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %49 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv.next108
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [51 x i32], ptr @work, i64 0, i64 %51
  %53 = trunc nuw nsw i64 %indvars.iv.next108 to i32
  store i32 %53, ptr %52, align 4, !tbaa !9
  %54 = getelementptr inbounds [51 x i32], ptr %13, i64 %51, i64 %indvars.iv.next108
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %51
  store i32 %55, ptr %56, align 4, !tbaa !9
  %indvars.iv.next108.1 = add nuw nsw i64 %indvars.iv107, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.preheader65.unr-lcssa, label %40, !llvm.loop !15

.preheader63:                                     ; preds = %.preheader65, %._crit_edge80
  %57 = phi i32 [ %65, %._crit_edge80 ], [ %11, %.preheader65 ]
  %indvars.iv113 = phi i64 [ %indvars.iv.next114, %._crit_edge80 ], [ 1, %.preheader65 ]
  %.not5877 = icmp slt i32 %57, 1
  br i1 %.not5877, label %.preheader63.._crit_edge80_crit_edge, label %.lr.ph79

.preheader63.._crit_edge80_crit_edge:             ; preds = %.preheader63
  %.pre = sext i32 %57 to i64
  br label %._crit_edge80

.lr.ph79:                                         ; preds = %.preheader63
  %58 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %indvars.iv113
  br label %66

._crit_edge83:                                    ; preds = %._crit_edge80, %.split.us, %.preheader65
  %.lcssa = phi i32 [ %11, %.preheader65 ], [ %11, %.split.us ], [ %65, %._crit_edge80 ]
  store ptr getelementptr inbounds (i8, ptr @match, i64 204), ptr @cur_match, align 8, !tbaa !5
  %59 = sext i32 %.lcssa to i64
  %60 = shl nsw i64 %59, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 getelementptr inbounds (i8, ptr @match, i64 208), i8 0, i64 %60, i1 false)
  tail call void @_Z2KMv()
  store i32 0, ptr @total, align 4, !tbaa !9
  %61 = load i32, ptr @n, align 4, !tbaa !9
  %.not5684 = icmp slt i32 %61, 1
  br i1 %.not5684, label %._crit_edge88, label %.lr.ph87

.lr.ph87:                                         ; preds = %._crit_edge83
  %62 = load ptr, ptr @cur_match, align 8, !tbaa !5
  %63 = load ptr, ptr @cur_e, align 8, !tbaa !5
  %64 = add nuw i32 %61, 1
  %wide.trip.count119 = zext i32 %64 to i64
  br label %83

._crit_edge80:                                    ; preds = %66, %.preheader63.._crit_edge80_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.preheader63.._crit_edge80_crit_edge ], [ %80, %66 ]
  %65 = phi i32 [ %57, %.preheader63.._crit_edge80_crit_edge ], [ %79, %66 ]
  %indvars.iv.next114 = add nuw nsw i64 %indvars.iv113, 1
  %.not55.not = icmp slt i64 %indvars.iv113, %.pre-phi
  br i1 %.not55.not, label %.preheader63, label %._crit_edge83, !llvm.loop !16

66:                                               ; preds = %.lr.ph79, %66
  %indvars.iv110 = phi i64 [ 1, %.lr.ph79 ], [ %indvars.iv.next111, %66 ]
  %67 = getelementptr inbounds [51 x [51 x i32]], ptr getelementptr inbounds (i8, ptr @e, i64 10404), i64 0, i64 %indvars.iv113, i64 %indvars.iv110
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = load ptr, ptr @cur_match, align 8, !tbaa !5
  %70 = getelementptr inbounds i32, ptr %69, i64 %indvars.iv110
  %71 = load i32, ptr %70, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %72
  %74 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %58, ptr noundef nonnull align 4 dereferenceable(4) %73)
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = add nsw i32 %75, %68
  %77 = load ptr, ptr @cur_e, align 8, !tbaa !5
  %78 = getelementptr inbounds [51 x i32], ptr %77, i64 %indvars.iv113, i64 %indvars.iv110
  store i32 %76, ptr %78, align 4, !tbaa !9
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %79 = load i32, ptr @n, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %.not58.not = icmp slt i64 %indvars.iv110, %80
  br i1 %.not58.not, label %66, label %._crit_edge80, !llvm.loop !17

._crit_edge88:                                    ; preds = %83, %._crit_edge83
  %81 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.04794)
  %82 = load i32, ptr @n, align 4, !tbaa !9
  %.not5789 = icmp slt i32 %82, 1
  br i1 %.not5789, label %._crit_edge93, label %.lr.ph92

83:                                               ; preds = %.lr.ph87, %83
  %indvars.iv116 = phi i64 [ 1, %.lr.ph87 ], [ %indvars.iv.next117, %83 ]
  %84 = phi i32 [ 0, %.lr.ph87 ], [ %99, %83 ]
  %85 = getelementptr inbounds i32, ptr %62, i64 %indvars.iv116
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds (i8, ptr @work, i64 204), i64 0, i64 %87
  %89 = trunc nuw nsw i64 %indvars.iv116 to i32
  store i32 %89, ptr %88, align 4, !tbaa !9
  %90 = getelementptr inbounds [51 x i32], ptr %63, i64 %87, i64 %indvars.iv116
  %91 = load i32, ptr %90, align 4, !tbaa !9
  %92 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds (i8, ptr @tim, i64 204), i64 0, i64 %87
  store i32 %91, ptr %92, align 4, !tbaa !9
  %93 = getelementptr inbounds [51 x i32], ptr @tim, i64 0, i64 %87
  %94 = load i32, ptr %93, align 4, !tbaa !9
  %95 = getelementptr inbounds [51 x [51 x i32]], ptr getelementptr inbounds (i8, ptr @e, i64 10404), i64 0, i64 %87, i64 %indvars.iv116
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = add i32 %94, %96
  %98 = sub i32 %91, %97
  %99 = add nsw i32 %98, %84
  store i32 %99, ptr @total, align 4, !tbaa !9
  %indvars.iv.next117 = add nuw nsw i64 %indvars.iv116, 1
  %exitcond120.not = icmp eq i64 %indvars.iv.next117, %wide.trip.count119
  br i1 %exitcond120.not, label %._crit_edge88, label %83, !llvm.loop !18

._crit_edge93:                                    ; preds = %.lr.ph92, %._crit_edge88
  %100 = load i32, ptr @total, align 4, !tbaa !9
  %101 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %100)
  %102 = add nuw nsw i32 %.04794, 1
  %103 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %104 = icmp eq i32 %103, 1
  %105 = load i32, ptr @n, align 4
  %106 = icmp ne i32 %105, 0
  %107 = select i1 %104, i1 %106, i1 false
  br i1 %107, label %.preheader66, label %._crit_edge95, !llvm.loop !19

.lr.ph92:                                         ; preds = %._crit_edge88, %.lr.ph92
  %indvars.iv121 = phi i64 [ %indvars.iv.next122, %.lr.ph92 ], [ 1, %._crit_edge88 ]
  %108 = getelementptr inbounds [51 x i32], ptr @work, i64 0, i64 %indvars.iv121
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds (i8, ptr @work, i64 204), i64 0, i64 %indvars.iv121
  %111 = load i32, ptr %110, align 4, !tbaa !9
  %112 = getelementptr inbounds [51 x i32], ptr getelementptr inbounds (i8, ptr @tim, i64 204), i64 0, i64 %indvars.iv121
  %113 = load i32, ptr %112, align 4, !tbaa !9
  %114 = trunc nuw nsw i64 %indvars.iv121 to i32
  %115 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %114, i32 noundef %109, i32 noundef %111, i32 noundef %113)
  %indvars.iv.next122 = add nuw nsw i64 %indvars.iv121, 1
  %116 = load i32, ptr @n, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %.not57.not = icmp slt i64 %indvars.iv121, %117
  br i1 %.not57.not, label %.lr.ph92, label %._crit_edge93, !llvm.loop !20
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 nounwind willreturn memory(argmem: write) }
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" }
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" }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12, !14}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12, !14}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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