; LLVM IR from eyangch/competitive-programming :: Codeforces/1677 (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" }

@MOD = external dso_local global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@V = external dso_local global [1000000 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 i8, align 1
  %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
  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 = %129, %127, %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 %130

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 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %25

25:                                               ; preds = %34, %22
  %26 = load i64, ptr %2, 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 %2) #7
  br label %37

30:                                               ; preds = %25
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = getelementptr inbounds [1000000 x i64], ptr @V, 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 %2, align 8, !tbaa !8
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %2, align 8, !tbaa !8
  br label %25, !llvm.loop !11

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #7
  store i8 1, ptr %3, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %38 = load i64, ptr @N, align 8, !tbaa !8
  %39 = sub nsw i64 %38, 1
  store i64 %39, ptr %4, align 8, !tbaa !8
  br label %40

40:                                               ; preds = %77, %37
  %41 = load i64, ptr %4, align 8, !tbaa !8
  %42 = icmp sge i64 %41, 0
  br i1 %42, label %44, label %43

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

44:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %45 = load i64, ptr %4, align 8, !tbaa !8
  %46 = load i64, ptr @K, align 8, !tbaa !8
  %47 = add nsw i64 %45, %46
  store i64 %47, ptr %5, align 8, !tbaa !8
  %48 = load i64, ptr %5, align 8, !tbaa !8
  %49 = load i64, ptr @N, align 8, !tbaa !8
  %50 = icmp sge i64 %48, %49
  br i1 %50, label %51, label %63

51:                                               ; preds = %44
  %52 = load i64, ptr %4, align 8, !tbaa !8
  %53 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !8
  %55 = icmp ne i64 %54, 0
  br i1 %55, label %56, label %62

56:                                               ; preds = %51
  %57 = load i64, ptr %4, align 8, !tbaa !8
  %58 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !8
  %60 = icmp ne i64 %59, -1
  br i1 %60, label %61, label %62

61:                                               ; preds = %56
  store i8 0, ptr %3, align 1, !tbaa !13
  br label %62

62:                                               ; preds = %61, %56, %51
  br label %69

63:                                               ; preds = %44
  %64 = load i64, ptr %4, align 8, !tbaa !8
  %65 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !8
  %67 = load i64, ptr %5, align 8, !tbaa !8
  %68 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %67
  store i64 %66, ptr %68, align 8, !tbaa !8
  br label %69

69:                                               ; preds = %63, %62
  %70 = load i64, ptr %4, align 8, !tbaa !8
  %71 = load i64, ptr @K, align 8, !tbaa !8
  %72 = icmp slt i64 %70, %71
  br i1 %72, label %73, label %76

73:                                               ; preds = %69
  %74 = load i64, ptr %4, align 8, !tbaa !8
  %75 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %74
  store i64 0, ptr %75, align 8, !tbaa !8
  br label %76

76:                                               ; preds = %73, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %77

77:                                               ; preds = %76
  %78 = load i64, ptr %4, align 8, !tbaa !8
  %79 = add nsw i64 %78, -1
  store i64 %79, ptr %4, align 8, !tbaa !8
  br label %40, !llvm.loop !15

80:                                               ; preds = %43
  %81 = load i8, ptr %3, align 1, !tbaa !13, !range !16, !noundef !17
  %82 = trunc i8 %81 to i1
  br i1 %82, label %86, label %83

83:                                               ; preds = %80
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  %85 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %84, i8 noundef signext 10)
  store i32 2, ptr %6, align 4
  br label %127, !llvm.loop !18

86:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 1, 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
  br label %87

87:                                               ; preds = %120, %86
  %88 = load i64, ptr %8, align 8, !tbaa !8
  %89 = load i64, ptr @N, align 8, !tbaa !8
  %90 = icmp slt i64 %88, %89
  br i1 %90, label %92, label %91

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

92:                                               ; preds = %87
  %93 = load i64, ptr %8, align 8, !tbaa !8
  %94 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !8
  %96 = icmp eq i64 %95, 0
  br i1 %96, label %97, label %106

97:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %98 = load i64, ptr %8, align 8, !tbaa !8
  %99 = add nsw i64 %98, 1
  store i64 %99, ptr %9, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %100 = load i64, ptr @K, align 8, !tbaa !8
  %101 = add nsw i64 %100, 1
  store i64 %101, ptr %10, align 8, !tbaa !8
  %102 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %103 = load i64, ptr %102, align 8, !tbaa !8
  %104 = load i64, ptr %7, align 8, !tbaa !8
  %105 = mul nsw i64 %104, %103
  store i64 %105, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %106

106:                                              ; preds = %97, %92
  %107 = load i64, ptr %8, align 8, !tbaa !8
  %108 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !8
  %110 = icmp eq i64 %109, -1
  br i1 %110, label %111, label %116

111:                                              ; preds = %106
  %112 = load i64, ptr %8, align 8, !tbaa !8
  %113 = add nsw i64 %112, 1
  %114 = load i64, ptr %7, align 8, !tbaa !8
  %115 = mul nsw i64 %114, %113
  store i64 %115, ptr %7, align 8, !tbaa !8
  br label %116

116:                                              ; preds = %111, %106
  %117 = load i64, ptr @MOD, align 8, !tbaa !8
  %118 = load i64, ptr %7, align 8, !tbaa !8
  %119 = srem i64 %118, %117
  store i64 %119, ptr %7, align 8, !tbaa !8
  br label %120

120:                                              ; preds = %116
  %121 = load i64, ptr %8, align 8, !tbaa !8
  %122 = add nsw i64 %121, 1
  store i64 %122, ptr %8, align 8, !tbaa !8
  br label %87, !llvm.loop !19

123:                                              ; preds = %91
  %124 = load i64, ptr %7, align 8, !tbaa !8
  %125 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %124)
  %126 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %125, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  store i32 0, ptr %6, align 4
  br label %127

127:                                              ; preds = %123, %83
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #7
  %128 = load i32, ptr %6, align 4
  switch i32 %128, label %132 [
    i32 0, label %129
    i32 2, label %18
  ]

129:                                              ; preds = %127
  br label %18, !llvm.loop !18

130:                                              ; preds = %18
  %131 = load i32, ptr %1, align 4
  ret i32 %131

132:                                              ; preds = %127
  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 noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

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

; 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: 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 = !{!"bool", !10, i64 0}
!15 = distinct !{!15, !12}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !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" }

@MOD = external dso_local local_unnamed_addr global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@V = external dso_local global [1000000 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 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) @T)
  %10 = load i64, ptr @T, align 8, !tbaa !8
  %11 = add nsw i64 %10, -1
  store i64 %11, ptr @T, align 8, !tbaa !8
  %.not50 = icmp eq i64 %10, 0
  br i1 %.not50, label %._crit_edge53, label %.lr.ph52

.lr.ph52:                                         ; preds = %0, %58
  %12 = 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)
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(8) @K)
  %14 = load i64, ptr @N, align 8, !tbaa !8
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge48

.preheader37:                                     ; preds = %.lr.ph
  %16 = icmp sgt i64 %21, 0
  br i1 %16, label %.lr.ph43, label %._crit_edge48

.lr.ph43:                                         ; preds = %.preheader37
  %17 = load i64, ptr @K, align 8, !tbaa !8
  br label %23

.lr.ph:                                           ; preds = %.lr.ph52, %.lr.ph
  %.02638 = phi i64 [ %20, %.lr.ph ], [ 0, %.lr.ph52 ]
  %18 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %.02638
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %18)
  %20 = add nuw nsw i64 %.02638, 1
  %21 = load i64, ptr @N, align 8, !tbaa !8
  %22 = icmp slt i64 %20, %21
  br i1 %22, label %.lr.ph, label %.preheader37, !llvm.loop !11

._crit_edge:                                      ; preds = %34
  br i1 %.129, label %.preheader, label %36

.preheader:                                       ; preds = %._crit_edge
  br i1 %16, label %.lr.ph47, label %._crit_edge48

23:                                               ; preds = %.lr.ph43, %34
  %.027.in41 = phi i64 [ %21, %.lr.ph43 ], [ %.02742, %34 ]
  %.02840 = phi i1 [ true, %.lr.ph43 ], [ %.129, %34 ]
  %.02742 = add nsw i64 %.027.in41, -1
  %24 = add nsw i64 %17, %.02742
  %.not33 = icmp slt i64 %24, %21
  %25 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %.02742
  %26 = load i64, ptr %25, align 8, !tbaa !8
  br i1 %.not33, label %29, label %27

27:                                               ; preds = %23
  switch i64 %26, label %28 [
    i64 0, label %31
    i64 -1, label %31
  ]

28:                                               ; preds = %27
  br label %31

29:                                               ; preds = %23
  %30 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %24
  store i64 %26, ptr %30, align 8, !tbaa !8
  br label %31

31:                                               ; preds = %27, %27, %28, %29
  %.129 = phi i1 [ false, %28 ], [ %.02840, %27 ], [ %.02840, %29 ], [ %.02840, %27 ]
  %.not36 = icmp sgt i64 %.027.in41, %17
  br i1 %.not36, label %34, label %32

32:                                               ; preds = %31
  %33 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %.02742
  store i64 0, ptr %33, align 8, !tbaa !8
  br label %34

34:                                               ; preds = %32, %31
  %35 = icmp ugt i64 %.027.in41, 1
  br i1 %35, label %23, label %._crit_edge, !llvm.loop !13

36:                                               ; preds = %._crit_edge
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  br label %58, !llvm.loop !14

._crit_edge48:                                    ; preds = %50, %.lr.ph52, %.preheader37, %.preheader
  %.025.lcssa = phi i64 [ 1, %.preheader ], [ 1, %.preheader37 ], [ 1, %.lr.ph52 ], [ %56, %50 ]
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.025.lcssa)
  br label %58

.lr.ph47:                                         ; preds = %.preheader, %50
  %39 = phi i64 [ %51, %50 ], [ %21, %.preheader ]
  %.046 = phi i64 [ %.pre-phi, %50 ], [ 0, %.preheader ]
  %.02545 = phi i64 [ %56, %50 ], [ 1, %.preheader ]
  %40 = getelementptr inbounds [1000000 x i64], ptr @V, i64 0, i64 %.046
  %41 = load i64, ptr %40, align 8, !tbaa !8
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %43, label %.lr.ph47._crit_edge

.lr.ph47._crit_edge:                              ; preds = %.lr.ph47
  %.pre57 = add nuw nsw i64 %.046, 1
  br label %50

43:                                               ; preds = %.lr.ph47
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %44 = add nuw nsw i64 %.046, 1
  store i64 %44, ptr %1, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %45 = load i64, ptr @K, align 8, !tbaa !8
  %46 = add nsw i64 %45, 1
  store i64 %46, ptr %2, align 8, !tbaa !8
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %48 = load i64, ptr %47, align 8, !tbaa !8
  %49 = mul nsw i64 %48, %.02545
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %.pre = load i64, ptr %40, align 8, !tbaa !8
  %.pre56 = load i64, ptr @N, align 8, !tbaa !8
  br label %50

50:                                               ; preds = %.lr.ph47._crit_edge, %43
  %.pre-phi = phi i64 [ %.pre57, %.lr.ph47._crit_edge ], [ %44, %43 ]
  %51 = phi i64 [ %39, %.lr.ph47._crit_edge ], [ %.pre56, %43 ]
  %52 = phi i64 [ %41, %.lr.ph47._crit_edge ], [ %.pre, %43 ]
  %.1 = phi i64 [ %.02545, %.lr.ph47._crit_edge ], [ %49, %43 ]
  %53 = icmp eq i64 %52, -1
  %54 = select i1 %53, i64 %.pre-phi, i64 1
  %.2 = mul nsw i64 %54, %.1
  %55 = load i64, ptr @MOD, align 8, !tbaa !8
  %56 = srem i64 %.2, %55
  %57 = icmp slt i64 %.pre-phi, %51
  br i1 %57, label %.lr.ph47, label %._crit_edge48, !llvm.loop !15

58:                                               ; preds = %._crit_edge48, %36
  %.sink = phi ptr [ %38, %._crit_edge48 ], [ %37, %36 ]
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %.sink, i8 noundef signext 10)
  %60 = load i64, ptr @T, align 8, !tbaa !8
  %61 = add nsw i64 %60, -1
  store i64 %61, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %60, 0
  br i1 %.not, label %._crit_edge53, label %.lr.ph52

._crit_edge53:                                    ; preds = %58, %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 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

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

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


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