; LLVM IR from eyangch/competitive-programming :: USACOtraining/3.4 (rockers)

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsiiiRA20_iRA20_S_iii(i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(1600), i32 noundef, i32 noundef, i32 noundef) #0

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [20 x i32], align 16
  %6 = alloca i32, align 4
  %7 = alloca [20 x [20 x i32]], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %18 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %20 = getelementptr i8, ptr %19, i64 -24
  %21 = load i64, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %21
  %23 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %22, ptr noundef null)
  %24 = load ptr, ptr @stdin, align 8, !tbaa !8
  %25 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %24)
  %26 = load ptr, ptr @stdout, align 8, !tbaa !8
  %27 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %26)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.start.p0(i64 80, ptr %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %41, %0
  %32 = load i32, ptr %6, align 4, !tbaa !11
  %33 = load i32, ptr %2, align 4, !tbaa !11
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

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

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

41:                                               ; preds = %36
  %42 = load i32, ptr %6, align 4, !tbaa !11
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %6, align 4, !tbaa !11
  br label %31, !llvm.loop !13

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

45:                                               ; preds = %118, %44
  %46 = load i32, ptr %8, align 4, !tbaa !11
  %47 = load i32, ptr %2, align 4, !tbaa !11
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %121

50:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %51 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %51, ptr %10, align 4, !tbaa !11
  br label %52

52:                                               ; preds = %114, %50
  %53 = load i32, ptr %10, align 4, !tbaa !11
  %54 = load i32, ptr %2, align 4, !tbaa !11
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %117

57:                                               ; preds = %52
  %58 = load i32, ptr %10, align 4, !tbaa !11
  %59 = load i32, ptr %8, align 4, !tbaa !11
  %60 = sub nsw i32 %58, %59
  %61 = add nsw i32 %60, 1
  %62 = zext i32 %61 to i64
  %63 = call ptr @llvm.stacksave.p0()
  store ptr %63, ptr %11, align 8
  %64 = alloca i32, i64 %62, align 16
  store i64 %62, ptr %12, align 8
  %65 = getelementptr inbounds [20 x i32], ptr %5, i64 0, i64 0
  %66 = load i32, ptr %8, align 4, !tbaa !11
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i32, ptr %65, i64 %67
  %69 = getelementptr inbounds [20 x i32], ptr %5, i64 0, i64 0
  %70 = load i32, ptr %10, align 4, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %69, i64 %71
  %73 = getelementptr inbounds i32, ptr %72, i64 1
  %74 = call noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef %68, ptr noundef %73, ptr noundef %64)
  %75 = load i32, ptr %10, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr %64, i64 %76
  %78 = load i32, ptr %8, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = sub i64 0, %79
  %81 = getelementptr inbounds i32, ptr %77, i64 %80
  %82 = getelementptr inbounds i32, ptr %81, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef %64, ptr noundef %82)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %83

83:                                               ; preds = %102, %57
  %84 = load i32, ptr %14, align 4, !tbaa !11
  %85 = load i32, ptr %10, align 4, !tbaa !11
  %86 = load i32, ptr %8, align 4, !tbaa !11
  %87 = sub nsw i32 %85, %86
  %88 = add nsw i32 %87, 1
  %89 = icmp slt i32 %84, %88
  br i1 %89, label %90, label %105

90:                                               ; preds = %83
  %91 = load i32, ptr %14, align 4, !tbaa !11
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i32, ptr %64, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !11
  %95 = load i32, ptr %13, align 4, !tbaa !11
  %96 = add nsw i32 %95, %94
  store i32 %96, ptr %13, align 4, !tbaa !11
  %97 = load i32, ptr %13, align 4, !tbaa !11
  %98 = load i32, ptr %3, align 4, !tbaa !11
  %99 = icmp sgt i32 %97, %98
  br i1 %99, label %100, label %101

100:                                              ; preds = %90
  br label %105

101:                                              ; preds = %90
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %14, align 4, !tbaa !11
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %14, align 4, !tbaa !11
  br label %83, !llvm.loop !15

105:                                              ; preds = %100, %83
  %106 = load i32, ptr %14, align 4, !tbaa !11
  %107 = load i32, ptr %8, align 4, !tbaa !11
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [20 x [20 x i32]], ptr %7, i64 0, i64 %108
  %110 = load i32, ptr %10, align 4, !tbaa !11
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [20 x i32], ptr %109, i64 0, i64 %111
  store i32 %106, ptr %112, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  %113 = load ptr, ptr %11, align 8
  call void @llvm.stackrestore.p0(ptr %113)
  br label %114

114:                                              ; preds = %105
  %115 = load i32, ptr %10, align 4, !tbaa !11
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %10, align 4, !tbaa !11
  br label %52, !llvm.loop !16

117:                                              ; preds = %56
  br label %118

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

121:                                              ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 0, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %122

122:                                              ; preds = %135, %121
  %123 = load i32, ptr %16, align 4, !tbaa !11
  %124 = load i32, ptr %2, align 4, !tbaa !11
  %125 = icmp slt i32 %123, %124
  br i1 %125, label %127, label %126

126:                                              ; preds = %122
  store i32 14, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %138

127:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %128 = load i32, ptr %2, align 4, !tbaa !11
  %129 = load i32, ptr %3, align 4, !tbaa !11
  %130 = load i32, ptr %4, align 4, !tbaa !11
  %131 = load i32, ptr %16, align 4, !tbaa !11
  %132 = call noundef i32 @_Z3dfsiiiRA20_iRA20_S_iii(i32 noundef %128, i32 noundef %129, i32 noundef %130, ptr noundef nonnull align 4 dereferenceable(80) %5, ptr noundef nonnull align 4 dereferenceable(1600) %7, i32 noundef %131, i32 noundef 0, i32 noundef 0)
  store i32 %132, ptr %17, align 4, !tbaa !11
  %133 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %134 = load i32, ptr %133, align 4, !tbaa !11
  store i32 %134, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %135

135:                                              ; preds = %127
  %136 = load i32, ptr %16, align 4, !tbaa !11
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %16, align 4, !tbaa !11
  br label %122, !llvm.loop !18

138:                                              ; preds = %126
  %139 = load i32, ptr %15, align 4, !tbaa !11
  %140 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %139)
  %141 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %140, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 1600, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  %142 = load i32, ptr %1, align 4
  ret i32 %142
}

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #6

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef, ptr noundef, ptr noundef) #7

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #7

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #6

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 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)) #7

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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" }
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 = { nocallback nofree nosync nounwind willreturn }
attributes #7 = { 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 #8 = { 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 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsiiiRA20_iRA20_S_iii(i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(1600), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [20 x i32], align 16
  %5 = alloca [20 x [20 x i32]], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = load ptr, ptr @stdin, align 8, !tbaa !8
  %15 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %14)
  %16 = load ptr, ptr @stdout, align 8, !tbaa !8
  %17 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %16)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %4) #8
  %21 = load i32, ptr %1, align 4, !tbaa !11
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 1600, ptr nonnull %5) #8
  br label %._crit_edge47.thread

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 1600, ptr nonnull %5) #8
  %23 = icmp sgt i32 %26, 0
  br i1 %23, label %.preheader.lr.ph, label %._crit_edge47.thread

.preheader.lr.ph:                                 ; preds = %._crit_edge
  %invariant.gep = getelementptr inbounds i8, ptr %4, i64 4
  br label %.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %24 = getelementptr inbounds [20 x i32], ptr %4, i64 0, i64 %indvars.iv
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %24)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr %1, align 4, !tbaa !11
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !13

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge45
  %29 = phi i32 [ %26, %.preheader.lr.ph ], [ %35, %._crit_edge45 ]
  %indvars.iv60 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next61, %._crit_edge45 ]
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv60, %30
  br i1 %31, label %.lr.ph44, label %._crit_edge45

.lr.ph44:                                         ; preds = %.preheader
  %32 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv60
  %33 = sub nsw i64 0, %indvars.iv60
  br label %.lr.ph39

._crit_edge47.thread:                             ; preds = %._crit_edge, %._crit_edge.thread
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %._crit_edge51

._crit_edge47:                                    ; preds = %._crit_edge45
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  store i32 0, ptr %6, align 4, !tbaa !11
  %34 = icmp sgt i32 %35, 0
  br i1 %34, label %.lr.ph50, label %._crit_edge51

._crit_edge45.loopexit:                           ; preds = %._crit_edge40
  %.pre = sext i32 %53 to i64
  br label %._crit_edge45

._crit_edge45:                                    ; preds = %._crit_edge45.loopexit, %.preheader
  %.pre-phi = phi i64 [ %.pre, %._crit_edge45.loopexit ], [ %30, %.preheader ]
  %35 = phi i32 [ %53, %._crit_edge45.loopexit ], [ %29, %.preheader ]
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %36 = icmp slt i64 %indvars.iv.next61, %.pre-phi
  br i1 %36, label %.preheader, label %._crit_edge47, !llvm.loop !15

.lr.ph39:                                         ; preds = %._crit_edge40, %.lr.ph44
  %indvars.iv62 = phi i64 [ %indvars.iv60, %.lr.ph44 ], [ %indvars.iv.next63, %._crit_edge40 ]
  %indvars.iv58 = phi i64 [ 1, %.lr.ph44 ], [ %indvars.iv.next59, %._crit_edge40 ]
  %37 = sub nuw nsw i64 %indvars.iv62, %indvars.iv60
  %38 = add nuw nsw i64 %37, 1
  %39 = call ptr @llvm.stacksave.p0()
  %40 = alloca i32, i64 %38, align 16
  %gep = getelementptr inbounds i32, ptr %invariant.gep, i64 %indvars.iv62
  %41 = call noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef nonnull %32, ptr noundef nonnull %gep, ptr noundef nonnull %40)
  %42 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv62
  %43 = getelementptr inbounds i32, ptr %42, i64 %33
  %44 = getelementptr inbounds i8, ptr %43, i64 4
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull %40, ptr noundef nonnull %44)
  %45 = load i32, ptr %2, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %.lr.ph39, %51
  %indvars.iv53 = phi i64 [ 0, %.lr.ph39 ], [ %indvars.iv.next54, %51 ]
  %.02936 = phi i32 [ 0, %.lr.ph39 ], [ %49, %51 ]
  %47 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv53
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = add nsw i32 %48, %.02936
  %50 = icmp sgt i32 %49, %45
  br i1 %50, label %._crit_edge40, label %51

51:                                               ; preds = %46
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next54, %indvars.iv58
  br i1 %exitcond.not, label %._crit_edge40, label %46, !llvm.loop !16

._crit_edge40:                                    ; preds = %51, %46
  %.028.lcssa.ph.in = phi i64 [ %indvars.iv58, %51 ], [ %indvars.iv53, %46 ]
  %.028.lcssa.ph = trunc i64 %.028.lcssa.ph.in to i32
  %52 = getelementptr inbounds [20 x [20 x i32]], ptr %5, i64 0, i64 %indvars.iv60, i64 %indvars.iv62
  store i32 %.028.lcssa.ph, ptr %52, align 4, !tbaa !11
  call void @llvm.stackrestore.p0(ptr %39)
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %53 = load i32, ptr %1, align 4, !tbaa !11
  %54 = trunc nuw i64 %indvars.iv.next63 to i32
  %55 = icmp sgt i32 %53, %54
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  br i1 %55, label %.lr.ph39, label %._crit_edge45.loopexit, !llvm.loop !17

._crit_edge51:                                    ; preds = %.lr.ph50, %._crit_edge47.thread, %._crit_edge47
  %56 = phi i32 [ 0, %._crit_edge47 ], [ 0, %._crit_edge47.thread ], [ %64, %.lr.ph50 ]
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %56)
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 1600, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0

.lr.ph50:                                         ; preds = %._crit_edge47, %.lr.ph50
  %59 = phi i32 [ %66, %.lr.ph50 ], [ %35, %._crit_edge47 ]
  %.048 = phi i32 [ %65, %.lr.ph50 ], [ 0, %._crit_edge47 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #8
  %60 = load i32, ptr %2, align 4, !tbaa !11
  %61 = load i32, ptr %3, align 4, !tbaa !11
  %62 = call noundef i32 @_Z3dfsiiiRA20_iRA20_S_iii(i32 noundef %59, i32 noundef %60, i32 noundef %61, ptr noundef nonnull align 4 dereferenceable(80) %4, ptr noundef nonnull align 4 dereferenceable(1600) %5, i32 noundef %.048, i32 noundef 0, i32 noundef 0)
  store i32 %62, ptr %7, align 4, !tbaa !11
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %64 = load i32, ptr %63, align 4, !tbaa !11
  store i32 %64, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #8
  %65 = add nuw nsw i32 %.048, 1
  %66 = load i32, ptr %1, align 4, !tbaa !11
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %.lr.ph50, label %._crit_edge51, !llvm.loop !18
}

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

; 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 ptr @freopen(ptr noundef, ptr noundef, ptr noundef) 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 nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #6

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #7

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #7

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #6

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) 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 #0 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)) #7

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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" }
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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #7 = { 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 #8 = { 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 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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