; LLVM IR from eyangch/competitive-programming :: Codeforces/1699 (d)

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

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

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@A = external dso_local global [5000 x i64], align 16
@f = external dso_local global [5000 x i64], align 16
@dp = external dso_local global [5000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", 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 i64, align 8
  %3 = alloca double, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  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 @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  br label %22

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

26:                                               ; preds = %22
  %27 = 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)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %28

28:                                               ; preds = %41, %26
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = load i64, ptr @N, align 8, !tbaa !8
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %44

33:                                               ; preds = %28
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [5000 x i64], ptr @A, 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)
  %37 = load i64, ptr %2, align 8, !tbaa !8
  %38 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !8
  %40 = add nsw i64 %39, -1
  store i64 %40, ptr %38, align 8, !tbaa !8
  br label %41

41:                                               ; preds = %33
  %42 = load i64, ptr %2, align 8, !tbaa !8
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %2, align 8, !tbaa !8
  br label %28, !llvm.loop !11

44:                                               ; preds = %32
  %45 = load i64, ptr @N, align 8, !tbaa !8
  %46 = getelementptr inbounds i64, ptr @dp, i64 %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store double -1.000000e+09, ptr %3, align 8, !tbaa !13
  call void @_ZSt4fillIPxdEvT_S1_RKT0_(ptr noundef @dp, ptr noundef %46, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  store i64 1, ptr @dp, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 1, ptr %4, align 8, !tbaa !8
  br label %47

47:                                               ; preds = %123, %44
  %48 = load i64, ptr %4, align 8, !tbaa !8
  %49 = load i64, ptr @N, align 8, !tbaa !8
  %50 = icmp slt i64 %48, %49
  br i1 %50, label %52, label %51

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

52:                                               ; preds = %47
  %53 = load i64, ptr @N, align 8, !tbaa !8
  %54 = getelementptr inbounds i64, ptr @f, i64 %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !15
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @f, ptr noundef %54, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %55 = load i64, ptr %4, align 8, !tbaa !8
  %56 = sub nsw i64 %55, 1
  store i64 %56, ptr %8, align 8, !tbaa !8
  br label %57

57:                                               ; preds = %103, %52
  %58 = load i64, ptr %8, align 8, !tbaa !8
  %59 = icmp sge i64 %58, 0
  br i1 %59, label %61, label %60

60:                                               ; preds = %57
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %106

61:                                               ; preds = %57
  %62 = load i64, ptr %4, align 8, !tbaa !8
  %63 = load i64, ptr %8, align 8, !tbaa !8
  %64 = sub nsw i64 %62, %63
  %65 = srem i64 %64, 2
  %66 = icmp eq i64 %65, 1
  br i1 %66, label %67, label %94

67:                                               ; preds = %61
  %68 = load i64, ptr %7, align 8, !tbaa !8
  %69 = load i64, ptr %4, align 8, !tbaa !8
  %70 = load i64, ptr %8, align 8, !tbaa !8
  %71 = sub nsw i64 %69, %70
  %72 = sub nsw i64 %71, 1
  %73 = sdiv i64 %72, 2
  %74 = icmp sle i64 %68, %73
  br i1 %74, label %75, label %94

75:                                               ; preds = %67
  %76 = load i64, ptr %8, align 8, !tbaa !8
  %77 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !8
  %79 = load i64, ptr %4, align 8, !tbaa !8
  %80 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !8
  %82 = icmp eq i64 %78, %81
  br i1 %82, label %83, label %94

83:                                               ; preds = %75
  %84 = load i64, ptr %4, align 8, !tbaa !8
  %85 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %86 = load i64, ptr %8, align 8, !tbaa !8
  %87 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !8
  %89 = add nsw i64 %88, 1
  store i64 %89, ptr %9, align 8, !tbaa !8
  %90 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %85, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %91 = load i64, ptr %90, align 8, !tbaa !8
  %92 = load i64, ptr %4, align 8, !tbaa !8
  %93 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %92
  store i64 %91, ptr %93, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %94

94:                                               ; preds = %83, %75, %67, %61
  %95 = load i64, ptr %8, align 8, !tbaa !8
  %96 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !8
  %98 = getelementptr inbounds [5000 x i64], ptr @f, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !8
  %100 = add nsw i64 %99, 1
  store i64 %100, ptr %98, align 8, !tbaa !8
  %101 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %98)
  %102 = load i64, ptr %101, align 8, !tbaa !8
  store i64 %102, ptr %7, align 8, !tbaa !8
  br label %103

103:                                              ; preds = %94
  %104 = load i64, ptr %8, align 8, !tbaa !8
  %105 = add nsw i64 %104, -1
  store i64 %105, ptr %8, align 8, !tbaa !8
  br label %57, !llvm.loop !17

106:                                              ; preds = %60
  %107 = load i64, ptr %7, align 8, !tbaa !8
  %108 = load i64, ptr %4, align 8, !tbaa !8
  %109 = sdiv i64 %108, 2
  %110 = icmp sle i64 %107, %109
  br i1 %110, label %111, label %122

111:                                              ; preds = %106
  %112 = load i64, ptr %4, align 8, !tbaa !8
  %113 = srem i64 %112, 2
  %114 = icmp eq i64 %113, 0
  br i1 %114, label %115, label %122

115:                                              ; preds = %111
  %116 = load i64, ptr %4, align 8, !tbaa !8
  %117 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 1, ptr %10, align 8, !tbaa !8
  %118 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %117, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %119 = load i64, ptr %118, align 8, !tbaa !8
  %120 = load i64, ptr %4, align 8, !tbaa !8
  %121 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %120
  store i64 %119, ptr %121, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %122

122:                                              ; preds = %115, %111, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %123

123:                                              ; preds = %122
  %124 = load i64, ptr %4, align 8, !tbaa !8
  %125 = add nsw i64 %124, 1
  store i64 %125, ptr %4, align 8, !tbaa !8
  br label %47, !llvm.loop !18

126:                                              ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 0, ptr %11, align 8, !tbaa !8
  %127 = load i64, ptr @N, align 8, !tbaa !8
  %128 = getelementptr inbounds i64, ptr @f, i64 %127
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !15
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @f, ptr noundef %128, ptr noundef nonnull align 4 dereferenceable(4) %12)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store i64 0, ptr %13, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %129 = load i64, ptr @N, align 8, !tbaa !8
  %130 = sub nsw i64 %129, 1
  store i64 %130, ptr %14, align 8, !tbaa !8
  br label %131

131:                                              ; preds = %163, %126
  %132 = load i64, ptr %14, align 8, !tbaa !8
  %133 = icmp sge i64 %132, 0
  br i1 %133, label %135, label %134

134:                                              ; preds = %131
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %166

135:                                              ; preds = %131
  %136 = load i64, ptr @N, align 8, !tbaa !8
  %137 = load i64, ptr %14, align 8, !tbaa !8
  %138 = sub nsw i64 %136, %137
  %139 = srem i64 %138, 2
  %140 = icmp eq i64 %139, 1
  br i1 %140, label %141, label %154

141:                                              ; preds = %135
  %142 = load i64, ptr %13, align 8, !tbaa !8
  %143 = load i64, ptr @N, align 8, !tbaa !8
  %144 = load i64, ptr %14, align 8, !tbaa !8
  %145 = sub nsw i64 %143, %144
  %146 = sub nsw i64 %145, 1
  %147 = sdiv i64 %146, 2
  %148 = icmp sle i64 %142, %147
  br i1 %148, label %149, label %154

149:                                              ; preds = %141
  %150 = load i64, ptr %14, align 8, !tbaa !8
  %151 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %150
  %152 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %151)
  %153 = load i64, ptr %152, align 8, !tbaa !8
  store i64 %153, ptr %11, align 8, !tbaa !8
  br label %154

154:                                              ; preds = %149, %141, %135
  %155 = load i64, ptr %14, align 8, !tbaa !8
  %156 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %155
  %157 = load i64, ptr %156, align 8, !tbaa !8
  %158 = getelementptr inbounds [5000 x i64], ptr @f, i64 0, i64 %157
  %159 = load i64, ptr %158, align 8, !tbaa !8
  %160 = add nsw i64 %159, 1
  store i64 %160, ptr %158, align 8, !tbaa !8
  %161 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %158)
  %162 = load i64, ptr %161, align 8, !tbaa !8
  store i64 %162, ptr %13, align 8, !tbaa !8
  br label %163

163:                                              ; preds = %154
  %164 = load i64, ptr %14, align 8, !tbaa !8
  %165 = add nsw i64 %164, -1
  store i64 %165, ptr %14, align 8, !tbaa !8
  br label %131, !llvm.loop !19

166:                                              ; preds = %134
  %167 = load i64, ptr %11, align 8, !tbaa !8
  %168 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %167)
  %169 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %168, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %22, !llvm.loop !20

170:                                              ; preds = %22
  %171 = load i32, ptr %1, align 4
  ret i32 %171
}

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

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

; 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 @_ZSt4fillIPxdEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

; 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

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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !10, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !10, i64 0}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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

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

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@A = external dso_local global [5000 x i64], align 16
@f = external dso_local global [5000 x i64], align 16
@dp = external dso_local global [5000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", 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 double, align 8
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %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 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %15 = 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) @T)
  %16 = load i64, ptr @T, align 8, !tbaa !8
  %17 = add nsw i64 %16, -1
  store i64 %17, ptr @T, align 8, !tbaa !8
  %.not54 = icmp eq i64 %16, 0
  br i1 %.not54, label %._crit_edge57, label %.lr.ph56

.lr.ph56:                                         ; preds = %0, %._crit_edge53
  %18 = 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)
  %19 = load i64, ptr @N, align 8, !tbaa !8
  %20 = icmp sgt i64 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph56
  %.lcssa = phi i64 [ %19, %.lr.ph56 ], [ %29, %.lr.ph ]
  %21 = getelementptr inbounds i64, ptr @dp, i64 %.lcssa
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  store double -1.000000e+09, ptr %1, align 8, !tbaa !11
  call void @_ZSt4fillIPxdEvT_S1_RKT0_(ptr noundef nonnull @dp, ptr noundef nonnull %21, ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  store i64 1, ptr @dp, align 16, !tbaa !8
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = icmp sgt i64 %22, 1
  br i1 %23, label %.lr.ph46, label %._crit_edge47

.lr.ph:                                           ; preds = %.lr.ph56, %.lr.ph
  %.03240 = phi i64 [ %28, %.lr.ph ], [ 0, %.lr.ph56 ]
  %24 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %.03240
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = load i64, ptr %24, align 8, !tbaa !8
  %27 = add nsw i64 %26, -1
  store i64 %27, ptr %24, align 8, !tbaa !8
  %28 = add nuw nsw i64 %.03240, 1
  %29 = load i64, ptr @N, align 8, !tbaa !8
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge47:                                    ; preds = %72, %._crit_edge
  %.lcssa39 = phi i64 [ %22, %._crit_edge ], [ %74, %72 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i64 0, ptr %6, align 8, !tbaa !8
  %31 = getelementptr inbounds i64, ptr @f, i64 %.lcssa39
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  store i32 0, ptr %7, align 4, !tbaa !15
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @f, ptr noundef nonnull %31, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #7
  store i64 0, ptr %8, align 8, !tbaa !8
  %32 = load i64, ptr @N, align 8, !tbaa !8
  %33 = icmp sgt i64 %32, 0
  br i1 %33, label %.lr.ph52, label %._crit_edge53

.lr.ph46:                                         ; preds = %._crit_edge, %72
  %34 = phi i64 [ %74, %72 ], [ %22, %._crit_edge ]
  %.03144 = phi i64 [ %73, %72 ], [ 1, %._crit_edge ]
  %35 = getelementptr inbounds i64, ptr @f, i64 %34
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !15
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @f, ptr noundef nonnull %35, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  store i64 0, ptr %3, align 8, !tbaa !8
  %36 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %.03144
  %37 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %.03144
  br label %42

38:                                               ; preds = %60
  %39 = lshr i64 %.03144, 1
  %.not36 = icmp sle i64 %67, %39
  %40 = and i64 %.03144, 1
  %41 = icmp eq i64 %40, 0
  %or.cond = and i1 %41, %.not36
  br i1 %or.cond, label %69, label %72

42:                                               ; preds = %.lr.ph46, %60
  %.03043.in = phi i64 [ %.03144, %.lr.ph46 ], [ %.03043, %60 ]
  %storemerge42 = phi i64 [ 0, %.lr.ph46 ], [ %67, %60 ]
  %.03043 = add nsw i64 %.03043.in, -1
  %43 = sub nsw i64 %.03144, %.03043
  %44 = and i64 %43, -9223372036854775807
  %45 = icmp eq i64 %44, 1
  br i1 %45, label %46, label %60

46:                                               ; preds = %42
  %47 = add nsw i64 %43, -1
  %48 = lshr exact i64 %47, 1
  %.not37 = icmp sgt i64 %storemerge42, %48
  br i1 %.not37, label %60, label %49

49:                                               ; preds = %46
  %50 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %.03043
  %51 = load i64, ptr %50, align 8, !tbaa !8
  %52 = load i64, ptr %36, align 8, !tbaa !8
  %53 = icmp eq i64 %51, %52
  br i1 %53, label %54, label %60

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %55 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %.03043
  %56 = load i64, ptr %55, align 8, !tbaa !8
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %4, align 8, !tbaa !8
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %37, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %59 = load i64, ptr %58, align 8, !tbaa !8
  store i64 %59, ptr %37, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %60

60:                                               ; preds = %54, %49, %46, %42
  %61 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %.03043
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = getelementptr inbounds [5000 x i64], ptr @f, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !8
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr %63, align 8, !tbaa !8
  %66 = 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) %63)
  %67 = load i64, ptr %66, align 8, !tbaa !8
  store i64 %67, ptr %3, align 8, !tbaa !8
  %68 = icmp sgt i64 %.03043.in, 1
  br i1 %68, label %42, label %38, !llvm.loop !17

69:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  store i64 1, ptr %5, align 8, !tbaa !8
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %37, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %71 = load i64, ptr %70, align 8, !tbaa !8
  store i64 %71, ptr %37, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  br label %72

72:                                               ; preds = %69, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %73 = add nuw nsw i64 %.03144, 1
  %74 = load i64, ptr @N, align 8, !tbaa !8
  %75 = icmp slt i64 %73, %74
  br i1 %75, label %.lr.ph46, label %._crit_edge47, !llvm.loop !18

._crit_edge53:                                    ; preds = %93, %._crit_edge47
  %76 = load i64, ptr %6, align 8, !tbaa !8
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %76)
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %77, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  %79 = load i64, ptr @T, align 8, !tbaa !8
  %80 = add nsw i64 %79, -1
  store i64 %80, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %79, 0
  br i1 %.not, label %._crit_edge57, label %.lr.ph56, !llvm.loop !19

.lr.ph52:                                         ; preds = %._crit_edge47, %93
  %81 = phi i64 [ %100, %93 ], [ 0, %._crit_edge47 ]
  %.050.in = phi i64 [ %.050, %93 ], [ %32, %._crit_edge47 ]
  %.050 = add nsw i64 %.050.in, -1
  %82 = load i64, ptr @N, align 8, !tbaa !8
  %83 = sub nsw i64 %82, %.050
  %84 = and i64 %83, -9223372036854775807
  %85 = icmp eq i64 %84, 1
  br i1 %85, label %86, label %93

86:                                               ; preds = %.lr.ph52
  %87 = add nsw i64 %83, -1
  %88 = lshr exact i64 %87, 1
  %.not35 = icmp sgt i64 %81, %88
  br i1 %.not35, label %93, label %89

89:                                               ; preds = %86
  %90 = getelementptr inbounds [5000 x i64], ptr @dp, i64 0, i64 %.050
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %90)
  %92 = load i64, ptr %91, align 8, !tbaa !8
  store i64 %92, ptr %6, align 8, !tbaa !8
  br label %93

93:                                               ; preds = %89, %86, %.lr.ph52
  %94 = getelementptr inbounds [5000 x i64], ptr @A, i64 0, i64 %.050
  %95 = load i64, ptr %94, align 8, !tbaa !8
  %96 = getelementptr inbounds [5000 x i64], ptr @f, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !8
  %98 = add nsw i64 %97, 1
  store i64 %98, ptr %96, align 8, !tbaa !8
  %99 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %96)
  %100 = load i64, ptr %99, align 8, !tbaa !8
  store i64 %100, ptr %8, align 8, !tbaa !8
  %101 = icmp ugt i64 %.050.in, 1
  br i1 %101, label %.lr.ph52, label %._crit_edge53, !llvm.loop !20

._crit_edge57:                                    ; preds = %._crit_edge53, %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 #1 align 2

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

; 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 @_ZSt4fillIPxdEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #5

; 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

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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 = { 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 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !10, i64 0}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}


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