; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/336 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::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 [501 x i32], align 16
@dp = external dso_local global [501 x [501 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; 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
  store i32 0, ptr %1, align 4
  %10 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = load ptr, ptr @_ZSt4cerr, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt4cerr, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = 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) #6
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %22

22:                                               ; preds = %32, %0
  %23 = load i32, ptr %2, align 4, !tbaa !8
  %24 = load i32, ptr @n, align 4, !tbaa !8
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !8
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %29
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %30)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %2, align 4, !tbaa !8
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !8
  br label %22, !llvm.loop !11

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %36

36:                                               ; preds = %48, %35
  %37 = load i32, ptr %3, align 4, !tbaa !8
  %38 = load i32, ptr @n, align 4, !tbaa !8
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %36
  %42 = load i32, ptr %3, align 4, !tbaa !8
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %43
  %45 = load i32, ptr %3, align 4, !tbaa !8
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [501 x i32], ptr %44, i64 0, i64 %46
  store i32 1, ptr %47, align 4, !tbaa !8
  br label %48

48:                                               ; preds = %41
  %49 = load i32, ptr %3, align 4, !tbaa !8
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %3, align 4, !tbaa !8
  br label %36, !llvm.loop !13

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

52:                                               ; preds = %77, %51
  %53 = load i32, ptr %4, align 4, !tbaa !8
  %54 = load i32, ptr @n, align 4, !tbaa !8
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %80

57:                                               ; preds = %52
  %58 = load i32, ptr %4, align 4, !tbaa !8
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !8
  %62 = load i32, ptr %4, align 4, !tbaa !8
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !8
  %67 = icmp eq i32 %61, %66
  %68 = zext i1 %67 to i64
  %69 = select i1 %67, i32 1, i32 2
  %70 = load i32, ptr %4, align 4, !tbaa !8
  %71 = sub nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %72
  %74 = load i32, ptr %4, align 4, !tbaa !8
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [501 x i32], ptr %73, i64 0, i64 %75
  store i32 %69, ptr %76, align 4, !tbaa !8
  br label %77

77:                                               ; preds = %57
  %78 = load i32, ptr %4, align 4, !tbaa !8
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %4, align 4, !tbaa !8
  br label %52, !llvm.loop !14

80:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 2, ptr %5, align 4, !tbaa !8
  br label %81

81:                                               ; preds = %199, %80
  %82 = load i32, ptr %5, align 4, !tbaa !8
  %83 = load i32, ptr @n, align 4, !tbaa !8
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %86, label %85

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

86:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !8
  br label %87

87:                                               ; preds = %195, %86
  %88 = load i32, ptr %7, align 4, !tbaa !8
  %89 = load i32, ptr %5, align 4, !tbaa !8
  %90 = add nsw i32 %88, %89
  %91 = load i32, ptr @n, align 4, !tbaa !8
  %92 = icmp slt i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %87
  store i32 14, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %198

94:                                               ; preds = %87
  %95 = load i32, ptr %5, align 4, !tbaa !8
  %96 = add nsw i32 %95, 1
  %97 = load i32, ptr %7, align 4, !tbaa !8
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %98
  %100 = load i32, ptr %7, align 4, !tbaa !8
  %101 = load i32, ptr %5, align 4, !tbaa !8
  %102 = add nsw i32 %100, %101
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [501 x i32], ptr %99, i64 0, i64 %103
  store i32 %96, ptr %104, align 4, !tbaa !8
  %105 = load i32, ptr %7, align 4, !tbaa !8
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !8
  %109 = load i32, ptr %7, align 4, !tbaa !8
  %110 = load i32, ptr %5, align 4, !tbaa !8
  %111 = add nsw i32 %109, %110
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !8
  %115 = icmp eq i32 %108, %114
  br i1 %115, label %116, label %145

116:                                              ; preds = %94
  %117 = load i32, ptr %7, align 4, !tbaa !8
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %118
  %120 = load i32, ptr %7, align 4, !tbaa !8
  %121 = load i32, ptr %5, align 4, !tbaa !8
  %122 = add nsw i32 %120, %121
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [501 x i32], ptr %119, i64 0, i64 %123
  %125 = load i32, ptr %7, align 4, !tbaa !8
  %126 = add nsw i32 %125, 1
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %127
  %129 = load i32, ptr %7, align 4, !tbaa !8
  %130 = load i32, ptr %5, align 4, !tbaa !8
  %131 = add nsw i32 %129, %130
  %132 = sub nsw i32 %131, 1
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [501 x i32], ptr %128, i64 0, i64 %133
  %135 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %124, ptr noundef nonnull align 4 dereferenceable(4) %134)
  %136 = load i32, ptr %135, align 4, !tbaa !8
  %137 = load i32, ptr %7, align 4, !tbaa !8
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %138
  %140 = load i32, ptr %7, align 4, !tbaa !8
  %141 = load i32, ptr %5, align 4, !tbaa !8
  %142 = add nsw i32 %140, %141
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [501 x i32], ptr %139, i64 0, i64 %143
  store i32 %136, ptr %144, align 4, !tbaa !8
  br label %145

145:                                              ; preds = %116, %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %146 = load i32, ptr %7, align 4, !tbaa !8
  store i32 %146, ptr %8, align 4, !tbaa !8
  br label %147

147:                                              ; preds = %191, %145
  %148 = load i32, ptr %8, align 4, !tbaa !8
  %149 = load i32, ptr %7, align 4, !tbaa !8
  %150 = load i32, ptr %5, align 4, !tbaa !8
  %151 = add nsw i32 %149, %150
  %152 = icmp sle i32 %148, %151
  br i1 %152, label %154, label %153

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

154:                                              ; preds = %147
  %155 = load i32, ptr %7, align 4, !tbaa !8
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %156
  %158 = load i32, ptr %7, align 4, !tbaa !8
  %159 = load i32, ptr %5, align 4, !tbaa !8
  %160 = add nsw i32 %158, %159
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [501 x i32], ptr %157, i64 0, i64 %161
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %163 = load i32, ptr %7, align 4, !tbaa !8
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %164
  %166 = load i32, ptr %8, align 4, !tbaa !8
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [501 x i32], ptr %165, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !8
  %170 = load i32, ptr %8, align 4, !tbaa !8
  %171 = add nsw i32 %170, 1
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %172
  %174 = load i32, ptr %7, align 4, !tbaa !8
  %175 = load i32, ptr %5, align 4, !tbaa !8
  %176 = add nsw i32 %174, %175
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [501 x i32], ptr %173, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !8
  %180 = add nsw i32 %169, %179
  store i32 %180, ptr %9, align 4, !tbaa !8
  %181 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %162, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %182 = load i32, ptr %181, align 4, !tbaa !8
  %183 = load i32, ptr %7, align 4, !tbaa !8
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %184
  %186 = load i32, ptr %7, align 4, !tbaa !8
  %187 = load i32, ptr %5, align 4, !tbaa !8
  %188 = add nsw i32 %186, %187
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [501 x i32], ptr %185, i64 0, i64 %189
  store i32 %182, ptr %190, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %191

191:                                              ; preds = %154
  %192 = load i32, ptr %8, align 4, !tbaa !8
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr %8, align 4, !tbaa !8
  br label %147, !llvm.loop !15

194:                                              ; preds = %153
  br label %195

195:                                              ; preds = %194
  %196 = load i32, ptr %7, align 4, !tbaa !8
  %197 = add nsw i32 %196, 1
  store i32 %197, ptr %7, align 4, !tbaa !8
  br label %87, !llvm.loop !16

198:                                              ; preds = %93
  br label %199

199:                                              ; preds = %198
  %200 = load i32, ptr %5, align 4, !tbaa !8
  %201 = add nsw i32 %200, 1
  store i32 %201, ptr %5, align 4, !tbaa !8
  br label %81, !llvm.loop !17

202:                                              ; preds = %85
  %203 = load i32, ptr @n, align 4, !tbaa !8
  %204 = sub nsw i32 %203, 1
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [501 x i32], ptr @dp, i64 0, i64 %205
  %207 = load i32, ptr %206, align 4, !tbaa !8
  %208 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %207)
  %209 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %208, i8 noundef signext 10)
  ret i32 0
}

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 @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

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 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


; 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 [501 x i32], align 16
@dp = external dso_local global [501 x [501 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %3 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %5
  %7 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %6, ptr noundef null)
  %8 = load ptr, ptr @_ZSt4cerr, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt4cerr, i64 %10
  %12 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  %13 = 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)
  %14 = load i32, ptr @n, align 4, !tbaa !8
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge70

.preheader59:                                     ; preds = %.lr.ph
  %16 = icmp sgt i32 %21, 0
  br i1 %16, label %.lr.ph63.preheader, label %._crit_edge70

.lr.ph63.preheader:                               ; preds = %.preheader59
  %wide.trip.count = zext nneg i32 %21 to i64
  %17 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %wide.trip.count, 3
  %18 = icmp ult i32 %21, 4
  br i1 %18, label %.preheader58.unr-lcssa, label %.lr.ph63.preheader.new

.lr.ph63.preheader.new:                           ; preds = %.lr.ph63.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph63

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %19 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %indvars.iv
  %20 = 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) %19)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr @n, align 4, !tbaa !8
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next, %22
  br i1 %23, label %.lr.ph, label %.preheader59, !llvm.loop !11

.preheader58.unr-lcssa:                           ; preds = %.lr.ph63, %.lr.ph63.preheader
  %indvars.iv75.unr = phi i64 [ 0, %.lr.ph63.preheader ], [ %indvars.iv.next76.3, %.lr.ph63 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader58, label %.lr.ph63.epil

.lr.ph63.epil:                                    ; preds = %.preheader58.unr-lcssa, %.lr.ph63.epil
  %indvars.iv75.epil = phi i64 [ %indvars.iv.next76.epil, %.lr.ph63.epil ], [ %indvars.iv75.unr, %.preheader58.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph63.epil ], [ 0, %.preheader58.unr-lcssa ]
  %24 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv75.epil, i64 %indvars.iv75.epil
  store i32 1, ptr %24, align 4, !tbaa !8
  %indvars.iv.next76.epil = add nuw nsw i64 %indvars.iv75.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader58, label %.lr.ph63.epil, !llvm.loop !13

.preheader58:                                     ; preds = %.lr.ph63.epil, %.preheader58.unr-lcssa
  %.not = icmp eq i32 %21, 1
  br i1 %.not, label %._crit_edge70, label %.lr.ph65.preheader

.lr.ph65.preheader:                               ; preds = %.preheader58
  %.pre = load i32, ptr @a, align 16, !tbaa !8
  %xtraiter121 = and i64 %17, 1
  %25 = icmp eq i32 %21, 2
  br i1 %25, label %.preheader57.unr-lcssa, label %.lr.ph65.preheader.new

.lr.ph65.preheader.new:                           ; preds = %.lr.ph65.preheader
  %unroll_iter124 = and i64 %17, -2
  br label %.lr.ph65

.lr.ph63:                                         ; preds = %.lr.ph63, %.lr.ph63.preheader.new
  %indvars.iv75 = phi i64 [ 0, %.lr.ph63.preheader.new ], [ %indvars.iv.next76.3, %.lr.ph63 ]
  %niter = phi i64 [ 0, %.lr.ph63.preheader.new ], [ %niter.next.3, %.lr.ph63 ]
  %26 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv75, i64 %indvars.iv75
  store i32 1, ptr %26, align 16, !tbaa !8
  %indvars.iv.next76 = or disjoint i64 %indvars.iv75, 1
  %27 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next76, i64 %indvars.iv.next76
  store i32 1, ptr %27, align 8, !tbaa !8
  %indvars.iv.next76.1 = or disjoint i64 %indvars.iv75, 2
  %28 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next76.1, i64 %indvars.iv.next76.1
  store i32 1, ptr %28, align 16, !tbaa !8
  %indvars.iv.next76.2 = or disjoint i64 %indvars.iv75, 3
  %29 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next76.2, i64 %indvars.iv.next76.2
  store i32 1, ptr %29, align 8, !tbaa !8
  %indvars.iv.next76.3 = add nuw nsw i64 %indvars.iv75, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader58.unr-lcssa, label %.lr.ph63, !llvm.loop !15

.preheader57.unr-lcssa:                           ; preds = %.lr.ph65, %.lr.ph65.preheader
  %.unr = phi i32 [ %.pre, %.lr.ph65.preheader ], [ %45, %.lr.ph65 ]
  %indvars.iv78.unr = phi i64 [ 1, %.lr.ph65.preheader ], [ %indvars.iv.next79.1, %.lr.ph65 ]
  %lcmp.mod123.not = icmp eq i64 %xtraiter121, 0
  br i1 %lcmp.mod123.not, label %.preheader57, label %.lr.ph65.epil

.lr.ph65.epil:                                    ; preds = %.preheader57.unr-lcssa
  %30 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %indvars.iv78.unr
  %31 = load i32, ptr %30, align 4, !tbaa !8
  %32 = add nsw i64 %indvars.iv78.unr, -1
  %33 = icmp eq i32 %31, %.unr
  %34 = select i1 %33, i32 1, i32 2
  %35 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %32, i64 %indvars.iv78.unr
  store i32 %34, ptr %35, align 4, !tbaa !8
  br label %.preheader57

.preheader57:                                     ; preds = %.preheader57.unr-lcssa, %.lr.ph65.epil
  %36 = icmp sgt i32 %21, 2
  br i1 %36, label %.preheader, label %._crit_edge70

.lr.ph65:                                         ; preds = %.lr.ph65, %.lr.ph65.preheader.new
  %37 = phi i32 [ %.pre, %.lr.ph65.preheader.new ], [ %45, %.lr.ph65 ]
  %indvars.iv78 = phi i64 [ 1, %.lr.ph65.preheader.new ], [ %indvars.iv.next79.1, %.lr.ph65 ]
  %niter125 = phi i64 [ 0, %.lr.ph65.preheader.new ], [ %niter125.next.1, %.lr.ph65 ]
  %38 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %indvars.iv78
  %39 = load i32, ptr %38, align 4, !tbaa !8
  %40 = add nsw i64 %indvars.iv78, -1
  %41 = icmp eq i32 %39, %37
  %42 = select i1 %41, i32 1, i32 2
  %43 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %40, i64 %indvars.iv78
  store i32 %42, ptr %43, align 4, !tbaa !8
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %44 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %indvars.iv.next79
  %45 = load i32, ptr %44, align 4, !tbaa !8
  %46 = icmp eq i32 %45, %39
  %47 = select i1 %46, i32 1, i32 2
  %48 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv78, i64 %indvars.iv.next79
  store i32 %47, ptr %48, align 4, !tbaa !8
  %indvars.iv.next79.1 = add nuw nsw i64 %indvars.iv78, 2
  %niter125.next.1 = add i64 %niter125, 2
  %niter125.ncmp.1 = icmp eq i64 %niter125.next.1, %unroll_iter124
  br i1 %niter125.ncmp.1, label %.preheader57.unr-lcssa, label %.lr.ph65, !llvm.loop !16

.preheader:                                       ; preds = %.preheader57, %._crit_edge
  %49 = phi i32 [ %60, %._crit_edge ], [ %21, %.preheader57 ]
  %indvars.iv101 = phi i64 [ %52, %._crit_edge ], [ 2, %.preheader57 ]
  %indvars.iv94 = phi i64 [ %indvars.iv.next95, %._crit_edge ], [ 3, %.preheader57 ]
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv101, %50
  %52 = add nuw nsw i64 %indvars.iv101, 1
  br i1 %51, label %.lr.ph68, label %._crit_edge

.lr.ph68:                                         ; preds = %.preheader
  %53 = trunc nuw nsw i64 %52 to i32
  br label %62

._crit_edge70:                                    ; preds = %._crit_edge, %0, %.preheader59, %.preheader58, %.preheader57
  %.lcssa = phi i32 [ %21, %.preheader57 ], [ %21, %.preheader58 ], [ %21, %.preheader59 ], [ %14, %0 ], [ %60, %._crit_edge ]
  %54 = add nsw i32 %.lcssa, -1
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [501 x i32], ptr @dp, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !8
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %57)
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %58, i8 noundef signext 10)
  ret i32 0

._crit_edge:                                      ; preds = %76, %.preheader
  %.pre-phi = phi i64 [ %50, %.preheader ], [ %79, %76 ]
  %60 = phi i32 [ %49, %.preheader ], [ %78, %76 ]
  %61 = icmp slt i64 %52, %.pre-phi
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  br i1 %61, label %.preheader, label %._crit_edge70, !llvm.loop !17

62:                                               ; preds = %.lr.ph68, %76
  %indvars.iv96 = phi i64 [ %indvars.iv94, %.lr.ph68 ], [ %indvars.iv.next97, %76 ]
  %indvars.iv83 = phi i64 [ 0, %.lr.ph68 ], [ %indvars.iv.next84, %76 ]
  %63 = add nuw nsw i64 %indvars.iv83, %indvars.iv101
  %64 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv83, i64 %63
  store i32 %53, ptr %64, align 4, !tbaa !8
  %65 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %indvars.iv83
  %66 = load i32, ptr %65, align 4, !tbaa !8
  %67 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %63
  %68 = load i32, ptr %67, align 4, !tbaa !8
  %69 = icmp eq i32 %66, %68
  br i1 %69, label %70, label %.preheader116

.preheader116:                                    ; preds = %70, %62
  br label %81

70:                                               ; preds = %62
  %71 = add nuw nsw i64 %indvars.iv83, 1
  %72 = add nsw i64 %63, -1
  %73 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %71, i64 %72
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %64, ptr noundef nonnull align 4 dereferenceable(4) %73)
  %75 = load i32, ptr %74, align 4, !tbaa !8
  store i32 %75, ptr %64, align 4, !tbaa !8
  br label %.preheader116

76:                                               ; preds = %81
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %77 = add nuw nsw i64 %indvars.iv.next84, %indvars.iv101
  %78 = load i32, ptr @n, align 4, !tbaa !8
  %79 = sext i32 %78 to i64
  %80 = icmp slt i64 %77, %79
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  br i1 %80, label %62, label %._crit_edge, !llvm.loop !18

81:                                               ; preds = %.preheader116, %81
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %81 ], [ %indvars.iv83, %.preheader116 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %82 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv83, i64 %indvars.iv85
  %83 = load i32, ptr %82, align 4, !tbaa !8
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %84 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next86, i64 %63
  %85 = load i32, ptr %84, align 4, !tbaa !8
  %86 = add nsw i32 %85, %83
  store i32 %86, ptr %1, align 4, !tbaa !8
  %87 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %64, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %88 = load i32, ptr %87, align 4, !tbaa !8
  store i32 %88, ptr %64, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %exitcond93.not = icmp eq i64 %indvars.iv.next86, %indvars.iv96
  br i1 %exitcond93.not, label %76, label %81, !llvm.loop !19
}

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

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


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