; LLVM IR from eyangch/competitive-programming :: Codeforces/1415 (e)

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

@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@c = external dso_local global [500000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #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 = 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
  store i32 0, ptr %1, align 4
  %12 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %13 = getelementptr i8, ptr %12, i64 -24
  %14 = load i64, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %14
  %16 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %15, ptr noundef null)
  %17 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %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 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 8 dereferenceable(8) @K)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %20

20:                                               ; preds = %29, %0
  %21 = load i64, ptr %2, align 8, !tbaa !8
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %20
  %26 = load i64, ptr %2, align 8, !tbaa !8
  %27 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %26
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %27)
  br label %29

29:                                               ; preds = %25
  %30 = load i64, ptr %2, align 8, !tbaa !8
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %2, align 8, !tbaa !8
  br label %20, !llvm.loop !11

32:                                               ; preds = %24
  %33 = load i64, ptr @N, align 8, !tbaa !8
  %34 = getelementptr inbounds i64, ptr @c, i64 %33
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @c, ptr noundef %34)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %35 = load i64, ptr @N, align 8, !tbaa !8
  %36 = sub nsw i64 %35, 1
  store i64 %36, ptr %5, align 8, !tbaa !8
  br label %37

37:                                               ; preds = %50, %32
  %38 = load i64, ptr %5, align 8, !tbaa !8
  %39 = icmp sge i64 %38, 0
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %37
  %42 = load i64, ptr %4, align 8, !tbaa !8
  %43 = load i64, ptr %3, align 8, !tbaa !8
  %44 = add nsw i64 %43, %42
  store i64 %44, ptr %3, align 8, !tbaa !8
  %45 = load i64, ptr %5, align 8, !tbaa !8
  %46 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !8
  %48 = load i64, ptr %4, align 8, !tbaa !8
  %49 = add nsw i64 %48, %47
  store i64 %49, ptr %4, align 8, !tbaa !8
  br label %50

50:                                               ; preds = %41
  %51 = load i64, ptr %5, align 8, !tbaa !8
  %52 = add nsw i64 %51, -1
  store i64 %52, ptr %5, align 8, !tbaa !8
  br label %37, !llvm.loop !13

53:                                               ; preds = %40
  %54 = load i64, ptr @K, align 8, !tbaa !8
  %55 = icmp eq i64 %54, 0
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load i64, ptr %3, align 8, !tbaa !8
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %57)
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %58, ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %106

60:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %61 = load i64, ptr %3, align 8, !tbaa !8
  store i64 %61, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store i64 0, 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 %62

62:                                               ; preds = %99, %60
  %63 = load i64, ptr %9, align 8, !tbaa !8
  %64 = load i64, ptr @N, align 8, !tbaa !8
  %65 = icmp slt i64 %63, %64
  br i1 %65, label %67, label %66

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

67:                                               ; preds = %62
  %68 = load i64, ptr %9, align 8, !tbaa !8
  %69 = load i64, ptr @K, align 8, !tbaa !8
  %70 = add nsw i64 %69, 1
  %71 = sdiv i64 %68, %70
  %72 = load i64, ptr %9, align 8, !tbaa !8
  %73 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %72
  %74 = load i64, ptr %73, align 8, !tbaa !8
  %75 = mul nsw i64 %71, %74
  %76 = load i64, ptr %8, align 8, !tbaa !8
  %77 = add nsw i64 %76, %75
  store i64 %77, ptr %8, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %78 = load i64, ptr %9, align 8, !tbaa !8
  %79 = load i64, ptr @K, align 8, !tbaa !8
  %80 = add nsw i64 %79, 1
  %81 = sdiv i64 %78, %80
  %82 = add nsw i64 %81, 1
  store i64 %82, ptr %10, align 8, !tbaa !8
  %83 = load i64, ptr %9, align 8, !tbaa !8
  %84 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !8
  %86 = load i64, ptr %4, align 8, !tbaa !8
  %87 = sub nsw i64 %86, %85
  store i64 %87, ptr %4, align 8, !tbaa !8
  %88 = load i64, ptr %3, align 8, !tbaa !8
  %89 = sub nsw i64 %88, %87
  store i64 %89, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %90 = load i64, ptr %8, align 8, !tbaa !8
  %91 = load i64, ptr %3, align 8, !tbaa !8
  %92 = add nsw i64 %90, %91
  %93 = load i64, ptr %4, align 8, !tbaa !8
  %94 = load i64, ptr %10, align 8, !tbaa !8
  %95 = mul nsw i64 %93, %94
  %96 = add nsw i64 %92, %95
  store i64 %96, ptr %11, align 8, !tbaa !8
  %97 = 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) %11)
  %98 = load i64, ptr %97, align 8, !tbaa !8
  store i64 %98, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %99

99:                                               ; preds = %67
  %100 = load i64, ptr %9, align 8, !tbaa !8
  %101 = add nsw i64 %100, 1
  store i64 %101, ptr %9, align 8, !tbaa !8
  br label %62, !llvm.loop !14

102:                                              ; preds = %66
  %103 = load i64, ptr %7, align 8, !tbaa !8
  %104 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %103)
  %105 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %104, ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  store i32 0, ptr %6, align 4
  br label %106

106:                                              ; preds = %102, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  %107 = load i32, ptr %6, align 4
  switch i32 %107, label %110 [
    i32 0, label %108
    i32 1, label %108
  ]

108:                                              ; preds = %106, %106
  %109 = load i32, ptr %1, align 4
  ret i32 %109

110:                                              ; preds = %106
  unreachable
}

; 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 @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) #5

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

; 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

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 = distinct !{!13, !12}
!14 = distinct !{!14, !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" }

@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@c = external dso_local global [500000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; 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 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %5
  %7 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %6, ptr noundef null)
  %8 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %9 = 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)
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) @K)
  %11 = load i64, ptr @N, align 8, !tbaa !8
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i64 [ %11, %0 ], [ %20, %.lr.ph ]
  %13 = getelementptr inbounds i64, ptr @c, i64 %.lcssa
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @c, ptr noundef nonnull %13)
  %14 = load i64, ptr @N, align 8, !tbaa !8
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph37.preheader, label %._crit_edge38.thread

.lr.ph37.preheader:                               ; preds = %._crit_edge
  %xtraiter = and i64 %14, 3
  %16 = icmp ult i64 %14, 4
  br i1 %16, label %._crit_edge38.unr-lcssa, label %.lr.ph37.preheader.new

.lr.ph37.preheader.new:                           ; preds = %.lr.ph37.preheader
  %unroll_iter = and i64 %14, 9223372036854775804
  br label %.lr.ph37

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.03132 = phi i64 [ %19, %.lr.ph ], [ 0, %0 ]
  %17 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %.03132
  %18 = 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) %17)
  %19 = add nuw nsw i64 %.03132, 1
  %20 = load i64, ptr @N, align 8, !tbaa !8
  %21 = icmp slt i64 %19, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge38.unr-lcssa:                          ; preds = %.lr.ph37, %.lr.ph37.preheader
  %.lcssa68.ph = phi i64 [ poison, %.lr.ph37.preheader ], [ %42, %.lr.ph37 ]
  %.lcssa67.ph = phi i64 [ poison, %.lr.ph37.preheader ], [ %45, %.lr.ph37 ]
  %.027.in35.unr = phi i64 [ %14, %.lr.ph37.preheader ], [ %.027.3, %.lr.ph37 ]
  %.02834.unr = phi i64 [ 0, %.lr.ph37.preheader ], [ %45, %.lr.ph37 ]
  %.02933.unr = phi i64 [ 0, %.lr.ph37.preheader ], [ %42, %.lr.ph37 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge38, label %.lr.ph37.epil

.lr.ph37.epil:                                    ; preds = %._crit_edge38.unr-lcssa, %.lr.ph37.epil
  %.027.in35.epil = phi i64 [ %.027.epil, %.lr.ph37.epil ], [ %.027.in35.unr, %._crit_edge38.unr-lcssa ]
  %.02834.epil = phi i64 [ %25, %.lr.ph37.epil ], [ %.02834.unr, %._crit_edge38.unr-lcssa ]
  %.02933.epil = phi i64 [ %22, %.lr.ph37.epil ], [ %.02933.unr, %._crit_edge38.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph37.epil ], [ 0, %._crit_edge38.unr-lcssa ]
  %.027.epil = add nsw i64 %.027.in35.epil, -1
  %22 = add nsw i64 %.02834.epil, %.02933.epil
  %23 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %.027.epil
  %24 = load i64, ptr %23, align 8, !tbaa !8
  %25 = add nsw i64 %24, %.02834.epil
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge38, label %.lr.ph37.epil, !llvm.loop !13

._crit_edge38:                                    ; preds = %.lr.ph37.epil, %._crit_edge38.unr-lcssa
  %.lcssa68 = phi i64 [ %.lcssa68.ph, %._crit_edge38.unr-lcssa ], [ %22, %.lr.ph37.epil ]
  %.lcssa67 = phi i64 [ %.lcssa67.ph, %._crit_edge38.unr-lcssa ], [ %25, %.lr.ph37.epil ]
  %26 = load i64, ptr @K, align 8, !tbaa !8
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %46, label %49

._crit_edge38.thread:                             ; preds = %._crit_edge
  %28 = load i64, ptr @K, align 8, !tbaa !8
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %46, label %.thread

.thread:                                          ; preds = %._crit_edge38.thread
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  store i64 0, ptr %1, align 8, !tbaa !8
  br label %._crit_edge47

.lr.ph37:                                         ; preds = %.lr.ph37, %.lr.ph37.preheader.new
  %.027.in35 = phi i64 [ %14, %.lr.ph37.preheader.new ], [ %.027.3, %.lr.ph37 ]
  %.02834 = phi i64 [ 0, %.lr.ph37.preheader.new ], [ %45, %.lr.ph37 ]
  %.02933 = phi i64 [ 0, %.lr.ph37.preheader.new ], [ %42, %.lr.ph37 ]
  %niter = phi i64 [ 0, %.lr.ph37.preheader.new ], [ %niter.next.3, %.lr.ph37 ]
  %.027 = add nsw i64 %.027.in35, -1
  %30 = add nsw i64 %.02834, %.02933
  %31 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %.027
  %32 = load i64, ptr %31, align 8, !tbaa !8
  %33 = add nsw i64 %32, %.02834
  %.027.1 = add nsw i64 %.027.in35, -2
  %34 = add nsw i64 %33, %30
  %35 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %.027.1
  %36 = load i64, ptr %35, align 8, !tbaa !8
  %37 = add nsw i64 %36, %33
  %.027.2 = add nsw i64 %.027.in35, -3
  %38 = add nsw i64 %37, %34
  %39 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %.027.2
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = add nsw i64 %40, %37
  %.027.3 = add nsw i64 %.027.in35, -4
  %42 = add nsw i64 %41, %38
  %43 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %.027.3
  %44 = load i64, ptr %43, align 8, !tbaa !8
  %45 = add nsw i64 %44, %41
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3.not = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3.not, label %._crit_edge38.unr-lcssa, label %.lr.ph37, !llvm.loop !15

46:                                               ; preds = %._crit_edge38.thread, %._crit_edge38
  %.029.lcssa54 = phi i64 [ 0, %._crit_edge38.thread ], [ %.lcssa68, %._crit_edge38 ]
  %47 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.029.lcssa54)
  %48 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %47, ptr noundef nonnull @.str)
  br label %71

49:                                               ; preds = %._crit_edge38
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  store i64 %.lcssa68, ptr %1, align 8, !tbaa !8
  br i1 %15, label %.lr.ph46, label %._crit_edge47

._crit_edge47:                                    ; preds = %.lr.ph46, %.thread, %49
  %50 = phi i64 [ %.lcssa68, %49 ], [ 0, %.thread ], [ %67, %.lr.ph46 ]
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %50)
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %51, ptr noundef nonnull @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  br label %71

.lr.ph46:                                         ; preds = %49, %.lr.ph46
  %.02544 = phi i64 [ %68, %.lr.ph46 ], [ 0, %49 ]
  %.02643 = phi i64 [ %59, %.lr.ph46 ], [ 0, %49 ]
  %.142 = phi i64 [ %61, %.lr.ph46 ], [ %.lcssa67, %49 ]
  %.13041 = phi i64 [ %62, %.lr.ph46 ], [ %.lcssa68, %49 ]
  %53 = load i64, ptr @K, align 8, !tbaa !8
  %54 = add nsw i64 %53, 1
  %55 = sdiv i64 %.02544, %54
  %56 = getelementptr inbounds [500000 x i64], ptr @c, i64 0, i64 %.02544
  %57 = load i64, ptr %56, align 8, !tbaa !8
  %58 = mul nsw i64 %57, %55
  %59 = add nsw i64 %58, %.02643
  %60 = add nsw i64 %55, 1
  %61 = sub nsw i64 %.142, %57
  %62 = sub nsw i64 %.13041, %61
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %63 = add nsw i64 %59, %62
  %64 = mul nsw i64 %61, %60
  %65 = add nsw i64 %63, %64
  store i64 %65, ptr %2, align 8, !tbaa !8
  %66 = 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)
  %67 = load i64, ptr %66, align 8, !tbaa !8
  store i64 %67, ptr %1, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %68 = add nuw nsw i64 %.02544, 1
  %69 = load i64, ptr @N, align 8, !tbaa !8
  %70 = icmp slt i64 %68, %69
  br i1 %70, label %.lr.ph46, label %._crit_edge47, !llvm.loop !16

71:                                               ; preds = %._crit_edge47, %46
  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 @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #5

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

; 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

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


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