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

; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@mat = external dso_local global [201 x [201 x i32]], align 16
@ans = external dso_local global i32, align 4
@s = external dso_local global %"class.std::set", align 8
@.str = external hidden unnamed_addr constant [7 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 norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::pair", align 8
  %11 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %12 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %13 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store i32 0, ptr %1, align 4
  br label %14

14:                                               ; preds = %190, %0
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m, ptr noundef @q)
  %16 = icmp eq i32 %15, 3
  br i1 %16, label %17, label %193

17:                                               ; preds = %14
  store i32 0, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %18

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

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

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

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

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

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %31
  %33 = getelementptr inbounds [201 x i32], ptr %32, i64 0, i64 0
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr %33, i64 %35
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %36)
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %39
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sub nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [201 x i32], ptr %40, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [201 x i32], ptr %48, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = add nsw i32 %45, %52
  %54 = load i32, ptr @q, align 4, !tbaa !5
  %55 = srem i32 %53, %54
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %57
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [201 x i32], ptr %58, i64 0, i64 %60
  store i32 %55, ptr %61, align 4, !tbaa !5
  %62 = load i32, ptr %2, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %63
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [201 x i32], ptr %64, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp slt i32 %68, 0
  br i1 %69, label %70, label %80

70:                                               ; preds = %29
  %71 = load i32, ptr @q, align 4, !tbaa !5
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %73
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [201 x i32], ptr %74, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = add nsw i32 %78, %71
  store i32 %79, ptr %77, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %70, %29
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %4, align 4, !tbaa !5
  br label %24, !llvm.loop !9

84:                                               ; preds = %28
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %2, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !11

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

89:                                               ; preds = %187, %88
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = load i32, ptr @m, align 4, !tbaa !5
  %92 = icmp sle i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %190

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

97:                                               ; preds = %183, %94
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = load i32, ptr @m, align 4, !tbaa !5
  %100 = icmp sle i32 %98, %99
  br i1 %100, label %102, label %101

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

102:                                              ; preds = %97
  call void @_ZNSt3setIiSt4lessIiESaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  br label %103

103:                                              ; preds = %179, %102
  %104 = load i32, ptr %7, 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 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %182

108:                                              ; preds = %103
  %109 = call { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %110 = getelementptr inbounds { ptr, i8 }, ptr %10, i32 0, i32 0
  %111 = extractvalue { ptr, i8 } %109, 0
  store ptr %111, ptr %110, align 8
  %112 = getelementptr inbounds { ptr, i8 }, ptr %10, i32 0, i32 1
  %113 = extractvalue { ptr, i8 } %109, 1
  store i8 %113, ptr %112, align 8
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = load i32, ptr %7, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %116
  %118 = load i32, ptr %6, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [201 x i32], ptr %117, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = add nsw i32 %114, %121
  %123 = load i32, ptr %7, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %124
  %126 = load i32, ptr %5, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [201 x i32], ptr %125, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = sub nsw i32 %122, %129
  store i32 %130, ptr %9, align 4, !tbaa !5
  %131 = load i32, ptr %9, align 4, !tbaa !5
  %132 = load i32, ptr @q, align 4, !tbaa !5
  %133 = icmp sge i32 %131, %132
  br i1 %133, label %134, label %138

134:                                              ; preds = %108
  %135 = load i32, ptr @q, align 4, !tbaa !5
  %136 = load i32, ptr %9, align 4, !tbaa !5
  %137 = sub nsw i32 %136, %135
  store i32 %137, ptr %9, align 4, !tbaa !5
  br label %146

138:                                              ; preds = %108
  %139 = load i32, ptr %9, align 4, !tbaa !5
  %140 = icmp slt i32 %139, 0
  br i1 %140, label %141, label %145

141:                                              ; preds = %138
  %142 = load i32, ptr @q, align 4, !tbaa !5
  %143 = load i32, ptr %9, align 4, !tbaa !5
  %144 = add nsw i32 %143, %142
  store i32 %144, ptr %9, align 4, !tbaa !5
  br label %145

145:                                              ; preds = %141, %138
  br label %146

146:                                              ; preds = %145, %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %147 = call ptr @_ZNSt3setIiSt4lessIiESaIiEE11upper_boundERKi(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %148 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %11, i32 0, i32 0
  store ptr %147, ptr %148, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %149 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  %150 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %12, i32 0, i32 0
  store ptr %149, ptr %150, align 8
  %151 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br i1 %151, label %152, label %157

152:                                              ; preds = %146
  %153 = load i32, ptr %9, align 4, !tbaa !5
  %154 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = sub nsw i32 %153, %155
  store i32 %156, ptr %8, align 4, !tbaa !5
  br label %164

157:                                              ; preds = %146
  %158 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %159 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  %160 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %13, i32 0, i32 0
  store ptr %159, ptr %160, align 8
  %161 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = sub nsw i32 %158, %162
  store i32 %163, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %164

164:                                              ; preds = %157, %152
  %165 = load i32, ptr %8, align 4, !tbaa !5
  %166 = icmp slt i32 %165, 0
  br i1 %166, label %167, label %171

167:                                              ; preds = %164
  %168 = load i32, ptr @q, align 4, !tbaa !5
  %169 = load i32, ptr %8, align 4, !tbaa !5
  %170 = add nsw i32 %169, %168
  store i32 %170, ptr %8, align 4, !tbaa !5
  br label %171

171:                                              ; preds = %167, %164
  %172 = load i32, ptr @ans, align 4, !tbaa !5
  %173 = load i32, ptr %8, align 4, !tbaa !5
  %174 = icmp slt i32 %172, %173
  br i1 %174, label %175, label %177

175:                                              ; preds = %171
  %176 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %176, ptr @ans, align 4, !tbaa !5
  br label %177

177:                                              ; preds = %175, %171
  %178 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %178, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %179

179:                                              ; preds = %177
  %180 = load i32, ptr %7, align 4, !tbaa !5
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %7, align 4, !tbaa !5
  br label %103, !llvm.loop !12

182:                                              ; preds = %107
  br label %183

183:                                              ; preds = %182
  %184 = load i32, ptr %6, align 4, !tbaa !5
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %6, align 4, !tbaa !5
  br label %97, !llvm.loop !13

186:                                              ; preds = %101
  br label %187

187:                                              ; preds = %186
  %188 = load i32, ptr %5, align 4, !tbaa !5
  %189 = add nsw i32 %188, 1
  store i32 %189, ptr %5, align 4, !tbaa !5
  br label %89, !llvm.loop !14

190:                                              ; preds = %93
  %191 = load i32, ptr @ans, align 4, !tbaa !5
  %192 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %191)
  br label %14, !llvm.loop !15

193:                                              ; preds = %14
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #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 void @_ZNSt3setIiSt4lessIiESaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt3setIiSt4lessIiESaIiEE11upper_boundERKi(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNKSt3setIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNKSt3setIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@mat = external dso_local global [201 x [201 x i32]], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@s = external dso_local global %"class.std::set", align 8
@.str = external hidden unnamed_addr constant [7 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %4 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @q)
  %7 = icmp eq i32 %6, 3
  br i1 %7, label %.lr.ph61, label %._crit_edge62

.lr.ph61:                                         ; preds = %0, %._crit_edge59
  store i32 0, ptr @ans, align 4, !tbaa !5
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %.not45 = icmp slt i32 %8, 1
  %.pre79 = load i32, ptr @m, align 4, !tbaa !5
  %9 = icmp slt i32 %.pre79, 1
  %or.cond = select i1 %.not45, i1 true, i1 %9
  br i1 %or.cond, label %.preheader42, label %.preheader

.preheader42:                                     ; preds = %._crit_edge, %.lr.ph61
  %10 = phi i32 [ %.pre79, %.lr.ph61 ], [ %15, %._crit_edge ]
  %.not3756 = icmp slt i32 %10, 0
  br i1 %.not3756, label %._crit_edge59, label %.lr.ph58

.preheader:                                       ; preds = %.lr.ph61, %._crit_edge
  %11 = phi i32 [ %14, %._crit_edge ], [ %8, %.lr.ph61 ]
  %12 = phi i32 [ %15, %._crit_edge ], [ %.pre79, %.lr.ph61 ]
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %._crit_edge ], [ 1, %.lr.ph61 ]
  %.not4143 = icmp slt i32 %12, 1
  br i1 %.not4143, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %13 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %indvars.iv65
  br label %17

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %14 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %11, %.preheader ]
  %15 = phi i32 [ %30, %._crit_edge.loopexit ], [ %12, %.preheader ]
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %16 = sext i32 %14 to i64
  %.not.not = icmp slt i64 %indvars.iv65, %16
  br i1 %.not.not, label %.preheader, label %.preheader42, !llvm.loop !9

17:                                               ; preds = %.lr.ph, %17
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %17 ]
  %18 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %18)
  %20 = add nsw i64 %indvars.iv, -1
  %21 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %indvars.iv65, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %indvars.iv65, i64 %indvars.iv
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = add nsw i32 %24, %22
  %26 = load i32, ptr @q, align 4, !tbaa !5
  %27 = srem i32 %25, %26
  %28 = icmp slt i32 %27, 0
  %29 = select i1 %28, i32 %26, i32 0
  %spec.select = add nsw i32 %27, %29
  store i32 %spec.select, ptr %23, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr @m, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %.not41.not = icmp slt i64 %indvars.iv, %31
  br i1 %.not41.not, label %17, label %._crit_edge.loopexit, !llvm.loop !12

.loopexit.loopexit:                               ; preds = %._crit_edge51
  %.pre80 = sext i32 %40 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph58
  %.pre-phi = phi i64 [ %.pre80, %.loopexit.loopexit ], [ %38, %.lr.ph58 ]
  %32 = phi i32 [ %40, %.loopexit.loopexit ], [ %37, %.lr.ph58 ]
  %.not37.not = icmp slt i64 %indvars.iv76, %.pre-phi
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  br i1 %.not37.not, label %.lr.ph58, label %._crit_edge59, !llvm.loop !13

._crit_edge59:                                    ; preds = %.loopexit, %.preheader42
  %33 = load i32, ptr @ans, align 4, !tbaa !5
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %33)
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @q)
  %36 = icmp eq i32 %35, 3
  br i1 %36, label %.lr.ph61, label %._crit_edge62, !llvm.loop !14

.lr.ph58:                                         ; preds = %.preheader42, %.loopexit
  %37 = phi i32 [ %32, %.loopexit ], [ %10, %.preheader42 ]
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %.loopexit ], [ 0, %.preheader42 ]
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %.loopexit ], [ 1, %.preheader42 ]
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %38 = sext i32 %37 to i64
  %.not3852.not = icmp slt i64 %indvars.iv76, %38
  br i1 %.not3852.not, label %.lr.ph55, label %.loopexit

.lr.ph55:                                         ; preds = %.lr.ph58, %._crit_edge51
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %._crit_edge51 ], [ %indvars.iv71, %.lr.ph58 ]
  call void @_ZNSt3setIiSt4lessIiESaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %.not3947 = icmp slt i32 %39, 1
  br i1 %.not3947, label %._crit_edge51, label %.lr.ph50

._crit_edge51:                                    ; preds = %77, %.lr.ph55
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %40 = load i32, ptr @m, align 4, !tbaa !5
  %41 = trunc nuw i64 %indvars.iv73 to i32
  %.not38.not = icmp sgt i32 %40, %41
  br i1 %.not38.not, label %.lr.ph55, label %.loopexit.loopexit, !llvm.loop !15

.lr.ph50:                                         ; preds = %.lr.ph55, %77
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %77 ], [ 1, %.lr.ph55 ]
  %42 = call { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %indvars.iv68, i64 %indvars.iv73
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add nsw i32 %45, %43
  %47 = getelementptr inbounds [201 x [201 x i32]], ptr @mat, i64 0, i64 %indvars.iv68, i64 %indvars.iv76
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sub i32 %46, %48
  store i32 %49, ptr %2, align 4, !tbaa !5
  %50 = load i32, ptr @q, align 4, !tbaa !5
  %.not40 = icmp slt i32 %49, %50
  br i1 %.not40, label %53, label %51

51:                                               ; preds = %.lr.ph50
  %52 = sub nsw i32 %49, %50
  store i32 %52, ptr %2, align 4, !tbaa !5
  br label %57

53:                                               ; preds = %.lr.ph50
  %54 = icmp slt i32 %49, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %53
  %56 = add nsw i32 %50, %49
  store i32 %56, ptr %2, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %53, %55, %51
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %58 = call ptr @_ZNSt3setIiSt4lessIiESaIiEE11upper_boundERKi(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store ptr %58, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %59 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  store ptr %59, ptr %4, align 8
  %60 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %61 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %60, label %62, label %65

62:                                               ; preds = %57
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  %64 = load i32, ptr %63, align 4, !tbaa !5
  br label %69

65:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %66 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  store ptr %66, ptr %5, align 8
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  %68 = load i32, ptr %67, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %69

69:                                               ; preds = %65, %62
  %.pn = phi i32 [ %64, %62 ], [ %68, %65 ]
  %.sink = sub nsw i32 %61, %.pn
  %70 = icmp slt i32 %.sink, 0
  %71 = load i32, ptr @q, align 4
  %72 = select i1 %70, i32 %71, i32 0
  %73 = add nsw i32 %.sink, %72
  %74 = load i32, ptr @ans, align 4, !tbaa !5
  %75 = icmp slt i32 %74, %73
  br i1 %75, label %76, label %77

76:                                               ; preds = %69
  store i32 %73, ptr @ans, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %76, %69
  %78 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %78, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %.not39.not = icmp slt i64 %indvars.iv68, %80
  br i1 %.not39.not, label %.lr.ph50, label %._crit_edge51, !llvm.loop !16

._crit_edge62:                                    ; preds = %._crit_edge59, %0
  ret i32 0
}

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

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

; Function Attrs: mustprogress 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 void @_ZNSt3setIiSt4lessIiESaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt3setIiSt4lessIiESaIiEE11upper_boundERKi(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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

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

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

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

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

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


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