; LLVM IR from eyangch/competitive-programming :: Codeforces/1521 (c)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"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" }

@T = external dso_local global i32, align 4
@N = external dso_local global i32, align 4
@p = external dso_local global [20000 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3qryiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %15 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %16 = getelementptr i8, ptr %15, i64 -24
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %17
  %19 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %18, ptr noundef null)
  %20 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %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) @T)
  br label %22

22:                                               ; preds = %120, %0
  %23 = load i32, ptr @T, align 4, !tbaa !8
  %24 = add nsw i32 %23, -1
  store i32 %24, ptr @T, align 4, !tbaa !8
  %25 = icmp ne i32 %23, 0
  br i1 %25, label %26, label %123

26:                                               ; preds = %22
  %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) @N)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %28 = load i32, ptr @N, align 4, !tbaa !8
  %29 = sub nsw i32 %28, 1
  %30 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef %29)
  store i32 %30, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %31 = load i32, ptr @N, align 4, !tbaa !8
  %32 = sub nsw i32 %31, 1
  %33 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 1, i32 noundef 0, i32 noundef %32)
  store i32 %33, ptr %4, align 4, !tbaa !8
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %35 = load i32, ptr %34, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  store i32 %35, ptr %2, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %36 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef 0, i32 noundef 1, i32 noundef 1)
  store i32 %36, ptr %6, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %37 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef 1, i32 noundef 0, i32 noundef 1)
  store i32 %37, ptr %7, align 4, !tbaa !8
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %39 = load i32, ptr %38, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  store i32 %39, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %40 = load i32, ptr %2, align 4, !tbaa !8
  %41 = sub nsw i32 %40, 1
  %42 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef %41)
  store i32 %42, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !8
  %43 = load i32, ptr %8, align 4, !tbaa !8
  %44 = load i32, ptr %2, align 4, !tbaa !8
  %45 = sub nsw i32 %44, 1
  %46 = icmp eq i32 %43, %45
  br i1 %46, label %47, label %50

47:                                               ; preds = %26
  %48 = load i32, ptr %2, align 4, !tbaa !8
  store i32 %48, ptr @p, align 16, !tbaa !8
  %49 = load i32, ptr %5, align 4, !tbaa !8
  store i32 %49, ptr getelementptr inbounds ([20000 x i32], ptr @p, i64 0, i64 1), align 4, !tbaa !8
  store i32 0, ptr %9, align 4, !tbaa !8
  store i32 1, ptr %10, align 4, !tbaa !8
  br label %53

50:                                               ; preds = %26
  %51 = load i32, ptr %5, align 4, !tbaa !8
  store i32 %51, ptr @p, align 16, !tbaa !8
  %52 = load i32, ptr %2, align 4, !tbaa !8
  store i32 %52, ptr getelementptr inbounds ([20000 x i32], ptr @p, i64 0, i64 1), align 4, !tbaa !8
  store i32 0, ptr %10, align 4, !tbaa !8
  store i32 1, ptr %9, align 4, !tbaa !8
  br label %53

53:                                               ; preds = %50, %47
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #7
  %54 = load i32, ptr @p, align 16, !tbaa !8
  %55 = load i32, ptr @N, align 4, !tbaa !8
  %56 = sdiv i32 %55, 2
  %57 = icmp sgt i32 %54, %56
  %58 = zext i1 %57 to i8
  store i8 %58, ptr %11, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 2, ptr %12, align 4, !tbaa !8
  br label %59

59:                                               ; preds = %100, %53
  %60 = load i32, ptr %12, align 4, !tbaa !8
  %61 = load i32, ptr @N, align 4, !tbaa !8
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %103

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !8
  %65 = load i8, ptr %11, align 1, !tbaa !11, !range !13, !noundef !14
  %66 = trunc i8 %65 to i1
  %67 = zext i1 %66 to i32
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %74

69:                                               ; preds = %64
  %70 = load i32, ptr %12, align 4, !tbaa !8
  %71 = load i32, ptr @N, align 4, !tbaa !8
  %72 = sub nsw i32 %71, 1
  %73 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef %70, i32 noundef %72)
  store i32 %73, ptr %13, align 4, !tbaa !8
  br label %77

74:                                               ; preds = %64
  %75 = load i32, ptr %12, align 4, !tbaa !8
  %76 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef %75, i32 noundef 0, i32 noundef 1)
  store i32 %76, ptr %13, align 4, !tbaa !8
  br label %77

