; LLVM IR from eyangch/competitive-programming :: USACOcontests/silver/2020.01 (berries)

; 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" }
%"struct.std::greater" = type { i8 }

@n = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@b = external dso_local global [1000 x i64], align 16
@bcurr = external dso_local global [1000 x i64], align 16
@_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 norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::greater", align 1
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"struct.std::greater", align 1
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %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 = load ptr, ptr @stdin, align 8, !tbaa !8
  %21 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %20)
  %22 = load ptr, ptr @stdout, align 8, !tbaa !8
  %23 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %22)
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 8 dereferenceable(8) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %26

26:                                               ; preds = %37, %0
  %27 = load i32, ptr %2, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = load i64, ptr @n, align 8, !tbaa !13
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %26
  %33 = load i32, ptr %2, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %34
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %35)
  br label %37

37:                                               ; preds = %32
  %38 = load i32, ptr %2, align 4, !tbaa !11
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !11
  br label %26, !llvm.loop !15

40:                                               ; preds = %31
  %41 = load i64, ptr @n, align 8, !tbaa !13
  %42 = getelementptr inbounds i64, ptr @b, i64 %41
  call void @_ZSt4sortIPxSt7greaterIiEEvT_S3_T0_(ptr noundef @b, ptr noundef %42)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 1, ptr %5, align 8, !tbaa !13
  br label %43

43:                                               ; preds = %132, %40
  %44 = load i64, ptr %5, align 8, !tbaa !13
  %45 = icmp sle i64 %44, 1000
  br i1 %45, label %47, label %46

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

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %63, %47
  %49 = load i32, ptr %8, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = load i64, ptr @n, align 8, !tbaa !13
  %52 = icmp slt i64 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %48
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %66

54:                                               ; preds = %48
  %55 = load i32, ptr %8, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !13
  %59 = load i64, ptr %5, align 8, !tbaa !13
  %60 = sdiv i64 %58, %59
  %61 = load i64, ptr %7, align 8, !tbaa !13
  %62 = add nsw i64 %61, %60
  store i64 %62, ptr %7, align 8, !tbaa !13
  br label %63

63:                                               ; preds = %54
  %64 = load i32, ptr %8, align 4, !tbaa !11
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %8, align 4, !tbaa !11
  br label %48, !llvm.loop !17

66:                                               ; preds = %53
  %67 = load i64, ptr %7, align 8, !tbaa !13
  %68 = load i64, ptr @k, align 8, !tbaa !13
  %69 = icmp sge i64 %67, %68
  br i1 %69, label %70, label %77

70:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %71 = load i64, ptr %5, align 8, !tbaa !13
  %72 = load i64, ptr @k, align 8, !tbaa !13
  %73 = mul nsw i64 %71, %72
  %74 = sdiv i64 %73, 2
  store i64 %74, ptr %9, align 8, !tbaa !13
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %76 = load i64, ptr %75, align 8, !tbaa !13
  store i64 %76, ptr %4, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  store i32 7, ptr %6, align 4
  br label %129

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

78:                                               ; preds = %94, %77
  %79 = load i32, ptr %10, align 4, !tbaa !11
  %80 = sext i32 %79 to i64
  %81 = load i64, ptr @n, align 8, !tbaa !13
  %82 = icmp slt i64 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %78
  store i32 11, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %97

84:                                               ; preds = %78
  %85 = load i32, ptr %10, align 4, !tbaa !11
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !13
  %89 = load i64, ptr %5, align 8, !tbaa !13
  %90 = srem i64 %88, %89
  %91 = load i32, ptr %10, align 4, !tbaa !11
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1000 x i64], ptr @bcurr, i64 0, i64 %92
  store i64 %90, ptr %93, align 8, !tbaa !13
  br label %94

94:                                               ; preds = %84
  %95 = load i32, ptr %10, align 4, !tbaa !11
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %10, align 4, !tbaa !11
  br label %78, !llvm.loop !18

97:                                               ; preds = %83
  %98 = load i64, ptr @n, align 8, !tbaa !13
  %99 = getelementptr inbounds i64, ptr @bcurr, i64 %98
  call void @_ZSt4sortIPxSt7greaterIiEEvT_S3_T0_(ptr noundef @bcurr, ptr noundef %99)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store i64 0, ptr %12, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %100

100:                                              ; preds = %115, %97
  %101 = load i32, ptr %13, align 4, !tbaa !11
  %102 = sext i32 %101 to i64
  %103 = load i64, ptr @k, align 8, !tbaa !13
  %104 = load i64, ptr %7, align 8, !tbaa !13
  %105 = sub nsw i64 %103, %104
  %106 = icmp slt i64 %102, %105
  br i1 %106, label %108, label %107

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

108:                                              ; preds = %100
  %109 = load i32, ptr %13, align 4, !tbaa !11
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1000 x i64], ptr @bcurr, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !13
  %113 = load i64, ptr %12, align 8, !tbaa !13
  %114 = add nsw i64 %113, %112
  store i64 %114, ptr %12, align 8, !tbaa !13
  br label %115

115:                                              ; preds = %108
  %116 = load i32, ptr %13, align 4, !tbaa !11
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %13, align 4, !tbaa !11
  br label %100, !llvm.loop !19

118:                                              ; preds = %107
  %119 = load i64, ptr %7, align 8, !tbaa !13
  %120 = load i64, ptr @k, align 8, !tbaa !13
  %121 = sdiv i64 %120, 2
  %122 = sub nsw i64 %119, %121
  %123 = load i64, ptr %5, align 8, !tbaa !13
  %124 = mul nsw i64 %122, %123
  %125 = load i64, ptr %12, align 8, !tbaa !13
  %126 = add nsw i64 %125, %124
  store i64 %126, ptr %12, align 8, !tbaa !13
  %127 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %128 = load i64, ptr %127, align 8, !tbaa !13
  store i64 %128, ptr %4, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  store i32 0, ptr %6, align 4
  br label %129

129:                                              ; preds = %118, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  %130 = load i32, ptr %6, align 4
  switch i32 %130, label %140 [
    i32 0, label %131
    i32 7, label %132
  ]

131:                                              ; preds = %129
  br label %132

132:                                              ; preds = %131, %129
  %133 = load i64, ptr %5, align 8, !tbaa !13
  %134 = add nsw i64 %133, 1
  store i64 %134, ptr %5, align 8, !tbaa !13
  br label %43, !llvm.loop !20

135:                                              ; preds = %46
  %136 = load i64, ptr %4, align 8, !tbaa !13
  %137 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %136)
  %138 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %137, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  %139 = load i32, ptr %1, align 4
  ret i32 %139

140:                                              ; preds = %129
  unreachable
}

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

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

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

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

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

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

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

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !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_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@b = external dso_local global [1000 x i64], align 16
@bcurr = external dso_local global [1000 x i64], align 16
@_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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %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 = load ptr, ptr @stdin, align 8, !tbaa !8
  %11 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %10)
  %12 = load ptr, ptr @stdout, align 8, !tbaa !8
  %13 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %12)
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(8) @k)
  %16 = load i64, ptr @n, align 8, !tbaa !11
  %17 = icmp sgt i64 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa37 = phi i64 [ %16, %0 ], [ %21, %.lr.ph ]
  %18 = getelementptr inbounds i64, ptr @b, i64 %.lcssa37
  tail call void @_ZSt4sortIPxSt7greaterIiEEvT_S3_T0_(ptr noundef nonnull @b, ptr noundef nonnull %18)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  store i64 0, ptr %1, align 8, !tbaa !11
  br label %.preheader35

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %19 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %indvars.iv
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i64, ptr @n, align 8, !tbaa !11
  %22 = icmp sgt i64 %21, %indvars.iv.next
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !13

.preheader35:                                     ; preds = %._crit_edge, %83
  %.02754 = phi i64 [ 1, %._crit_edge ], [ %85, %83 ]
  %23 = load i64, ptr @n, align 8, !tbaa !11
  %24 = icmp sgt i64 %23, 0
  br i1 %24, label %.lr.ph41.preheader, label %._crit_edge42.thread

.lr.ph41.preheader:                               ; preds = %.preheader35
  %25 = add nsw i64 %23, -1
  %xtraiter = and i64 %23, 1
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %._crit_edge42.unr-lcssa, label %.lr.ph41.preheader.new

.lr.ph41.preheader.new:                           ; preds = %.lr.ph41.preheader
  %unroll_iter = and i64 %23, 9223372036854775806
  br label %.lr.ph41

27:                                               ; preds = %83
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %84)
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  ret i32 0

._crit_edge42.unr-lcssa:                          ; preds = %.lr.ph41, %.lr.ph41.preheader
  %.lcssa.ph = phi i64 [ poison, %.lr.ph41.preheader ], [ %44, %.lr.ph41 ]
  %indvars.iv58.unr = phi i64 [ 0, %.lr.ph41.preheader ], [ %indvars.iv.next59.1, %.lr.ph41 ]
  %.02639.unr = phi i64 [ 0, %.lr.ph41.preheader ], [ %44, %.lr.ph41 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge42, label %.lr.ph41.epil

.lr.ph41.epil:                                    ; preds = %._crit_edge42.unr-lcssa
  %30 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %indvars.iv58.unr
  %31 = load i64, ptr %30, align 8, !tbaa !11
  %32 = sdiv i64 %31, %.02754
  %33 = add nsw i64 %32, %.02639.unr
  br label %._crit_edge42

._crit_edge42:                                    ; preds = %._crit_edge42.unr-lcssa, %.lr.ph41.epil
  %.lcssa = phi i64 [ %.lcssa.ph, %._crit_edge42.unr-lcssa ], [ %33, %.lr.ph41.epil ]
  %34 = load i64, ptr @k, align 8, !tbaa !11
  %.not = icmp slt i64 %.lcssa, %34
  br i1 %.not, label %.preheader, label %45

._crit_edge42.thread:                             ; preds = %.preheader35
  %35 = load i64, ptr @k, align 8, !tbaa !11
  %.not71 = icmp sgt i64 %35, 0
  br i1 %.not71, label %._crit_edge47, label %45

.preheader:                                       ; preds = %._crit_edge42
  br i1 %24, label %.lr.ph46.preheader, label %._crit_edge47

.lr.ph46.preheader:                               ; preds = %.preheader
  %xtraiter90 = and i64 %23, 1
  %36 = icmp eq i64 %25, 0
  br i1 %36, label %._crit_edge47.loopexit.unr-lcssa, label %.lr.ph46.preheader.new

.lr.ph46.preheader.new:                           ; preds = %.lr.ph46.preheader
  %unroll_iter92 = and i64 %23, 9223372036854775806
  br label %.lr.ph46

.lr.ph41:                                         ; preds = %.lr.ph41, %.lr.ph41.preheader.new
  %indvars.iv58 = phi i64 [ 0, %.lr.ph41.preheader.new ], [ %indvars.iv.next59.1, %.lr.ph41 ]
  %.02639 = phi i64 [ 0, %.lr.ph41.preheader.new ], [ %44, %.lr.ph41 ]
  %niter = phi i64 [ 0, %.lr.ph41.preheader.new ], [ %niter.next.1, %.lr.ph41 ]
  %37 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %indvars.iv58
  %38 = load i64, ptr %37, align 16, !tbaa !11
  %39 = sdiv i64 %38, %.02754
  %40 = add nsw i64 %39, %.02639
  %indvars.iv.next59 = or disjoint i64 %indvars.iv58, 1
  %41 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %indvars.iv.next59
  %42 = load i64, ptr %41, align 8, !tbaa !11
  %43 = sdiv i64 %42, %.02754
  %44 = add nsw i64 %43, %40
  %indvars.iv.next59.1 = add nuw nsw i64 %indvars.iv58, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge42.unr-lcssa, label %.lr.ph41, !llvm.loop !15

45:                                               ; preds = %._crit_edge42.thread, %._crit_edge42
  %46 = phi i64 [ %35, %._crit_edge42.thread ], [ %34, %._crit_edge42 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  %47 = mul nsw i64 %46, %.02754
  %48 = sdiv i64 %47, 2
  store i64 %48, ptr %2, align 8, !tbaa !11
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %50 = load i64, ptr %49, align 8, !tbaa !11
  store i64 %50, ptr %1, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  br label %83

._crit_edge47.loopexit.unr-lcssa:                 ; preds = %.lr.ph46, %.lr.ph46.preheader
  %indvars.iv61.unr = phi i64 [ 0, %.lr.ph46.preheader ], [ %indvars.iv.next62.1, %.lr.ph46 ]
  %lcmp.mod91.not = icmp eq i64 %xtraiter90, 0
  br i1 %lcmp.mod91.not, label %._crit_edge47, label %.lr.ph46.epil

.lr.ph46.epil:                                    ; preds = %._crit_edge47.loopexit.unr-lcssa
  %51 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %indvars.iv61.unr
  %52 = load i64, ptr %51, align 8, !tbaa !11
  %53 = srem i64 %52, %.02754
  %54 = getelementptr inbounds [1000 x i64], ptr @bcurr, i64 0, i64 %indvars.iv61.unr
  store i64 %53, ptr %54, align 8, !tbaa !11
  br label %._crit_edge47

._crit_edge47:                                    ; preds = %.lr.ph46.epil, %._crit_edge47.loopexit.unr-lcssa, %._crit_edge42.thread, %.preheader
  %.026.lcssa7274 = phi i64 [ %.lcssa, %.preheader ], [ 0, %._crit_edge42.thread ], [ %.lcssa, %._crit_edge47.loopexit.unr-lcssa ], [ %.lcssa, %.lr.ph46.epil ]
  %55 = getelementptr inbounds i64, ptr @bcurr, i64 %23
  call void @_ZSt4sortIPxSt7greaterIiEEvT_S3_T0_(ptr noundef nonnull @bcurr, ptr noundef nonnull %55)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %56 = load i64, ptr @k, align 8, !tbaa !11
  %57 = sub nsw i64 %56, %.026.lcssa7274
  %58 = icmp sgt i64 %57, 0
  br i1 %58, label %.lr.ph50.preheader, label %._crit_edge51

.lr.ph50.preheader:                               ; preds = %._crit_edge47
  %min.iters.check = icmp ult i64 %57, 4
  br i1 %min.iters.check, label %.lr.ph50.preheader83, label %vector.ph

.lr.ph50.preheader83:                             ; preds = %middle.block, %.lr.ph50.preheader
  %indvars.iv65.ph = phi i64 [ 0, %.lr.ph50.preheader ], [ %n.vec, %middle.block ]
  %.ph = phi i64 [ 0, %.lr.ph50.preheader ], [ %64, %middle.block ]
  br label %.lr.ph50

vector.ph:                                        ; preds = %.lr.ph50.preheader
  %n.vec = and i64 %57, 9223372036854775804
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %61, %vector.body ]
  %vec.phi81 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %62, %vector.body ]
  %59 = getelementptr inbounds [1000 x i64], ptr @bcurr, i64 0, i64 %index
  %60 = getelementptr inbounds i8, ptr %59, i64 16
  %wide.load = load <2 x i64>, ptr %59, align 16, !tbaa !11
  %wide.load82 = load <2 x i64>, ptr %60, align 16, !tbaa !11
  %61 = add <2 x i64> %vec.phi, %wide.load
  %62 = add <2 x i64> %vec.phi81, %wide.load82
  %index.next = add nuw i64 %index, 4
  %63 = icmp eq i64 %index.next, %n.vec
  br i1 %63, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %62, %61
  %64 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %57, %n.vec
  br i1 %cmp.n, label %._crit_edge51, label %.lr.ph50.preheader83

.lr.ph46:                                         ; preds = %.lr.ph46, %.lr.ph46.preheader.new
  %indvars.iv61 = phi i64 [ 0, %.lr.ph46.preheader.new ], [ %indvars.iv.next62.1, %.lr.ph46 ]
  %niter93 = phi i64 [ 0, %.lr.ph46.preheader.new ], [ %niter93.next.1, %.lr.ph46 ]
  %65 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %indvars.iv61
  %66 = load i64, ptr %65, align 16, !tbaa !11
  %67 = srem i64 %66, %.02754
  %68 = getelementptr inbounds [1000 x i64], ptr @bcurr, i64 0, i64 %indvars.iv61
  store i64 %67, ptr %68, align 16, !tbaa !11
  %indvars.iv.next62 = or disjoint i64 %indvars.iv61, 1
  %69 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %indvars.iv.next62
  %70 = load i64, ptr %69, align 8, !tbaa !11
  %71 = srem i64 %70, %.02754
  %72 = getelementptr inbounds [1000 x i64], ptr @bcurr, i64 0, i64 %indvars.iv.next62
  store i64 %71, ptr %72, align 8, !tbaa !11
  %indvars.iv.next62.1 = add nuw nsw i64 %indvars.iv61, 2
  %niter93.next.1 = add i64 %niter93, 2
  %niter93.ncmp.1 = icmp eq i64 %niter93.next.1, %unroll_iter92
  br i1 %niter93.ncmp.1, label %._crit_edge47.loopexit.unr-lcssa, label %.lr.ph46, !llvm.loop !19

._crit_edge51:                                    ; preds = %.lr.ph50, %middle.block, %._crit_edge47
  %73 = phi i64 [ 0, %._crit_edge47 ], [ %64, %middle.block ], [ %82, %.lr.ph50 ]
  %.neg = sdiv i64 %56, -2
  %74 = add i64 %.neg, %.026.lcssa7274
  %75 = mul nsw i64 %74, %.02754
  %76 = add nsw i64 %73, %75
  store i64 %76, ptr %3, align 8, !tbaa !11
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %78 = load i64, ptr %77, align 8, !tbaa !11
  store i64 %78, ptr %1, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  br label %83

.lr.ph50:                                         ; preds = %.lr.ph50.preheader83, %.lr.ph50
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %.lr.ph50 ], [ %indvars.iv65.ph, %.lr.ph50.preheader83 ]
  %79 = phi i64 [ %82, %.lr.ph50 ], [ %.ph, %.lr.ph50.preheader83 ]
  %80 = getelementptr inbounds [1000 x i64], ptr @bcurr, i64 0, i64 %indvars.iv65
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = add nsw i64 %79, %81
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %exitcond68.not = icmp eq i64 %indvars.iv.next66, %57
  br i1 %exitcond68.not, label %._crit_edge51, label %.lr.ph50, !llvm.loop !20

83:                                               ; preds = %._crit_edge51, %45
  %84 = phi i64 [ %78, %._crit_edge51 ], [ %50, %45 ]
  %85 = add nuw nsw i64 %.02754, 1
  %exitcond69.not = icmp eq i64 %85, 1001
  br i1 %exitcond69.not, label %27, label %.preheader35, !llvm.loop !21
}

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

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

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

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

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

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #7

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


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