; LLVM IR from eyangch/competitive-programming :: Codeforces/1706 (d2)

; 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
@K = external dso_local global i64, align 8
@A = external dso_local global [100000 x i64], align 16
@M = external dso_local global [100001 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 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 i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %17 = 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 %18

18:                                               ; preds = %122, %0
  %19 = load i64, ptr @T, align 8, !tbaa !8
  %20 = add nsw i64 %19, -1
  store i64 %20, ptr @T, align 8, !tbaa !8
  %21 = icmp ne i64 %19, 0
  br i1 %21, label %22, label %126

22:                                               ; preds = %18
  %23 = 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)
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %23, 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
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @M, ptr noundef getelementptr inbounds (i64, ptr @M, i64 100001), ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %25

25:                                               ; preds = %34, %22
  %26 = load i64, ptr %3, align 8, !tbaa !8
  %27 = load i64, ptr @N, align 8, !tbaa !8
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %37

30:                                               ; preds = %25
  %31 = load i64, ptr %3, align 8, !tbaa !8
  %32 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %31
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %32)
  br label %34

34:                                               ; preds = %30
  %35 = load i64, ptr %3, align 8, !tbaa !8
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %3, align 8, !tbaa !8
  br label %25, !llvm.loop !13

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  br label %38

38:                                               ; preds = %95, %37
  %39 = load i64, ptr %4, align 8, !tbaa !8
  %40 = load i64, ptr @N, align 8, !tbaa !8
  %41 = icmp slt i64 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %98

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 1, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store i64 1000000000000000, ptr %6, align 8, !tbaa !8
  br label %44

44:                                               ; preds = %50, %43
  %45 = load i64, ptr %5, align 8, !tbaa !8
  %46 = load i64, ptr %4, align 8, !tbaa !8
  %47 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !8
  %49 = icmp sle i64 %45, %48
  br i1 %49, label %50, label %80

50:                                               ; preds = %44
  %51 = load i64, ptr %4, align 8, !tbaa !8
  %52 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !8
  %54 = load i64, ptr %5, align 8, !tbaa !8
  %55 = sdiv i64 %53, %54
  %56 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %55
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %56, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %58 = load i64, ptr %57, align 8, !tbaa !8
  %59 = load i64, ptr %4, align 8, !tbaa !8
  %60 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !8
  %62 = load i64, ptr %5, align 8, !tbaa !8
  %63 = sdiv i64 %61, %62
  %64 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %63
  store i64 %58, ptr %64, align 8, !tbaa !8
  %65 = load i64, ptr %4, align 8, !tbaa !8
  %66 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !8
  %68 = load i64, ptr %5, align 8, !tbaa !8
  %69 = sdiv i64 %67, %68
  store i64 %69, ptr %6, align 8, !tbaa !8
  %70 = load i64, ptr %4, align 8, !tbaa !8
  %71 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !8
  %73 = load i64, ptr %4, align 8, !tbaa !8
  %74 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %73
  %75 = load i64, ptr %74, align 8, !tbaa !8
  %76 = load i64, ptr %5, align 8, !tbaa !8
  %77 = sdiv i64 %75, %76
  %78 = sdiv i64 %72, %77
  %79 = add nsw i64 %78, 1
  store i64 %79, ptr %5, align 8, !tbaa !8
  br label %44, !llvm.loop !15

80:                                               ; preds = %44
  %81 = load i64, ptr %4, align 8, !tbaa !8
  %82 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !8
  %84 = load i64, ptr %5, align 8, !tbaa !8
  %85 = sdiv i64 %83, %84
  %86 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %85
  %87 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %86, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %88 = load i64, ptr %87, align 8, !tbaa !8
  %89 = load i64, ptr %4, align 8, !tbaa !8
  %90 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !8
  %92 = load i64, ptr %5, align 8, !tbaa !8
  %93 = sdiv i64 %91, %92
  %94 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %93
  store i64 %88, ptr %94, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %95

95:                                               ; preds = %80
  %96 = load i64, ptr %4, align 8, !tbaa !8
  %97 = add nsw i64 %96, 1
  store i64 %97, ptr %4, align 8, !tbaa !8
  br label %38, !llvm.loop !16

98:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 1000000000000000, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %99 = load i64, ptr @N, align 8, !tbaa !8
  %100 = getelementptr inbounds i64, ptr @A, i64 %99
  %101 = call noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef @A, ptr noundef %100)
  %102 = load i64, ptr %101, align 8, !tbaa !8
  %103 = load i64, ptr @K, align 8, !tbaa !8
  %104 = sdiv i64 %102, %103
  store i64 %104, ptr %8, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !8
  br label %105

105:                                              ; preds = %119, %98
  %106 = load i64, ptr %9, align 8, !tbaa !8
  %107 = icmp sle i64 %106, 100000
  br i1 %107, label %109, label %108

108:                                              ; preds = %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %122

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %110 = load i64, ptr %8, align 8, !tbaa !8
  %111 = load i64, ptr %9, align 8, !tbaa !8
  %112 = sub nsw i64 %110, %111
  store i64 %112, ptr %10, align 8, !tbaa !8
  %113 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %114 = load i64, ptr %113, align 8, !tbaa !8
  store i64 %114, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  %115 = load i64, ptr %9, align 8, !tbaa !8
  %116 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %115
  %117 = 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) %116)
  %118 = load i64, ptr %117, align 8, !tbaa !8
  store i64 %118, ptr %8, align 8, !tbaa !8
  br label %119

119:                                              ; preds = %109
  %120 = load i64, ptr %9, align 8, !tbaa !8
  %121 = add nsw i64 %120, 1
  store i64 %121, ptr %9, align 8, !tbaa !8
  br label %105, !llvm.loop !17

122:                                              ; preds = %108
  %123 = load i64, ptr %7, align 8, !tbaa !8
  %124 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %123)
  %125 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %124, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %18, !llvm.loop !18

126:                                              ; preds = %18
  %127 = load i32, ptr %1, align 4
  ret i32 %127
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 dso_local noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_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) #4

; 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 = { 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 #5 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@A = external dso_local global [100000 x i64], align 16
@M = external dso_local global [100001 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 i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %8
  %10 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %9, ptr noundef null)
  %11 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %12 = 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)
  %13 = load i64, ptr @T, align 8, !tbaa !8
  %14 = add nsw i64 %13, -1
  store i64 %14, ptr @T, align 8, !tbaa !8
  %.not43 = icmp eq i64 %13, 0
  br i1 %.not43, label %._crit_edge46, label %.lr.ph45

.lr.ph45:                                         ; preds = %0, %52
  %15 = 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)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(8) @K)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 0, ptr %1, align 4, !tbaa !11
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @M, ptr noundef nonnull getelementptr inbounds (i8, ptr @M, i64 800008), ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %17 = load i64, ptr @N, align 8, !tbaa !8
  %18 = icmp sgt i64 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge40

.preheader:                                       ; preds = %.lr.ph
  %19 = icmp sgt i64 %23, 0
  br i1 %19, label %.lr.ph39, label %._crit_edge40

.lr.ph:                                           ; preds = %.lr.ph45, %.lr.ph
  %.02732 = phi i64 [ %22, %.lr.ph ], [ 0, %.lr.ph45 ]
  %20 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %.02732
  %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) %20)
  %22 = add nuw nsw i64 %.02732, 1
  %23 = load i64, ptr @N, align 8, !tbaa !8
  %24 = icmp slt i64 %22, %23
  br i1 %24, label %.lr.ph, label %.preheader, !llvm.loop !13

