; LLVM IR from eyangch/competitive-programming :: USACOcontests/gold/2017.02 (nocross)

; 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::basic_istream" = type { ptr, i64, %"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i32, align 4
@a = external dso_local global [1000 x i32], align 16
@b = external dso_local global [1000 x i32], align 16
@dp = external dso_local global [1000 x [1000 x i32]], align 16
@mx = external dso_local global [1000 x [1000 x i32]], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = 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
  store i32 0, ptr %1, align 4
  %7 = load ptr, ptr @stdin, align 8, !tbaa !5
  %8 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %7)
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  %10 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %9)
  %11 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %12 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %13 = getelementptr i8, ptr %12, i64 -24
  %14 = load i64, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %14
  %16 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %15, ptr noundef null)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %28, %0
  %19 = load i32, ptr %2, align 4, !tbaa !11
  %20 = load i32, ptr @N, align 4, !tbaa !11
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !11
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1000 x i32], ptr @a, i64 0, i64 %25
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %26)
  br label %28

28:                                               ; preds = %23
  %29 = load i32, ptr %2, align 4, !tbaa !11
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !11
  br label %18, !llvm.loop !13

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %32

32:                                               ; preds = %42, %31
  %33 = load i32, ptr %3, align 4, !tbaa !11
  %34 = load i32, ptr @N, align 4, !tbaa !11
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

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

37:                                               ; preds = %32
  %38 = load i32, ptr %3, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1000 x i32], ptr @b, i64 0, i64 %39
  %41 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %40)
  br label %42

42:                                               ; preds = %37
  %43 = load i32, ptr %3, align 4, !tbaa !11
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %3, align 4, !tbaa !11
  br label %32, !llvm.loop !15

45:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %174, %45
  %47 = load i32, ptr %4, align 4, !tbaa !11
  %48 = load i32, ptr @N, align 4, !tbaa !11
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %177

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %52

52:                                               ; preds = %170, %51
  %53 = load i32, ptr %6, align 4, !tbaa !11
  %54 = load i32, ptr @N, align 4, !tbaa !11
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %173

57:                                               ; preds = %52
  %58 = load i32, ptr %4, align 4, !tbaa !11
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %60, label %79

60:                                               ; preds = %57
  %61 = load i32, ptr %6, align 4, !tbaa !11
  %62 = icmp sgt i32 %61, 0
  br i1 %62, label %63, label %79

63:                                               ; preds = %60
  %64 = load i32, ptr %4, align 4, !tbaa !11
  %65 = sub nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %66
  %68 = load i32, ptr %6, align 4, !tbaa !11
  %69 = sub nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1000 x i32], ptr %67, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !11
  %73 = load i32, ptr %4, align 4, !tbaa !11
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %74
  %76 = load i32, ptr %6, align 4, !tbaa !11
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1000 x i32], ptr %75, i64 0, i64 %77
  store i32 %72, ptr %78, align 4, !tbaa !11
  br label %79

79:                                               ; preds = %63, %60, %57
  %80 = load i32, ptr %4, align 4, !tbaa !11
  %81 = icmp sgt i32 %80, 0
  br i1 %81, label %82, label %104

82:                                               ; preds = %79
  %83 = load i32, ptr %4, align 4, !tbaa !11
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %84
  %86 = load i32, ptr %6, align 4, !tbaa !11
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1000 x i32], ptr %85, i64 0, i64 %87
  %89 = load i32, ptr %4, align 4, !tbaa !11
  %90 = sub nsw i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %91
  %93 = load i32, ptr %6, align 4, !tbaa !11
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [1000 x i32], ptr %92, i64 0, i64 %94
  %96 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %88, ptr noundef nonnull align 4 dereferenceable(4) %95)
  %97 = load i32, ptr %96, align 4, !tbaa !11
  %98 = load i32, ptr %4, align 4, !tbaa !11
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %99
  %101 = load i32, ptr %6, align 4, !tbaa !11
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1000 x i32], ptr %100, i64 0, i64 %102
  store i32 %97, ptr %103, align 4, !tbaa !11
  br label %104

104:                                              ; preds = %82, %79
  %105 = load i32, ptr %6, align 4, !tbaa !11
  %106 = icmp sgt i32 %105, 0
  br i1 %106, label %107, label %129

107:                                              ; preds = %104
  %108 = load i32, ptr %4, align 4, !tbaa !11
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %109
  %111 = load i32, ptr %6, align 4, !tbaa !11
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [1000 x i32], ptr %110, i64 0, i64 %112
  %114 = load i32, ptr %4, align 4, !tbaa !11
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %115
  %117 = load i32, ptr %6, align 4, !tbaa !11
  %118 = sub nsw i32 %117, 1
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [1000 x i32], ptr %116, i64 0, i64 %119
  %121 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %113, ptr noundef nonnull align 4 dereferenceable(4) %120)
  %122 = load i32, ptr %121, align 4, !tbaa !11
  %123 = load i32, ptr %4, align 4, !tbaa !11
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %124
  %126 = load i32, ptr %6, align 4, !tbaa !11
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1000 x i32], ptr %125, i64 0, i64 %127
  store i32 %122, ptr %128, align 4, !tbaa !11
  br label %129

129:                                              ; preds = %107, %104
  %130 = load i32, ptr %4, align 4, !tbaa !11
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [1000 x i32], ptr @a, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !11
  %134 = load i32, ptr %6, align 4, !tbaa !11
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1000 x i32], ptr @b, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !11
  %138 = sub nsw i32 %133, %137
  %139 = call i32 @llvm.abs.i32(i32 %138, i1 true)
  %140 = icmp sle i32 %139, 4
  %141 = zext i1 %140 to i32
  %142 = load i32, ptr %4, align 4, !tbaa !11
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %143
  %145 = load i32, ptr %6, align 4, !tbaa !11
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1000 x i32], ptr %144, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !11
  %149 = add nsw i32 %148, %141
  store i32 %149, ptr %147, align 4, !tbaa !11
  %150 = load i32, ptr %4, align 4, !tbaa !11
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %151
  %153 = load i32, ptr %6, align 4, !tbaa !11
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [1000 x i32], ptr %152, i64 0, i64 %154
  %156 = load i32, ptr %4, align 4, !tbaa !11
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %157
  %159 = load i32, ptr %6, align 4, !tbaa !11
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [1000 x i32], ptr %158, i64 0, i64 %160
  %162 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %155, ptr noundef nonnull align 4 dereferenceable(4) %161)
  %163 = load i32, ptr %162, align 4, !tbaa !11
  %164 = load i32, ptr %4, align 4, !tbaa !11
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %165
  %167 = load i32, ptr %6, align 4, !tbaa !11
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [1000 x i32], ptr %166, i64 0, i64 %168
  store i32 %163, ptr %169, align 4, !tbaa !11
  br label %170

170:                                              ; preds = %129
  %171 = load i32, ptr %6, align 4, !tbaa !11
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %6, align 4, !tbaa !11
  br label %52, !llvm.loop !16

173:                                              ; preds = %56
  br label %174

174:                                              ; preds = %173
  %175 = load i32, ptr %4, align 4, !tbaa !11
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %4, align 4, !tbaa !11
  br label %46, !llvm.loop !17

177:                                              ; preds = %50
  %178 = load i32, ptr @N, align 4, !tbaa !11
  %179 = sub nsw i32 %178, 1
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %180
  %182 = load i32, ptr @N, align 4, !tbaa !11
  %183 = sub nsw i32 %182, 1
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [1000 x i32], ptr %181, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !11
  %187 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %186)
  %188 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %187, ptr noundef @.str.4)
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

; 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: 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)) #4

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

; 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) #6

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


; 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::basic_istream" = type { ptr, i64, %"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i32, align 4
@a = external dso_local global [1000 x i32], align 16
@b = external dso_local global [1000 x i32], align 16
@dp = external dso_local global [1000 x [1000 x i32]], align 16
@mx = external dso_local global [1000 x [1000 x i32]], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = 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 = load ptr, ptr @stdin, align 8, !tbaa !5
  %2 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %1)
  %3 = load ptr, ptr @stdout, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %3)
  %5 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %6 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %8
  %10 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %9, ptr noundef null)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %12 = load i32, ptr @N, align 4, !tbaa !11
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge53

.preheader46:                                     ; preds = %.lr.ph
  %14 = icmp sgt i32 %17, 0
  br i1 %14, label %.lr.ph49, label %._crit_edge53

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %15 = getelementptr inbounds [1000 x i32], ptr @a, i64 0, i64 %indvars.iv
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr @N, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %.lr.ph, label %.preheader46, !llvm.loop !13

.preheader45:                                     ; preds = %.lr.ph49
  %20 = icmp sgt i32 %23, 0
  br i1 %20, label %.preheader, label %._crit_edge53

.lr.ph49:                                         ; preds = %.preheader46, %.lr.ph49
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %.lr.ph49 ], [ 0, %.preheader46 ]
  %21 = getelementptr inbounds [1000 x i32], ptr @b, i64 0, i64 %indvars.iv60
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %23 = load i32, ptr @N, align 4, !tbaa !11
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next61, %24
  br i1 %25, label %.lr.ph49, label %.preheader45, !llvm.loop !15

.preheader:                                       ; preds = %.preheader45, %._crit_edge
  %26 = phi i32 [ %82, %._crit_edge ], [ %23, %.preheader45 ]
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %._crit_edge ], [ 0, %.preheader45 ]
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph51, label %._crit_edge

.lr.ph51:                                         ; preds = %.preheader
  %.not = icmp eq i64 %indvars.iv71, 0
  %28 = add nsw i64 %indvars.iv71, -1
  %29 = getelementptr inbounds [1000 x i32], ptr @a, i64 0, i64 %indvars.iv71
  br i1 %.not, label %.lr.ph51.split.us.preheader._crit_edge, label %30

30:                                               ; preds = %.lr.ph51
  %31 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %indvars.iv71, i64 0
  %32 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %28, i64 0
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %31, ptr noundef nonnull align 4 dereferenceable(4) %32)
  %34 = load i32, ptr %33, align 4, !tbaa !11
  store i32 %34, ptr %31, align 16, !tbaa !11
  %.phi.trans.insert = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %indvars.iv71, i64 0
  %.pre75 = load i32, ptr %.phi.trans.insert, align 16, !tbaa !11
  %.pre74 = load i32, ptr @b, align 16, !tbaa !11
  %.pre = load i32, ptr %29, align 4, !tbaa !11
  %35 = sub nsw i32 %.pre, %.pre74
  %36 = tail call i32 @llvm.abs.i32(i32 %35, i1 true)
  %37 = icmp ult i32 %36, 5
  %38 = zext i1 %37 to i32
  %39 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %indvars.iv71, i64 0
  %40 = add nsw i32 %.pre75, %38
  store i32 %40, ptr %39, align 16, !tbaa !11
  %41 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %indvars.iv71, i64 0
  %42 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %41, ptr noundef nonnull align 4 dereferenceable(4) %39)
  %43 = load i32, ptr %42, align 4, !tbaa !11
  store i32 %43, ptr %41, align 16, !tbaa !11
  %44 = load i32, ptr @N, align 4, !tbaa !11
  %45 = icmp sgt i32 %44, 1
  br i1 %45, label %.lr.ph51.split.peel.next, label %._crit_edge

.lr.ph51.split.us.preheader._crit_edge:           ; preds = %.lr.ph51
  %.pre83 = load i32, ptr @dp, align 16, !tbaa !11
  %.pre82 = load i32, ptr @b, align 16, !tbaa !11
  %.pre81 = load i32, ptr %29, align 4, !tbaa !11
  %46 = sub nsw i32 %.pre81, %.pre82
  %47 = tail call i32 @llvm.abs.i32(i32 %46, i1 true)
  %48 = icmp ult i32 %47, 5
  %49 = zext i1 %48 to i32
  %50 = add nsw i32 %.pre83, %49
  store i32 %50, ptr @dp, align 16, !tbaa !11
  %51 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mx, ptr noundef nonnull align 4 dereferenceable(4) @dp)
  %52 = load i32, ptr %51, align 4, !tbaa !11
  store i32 %52, ptr @mx, align 16, !tbaa !11
  %53 = load i32, ptr @N, align 4, !tbaa !11
  %54 = icmp sgt i32 %53, 1
  br i1 %54, label %.lr.ph51.split.us.peel.next, label %._crit_edge

.lr.ph51.split.us.peel.next:                      ; preds = %.lr.ph51.split.us.preheader._crit_edge, %.lr.ph51.split.us.peel.next
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %.lr.ph51.split.us.peel.next ], [ 1, %.lr.ph51.split.us.preheader._crit_edge ]
  %55 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 0, i64 %indvars.iv67
  %56 = add nsw i64 %indvars.iv67, -1
  %57 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 0, i64 %56
  %58 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %55, ptr noundef nonnull align 4 dereferenceable(4) %57)
  %59 = load i32, ptr %58, align 4, !tbaa !11
  store i32 %59, ptr %55, align 4, !tbaa !11
  %60 = load i32, ptr %29, align 4, !tbaa !11
  %61 = getelementptr inbounds [1000 x i32], ptr @b, i64 0, i64 %indvars.iv67
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = sub nsw i32 %60, %62
  %64 = tail call i32 @llvm.abs.i32(i32 %63, i1 true)
  %65 = icmp ult i32 %64, 5
  %66 = zext i1 %65 to i32
  %67 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 0, i64 %indvars.iv67
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = add nsw i32 %68, %66
  store i32 %69, ptr %67, align 4, !tbaa !11
  %70 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 0, i64 %indvars.iv67
  %71 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %70, ptr noundef nonnull align 4 dereferenceable(4) %67)
  %72 = load i32, ptr %71, align 4, !tbaa !11
  store i32 %72, ptr %70, align 4, !tbaa !11
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %73 = load i32, ptr @N, align 4, !tbaa !11
  %74 = sext i32 %73 to i64
  %75 = icmp slt i64 %indvars.iv.next68, %74
  br i1 %75, label %.lr.ph51.split.us.peel.next, label %._crit_edge, !llvm.loop !16

._crit_edge53:                                    ; preds = %._crit_edge, %0, %.preheader46, %.preheader45
  %.lcssa = phi i32 [ %23, %.preheader45 ], [ %17, %.preheader46 ], [ %12, %0 ], [ %82, %._crit_edge ]
  %76 = add nsw i32 %.lcssa, -1
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %77, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !11
  %80 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %79)
  %81 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %80, ptr noundef nonnull @.str.4)
  ret i32 0

._crit_edge:                                      ; preds = %.lr.ph51.split.peel.next, %.lr.ph51.split.us.peel.next, %30, %.lr.ph51.split.us.preheader._crit_edge, %.preheader
  %82 = phi i32 [ %26, %.preheader ], [ %53, %.lr.ph51.split.us.preheader._crit_edge ], [ %44, %30 ], [ %73, %.lr.ph51.split.us.peel.next ], [ %105, %.lr.ph51.split.peel.next ]
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %83 = sext i32 %82 to i64
  %84 = icmp slt i64 %indvars.iv.next72, %83
  br i1 %84, label %.preheader, label %._crit_edge53, !llvm.loop !18

.lr.ph51.split.peel.next:                         ; preds = %30, %.lr.ph51.split.peel.next
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %.lr.ph51.split.peel.next ], [ 1, %30 ]
  %85 = add nsw i64 %indvars.iv63, -1
  %86 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %28, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !11
  %88 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %indvars.iv71, i64 %indvars.iv63
  store i32 %87, ptr %88, align 4, !tbaa !11
  %89 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %indvars.iv71, i64 %indvars.iv63
  %90 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %28, i64 %indvars.iv63
  %91 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %89, ptr noundef nonnull align 4 dereferenceable(4) %90)
  %92 = load i32, ptr %91, align 4, !tbaa !11
  store i32 %92, ptr %89, align 4, !tbaa !11
  %93 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %indvars.iv71, i64 %85
  %94 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %89, ptr noundef nonnull align 4 dereferenceable(4) %93)
  %95 = load i32, ptr %94, align 4, !tbaa !11
  store i32 %95, ptr %89, align 4, !tbaa !11
  %.pre80 = load i32, ptr %88, align 4, !tbaa !11
  %.phi.trans.insert77 = getelementptr inbounds [1000 x i32], ptr @b, i64 0, i64 %indvars.iv63
  %.pre78 = load i32, ptr %.phi.trans.insert77, align 4, !tbaa !11
  %.pre76 = load i32, ptr %29, align 4, !tbaa !11
  %96 = sub nsw i32 %.pre76, %.pre78
  %97 = tail call i32 @llvm.abs.i32(i32 %96, i1 true)
  %98 = icmp ult i32 %97, 5
  %99 = zext i1 %98 to i32
  %100 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %indvars.iv71, i64 %indvars.iv63
  %101 = add nsw i32 %.pre80, %99
  store i32 %101, ptr %100, align 4, !tbaa !11
  %102 = getelementptr inbounds [1000 x [1000 x i32]], ptr @mx, i64 0, i64 %indvars.iv71, i64 %indvars.iv63
  %103 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %102, ptr noundef nonnull align 4 dereferenceable(4) %100)
  %104 = load i32, ptr %103, align 4, !tbaa !11
  store i32 %104, ptr %102, align 4, !tbaa !11
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %105 = load i32, ptr @N, align 4, !tbaa !11
  %106 = sext i32 %105 to i64
  %107 = icmp slt i64 %indvars.iv.next64, %106
  br i1 %107, label %.lr.ph51.split.peel.next, label %._crit_edge, !llvm.loop !20
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #2 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #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 #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) 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 = { "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 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 #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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" }

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

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


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