; LLVM IR from tangjz/acm-icpc :: self_training/2015-09-22 (A)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@tot_r = external dso_local global i32, align 4
@tot_c = external dso_local global i32, align 4
@rid = external dso_local global [111 x [111 x i32]], align 16
@cid = external dso_local global [111 x [111 x i32]], align 16
@match = external dso_local global [12321 x i32], align 16
@ans = external dso_local global i32, align 4
@str = external dso_local global [111 x [111 x i8]], align 16
@e = external dso_local global [12321 x %"class.std::vector"], align 16
@vis = external dso_local global [12321 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z4pathi(i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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
  store i32 0, ptr %1, align 4
  br label %12

12:                                               ; preds = %216, %0
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %219

15:                                               ; preds = %12
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot_c, align 4, !tbaa !5
  store i32 0, ptr @tot_r, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %28, %15
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %16
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %23
  %25 = getelementptr inbounds [111 x i8], ptr %24, i64 0, i64 0
  %26 = getelementptr inbounds i8, ptr %25, i64 1
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %26)
  br label %28

28:                                               ; preds = %21
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %16, !llvm.loop !9

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

32:                                               ; preds = %80, %31
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = icmp sle i32 %33, %34
  br i1 %35, label %37, label %36

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

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

38:                                               ; preds = %76, %37
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %79

43:                                               ; preds = %38
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %45
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [111 x i8], ptr %46, i64 0, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = sext i8 %50 to i32
  %52 = icmp ne i32 %51, 46
  br i1 %52, label %53, label %54

53:                                               ; preds = %43
  br label %76

54:                                               ; preds = %43
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %56
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [111 x i8], ptr %57, i64 0, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !11
  %63 = sext i8 %62 to i32
  %64 = icmp ne i32 %63, 46
  br i1 %64, label %65, label %68

65:                                               ; preds = %54
  %66 = load i32, ptr @tot_r, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr @tot_r, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %65, %54
  %69 = load i32, ptr @tot_r, align 4, !tbaa !5
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [111 x [111 x i32]], ptr @rid, i64 0, i64 %71
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [111 x i32], ptr %72, i64 0, i64 %74
  store i32 %69, ptr %75, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %68, %53
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %5, align 4, !tbaa !5
  br label %38, !llvm.loop !12

79:                                               ; preds = %42
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %3, align 4, !tbaa !5
  br label %32, !llvm.loop !13

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

84:                                               ; preds = %132, %83
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = icmp sle i32 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %135

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

90:                                               ; preds = %128, %89
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = icmp sle i32 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  store i32 16, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %131

95:                                               ; preds = %90
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %97
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [111 x i8], ptr %98, i64 0, i64 %100
  %102 = load i8, ptr %101, align 1, !tbaa !11
  %103 = sext i8 %102 to i32
  %104 = icmp ne i32 %103, 46
  br i1 %104, label %105, label %106

105:                                              ; preds = %95
  br label %128

106:                                              ; preds = %95
  %107 = load i32, ptr %7, align 4, !tbaa !5
  %108 = sub nsw i32 %107, 1
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %109
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [111 x i8], ptr %110, i64 0, i64 %112
  %114 = load i8, ptr %113, align 1, !tbaa !11
  %115 = sext i8 %114 to i32
  %116 = icmp ne i32 %115, 46
  br i1 %116, label %117, label %120

117:                                              ; preds = %106
  %118 = load i32, ptr @tot_c, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr @tot_c, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %117, %106
  %121 = load i32, ptr @tot_c, align 4, !tbaa !5
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [111 x [111 x i32]], ptr @cid, i64 0, i64 %123
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [111 x i32], ptr %124, i64 0, i64 %126
  store i32 %121, ptr %127, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %120, %105
  %129 = load i32, ptr %7, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %7, align 4, !tbaa !5
  br label %90, !llvm.loop !14

131:                                              ; preds = %94
  br label %132

132:                                              ; preds = %131
  %133 = load i32, ptr %6, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %6, align 4, !tbaa !5
  br label %84, !llvm.loop !15

135:                                              ; preds = %88
  store i32 0, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %136

136:                                              ; preds = %145, %135
  %137 = load i32, ptr %8, align 4, !tbaa !5
  %138 = load i32, ptr @tot_r, align 4, !tbaa !5
  %139 = icmp sle i32 %137, %138
  br i1 %139, label %141, label %140

140:                                              ; preds = %136
  store i32 19, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %148

141:                                              ; preds = %136
  %142 = load i32, ptr %8, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [12321 x %"class.std::vector"], ptr @e, i64 0, i64 %143
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %144) #6
  br label %145

145:                                              ; preds = %141
  %146 = load i32, ptr %8, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %8, align 4, !tbaa !5
  br label %136, !llvm.loop !16

148:                                              ; preds = %140
  %149 = load i32, ptr @tot_c, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = mul i64 %150, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @match, i64 1), i8 0, i64 %151, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %152

152:                                              ; preds = %194, %148
  %153 = load i32, ptr %9, align 4, !tbaa !5
  %154 = load i32, ptr @n, align 4, !tbaa !5
  %155 = icmp sle i32 %153, %154
  br i1 %155, label %157, label %156

156:                                              ; preds = %152
  store i32 22, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %197

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

158:                                              ; preds = %190, %157
  %159 = load i32, ptr %10, align 4, !tbaa !5
  %160 = load i32, ptr @n, align 4, !tbaa !5
  %161 = icmp sle i32 %159, %160
  br i1 %161, label %163, label %162

162:                                              ; preds = %158
  store i32 25, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %193

163:                                              ; preds = %158
  %164 = load i32, ptr %9, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %165
  %167 = load i32, ptr %10, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [111 x i8], ptr %166, i64 0, i64 %168
  %170 = load i8, ptr %169, align 1, !tbaa !11
  %171 = sext i8 %170 to i32
  %172 = icmp ne i32 %171, 46
  br i1 %172, label %173, label %174

173:                                              ; preds = %163
  br label %190

174:                                              ; preds = %163
  %175 = load i32, ptr %9, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [111 x [111 x i32]], ptr @rid, i64 0, i64 %176
  %178 = load i32, ptr %10, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [111 x i32], ptr %177, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [12321 x %"class.std::vector"], ptr @e, i64 0, i64 %182
  %184 = load i32, ptr %9, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [111 x [111 x i32]], ptr @cid, i64 0, i64 %185
  %187 = load i32, ptr %10, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [111 x i32], ptr %186, i64 0, i64 %188
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %183, ptr noundef nonnull align 4 dereferenceable(4) %189)
  br label %190

190:                                              ; preds = %174, %173
  %191 = load i32, ptr %10, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr %10, align 4, !tbaa !5
  br label %158, !llvm.loop !17

193:                                              ; preds = %162
  br label %194

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

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

198:                                              ; preds = %213, %197
  %199 = load i32, ptr %11, align 4, !tbaa !5
  %200 = load i32, ptr @tot_r, align 4, !tbaa !5
  %201 = icmp sle i32 %199, %200
  br i1 %201, label %203, label %202

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

203:                                              ; preds = %198
  %204 = load i32, ptr @tot_c, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = mul i64 %205, 1
  call void @llvm.memset.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %206, i1 false)
  %207 = load i32, ptr %11, align 4, !tbaa !5
  %208 = call noundef zeroext i1 @_Z4pathi(i32 noundef %207)
  br i1 %208, label %209, label %212

209:                                              ; preds = %203
  %210 = load i32, ptr @ans, align 4, !tbaa !5
  %211 = add nsw i32 %210, 1
  store i32 %211, ptr @ans, align 4, !tbaa !5
  br label %212

212:                                              ; preds = %209, %203
  br label %213

213:                                              ; preds = %212
  %214 = load i32, ptr %11, align 4, !tbaa !5
  %215 = add nsw i32 %214, 1
  store i32 %215, ptr %11, align 4, !tbaa !5
  br label %198, !llvm.loop !19

216:                                              ; preds = %202
  %217 = load i32, ptr @ans, align 4, !tbaa !5
  %218 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %217)
  br label %12, !llvm.loop !20

219:                                              ; preds = %12
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #0 align 2

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

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@tot_r = external dso_local local_unnamed_addr global i32, align 4
@tot_c = external dso_local local_unnamed_addr global i32, align 4
@rid = external dso_local local_unnamed_addr global [111 x [111 x i32]], align 16
@cid = external dso_local global [111 x [111 x i32]], align 16
@match = external dso_local local_unnamed_addr global [12321 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@str = external dso_local global [111 x [111 x i8]], align 16
@e = external dso_local global [12321 x %"class.std::vector"], align 16
@vis = external dso_local local_unnamed_addr global [12321 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %.lr.ph109, label %._crit_edge110

.lr.ph109:                                        ; preds = %0, %._crit_edge107
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot_c, align 4, !tbaa !5
  store i32 0, ptr @tot_r, align 4, !tbaa !5
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not65 = icmp slt i32 %3, 1
  br i1 %.not65, label %.preheader63.thread, label %.lr.ph

.preheader64:                                     ; preds = %.lr.ph
  %tot_r.promoted70.pre = load i32, ptr @tot_r, align 4, !tbaa !5
  %.not4776 = icmp slt i32 %7, 1
  br i1 %.not4776, label %.preheader63.thread, label %.preheader61.preheader

.preheader61.preheader:                           ; preds = %.preheader64
  %4 = add nuw i32 %7, 1
  %wide.trip.count119 = zext i32 %4 to i64
  br label %.preheader61

.lr.ph:                                           ; preds = %.lr.ph109, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph109 ]
  %5 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %indvars.iv, i64 1
  %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
  %.not.not = icmp slt i64 %indvars.iv, %8
  br i1 %.not.not, label %.lr.ph, label %.preheader64, !llvm.loop !9

.preheader63.thread:                              ; preds = %.preheader64, %.lr.ph109
  %.lcssa147.ph = phi i32 [ %7, %.preheader64 ], [ %3, %.lr.ph109 ]
  %.ph = phi i32 [ %tot_r.promoted70.pre, %.preheader64 ], [ 0, %.lr.ph109 ]
  %tot_c.promoted83151 = load i32, ptr @tot_c, align 4, !tbaa !5
  br label %._crit_edge92.split

.preheader63:                                     ; preds = %._crit_edge
  %tot_c.promoted83 = load i32, ptr @tot_c, align 4, !tbaa !5
  br i1 %.not4776, label %._crit_edge92.split, label %.preheader60.preheader

.preheader60.preheader:                           ; preds = %.preheader63
  %9 = add nuw i32 %7, 1
  %wide.trip.count129 = zext i32 %9 to i64
  br label %.preheader60

.preheader61:                                     ; preds = %.preheader61.preheader, %._crit_edge
  %indvars.iv116 = phi i64 [ 1, %.preheader61.preheader ], [ %indvars.iv.next117, %._crit_edge ]
  %tot_r.promoted7577 = phi i32 [ %tot_r.promoted70.pre, %.preheader61.preheader ], [ %tot_r.promoted71, %._crit_edge ]
  br label %10

._crit_edge:                                      ; preds = %23
  %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 %.preheader63, label %.preheader61, !llvm.loop !11

10:                                               ; preds = %.preheader61, %23
  %indvars.iv113 = phi i64 [ 1, %.preheader61 ], [ %indvars.iv.next114, %23 ]
  %tot_r.promoted73 = phi i32 [ %tot_r.promoted7577, %.preheader61 ], [ %tot_r.promoted71, %23 ]
  %11 = phi i32 [ %tot_r.promoted7577, %.preheader61 ], [ %24, %23 ]
  %12 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %indvars.iv116, i64 %indvars.iv113
  %13 = load i8, ptr %12, align 1, !tbaa !12
  %.not58 = icmp eq i8 %13, 46
  br i1 %.not58, label %14, label %23

14:                                               ; preds = %10
  %15 = add nsw i64 %indvars.iv113, -1
  %16 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %indvars.iv116, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !12
  %.not59 = icmp eq i8 %17, 46
  br i1 %.not59, label %20, label %18

18:                                               ; preds = %14
  %19 = add nsw i32 %11, 1
  store i32 %19, ptr @tot_r, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %18, %14
  %tot_r.promoted72 = phi i32 [ %19, %18 ], [ %tot_r.promoted73, %14 ]
  %21 = phi i32 [ %19, %18 ], [ %11, %14 ]
  %22 = getelementptr inbounds [111 x [111 x i32]], ptr @rid, i64 0, i64 %indvars.iv116, i64 %indvars.iv113
  store i32 %21, ptr %22, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %10, %20
  %tot_r.promoted71 = phi i32 [ %tot_r.promoted73, %10 ], [ %tot_r.promoted72, %20 ]
  %24 = phi i32 [ %11, %10 ], [ %21, %20 ]
  %indvars.iv.next114 = add nuw nsw i64 %indvars.iv113, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next114, %wide.trip.count119
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !13

.preheader60:                                     ; preds = %.preheader60.preheader, %._crit_edge82
  %indvars.iv126 = phi i64 [ 1, %.preheader60.preheader ], [ %indvars.iv.next127, %._crit_edge82 ]
  %tot_c.promoted8890 = phi i32 [ %tot_c.promoted83, %.preheader60.preheader ], [ %tot_c.promoted84, %._crit_edge82 ]
  br label %27

._crit_edge92.split:                              ; preds = %._crit_edge82, %.preheader63.thread, %.preheader63
  %25 = phi i32 [ %tot_r.promoted71, %.preheader63 ], [ %.ph, %.preheader63.thread ], [ %tot_r.promoted71, %._crit_edge82 ]
  %.lcssa147152 = phi i32 [ %7, %.preheader63 ], [ %.lcssa147.ph, %.preheader63.thread ], [ %7, %._crit_edge82 ]
  %26 = phi i32 [ %tot_c.promoted83, %.preheader63 ], [ %tot_c.promoted83151, %.preheader63.thread ], [ %tot_c.promoted84, %._crit_edge82 ]
  store i32 0, ptr @ans, align 4, !tbaa !5
  %.not4993 = icmp slt i32 %25, 1
  br i1 %.not4993, label %._crit_edge97, label %.lr.ph96

._crit_edge82:                                    ; preds = %40
  %indvars.iv.next127 = add nuw nsw i64 %indvars.iv126, 1
  %exitcond130.not = icmp eq i64 %indvars.iv.next127, %wide.trip.count129
  br i1 %exitcond130.not, label %._crit_edge92.split, label %.preheader60, !llvm.loop !14

27:                                               ; preds = %.preheader60, %40
  %indvars.iv121 = phi i64 [ 1, %.preheader60 ], [ %indvars.iv.next122, %40 ]
  %tot_c.promoted86 = phi i32 [ %tot_c.promoted8890, %.preheader60 ], [ %tot_c.promoted84, %40 ]
  %28 = phi i32 [ %tot_c.promoted8890, %.preheader60 ], [ %41, %40 ]
  %29 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %indvars.iv121, i64 %indvars.iv126
  %30 = load i8, ptr %29, align 1, !tbaa !12
  %.not55 = icmp eq i8 %30, 46
  br i1 %.not55, label %31, label %40

31:                                               ; preds = %27
  %32 = add nsw i64 %indvars.iv121, -1
  %33 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %32, i64 %indvars.iv126
  %34 = load i8, ptr %33, align 1, !tbaa !12
  %.not56 = icmp eq i8 %34, 46
  br i1 %.not56, label %37, label %35

35:                                               ; preds = %31
  %36 = add nsw i32 %28, 1
  store i32 %36, ptr @tot_c, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %35, %31
  %tot_c.promoted85 = phi i32 [ %36, %35 ], [ %tot_c.promoted86, %31 ]
  %38 = phi i32 [ %36, %35 ], [ %28, %31 ]
  %39 = getelementptr inbounds [111 x [111 x i32]], ptr @cid, i64 0, i64 %indvars.iv121, i64 %indvars.iv126
  store i32 %38, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %27, %37
  %tot_c.promoted84 = phi i32 [ %tot_c.promoted86, %27 ], [ %tot_c.promoted85, %37 ]
  %41 = phi i32 [ %28, %27 ], [ %38, %37 ]
  %indvars.iv.next122 = add nuw nsw i64 %indvars.iv121, 1
  %exitcond125.not = icmp eq i64 %indvars.iv.next122, %wide.trip.count129
  br i1 %exitcond125.not, label %._crit_edge82, label %27, !llvm.loop !15

._crit_edge97.loopexit:                           ; preds = %.lr.ph96
  %.pre = load i32, ptr @tot_c, align 4, !tbaa !5
  %.pre141 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge97

._crit_edge97:                                    ; preds = %._crit_edge97.loopexit, %._crit_edge92.split
  %42 = phi i32 [ %48, %._crit_edge97.loopexit ], [ %25, %._crit_edge92.split ]
  %43 = phi i32 [ %.pre141, %._crit_edge97.loopexit ], [ %.lcssa147152, %._crit_edge92.split ]
  %44 = phi i32 [ %.pre, %._crit_edge97.loopexit ], [ %26, %._crit_edge92.split ]
  %45 = sext i32 %44 to i64
  %46 = shl nsw i64 %45, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @match, i64 4), i8 0, i64 %46, i1 false)
  %.not50102 = icmp slt i32 %43, 1
  br i1 %.not50102, label %.preheader62, label %.preheader

.lr.ph96:                                         ; preds = %._crit_edge92.split, %.lr.ph96
  %indvars.iv131 = phi i64 [ %indvars.iv.next132, %.lr.ph96 ], [ 1, %._crit_edge92.split ]
  %47 = getelementptr inbounds [12321 x %"class.std::vector"], ptr @e, i64 0, i64 %indvars.iv131
  tail call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %47) #5
  %indvars.iv.next132 = add nuw nsw i64 %indvars.iv131, 1
  %48 = load i32, ptr @tot_r, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %.not49.not = icmp slt i64 %indvars.iv131, %49
  br i1 %.not49.not, label %.lr.ph96, label %._crit_edge97.loopexit, !llvm.loop !16

.preheader62.loopexit:                            ; preds = %._crit_edge101
  %.pre143 = load i32, ptr @tot_r, align 4, !tbaa !5
  br label %.preheader62

.preheader62:                                     ; preds = %.preheader62.loopexit, %._crit_edge97
  %50 = phi i32 [ %.pre143, %.preheader62.loopexit ], [ %42, %._crit_edge97 ]
  %.not51104 = icmp slt i32 %50, 1
  br i1 %.not51104, label %._crit_edge107, label %.lr.ph106

.preheader:                                       ; preds = %._crit_edge97, %._crit_edge101
  %51 = phi i32 [ %52, %._crit_edge101 ], [ %43, %._crit_edge97 ]
  %indvars.iv137 = phi i64 [ %indvars.iv.next138, %._crit_edge101 ], [ 1, %._crit_edge97 ]
  %.not5298 = icmp slt i32 %51, 1
  br i1 %.not5298, label %._crit_edge101, label %.lr.ph100

._crit_edge101:                                   ; preds = %64, %.preheader
  %52 = phi i32 [ %51, %.preheader ], [ %65, %64 ]
  %indvars.iv.next138 = add nuw nsw i64 %indvars.iv137, 1
  %53 = sext i32 %52 to i64
  %.not50.not = icmp slt i64 %indvars.iv137, %53
  br i1 %.not50.not, label %.preheader, label %.preheader62.loopexit, !llvm.loop !17

.lr.ph100:                                        ; preds = %.preheader, %64
  %54 = phi i32 [ %65, %64 ], [ %51, %.preheader ]
  %55 = phi i32 [ %66, %64 ], [ %51, %.preheader ]
  %indvars.iv134 = phi i64 [ %indvars.iv.next135, %64 ], [ 1, %.preheader ]
  %56 = getelementptr inbounds [111 x [111 x i8]], ptr @str, i64 0, i64 %indvars.iv137, i64 %indvars.iv134
  %57 = load i8, ptr %56, align 1, !tbaa !12
  %.not53 = icmp eq i8 %57, 46
  br i1 %.not53, label %58, label %64

58:                                               ; preds = %.lr.ph100
  %59 = getelementptr inbounds [111 x [111 x i32]], ptr @rid, i64 0, i64 %indvars.iv137, i64 %indvars.iv134
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [12321 x %"class.std::vector"], ptr @e, i64 0, i64 %61
  %63 = getelementptr inbounds [111 x [111 x i32]], ptr @cid, i64 0, i64 %indvars.iv137, i64 %indvars.iv134
  tail call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %62, ptr noundef nonnull align 4 dereferenceable(4) %63)
  %.pre142 = load i32, ptr @n, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %.lr.ph100, %58
  %65 = phi i32 [ %54, %.lr.ph100 ], [ %.pre142, %58 ]
  %66 = phi i32 [ %55, %.lr.ph100 ], [ %.pre142, %58 ]
  %indvars.iv.next135 = add nuw nsw i64 %indvars.iv134, 1
  %67 = sext i32 %66 to i64
  %.not52.not = icmp slt i64 %indvars.iv134, %67
  br i1 %.not52.not, label %.lr.ph100, label %._crit_edge101, !llvm.loop !18

._crit_edge107:                                   ; preds = %78, %.preheader62
  %68 = load i32, ptr @ans, align 4, !tbaa !5
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %68)
  %70 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %71 = icmp eq i32 %70, 1
  br i1 %71, label %.lr.ph109, label %._crit_edge110, !llvm.loop !19

.lr.ph106:                                        ; preds = %.preheader62, %78
  %.0105 = phi i32 [ %79, %78 ], [ 1, %.preheader62 ]
  %72 = load i32, ptr @tot_c, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %73, i1 false)
  %74 = tail call noundef zeroext i1 @_Z4pathi(i32 noundef %.0105)
  br i1 %74, label %75, label %78

75:                                               ; preds = %.lr.ph106
  %76 = load i32, ptr @ans, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr @ans, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %.lr.ph106, %75
  %79 = add nuw nsw i32 %.0105, 1
  %80 = load i32, ptr @tot_r, align 4, !tbaa !5
  %.not51.not = icmp slt i32 %.0105, %80
  br i1 %.not51.not, label %.lr.ph106, label %._crit_edge107, !llvm.loop !20

._crit_edge110:                                   ; preds = %._crit_edge107, %0
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

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

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 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 #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}


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