; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/252 Division 2/Problem D (D)

; 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 }
%"class.std::allocator" = type { i8 }

@n = external dso_local global i32, align 4
@p = external dso_local global [3001 x i32], align 16
@v = external dso_local global [3001 x i32], align 16
@m = external dso_local global i32, align 4
@cnt = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 personality ptr @__gxx_personality_v0 {
  %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 %"class.std::vector", align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.std::allocator", align 1
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %26, %0
  %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) #8
  br label %29

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

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

29:                                               ; preds = %20
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %31

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

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %50

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [3001 x i32], ptr @v, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %46, label %42

42:                                               ; preds = %36
  %43 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z5visiti(i32 noundef %43)
  %44 = load i32, ptr @cnt, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr @cnt, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %42, %36
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !11

50:                                               ; preds = %35
  call void @llvm.memset.p0.i64(ptr align 16 @v, i8 0, i64 12004, i1 false)
  %51 = load i32, ptr @n, align 4, !tbaa !5
  %52 = load i32, ptr @m, align 4, !tbaa !5
  %53 = sub nsw i32 %51, %52
  store i32 %53, ptr @m, align 4, !tbaa !5
  %54 = load i32, ptr @m, align 4, !tbaa !5
  %55 = load i32, ptr @cnt, align 4, !tbaa !5
  %56 = sub nsw i32 %54, %55
  %57 = call i32 @llvm.abs.i32(i32 %56, i1 true)
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %57)
  %59 = load i32, ptr @m, align 4, !tbaa !5
  %60 = load i32, ptr @cnt, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %62, label %91

62:                                               ; preds = %50
  call void @_Z5visiti(i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 2, ptr %4, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %87, %62
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = load i32, ptr @n, align 4, !tbaa !5
  %66 = icmp sle i32 %64, %65
  br i1 %66, label %67, label %71

67:                                               ; preds = %63
  %68 = load i32, ptr @cnt, align 4, !tbaa !5
  %69 = load i32, ptr @m, align 4, !tbaa !5
  %70 = icmp sgt i32 %68, %69
  br label %71

71:                                               ; preds = %67, %63
  %72 = phi i1 [ false, %63 ], [ %70, %67 ]
  br i1 %72, label %74, label %73

73:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %90

74:                                               ; preds = %71
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [3001 x i32], ptr @v, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %86, label %80

80:                                               ; preds = %74
  %81 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z5visiti(i32 noundef %81)
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef 1, i32 noundef %82)
  %84 = load i32, ptr @cnt, align 4, !tbaa !5
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr @cnt, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %80, %74
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %4, align 4, !tbaa !5
  br label %63, !llvm.loop !12

90:                                               ; preds = %73
  br label %194

91:                                               ; preds = %50
  %92 = load i32, ptr @m, align 4, !tbaa !5
  %93 = load i32, ptr @cnt, align 4, !tbaa !5
  %94 = icmp sgt i32 %92, %93
  br i1 %94, label %95, label %193

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

96:                                               ; preds = %188, %95
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = load i32, ptr @n, align 4, !tbaa !5
  %99 = icmp sle i32 %97, %98
  br i1 %99, label %100, label %104

100:                                              ; preds = %96
  %101 = load i32, ptr @m, align 4, !tbaa !5
  %102 = load i32, ptr @cnt, align 4, !tbaa !5
  %103 = icmp sgt i32 %101, %102
  br label %104

104:                                              ; preds = %100, %96
  %105 = phi i1 [ false, %96 ], [ %103, %100 ]
  br i1 %105, label %107, label %106

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

107:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #8
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  %110 = sext i32 %109 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 -1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #8
  call void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #8
  invoke void @_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %110, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 1 dereferenceable(1) %9)
          to label %111 unwind label %121

111:                                              ; preds = %107
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %112 = load i32, ptr %5, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [3001 x i32], ptr @p, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  store i32 %115, ptr %13, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %131, %111
  %117 = load i32, ptr %13, align 4, !tbaa !5
  %118 = load i32, ptr %5, align 4, !tbaa !5
  %119 = icmp ne i32 %117, %118
  br i1 %119, label %125, label %120

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

121:                                              ; preds = %107
  %122 = landingpad { ptr, i32 }
          cleanup
  %123 = extractvalue { ptr, i32 } %122, 0
  store ptr %123, ptr %10, align 8
  %124 = extractvalue { ptr, i32 } %122, 1
  store i32 %124, ptr %11, align 4
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %191

125:                                              ; preds = %116
  %126 = load i32, ptr %12, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %12, align 4, !tbaa !5
  %128 = load i32, ptr %13, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %129) #8
  store i32 %126, ptr %130, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %125
  %132 = load i32, ptr %13, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [3001 x i32], ptr @p, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  store i32 %135, ptr %13, align 4, !tbaa !5
  br label %116, !llvm.loop !13

136:                                              ; preds = %120
  %137 = load i32, ptr %12, align 4, !tbaa !5
  %138 = load i32, ptr %5, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %139) #8
  store i32 %137, ptr %140, align 4, !tbaa !5
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %141 = load i32, ptr %5, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %14, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %184, %136
  %144 = load i32, ptr %14, align 4, !tbaa !5
  %145 = load i32, ptr @n, align 4, !tbaa !5
  %146 = icmp sle i32 %144, %145
  br i1 %146, label %147, label %151

147:                                              ; preds = %143
  %148 = load i32, ptr @m, align 4, !tbaa !5
  %149 = load i32, ptr @cnt, align 4, !tbaa !5
  %150 = icmp sgt i32 %148, %149
  br label %151

151:                                              ; preds = %147, %143
  %152 = phi i1 [ false, %143 ], [ %150, %147 ]
  br i1 %152, label %154, label %153

153:                                              ; preds = %151
  store i32 17, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %187

154:                                              ; preds = %151
  %155 = load i32, ptr %14, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %156) #8
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = load i32, ptr %12, align 4, !tbaa !5
  %160 = icmp sge i32 %158, %159
  br i1 %160, label %161, label %183

161:                                              ; preds = %154
  %162 = load i32, ptr %5, align 4, !tbaa !5
  %163 = load i32, ptr %14, align 4, !tbaa !5
  %164 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %162, i32 noundef %163)
          to label %165 unwind label %179

165:                                              ; preds = %161
  %166 = load i32, ptr @m, align 4, !tbaa !5
  %167 = add nsw i32 %166, -1
  store i32 %167, ptr @m, align 4, !tbaa !5
  %168 = load i32, ptr %14, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %169) #8
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %12, align 4, !tbaa !5
  %173 = load i32, ptr %5, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [3001 x i32], ptr @p, i64 0, i64 %174
  %176 = load i32, ptr %14, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [3001 x i32], ptr @p, i64 0, i64 %177
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %175, ptr noundef nonnull align 4 dereferenceable(4) %178) #8
  br label %183

179:                                              ; preds = %161
  %180 = landingpad { ptr, i32 }
          cleanup
  %181 = extractvalue { ptr, i32 } %180, 0
  store ptr %181, ptr %10, align 8
  %182 = extractvalue { ptr, i32 } %180, 1
  store i32 %182, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #8
  br label %191

183:                                              ; preds = %165, %154
  br label %184

184:                                              ; preds = %183
  %185 = load i32, ptr %14, align 4, !tbaa !5
  %186 = add nsw i32 %185, 1
  store i32 %186, ptr %14, align 4, !tbaa !5
  br label %143, !llvm.loop !14

187:                                              ; preds = %153
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #8
  br label %188

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

191:                                              ; preds = %179, %121
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %195

192:                                              ; preds = %106
  br label %193

193:                                              ; preds = %192, %91
  br label %194

194:                                              ; preds = %193, %90
  ret i32 0

195:                                              ; preds = %191
  %196 = load ptr, ptr %10, align 8
  %197 = load i32, ptr %11, align 4
  %198 = insertvalue { ptr, i32 } poison, ptr %196, 0
  %199 = insertvalue { ptr, i32 } %198, i32 %197, 1
  resume { ptr, i32 } %199
}

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #6 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #6 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #6 align 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { 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 #8 = { 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::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 }
%"class.std::allocator" = type { i8 }

@n = external dso_local global i32, align 4
@p = external dso_local global [3001 x i32], align 16
@v = external dso_local local_unnamed_addr global [3001 x i32], align 16
@m = external dso_local global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::vector", align 8
  %2 = alloca i32, align 4
  %3 = alloca %"class.std::allocator", align 1
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not47 = icmp slt i32 %5, 1
  br i1 %.not47, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not4149 = icmp slt i32 %7, 1
  br i1 %.not4149, label %._crit_edge53, label %.lr.ph52

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

._crit_edge53:                                    ; preds = %28, %._crit_edge
  %.lcssa = phi i32 [ %7, %._crit_edge ], [ %29, %28 ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(12004) @v, i8 0, i64 12004, i1 false)
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %13 = sub nsw i32 %.lcssa, %12
  store i32 %13, ptr @m, align 4, !tbaa !5
  %14 = load i32, ptr @cnt, align 4, !tbaa !5
  %15 = sub nsw i32 %13, %14
  %16 = tail call i32 @llvm.abs.i32(i32 %15, i1 true)
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %16)
  %18 = load i32, ptr @m, align 4
  %19 = load i32, ptr @cnt, align 4
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %31, label %56

.lr.ph52:                                         ; preds = %._crit_edge, %28
  %21 = phi i32 [ %29, %28 ], [ %7, %._crit_edge ]
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %28 ], [ 1, %._crit_edge ]
  %22 = getelementptr inbounds [3001 x i32], ptr @v, i64 0, i64 %indvars.iv76
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %.not45 = icmp eq i32 %23, 0
  br i1 %.not45, label %24, label %28

24:                                               ; preds = %.lr.ph52
  %25 = trunc nuw nsw i64 %indvars.iv76 to i32
  tail call void @_Z5visiti(i32 noundef %25)
  %26 = load i32, ptr @cnt, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @cnt, align 4, !tbaa !5
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %.lr.ph52, %24
  %29 = phi i32 [ %21, %.lr.ph52 ], [ %.pre, %24 ]
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %30 = sext i32 %29 to i64
  %.not41.not = icmp slt i64 %indvars.iv76, %30
  br i1 %.not41.not, label %.lr.ph52, label %._crit_edge53, !llvm.loop !11

31:                                               ; preds = %._crit_edge53
  tail call void @_Z5visiti(i32 noundef 1)
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = icmp sgt i32 %32, 1
  %34 = load i32, ptr @cnt, align 4
  %35 = load i32, ptr @m, align 4
  %36 = icmp sgt i32 %34, %35
  %37 = select i1 %33, i1 %36, i1 false
  br i1 %37, label %.lr.ph71, label %.loopexit

.lr.ph71:                                         ; preds = %31, %48
  %38 = phi i32 [ %49, %48 ], [ %35, %31 ]
  %39 = phi i32 [ %50, %48 ], [ %34, %31 ]
  %40 = phi i32 [ %51, %48 ], [ %32, %31 ]
  %indvars.iv87 = phi i64 [ %indvars.iv.next88, %48 ], [ 2, %31 ]
  %41 = getelementptr inbounds [3001 x i32], ptr @v, i64 0, i64 %indvars.iv87
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %.not44 = icmp eq i32 %42, 0
  br i1 %.not44, label %43, label %48

43:                                               ; preds = %.lr.ph71
  %44 = trunc nuw nsw i64 %indvars.iv87 to i32
  tail call void @_Z5visiti(i32 noundef %44)
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 1, i32 noundef %44)
  %46 = load i32, ptr @cnt, align 4, !tbaa !5
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr @cnt, align 4, !tbaa !5
  %.pre90 = load i32, ptr @n, align 4, !tbaa !5
  %.pre91 = load i32, ptr @m, align 4
  br label %48

48:                                               ; preds = %.lr.ph71, %43
  %49 = phi i32 [ %38, %.lr.ph71 ], [ %.pre91, %43 ]
  %50 = phi i32 [ %39, %.lr.ph71 ], [ %47, %43 ]
  %51 = phi i32 [ %40, %.lr.ph71 ], [ %.pre90, %43 ]
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %52 = sext i32 %51 to i64
  %53 = icmp slt i64 %indvars.iv87, %52
  %54 = icmp sgt i32 %50, %49
  %55 = select i1 %53, i1 %54, i1 false
  br i1 %55, label %.lr.ph71, label %.loopexit, !llvm.loop !12

56:                                               ; preds = %._crit_edge53
  %57 = icmp sgt i32 %18, %19
  %58 = load i32, ptr @n, align 4
  %59 = icmp sgt i32 %58, 0
  %or.cond = select i1 %57, i1 %59, i1 false
  br i1 %or.cond, label %.lr.ph68, label %.loopexit

.lr.ph68:                                         ; preds = %56, %._crit_edge66
  %indvars.iv84 = phi i64 [ %indvars.iv.next85, %._crit_edge66 ], [ 1, %56 ]
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %._crit_edge66 ], [ 2, %56 ]
  %60 = phi i32 [ %82, %._crit_edge66 ], [ %58, %56 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #8
  %61 = add nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  store i32 -1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #8
  call void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #8
  invoke void @_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %62, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %63 unwind label %75

63:                                               ; preds = %.lr.ph68
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  %64 = getelementptr inbounds [3001 x i32], ptr @p, i64 0, i64 %indvars.iv84
  %.03354 = load i32, ptr %64, align 4, !tbaa !5
  %65 = zext i32 %.03354 to i64
  %.not4255 = icmp eq i64 %indvars.iv84, %65
  br i1 %.not4255, label %._crit_edge60, label %.lr.ph59

._crit_edge60:                                    ; preds = %.lr.ph59, %63
  %.034.lcssa = phi i32 [ 0, %63 ], [ %77, %.lr.ph59 ]
  %66 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv84) #8
  store i32 %.034.lcssa, ptr %66, align 4, !tbaa !5
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %indvars.iv84, %68
  %70 = load i32, ptr @m, align 4
  %71 = load i32, ptr @cnt, align 4
  %72 = icmp sgt i32 %70, %71
  %73 = select i1 %69, i1 %72, i1 false
  br i1 %73, label %.lr.ph65.preheader, label %._crit_edge66

.lr.ph65.preheader:                               ; preds = %._crit_edge60
  %74 = trunc nuw nsw i64 %indvars.iv84 to i32
  br label %.lr.ph65

75:                                               ; preds = %.lr.ph68
  %76 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #8
  resume { ptr, i32 } %76

.lr.ph59:                                         ; preds = %63, %.lr.ph59
  %.03357 = phi i32 [ %.033, %.lr.ph59 ], [ %.03354, %63 ]
  %.03456 = phi i32 [ %77, %.lr.ph59 ], [ 0, %63 ]
  %77 = add nuw nsw i32 %.03456, 1
  %78 = sext i32 %.03357 to i64
  %79 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %78) #8
  store i32 %.03456, ptr %79, align 4, !tbaa !5
  %80 = getelementptr inbounds [3001 x i32], ptr @p, i64 0, i64 %78
  %.033 = load i32, ptr %80, align 4, !tbaa !5
  %81 = zext i32 %.033 to i64
  %.not42 = icmp eq i64 %indvars.iv84, %81
  br i1 %.not42, label %._crit_edge60, label %.lr.ph59, !llvm.loop !13

._crit_edge66:                                    ; preds = %.lr.ph65._crit_edge, %._crit_edge60
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #8
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = icmp slt i64 %indvars.iv84, %83
  %85 = load i32, ptr @m, align 4
  %86 = load i32, ptr @cnt, align 4
  %87 = icmp sgt i32 %85, %86
  %88 = select i1 %84, i1 %87, i1 false
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  br i1 %88, label %.lr.ph68, label %.loopexit, !llvm.loop !14

.lr.ph65:                                         ; preds = %.lr.ph65.preheader, %.lr.ph65._crit_edge
  %indvars.iv81 = phi i64 [ %indvars.iv79, %.lr.ph65.preheader ], [ %indvars.iv.next82, %.lr.ph65._crit_edge ]
  %.162 = phi i32 [ 0, %.lr.ph65.preheader ], [ %.2, %.lr.ph65._crit_edge ]
  %89 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv81) #8
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %.not43 = icmp slt i32 %90, %.162
  %.pre92 = trunc nuw i64 %indvars.iv81 to i32
  br i1 %.not43, label %.lr.ph65._crit_edge, label %91

91:                                               ; preds = %.lr.ph65
  %92 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %74, i32 noundef %.pre92)
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = add nsw i32 %93, -1
  store i32 %94, ptr @m, align 4, !tbaa !5
  %95 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv81) #8
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  %98 = getelementptr inbounds [3001 x i32], ptr @p, i64 0, i64 %indvars.iv81
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %64, ptr noundef nonnull align 4 dereferenceable(4) %98) #8
  br label %.lr.ph65._crit_edge

.lr.ph65._crit_edge:                              ; preds = %.lr.ph65, %91
  %.2 = phi i32 [ %97, %91 ], [ %.162, %.lr.ph65 ]
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %99 = load i32, ptr @n, align 4, !tbaa !5
  %100 = icmp sgt i32 %99, %.pre92
  %101 = load i32, ptr @m, align 4
  %102 = load i32, ptr @cnt, align 4
  %103 = icmp sgt i32 %101, %102
  %104 = select i1 %100, i1 %103, i1 false
  br i1 %104, label %.lr.ph65, label %._crit_edge66, !llvm.loop !15

.loopexit:                                        ; preds = %._crit_edge66, %48, %31, %56
  ret i32 0
}

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

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

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

; 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #6 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #6 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #6 align 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { 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 #8 = { 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}


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