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

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

%"struct.std::pair" = type { i32, i32 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@g = external dso_local global [3002 x [3002 x i8]], align 16
@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@off = external dso_local global i32, align 4
@a = external dso_local global [5000 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 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 i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %35, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = icmp sle i32 %16, 3001
  br i1 %17, label %19, label %18

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

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

20:                                               ; preds = %31, %19
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp sle i32 %21, 3001
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %34

24:                                               ; preds = %20
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %26
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [3002 x i8], ptr %27, i64 0, i64 %29
  store i8 32, ptr %30, align 1, !tbaa !9
  br label %31

31:                                               ; preds = %24
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !5
  br label %20, !llvm.loop !10

34:                                               ; preds = %23
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !12

38:                                               ; preds = %18
  store i32 0, ptr getelementptr inbounds (%"struct.std::pair", ptr @a, i32 0, i32 1), align 4, !tbaa !13
  store i32 0, ptr @a, align 16, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %39

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

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

44:                                               ; preds = %39
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x)
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %48
  %50 = getelementptr inbounds %"struct.std::pair", ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !15
  %52 = load i32, ptr @x, align 4, !tbaa !5
  %53 = add nsw i32 %51, %52
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %55
  %57 = getelementptr inbounds %"struct.std::pair", ptr %56, i32 0, i32 0
  store i32 %53, ptr %57, align 8, !tbaa !15
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = srem i32 %58, 2
  %60 = icmp eq i32 %59, 1
  br i1 %60, label %61, label %74

61:                                               ; preds = %44
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %64
  %66 = getelementptr inbounds %"struct.std::pair", ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 4, !tbaa !13
  %68 = load i32, ptr @x, align 4, !tbaa !5
  %69 = add nsw i32 %67, %68
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %71
  %73 = getelementptr inbounds %"struct.std::pair", ptr %72, i32 0, i32 1
  store i32 %69, ptr %73, align 4, !tbaa !13
  br label %87

74:                                               ; preds = %44
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = sub nsw i32 %75, 1
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %77
  %79 = getelementptr inbounds %"struct.std::pair", ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 4, !tbaa !13
  %81 = load i32, ptr @x, align 4, !tbaa !5
  %82 = sub nsw i32 %80, %81
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %84
  %86 = getelementptr inbounds %"struct.std::pair", ptr %85, i32 0, i32 1
  store i32 %82, ptr %86, align 4, !tbaa !13
  br label %87

87:                                               ; preds = %74, %61
  br label %88

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

91:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 5000, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %92 = load i32, ptr getelementptr inbounds (%"struct.std::pair", ptr @a, i32 0, i32 1), align 4, !tbaa !13
  %93 = load i32, ptr @off, align 4, !tbaa !5
  %94 = add nsw i32 %92, %93
  store i32 %94, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %95 = load i32, ptr @a, align 16, !tbaa !15
  store i32 %95, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %96

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

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

101:                                              ; preds = %96
  %102 = load i32, ptr %10, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %103
  %105 = getelementptr inbounds %"struct.std::pair", ptr %104, i32 0, i32 1
  %106 = load i32, ptr %105, align 4, !tbaa !13
  %107 = load i32, ptr @off, align 4, !tbaa !5
  %108 = add nsw i32 %106, %107
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = icmp sgt i32 %108, %109
  br i1 %110, label %111, label %141

111:                                              ; preds = %101
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %8, align 4, !tbaa !5
  %114 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %115 = load i32, ptr %114, align 4, !tbaa !5
  store i32 %115, ptr %6, align 4, !tbaa !5
  %116 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %117 = load i32, ptr %116, align 4, !tbaa !5
  store i32 %117, ptr %7, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %135, %111
  %119 = load i32, ptr %8, align 4, !tbaa !5
  %120 = load i32, ptr %10, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %121
  %123 = getelementptr inbounds %"struct.std::pair", ptr %122, i32 0, i32 1
  %124 = load i32, ptr %123, align 4, !tbaa !13
  %125 = load i32, ptr @off, align 4, !tbaa !5
  %126 = add nsw i32 %124, %125
  %127 = icmp sle i32 %119, %126
  br i1 %127, label %128, label %140

128:                                              ; preds = %118
  %129 = load i32, ptr %8, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %130
  %132 = load i32, ptr %9, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [3002 x i8], ptr %131, i64 0, i64 %133
  store i8 47, ptr %134, align 1, !tbaa !9
  br label %135

135:                                              ; preds = %128
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %8, align 4, !tbaa !5
  %138 = load i32, ptr %9, align 4, !tbaa !5
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %9, align 4, !tbaa !5
  br label %118, !llvm.loop !17

140:                                              ; preds = %118
  br label %171

141:                                              ; preds = %101
  %142 = load i32, ptr %8, align 4, !tbaa !5
  %143 = add nsw i32 %142, -1
  store i32 %143, ptr %8, align 4, !tbaa !5
  %144 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %145 = load i32, ptr %144, align 4, !tbaa !5
  store i32 %145, ptr %6, align 4, !tbaa !5
  %146 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %147 = load i32, ptr %146, align 4, !tbaa !5
  store i32 %147, ptr %7, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %165, %141
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = load i32, ptr %10, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %151
  %153 = getelementptr inbounds %"struct.std::pair", ptr %152, i32 0, i32 1
  %154 = load i32, ptr %153, align 4, !tbaa !13
  %155 = load i32, ptr @off, align 4, !tbaa !5
  %156 = add nsw i32 %154, %155
  %157 = icmp sgt i32 %149, %156
  br i1 %157, label %158, label %170

158:                                              ; preds = %148
  %159 = load i32, ptr %8, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %160
  %162 = load i32, ptr %9, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [3002 x i8], ptr %161, i64 0, i64 %163
  store i8 92, ptr %164, align 1, !tbaa !9
  br label %165

165:                                              ; preds = %158
  %166 = load i32, ptr %8, align 4, !tbaa !5
  %167 = add nsw i32 %166, -1
  store i32 %167, ptr %8, align 4, !tbaa !5
  %168 = load i32, ptr %9, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %9, align 4, !tbaa !5
  br label %148, !llvm.loop !18

170:                                              ; preds = %148
  br label %171

171:                                              ; preds = %170, %140
  br label %172

172:                                              ; preds = %171
  %173 = load i32, ptr %10, align 4, !tbaa !5
  %174 = add nsw i32 %173, 1
  store i32 %174, ptr %10, align 4, !tbaa !5
  br label %96, !llvm.loop !19

175:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %176 = load i32, ptr @n, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %177
  %179 = getelementptr inbounds %"struct.std::pair", ptr %178, i32 0, i32 1
  %180 = load i32, ptr %179, align 4, !tbaa !13
  %181 = load i32, ptr @off, align 4, !tbaa !5
  %182 = add nsw i32 %180, %181
  store i32 %182, ptr %11, align 4, !tbaa !5
  %183 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %184 = load i32, ptr %183, align 4, !tbaa !5
  store i32 %184, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %185 = load i32, ptr @n, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %186
  %188 = getelementptr inbounds %"struct.std::pair", ptr %187, i32 0, i32 1
  %189 = load i32, ptr %188, align 4, !tbaa !13
  %190 = load i32, ptr @off, align 4, !tbaa !5
  %191 = add nsw i32 %189, %190
  store i32 %191, ptr %12, align 4, !tbaa !5
  %192 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %193 = load i32, ptr %192, align 4, !tbaa !5
  store i32 %193, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %194 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %194, ptr %8, align 4, !tbaa !5
  br label %195

195:                                              ; preds = %228, %175
  %196 = load i32, ptr %8, align 4, !tbaa !5
  %197 = load i32, ptr %7, align 4, !tbaa !5
  %198 = icmp sge i32 %196, %197
  br i1 %198, label %199, label %231

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

200:                                              ; preds = %218, %199
  %201 = load i32, ptr %13, align 4, !tbaa !5
  %202 = load i32, ptr @n, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %203
  %205 = getelementptr inbounds %"struct.std::pair", ptr %204, i32 0, i32 0
  %206 = load i32, ptr %205, align 8, !tbaa !15
  %207 = icmp slt i32 %201, %206
  br i1 %207, label %209, label %208

208:                                              ; preds = %200
  store i32 23, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %221

209:                                              ; preds = %200
  %210 = load i32, ptr %8, align 4, !tbaa !5
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %211
  %213 = load i32, ptr %13, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [3002 x i8], ptr %212, i64 0, i64 %214
  %216 = load i8, ptr %215, align 1, !tbaa !9
  %217 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext %216)
  br label %218

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

221:                                              ; preds = %208
  %222 = load i32, ptr %8, align 4, !tbaa !5
  %223 = load i32, ptr %7, align 4, !tbaa !5
  %224 = icmp ne i32 %222, %223
  br i1 %224, label %225, label %227

225:                                              ; preds = %221
  %226 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  br label %227

227:                                              ; preds = %225, %221
  br label %228

228:                                              ; preds = %227
  %229 = load i32, ptr %8, align 4, !tbaa !5
  %230 = add nsw i32 %229, -1
  store i32 %230, ptr %8, align 4, !tbaa !5
  br label %195, !llvm.loop !21

231:                                              ; preds = %195
  store i32 0, ptr %1, align 4
  store i32 1, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %232 = load i32, ptr %1, align 4
  ret i32 %232
}

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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #4

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4

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 = { 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 #4 = { inlinehint 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = !{!14, !6, i64 4}
!14 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 0}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11}
!18 = distinct !{!18, !11}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11}
!21 = distinct !{!21, !11}


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

%"struct.std::pair" = type { i32, i32 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@g = external dso_local local_unnamed_addr global [3002 x [3002 x i8]], align 16
@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@off = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global [5000 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 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 i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(9012004) @g, i8 32, i64 9012004, i1 false), !tbaa !5
  store i32 0, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !8
  store i32 0, ptr @a, align 16, !tbaa !11
  %7 = load i32, ptr @n, align 4, !tbaa !12
  %.not46 = icmp slt i32 %7, 1
  br i1 %.not46, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  store i32 5000, ptr %2, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %8 = load i32, ptr @off, align 4, !tbaa !12
  store i32 %8, ptr %3, align 4, !tbaa !12
  br label %._crit_edge.._crit_edge64_crit_edge

._crit_edge:                                      ; preds = %.lr.ph
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !8
  %.pre99 = load i32, ptr @a, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  store i32 5000, ptr %2, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %9 = load i32, ptr @off, align 4, !tbaa !12
  %10 = add nsw i32 %9, %.pre
  store i32 %10, ptr %3, align 4, !tbaa !12
  %.not3759 = icmp slt i32 %25, 1
  br i1 %.not3759, label %._crit_edge.._crit_edge64_crit_edge, label %.lr.ph63

._crit_edge.._crit_edge64_crit_edge:              ; preds = %._crit_edge.thread, %._crit_edge
  %11 = phi i32 [ %8, %._crit_edge.thread ], [ %9, %._crit_edge ]
  %12 = phi i32 [ %7, %._crit_edge.thread ], [ %25, %._crit_edge ]
  %.pre106 = sext i32 %12 to i64
  br label %._crit_edge64

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %14 = add nsw i64 %indvars.iv, -1
  %15 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %14
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = load i32, ptr @x, align 4, !tbaa !12
  %18 = add nsw i32 %17, %16
  %19 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv
  store i32 %18, ptr %19, align 8, !tbaa !11
  %20 = and i64 %indvars.iv, 1
  %.not41 = icmp eq i64 %20, 0
  %21 = getelementptr inbounds i8, ptr %15, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !8
  %23 = sub i32 0, %17
  %.sink.p = select i1 %.not41, i32 %23, i32 %17
  %.sink = add i32 %22, %.sink.p
  %24 = getelementptr inbounds i8, ptr %19, i64 4
  store i32 %.sink, ptr %24, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i32, ptr @n, align 4, !tbaa !12
  %26 = sext i32 %25 to i64
  %.not.not = icmp slt i64 %indvars.iv, %26
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge64:                                    ; preds = %.loopexit, %._crit_edge.._crit_edge64_crit_edge
  %.pre-phi = phi i64 [ %.pre106, %._crit_edge.._crit_edge64_crit_edge ], [ %98, %.loopexit ]
  %27 = phi i32 [ %11, %._crit_edge.._crit_edge64_crit_edge ], [ %96, %.loopexit ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %28 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %.pre-phi, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !8
  %30 = add nsw i32 %27, %29
  store i32 %30, ptr %4, align 4, !tbaa !12
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %32 = load i32, ptr %31, align 4, !tbaa !12
  store i32 %32, ptr %1, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  %33 = load i32, ptr @n, align 4, !tbaa !12
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %34, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !8
  %37 = load i32, ptr @off, align 4, !tbaa !12
  %38 = add nsw i32 %37, %36
  store i32 %38, ptr %5, align 4, !tbaa !12
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %40 = load i32, ptr %39, align 4, !tbaa !12
  store i32 %40, ptr %2, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  %41 = load i32, ptr %1, align 4, !tbaa !12
  store i32 %41, ptr %3, align 4, !tbaa !12
  %.not3869 = icmp slt i32 %41, %40
  br i1 %.not3869, label %._crit_edge70, label %.preheader.preheader

.preheader.preheader:                             ; preds = %._crit_edge64
  %.pre101 = load i32, ptr @n, align 4, !tbaa !12
  br label %.preheader

.lr.ph63:                                         ; preds = %._crit_edge, %.loopexit
  %42 = phi i32 [ %95, %.loopexit ], [ %10, %._crit_edge ]
  %43 = phi i32 [ %96, %.loopexit ], [ %9, %._crit_edge ]
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %.loopexit ], [ 1, %._crit_edge ]
  %.02960 = phi i32 [ %.3, %.loopexit ], [ %.pre99, %._crit_edge ]
  %44 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv93, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !8
  %46 = add nsw i32 %43, %45
  %47 = icmp sgt i32 %46, %42
  br i1 %47, label %48, label %70

48:                                               ; preds = %.lr.ph63
  %49 = add nsw i32 %42, 1
  store i32 %49, ptr %3, align 4, !tbaa !12
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %51 = load i32, ptr %50, align 4, !tbaa !12
  store i32 %51, ptr %1, align 4, !tbaa !12
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %53 = load i32, ptr %52, align 4, !tbaa !12
  store i32 %53, ptr %2, align 4, !tbaa !12
  %54 = load i32, ptr %44, align 4, !tbaa !8
  %55 = load i32, ptr @off, align 4, !tbaa !12
  %56 = add nsw i32 %55, %54
  %.promoted52 = load i32, ptr %3, align 4, !tbaa !12
  %.not4053 = icmp sgt i32 %.promoted52, %56
  br i1 %.not4053, label %.loopexit, label %.lr.ph56.preheader

.lr.ph56.preheader:                               ; preds = %48
  %57 = sext i32 %.02960 to i64
  %58 = sext i32 %.promoted52 to i64
  %59 = add i32 %54, 1
  %60 = add i32 %59, %55
  %61 = sub i32 %60, %.promoted52
  %62 = add i32 %54, %55
  %63 = sub i32 %62, %.promoted52
  %xtraiter115 = and i32 %61, 3
  %lcmp.mod116.not = icmp eq i32 %xtraiter115, 0
  br i1 %lcmp.mod116.not, label %.lr.ph56.prol.loopexit, label %.lr.ph56.prol

.lr.ph56.prol:                                    ; preds = %.lr.ph56.preheader, %.lr.ph56.prol
  %indvars.iv88.prol = phi i64 [ %indvars.iv.next89.prol, %.lr.ph56.prol ], [ %58, %.lr.ph56.preheader ]
  %indvars.iv86.prol = phi i64 [ %indvars.iv.next87.prol, %.lr.ph56.prol ], [ %57, %.lr.ph56.preheader ]
  %prol.iter117 = phi i32 [ %prol.iter117.next, %.lr.ph56.prol ], [ 0, %.lr.ph56.preheader ]
  %64 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv88.prol, i64 %indvars.iv86.prol
  store i8 47, ptr %64, align 1, !tbaa !5
  %indvars.iv.next89.prol = add nsw i64 %indvars.iv88.prol, 1
  %indvars.iv.next87.prol = add nsw i64 %indvars.iv86.prol, 1
  %prol.iter117.next = add i32 %prol.iter117, 1
  %prol.iter117.cmp.not = icmp eq i32 %prol.iter117.next, %xtraiter115
  br i1 %prol.iter117.cmp.not, label %.lr.ph56.prol.loopexit, label %.lr.ph56.prol, !llvm.loop !15

.lr.ph56.prol.loopexit:                           ; preds = %.lr.ph56.prol, %.lr.ph56.preheader
  %indvars.iv.next87.lcssa.unr = phi i64 [ poison, %.lr.ph56.preheader ], [ %indvars.iv.next87.prol, %.lr.ph56.prol ]
  %indvars.iv88.unr = phi i64 [ %58, %.lr.ph56.preheader ], [ %indvars.iv.next89.prol, %.lr.ph56.prol ]
  %indvars.iv86.unr = phi i64 [ %57, %.lr.ph56.preheader ], [ %indvars.iv.next87.prol, %.lr.ph56.prol ]
  %65 = icmp ult i32 %63, 3
  br i1 %65, label %..loopexit_crit_edge, label %.lr.ph56

.lr.ph56:                                         ; preds = %.lr.ph56.prol.loopexit, %.lr.ph56
  %indvars.iv88 = phi i64 [ %indvars.iv.next89.3, %.lr.ph56 ], [ %indvars.iv88.unr, %.lr.ph56.prol.loopexit ]
  %indvars.iv86 = phi i64 [ %indvars.iv.next87.3, %.lr.ph56 ], [ %indvars.iv86.unr, %.lr.ph56.prol.loopexit ]
  %66 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv88, i64 %indvars.iv86
  store i8 47, ptr %66, align 1, !tbaa !5
  %indvars.iv.next89 = add nsw i64 %indvars.iv88, 1
  %indvars.iv.next87 = add nsw i64 %indvars.iv86, 1
  %67 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv.next89, i64 %indvars.iv.next87
  store i8 47, ptr %67, align 1, !tbaa !5
  %indvars.iv.next89.1 = add nsw i64 %indvars.iv88, 2
  %indvars.iv.next87.1 = add nsw i64 %indvars.iv86, 2
  %68 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv.next89.1, i64 %indvars.iv.next87.1
  store i8 47, ptr %68, align 1, !tbaa !5
  %indvars.iv.next89.2 = add nsw i64 %indvars.iv88, 3
  %indvars.iv.next87.2 = add nsw i64 %indvars.iv86, 3
  %69 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv.next89.2, i64 %indvars.iv.next87.2
  store i8 47, ptr %69, align 1, !tbaa !5
  %indvars.iv.next89.3 = add nsw i64 %indvars.iv88, 4
  %indvars.iv.next87.3 = add nsw i64 %indvars.iv86, 4
  %lftr.wideiv.3 = trunc i64 %indvars.iv.next89.3 to i32
  %exitcond.not.3 = icmp eq i32 %60, %lftr.wideiv.3
  br i1 %exitcond.not.3, label %..loopexit_crit_edge, label %.lr.ph56, !llvm.loop !17

70:                                               ; preds = %.lr.ph63
  %71 = add nsw i32 %42, -1
  store i32 %71, ptr %3, align 4, !tbaa !12
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %73 = load i32, ptr %72, align 4, !tbaa !12
  store i32 %73, ptr %1, align 4, !tbaa !12
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %75 = load i32, ptr %74, align 4, !tbaa !12
  store i32 %75, ptr %2, align 4, !tbaa !12
  %76 = load i32, ptr %44, align 4, !tbaa !8
  %77 = load i32, ptr @off, align 4, !tbaa !12
  %78 = add nsw i32 %77, %76
  %.promoted = load i32, ptr %3, align 4, !tbaa !12
  %79 = icmp sgt i32 %.promoted, %78
  br i1 %79, label %.lr.ph50.preheader, label %.loopexit

.lr.ph50.preheader:                               ; preds = %70
  %80 = sext i32 %.02960 to i64
  %81 = sext i32 %.promoted to i64
  %82 = sext i32 %78 to i64
  %83 = sub nsw i64 %81, %82
  %xtraiter = and i64 %83, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph50.prol.loopexit, label %.lr.ph50.prol

.lr.ph50.prol:                                    ; preds = %.lr.ph50.preheader, %.lr.ph50.prol
  %indvars.iv81.prol = phi i64 [ %indvars.iv.next82.prol, %.lr.ph50.prol ], [ %81, %.lr.ph50.preheader ]
  %indvars.iv79.prol = phi i64 [ %indvars.iv.next80.prol, %.lr.ph50.prol ], [ %80, %.lr.ph50.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph50.prol ], [ 0, %.lr.ph50.preheader ]
  %84 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv81.prol, i64 %indvars.iv79.prol
  store i8 92, ptr %84, align 1, !tbaa !5
  %indvars.iv.next82.prol = add nsw i64 %indvars.iv81.prol, -1
  %indvars.iv.next80.prol = add nsw i64 %indvars.iv79.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph50.prol.loopexit, label %.lr.ph50.prol, !llvm.loop !18

.lr.ph50.prol.loopexit:                           ; preds = %.lr.ph50.prol, %.lr.ph50.preheader
  %indvars.iv81.unr = phi i64 [ %81, %.lr.ph50.preheader ], [ %indvars.iv.next82.prol, %.lr.ph50.prol ]
  %indvars.iv79.unr = phi i64 [ %80, %.lr.ph50.preheader ], [ %indvars.iv.next80.prol, %.lr.ph50.prol ]
  %indvars.iv.next82.lcssa.unr = phi i64 [ poison, %.lr.ph50.preheader ], [ %indvars.iv.next82.prol, %.lr.ph50.prol ]
  %indvars.iv.next80.lcssa.unr = phi i64 [ poison, %.lr.ph50.preheader ], [ %indvars.iv.next80.prol, %.lr.ph50.prol ]
  %85 = sub nsw i64 %82, %81
  %86 = icmp ugt i64 %85, -4
  br i1 %86, label %..loopexit42_crit_edge, label %.lr.ph50

.lr.ph50:                                         ; preds = %.lr.ph50.prol.loopexit, %.lr.ph50
  %indvars.iv81 = phi i64 [ %indvars.iv.next82.3, %.lr.ph50 ], [ %indvars.iv81.unr, %.lr.ph50.prol.loopexit ]
  %indvars.iv79 = phi i64 [ %indvars.iv.next80.3, %.lr.ph50 ], [ %indvars.iv79.unr, %.lr.ph50.prol.loopexit ]
  %87 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv81, i64 %indvars.iv79
  store i8 92, ptr %87, align 1, !tbaa !5
  %indvars.iv.next82 = add nsw i64 %indvars.iv81, -1
  %indvars.iv.next80 = add nsw i64 %indvars.iv79, 1
  %88 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv.next82, i64 %indvars.iv.next80
  store i8 92, ptr %88, align 1, !tbaa !5
  %indvars.iv.next82.1 = add nsw i64 %indvars.iv81, -2
  %indvars.iv.next80.1 = add nsw i64 %indvars.iv79, 2
  %89 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv.next82.1, i64 %indvars.iv.next80.1
  store i8 92, ptr %89, align 1, !tbaa !5
  %indvars.iv.next82.2 = add nsw i64 %indvars.iv81, -3
  %indvars.iv.next80.2 = add nsw i64 %indvars.iv79, 3
  %90 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %indvars.iv.next82.2, i64 %indvars.iv.next80.2
  store i8 92, ptr %90, align 1, !tbaa !5
  %indvars.iv.next82.3 = add nsw i64 %indvars.iv81, -4
  %indvars.iv.next80.3 = add nsw i64 %indvars.iv79, 4
  %91 = icmp sgt i64 %indvars.iv.next82.3, %82
  br i1 %91, label %.lr.ph50, label %..loopexit42_crit_edge, !llvm.loop !19

..loopexit_crit_edge:                             ; preds = %.lr.ph56, %.lr.ph56.prol.loopexit
  %indvars.iv.next87.lcssa = phi i64 [ %indvars.iv.next87.lcssa.unr, %.lr.ph56.prol.loopexit ], [ %indvars.iv.next87.3, %.lr.ph56 ]
  %92 = trunc nsw i64 %indvars.iv.next87.lcssa to i32
  store i32 %60, ptr %3, align 4, !tbaa !12
  br label %.loopexit

..loopexit42_crit_edge:                           ; preds = %.lr.ph50, %.lr.ph50.prol.loopexit
  %indvars.iv.next82.lcssa = phi i64 [ %indvars.iv.next82.lcssa.unr, %.lr.ph50.prol.loopexit ], [ %indvars.iv.next82.3, %.lr.ph50 ]
  %indvars.iv.next80.lcssa = phi i64 [ %indvars.iv.next80.lcssa.unr, %.lr.ph50.prol.loopexit ], [ %indvars.iv.next80.3, %.lr.ph50 ]
  %93 = trunc nsw i64 %indvars.iv.next82.lcssa to i32
  %94 = trunc nsw i64 %indvars.iv.next80.lcssa to i32
  store i32 %93, ptr %3, align 4, !tbaa !12
  br label %.loopexit

.loopexit:                                        ; preds = %70, %..loopexit42_crit_edge, %48, %..loopexit_crit_edge
  %95 = phi i32 [ %60, %..loopexit_crit_edge ], [ %.promoted52, %48 ], [ %93, %..loopexit42_crit_edge ], [ %.promoted, %70 ]
  %96 = phi i32 [ %55, %..loopexit_crit_edge ], [ %55, %48 ], [ %77, %..loopexit42_crit_edge ], [ %77, %70 ]
  %.3 = phi i32 [ %92, %..loopexit_crit_edge ], [ %.02960, %48 ], [ %94, %..loopexit42_crit_edge ], [ %.02960, %70 ]
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %97 = load i32, ptr @n, align 4, !tbaa !12
  %98 = sext i32 %97 to i64
  %.not37.not = icmp slt i64 %indvars.iv93, %98
  br i1 %.not37.not, label %.lr.ph63, label %._crit_edge64, !llvm.loop !20

.preheader:                                       ; preds = %.preheader.preheader, %119
  %99 = phi i32 [ %40, %.preheader.preheader ], [ %.pre105, %119 ]
  %100 = phi i32 [ %41, %.preheader.preheader ], [ %121, %119 ]
  %101 = phi i32 [ %.pre101, %.preheader.preheader ], [ %.pre100, %119 ]
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %102
  %104 = load i32, ptr %103, align 8, !tbaa !11
  %105 = icmp sgt i32 %104, 0
  br i1 %105, label %.lr.ph67, label %._crit_edge68

._crit_edge68.loopexit:                           ; preds = %.lr.ph67
  %.pre102 = load i32, ptr %3, align 4, !tbaa !12
  %.pre103 = load i32, ptr %2, align 4, !tbaa !12
  br label %._crit_edge68

._crit_edge68:                                    ; preds = %._crit_edge68.loopexit, %.preheader
  %106 = phi i32 [ %.pre103, %._crit_edge68.loopexit ], [ %99, %.preheader ]
  %107 = phi i32 [ %.pre102, %._crit_edge68.loopexit ], [ %100, %.preheader ]
  %.not39 = icmp eq i32 %107, %106
  br i1 %.not39, label %._crit_edge70, label %119

.lr.ph67:                                         ; preds = %.preheader, %.lr.ph67
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %.lr.ph67 ], [ 0, %.preheader ]
  %108 = load i32, ptr %3, align 4, !tbaa !12
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [3002 x [3002 x i8]], ptr @g, i64 0, i64 %109, i64 %indvars.iv96
  %111 = load i8, ptr %110, align 1, !tbaa !5
  %112 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext %111)
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %113 = load i32, ptr @n, align 4, !tbaa !12
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [5000 x %"struct.std::pair"], ptr @a, i64 0, i64 %114
  %116 = load i32, ptr %115, align 8, !tbaa !11
  %117 = sext i32 %116 to i64
  %118 = icmp slt i64 %indvars.iv.next97, %117
  br i1 %118, label %.lr.ph67, label %._crit_edge68.loopexit, !llvm.loop !21

119:                                              ; preds = %._crit_edge68
  %120 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.1)
  %.pre100 = load i32, ptr @n, align 4, !tbaa !12
  %.pre104 = load i32, ptr %3, align 4, !tbaa !12
  %.pre105 = load i32, ptr %2, align 4, !tbaa !12
  %121 = add nsw i32 %.pre104, -1
  store i32 %121, ptr %3, align 4, !tbaa !12
  %.not38.not = icmp sgt i32 %.pre104, %.pre105
  br i1 %.not38.not, label %.preheader, label %._crit_edge70, !llvm.loop !22

._crit_edge70:                                    ; preds = %119, %._crit_edge68, %._crit_edge64
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #4

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

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

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 = { 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 #4 = { inlinehint 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 4}
!9 = !{!"_ZTSSt4pairIiiE", !10, i64 0, !10, i64 4}
!10 = !{!"int", !6, i64 0}
!11 = !{!9, !10, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}


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