77:                                               ; preds = %74, %69
  %78 = load i32, ptr %13, align 4, !tbaa !8
  %79 = load i32, ptr @p, align 16, !tbaa !8
  %80 = icmp eq i32 %78, %79
  br i1 %80, label %81, label %95

81:                                               ; preds = %77
  %82 = load i8, ptr %11, align 1, !tbaa !11, !range !13, !noundef !14
  %83 = trunc i8 %82 to i1
  %84 = zext i1 %83 to i32
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %89

86:                                               ; preds = %81
  %87 = load i32, ptr %12, align 4, !tbaa !8
  %88 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef %87, i32 noundef 0, i32 noundef 1)
  store i32 %88, ptr %13, align 4, !tbaa !8
  br label %94

89:                                               ; preds = %81
  %90 = load i32, ptr %12, align 4, !tbaa !8
  %91 = load i32, ptr @N, align 4, !tbaa !8
  %92 = sub nsw i32 %91, 1
  %93 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef %90, i32 noundef %92)
  store i32 %93, ptr %13, align 4, !tbaa !8
  br label %94

94:                                               ; preds = %89, %86
  br label %95

95:                                               ; preds = %94, %77
  %96 = load i32, ptr %13, align 4, !tbaa !8
  %97 = load i32, ptr %12, align 4, !tbaa !8
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [20000 x i32], ptr @p, i64 0, i64 %98
  store i32 %96, ptr %99, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %100

100:                                              ; preds = %95
  %101 = load i32, ptr %12, align 4, !tbaa !8
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %12, align 4, !tbaa !8
  br label %59, !llvm.loop !15

103:                                              ; preds = %63
  %104 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !8
  br label %105

105:                                              ; preds = %117, %103
  %106 = load i32, ptr %14, align 4, !tbaa !8
  %107 = load i32, ptr @N, align 4, !tbaa !8
  %108 = icmp slt i32 %106, %107
  br i1 %108, label %110, label %109

109:                                              ; preds = %105
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %120

110:                                              ; preds = %105
  %111 = load i32, ptr %14, align 4, !tbaa !8
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [20000 x i32], ptr @p, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !8
  %115 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %114)
  %116 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %115, ptr noundef @.str.1)
  br label %117

117:                                              ; preds = %110
  %118 = load i32, ptr %14, align 4, !tbaa !8
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %14, align 4, !tbaa !8
  br label %105, !llvm.loop !17

120:                                              ; preds = %109
  %121 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.2)
  %122 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout)
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %22, !llvm.loop !18

123:                                              ; preds = %22
  %124 = load i32, ptr %1, align 4
  ret i32 %124
}

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

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

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { 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 #6 = { 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 #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 = !{!"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 = !{!12, !12, i64 0}
!12 = !{!"bool", !10, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


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

@T = external dso_local global i32, align 4
@N = external dso_local global i32, align 4
@p = external dso_local local_unnamed_addr global [20000 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

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

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

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

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

.lr.ph37:                                         ; preds = %0, %._crit_edge34
  %14 = 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 nonnull %1) #7
  %15 = load i32, ptr @N, align 4, !tbaa !8
  %16 = add nsw i32 %15, -1
  %17 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef %16)
  store i32 %17, ptr %1, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %18 = load i32, ptr @N, align 4, !tbaa !8
  %19 = add nsw i32 %18, -1
  %20 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 1, i32 noundef 0, i32 noundef %19)
  store i32 %20, ptr %2, align 4, !tbaa !8
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %22 = load i32, ptr %21, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %23 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef 0, i32 noundef 1, i32 noundef 1)
  store i32 %23, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %24 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef 1, i32 noundef 0, i32 noundef 1)
  store i32 %24, ptr %4, align 4, !tbaa !8
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %26 = load i32, ptr %25, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %27 = add nsw i32 %22, -1
  %28 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef %27)
  %29 = icmp eq i32 %28, %27
  %. = select i1 %29, i32 %22, i32 %26
  %.27 = select i1 %29, i32 %26, i32 %22
  store i32 %., ptr @p, align 16, !tbaa !8
  store i32 %.27, ptr getelementptr inbounds (i8, ptr @p, i64 4), align 4, !tbaa !8
  %30 = load i32, ptr @N, align 4, !tbaa !8
  %31 = icmp sgt i32 %30, 2
  br i1 %31, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph37
  %32 = lshr i32 %30, 1
  %.not26 = icmp sgt i32 %., %32
  br i1 %.not26, label %.lr.ph.split.us, label %.thread