._crit_edge40:                                    ; preds = %._crit_edge, %.lr.ph45, %.preheader
  %.lcssa31 = phi i64 [ %23, %.preheader ], [ %17, %.lr.ph45 ], [ %50, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  store i64 1000000000000000, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %25 = getelementptr inbounds i64, ptr @A, i64 %.lcssa31
  %26 = call noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef nonnull @A, ptr noundef nonnull %25)
  %27 = load i64, ptr %26, align 8, !tbaa !8
  %28 = load i64, ptr @K, align 8, !tbaa !8
  %29 = sdiv i64 %27, %28
  store i64 %29, ptr %4, align 8, !tbaa !8
  br label %58

.lr.ph39:                                         ; preds = %.preheader, %._crit_edge
  %.02638 = phi i64 [ %49, %._crit_edge ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i64 1000000000000000, ptr %2, align 8, !tbaa !8
  %30 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %.02638
  %31 = load i64, ptr %30, align 8, !tbaa !8
  %.not2933 = icmp slt i64 %31, 1
  br i1 %.not2933, label %._crit_edge, label %.lr.ph35

.lr.ph35:                                         ; preds = %.lr.ph39, %.lr.ph35
  %32 = phi i64 [ %37, %.lr.ph35 ], [ %31, %.lr.ph39 ]
  %.02534 = phi i64 [ %41, %.lr.ph35 ], [ 1, %.lr.ph39 ]
  %33 = sdiv i64 %32, %.02534
  %34 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %33
  %35 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %34, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %36 = load i64, ptr %35, align 8, !tbaa !8
  %37 = load i64, ptr %30, align 8, !tbaa !8
  %38 = sdiv i64 %37, %.02534
  %39 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %38
  store i64 %36, ptr %39, align 8, !tbaa !8
  store i64 %38, ptr %2, align 8, !tbaa !8
  %40 = sdiv i64 %37, %38
  %41 = add nsw i64 %40, 1
  %.not29.not = icmp slt i64 %40, %37
  br i1 %.not29.not, label %.lr.ph35, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph35, %.lr.ph39
  %.025.lcssa = phi i64 [ 1, %.lr.ph39 ], [ %41, %.lr.ph35 ]
  %.lcssa = phi i64 [ %31, %.lr.ph39 ], [ %37, %.lr.ph35 ]
  %42 = sdiv i64 %.lcssa, %.025.lcssa
  %43 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %42
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %46 = load i64, ptr %30, align 8, !tbaa !8
  %47 = sdiv i64 %46, %.025.lcssa
  %48 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %47
  store i64 %45, ptr %48, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %49 = add nuw nsw i64 %.02638, 1
  %50 = load i64, ptr @N, align 8, !tbaa !8
  %51 = icmp slt i64 %49, %50
  br i1 %51, label %.lr.ph39, label %._crit_edge40, !llvm.loop !16

52:                                               ; preds = %58
  %53 = load i64, ptr %3, align 8, !tbaa !8
  %54 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %53)
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %54, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %56 = load i64, ptr @T, align 8, !tbaa !8
  %57 = add nsw i64 %56, -1
  store i64 %57, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %56, 0
  br i1 %.not, label %._crit_edge46, label %.lr.ph45, !llvm.loop !17

58:                                               ; preds = %._crit_edge40, %58
  %59 = phi i64 [ %29, %._crit_edge40 ], [ %65, %58 ]
  %.042 = phi i64 [ 0, %._crit_edge40 ], [ %66, %58 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %60 = sub nsw i64 %59, %.042
  store i64 %60, ptr %5, align 8, !tbaa !8
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %62 = load i64, ptr %61, align 8, !tbaa !8
  store i64 %62, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  %63 = getelementptr inbounds [100001 x i64], ptr @M, i64 0, i64 %.042
  %64 = 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) %63)
  %65 = load i64, ptr %64, align 8, !tbaa !8
  store i64 %65, ptr %4, align 8, !tbaa !8
  %66 = add nuw nsw i64 %.042, 1
  %exitcond.not = icmp eq i64 %66, 100001
  br i1 %exitcond.not, label %52, label %58, !llvm.loop !18

._crit_edge46:                                    ; preds = %52, %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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 dso_local noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_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 #4

; 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 = { 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 #5 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass