; LLVM IR from tangjz/acm-icpc :: codeforces/complete (2B)

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

@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@num = external dso_local global [1001 x [1001 x i32]], align 16
@d2 = external dso_local global [1001 x [1001 x i32]], align 16
@d5 = external dso_local global [1001 x [1001 x i32]], align 16
@dr2 = external dso_local global [1001 x [1001 x i8]], align 16
@dr5 = external dso_local global [1001 x [1001 x i8]], align 16
@flag = external dso_local global i8, align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z2dpPA1001_iPA1001_ci(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5printPA1001_cii(ptr noundef, i32 noundef, i32 noundef) #2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %4 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %5 = 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)
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %39, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp slt i32 %7, %8
  br i1 %9, label %10, label %42

10:                                               ; preds = %6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %35, %10
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %15, label %38

15:                                               ; preds = %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1001 x [1001 x i32]], ptr @num, i64 0, i64 %17
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1001 x i32], ptr %18, i64 0, i64 %20
  %22 = 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)
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [1001 x [1001 x i32]], ptr @num, i64 0, i64 %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1001 x i32], ptr %25, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %34, label %31

31:                                               ; preds = %15
  store i8 1, ptr @flag, align 1, !tbaa !9
  %32 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %32, ptr @x, align 4, !tbaa !5
  %33 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %33, ptr @y, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %31, %15
  br label %35

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

38:                                               ; preds = %11
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !13

42:                                               ; preds = %6
  call void @_Z2dpPA1001_iPA1001_ci(ptr noundef @d2, ptr noundef @dr2, i32 noundef 2)
  call void @_Z2dpPA1001_iPA1001_ci(ptr noundef @d5, ptr noundef @dr5, i32 noundef 5)
  %43 = load i8, ptr @flag, align 1, !tbaa !9, !range !14, !noundef !15
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %119

45:                                               ; preds = %42
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d2, i64 0, i64 %48
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1001 x i32], ptr %49, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %63, label %56

56:                                               ; preds = %45
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 48)
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %59 = load i32, ptr @n, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = sub nsw i32 %61, 1
  call void @_Z5printPA1001_cii(ptr noundef @dr2, i32 noundef %60, i32 noundef %62)
  br label %118

63:                                               ; preds = %45
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = sub nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d5, i64 0, i64 %66
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1001 x i32], ptr %67, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %81, label %74

74:                                               ; preds = %63
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 48)
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %75, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %77 = load i32, ptr @n, align 4, !tbaa !5
  %78 = sub nsw i32 %77, 1
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = sub nsw i32 %79, 1
  call void @_Z5printPA1001_cii(ptr noundef @dr5, i32 noundef %78, i32 noundef %80)
  br label %117

81:                                               ; preds = %63
  %82 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 49)
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %82, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %90, %81
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = load i32, ptr @x, align 4, !tbaa !5
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %88, label %93

88:                                               ; preds = %84
  %89 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 68)
  br label %90

90:                                               ; preds = %88
  %91 = load i32, ptr %2, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %2, align 4, !tbaa !5
  br label %84, !llvm.loop !16

93:                                               ; preds = %84
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %101, %93
  %95 = load i32, ptr %2, align 4, !tbaa !5
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = sub nsw i32 %96, 1
  %98 = icmp slt i32 %95, %97
  br i1 %98, label %99, label %104

99:                                               ; preds = %94
  %100 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 82)
  br label %101

101:                                              ; preds = %99
  %102 = load i32, ptr %2, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %2, align 4, !tbaa !5
  br label %94, !llvm.loop !17

104:                                              ; preds = %94
  %105 = load i32, ptr @x, align 4, !tbaa !5
  store i32 %105, ptr %2, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %113, %104
  %107 = load i32, ptr %2, align 4, !tbaa !5
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = icmp slt i32 %107, %109
  br i1 %110, label %111, label %116

111:                                              ; preds = %106
  %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 68)
  br label %113

113:                                              ; preds = %111
  %114 = load i32, ptr %2, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %2, align 4, !tbaa !5
  br label %106, !llvm.loop !18

116:                                              ; preds = %106
  br label %117

117:                                              ; preds = %116, %74
  br label %118

118:                                              ; preds = %117, %56
  br label %172

119:                                              ; preds = %42
  %120 = load i32, ptr @n, align 4, !tbaa !5
  %121 = sub nsw i32 %120, 1
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d2, i64 0, i64 %122
  %124 = load i32, ptr @n, align 4, !tbaa !5
  %125 = sub nsw i32 %124, 1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1001 x i32], ptr %123, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = load i32, ptr @n, align 4, !tbaa !5
  %130 = sub nsw i32 %129, 1
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d5, i64 0, i64 %131
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = sub nsw i32 %133, 1
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1001 x i32], ptr %132, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = icmp slt i32 %128, %137
  br i1 %138, label %139, label %155

139:                                              ; preds = %119
  %140 = load i32, ptr @n, align 4, !tbaa !5
  %141 = sub nsw i32 %140, 1
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d2, i64 0, i64 %142
  %144 = load i32, ptr @n, align 4, !tbaa !5
  %145 = sub nsw i32 %144, 1
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1001 x i32], ptr %143, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %148)
  %150 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %149, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %151 = load i32, ptr @n, align 4, !tbaa !5
  %152 = sub nsw i32 %151, 1
  %153 = load i32, ptr @n, align 4, !tbaa !5
  %154 = sub nsw i32 %153, 1
  call void @_Z5printPA1001_cii(ptr noundef @dr2, i32 noundef %152, i32 noundef %154)
  br label %171

155:                                              ; preds = %119
  %156 = load i32, ptr @n, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d5, i64 0, i64 %158
  %160 = load i32, ptr @n, align 4, !tbaa !5
  %161 = sub nsw i32 %160, 1
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1001 x i32], ptr %159, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %164)
  %166 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %165, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %167 = load i32, ptr @n, align 4, !tbaa !5
  %168 = sub nsw i32 %167, 1
  %169 = load i32, ptr @n, align 4, !tbaa !5
  %170 = sub nsw i32 %169, 1
  call void @_Z5printPA1001_cii(ptr noundef @dr5, i32 noundef %168, i32 noundef %170)
  br label %171

171:                                              ; preds = %155, %139
  br label %172

172:                                              ; preds = %171, %118
  %173 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { 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 #5 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !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_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 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@x = external dso_local local_unnamed_addr global i32, align 4
@y = external dso_local local_unnamed_addr global i32, align 4
@num = external dso_local global [1001 x [1001 x i32]], align 16
@d2 = external dso_local global [1001 x [1001 x i32]], align 16
@d5 = external dso_local global [1001 x [1001 x i32]], align 16
@dr2 = external dso_local global [1001 x [1001 x i8]], align 16
@dr5 = external dso_local global [1001 x [1001 x i8]], align 16
@flag = external dso_local local_unnamed_addr global i8, align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z2dpPA1001_iPA1001_ci(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5printPA1001_cii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; 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 #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = 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)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.preheader21, label %._crit_edge24

.preheader21:                                     ; preds = %0, %._crit_edge
  %5 = phi i32 [ %18, %._crit_edge ], [ %3, %0 ]
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %._crit_edge ], [ 0, %0 ]
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %.preheader21.._crit_edge_crit_edge

.preheader21.._crit_edge_crit_edge:               ; preds = %.preheader21
  %.pre39 = sext i32 %5 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %.preheader21
  %7 = trunc nuw nsw i64 %indvars.iv36 to i32
  br label %8

8:                                                ; preds = %.lr.ph, %14
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %14 ]
  %9 = getelementptr inbounds [1001 x [1001 x i32]], ptr @num, i64 0, i64 %indvars.iv36, i64 %indvars.iv
  %10 = 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) %9)
  %11 = load i32, ptr %9, align 4, !tbaa !5
  %.not20 = icmp eq i32 %11, 0
  br i1 %.not20, label %12, label %14

12:                                               ; preds = %8
  store i8 1, ptr @flag, align 1, !tbaa !9
  store i32 %7, ptr @x, align 4, !tbaa !5
  %13 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %13, ptr @y, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %8, %12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = icmp slt i64 %indvars.iv.next, %16
  br i1 %17, label %8, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %14, %.preheader21.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre39, %.preheader21.._crit_edge_crit_edge ], [ %16, %14 ]
  %18 = phi i32 [ %5, %.preheader21.._crit_edge_crit_edge ], [ %15, %14 ]
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %19 = icmp slt i64 %indvars.iv.next37, %.pre-phi
  br i1 %19, label %.preheader21, label %._crit_edge24, !llvm.loop !13

._crit_edge24:                                    ; preds = %._crit_edge, %0
  tail call void @_Z2dpPA1001_iPA1001_ci(ptr noundef nonnull @d2, ptr noundef nonnull @dr2, i32 noundef 2)
  tail call void @_Z2dpPA1001_iPA1001_ci(ptr noundef nonnull @d5, ptr noundef nonnull @dr5, i32 noundef 5)
  %20 = load i8, ptr @flag, align 1, !tbaa !9, !range !15, !noundef !16
  %21 = trunc nuw i8 %20 to i1
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d2, i64 0, i64 %24, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  br i1 %21, label %27, label %59

27:                                               ; preds = %._crit_edge24
  %.not = icmp eq i32 %26, 0
  br i1 %.not, label %28, label %30

28:                                               ; preds = %27
  %29 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 48)
  br label %.loopexit.sink.split

30:                                               ; preds = %27
  %31 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d5, i64 0, i64 %24, i64 %24
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.not19 = icmp eq i32 %32, 0
  br i1 %.not19, label %33, label %35

33:                                               ; preds = %30
  %34 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 48)
  br label %.loopexit.sink.split

35:                                               ; preds = %30
  %36 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 49)
  %37 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %38 = load i32, ptr @x, align 4, !tbaa !5
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %.lr.ph27, label %.preheader

.preheader:                                       ; preds = %.lr.ph27, %35
  %40 = phi i32 [ %38, %35 ], [ %45, %.lr.ph27 ]
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = icmp sgt i32 %41, 1
  br i1 %42, label %.lr.ph29, label %.preheader.._crit_edge30_crit_edge

.preheader.._crit_edge30_crit_edge:               ; preds = %.preheader
  %.pre40 = add nsw i32 %41, -1
  br label %._crit_edge30

.lr.ph27:                                         ; preds = %35, %.lr.ph27
  %.125 = phi i32 [ %44, %.lr.ph27 ], [ 0, %35 ]
  %43 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 68)
  %44 = add nuw nsw i32 %.125, 1
  %45 = load i32, ptr @x, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %.lr.ph27, label %.preheader, !llvm.loop !17

.lr.ph29:                                         ; preds = %.preheader, %.lr.ph29
  %.228 = phi i32 [ %48, %.lr.ph29 ], [ 0, %.preheader ]
  %47 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 82)
  %48 = add nuw nsw i32 %.228, 1
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  %51 = icmp slt i32 %48, %50
  br i1 %51, label %.lr.ph29, label %._crit_edge30.loopexit, !llvm.loop !18

._crit_edge30.loopexit:                           ; preds = %.lr.ph29
  %.pre = load i32, ptr @x, align 4, !tbaa !5
  br label %._crit_edge30

._crit_edge30:                                    ; preds = %.preheader.._crit_edge30_crit_edge, %._crit_edge30.loopexit
  %.pre-phi41 = phi i32 [ %.pre40, %.preheader.._crit_edge30_crit_edge ], [ %50, %._crit_edge30.loopexit ]
  %52 = phi i32 [ %40, %.preheader.._crit_edge30_crit_edge ], [ %.pre, %._crit_edge30.loopexit ]
  %53 = icmp slt i32 %52, %.pre-phi41
  br i1 %53, label %.lr.ph33, label %.loopexit

.lr.ph33:                                         ; preds = %._crit_edge30, %.lr.ph33
  %.331 = phi i32 [ %55, %.lr.ph33 ], [ %52, %._crit_edge30 ]
  %54 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 68)
  %55 = add nsw i32 %.331, 1
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = add nsw i32 %56, -1
  %58 = icmp slt i32 %55, %57
  br i1 %58, label %.lr.ph33, label %.loopexit, !llvm.loop !19

59:                                               ; preds = %._crit_edge24
  %60 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d5, i64 0, i64 %24, i64 %24
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = icmp slt i32 %26, %61
  br i1 %62, label %63, label %65

63:                                               ; preds = %59
  %64 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %26)
  br label %.loopexit.sink.split

65:                                               ; preds = %59
  %66 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %61)
  br label %.loopexit.sink.split

.loopexit.sink.split:                             ; preds = %33, %28, %65, %63
  %.sink = phi ptr [ %64, %63 ], [ %66, %65 ], [ %29, %28 ], [ %34, %33 ]
  %dr2.sink = phi ptr [ @dr2, %63 ], [ @dr5, %65 ], [ @dr2, %28 ], [ @dr5, %33 ]
  %67 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %.sink, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = add nsw i32 %68, -1
  tail call void @_Z5printPA1001_cii(ptr noundef nonnull %dr2.sink, i32 noundef %69, i32 noundef %69)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph33, %.loopexit.sink.split, %._crit_edge30
  %70 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { 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 #4 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12, !14}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


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