.lr.ph.split.us:                                  ; preds = %.lr.ph, %41
  %indvars.iv41 = phi i64 [ %indvars.iv.next42, %41 ], [ 2, %.lr.ph ]
  %33 = trunc nuw nsw i64 %indvars.iv41 to i32
  %34 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef %33, i32 noundef 0, i32 noundef 1)
  %35 = load i32, ptr @p, align 16, !tbaa !8
  %36 = icmp eq i32 %34, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %.lr.ph.split.us
  %38 = load i32, ptr @N, align 4, !tbaa !8
  %39 = add nsw i32 %38, -1
  %40 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef %33, i32 noundef %39)
  br label %41

41:                                               ; preds = %37, %.lr.ph.split.us
  %.1.us = phi i32 [ %40, %37 ], [ %34, %.lr.ph.split.us ]
  %42 = getelementptr inbounds [20000 x i32], ptr @p, i64 0, i64 %indvars.iv41
  store i32 %.1.us, ptr %42, align 4, !tbaa !8
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %43 = load i32, ptr @N, align 4, !tbaa !8
  %44 = sext i32 %43 to i64
  %45 = icmp slt i64 %indvars.iv.next42, %44
  br i1 %45, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %56, %41, %.lr.ph37
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.3)
  %47 = load i32, ptr @N, align 4, !tbaa !8
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph33, label %._crit_edge34

.thread:                                          ; preds = %.lr.ph, %56
  %indvars.iv = phi i64 [ %indvars.iv.next, %56 ], [ 2, %.lr.ph ]
  %49 = phi i32 [ %58, %56 ], [ %30, %.lr.ph ]
  %50 = add nsw i32 %49, -1
  %51 = trunc nuw nsw i64 %indvars.iv to i32
  %52 = call noundef i32 @_Z3qryiiii(i32 noundef 0, i32 noundef 0, i32 noundef %51, i32 noundef %50)
  %53 = load i32, ptr @p, align 16, !tbaa !8
  %54 = icmp eq i32 %52, %53
  br i1 %54, label %.thread29, label %56

.thread29:                                        ; preds = %.thread
  %55 = call noundef i32 @_Z3qryiiii(i32 noundef 1, i32 noundef %51, i32 noundef 0, i32 noundef 1)
  br label %56

56:                                               ; preds = %.thread, %.thread29
  %.1 = phi i32 [ %55, %.thread29 ], [ %52, %.thread ]
  %57 = getelementptr inbounds [20000 x i32], ptr @p, i64 0, i64 %indvars.iv
  store i32 %.1, ptr %57, align 4, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = load i32, ptr @N, align 4, !tbaa !8
  %59 = sext i32 %58 to i64
  %60 = icmp slt i64 %indvars.iv.next, %59
  br i1 %60, label %.thread, label %._crit_edge, !llvm.loop !11

._crit_edge34:                                    ; preds = %.lr.ph33, %._crit_edge
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.2)
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout)
  %63 = load i32, ptr @T, align 4, !tbaa !8
  %64 = add nsw i32 %63, -1
  store i32 %64, ptr @T, align 4, !tbaa !8
  %.not = icmp eq i32 %63, 0
  br i1 %.not, label %._crit_edge38, label %.lr.ph37, !llvm.loop !13

.lr.ph33:                                         ; preds = %._crit_edge, %.lr.ph33
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %.lr.ph33 ], [ 0, %._crit_edge ]
  %65 = getelementptr inbounds [20000 x i32], ptr @p, i64 0, i64 %indvars.iv44
  %66 = load i32, ptr %65, align 4, !tbaa !8
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %66)
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %67, ptr noundef nonnull @.str.1)
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %69 = load i32, ptr @N, align 4, !tbaa !8
  %70 = sext i32 %69 to i64
  %71 = icmp slt i64 %indvars.iv.next45, %70
  br i1 %71, label %.lr.ph33, label %._crit_edge34, !llvm.loop !14

._crit_edge38:                                    ; preds = %._crit_edge34, %0
  ret i32 0
}

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

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

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { 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 #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 = !{!"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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass