; LLVM IR from Tunghohin/Competitive_Coding :: Codeforces (cf1513_C)

; 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 i32, align 4
@dp = external dso_local global [15 x [200010 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() #0

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %8 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %10
  %12 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  %13 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %15
  %17 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %19

19:                                               ; preds = %28, %0
  %20 = load i32, ptr %3, align 4, !tbaa !8
  %21 = icmp sle i32 %20, 9
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %31

23:                                               ; preds = %19
  %24 = load i32, ptr %3, align 4, !tbaa !8
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 %25
  %27 = getelementptr inbounds [200010 x i32], ptr %26, i64 0, i64 0
  store i32 1, ptr %27, align 8, !tbaa !8
  br label %28

28:                                               ; preds = %23
  %29 = load i32, ptr %3, align 4, !tbaa !8
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !8
  br label %19, !llvm.loop !11

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %32

32:                                               ; preds = %77, %31
  %33 = load i32, ptr %4, align 4, !tbaa !8
  %34 = icmp sle i32 %33, 200000
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %80

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !8
  br label %37

37:                                               ; preds = %57, %36
  %38 = load i32, ptr %6, align 4, !tbaa !8
  %39 = icmp sle i32 %38, 8
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %37
  %42 = load i32, ptr %6, align 4, !tbaa !8
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 %44
  %46 = load i32, ptr %4, align 4, !tbaa !8
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200010 x i32], ptr %45, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !8
  %51 = load i32, ptr %6, align 4, !tbaa !8
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 %52
  %54 = load i32, ptr %4, align 4, !tbaa !8
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [200010 x i32], ptr %53, i64 0, i64 %55
  store i32 %50, ptr %56, align 4, !tbaa !8
  br label %57

57:                                               ; preds = %41
  %58 = load i32, ptr %6, align 4, !tbaa !8
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %6, align 4, !tbaa !8
  br label %37, !llvm.loop !13

60:                                               ; preds = %40
  %61 = load i32, ptr %4, align 4, !tbaa !8
  %62 = sub nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200010 x i32], ptr @dp, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !8
  %66 = load i32, ptr %4, align 4, !tbaa !8
  %67 = sub nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [200010 x i32], ptr getelementptr inbounds ([15 x [200010 x i32]], ptr @dp, i64 0, i64 1), i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !8
  %71 = add nsw i32 %65, %70
  %72 = load i32, ptr @mod, align 4, !tbaa !8
  %73 = srem i32 %71, %72
  %74 = load i32, ptr %4, align 4, !tbaa !8
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [200010 x i32], ptr getelementptr inbounds ([15 x [200010 x i32]], ptr @dp, i64 0, i64 9), i64 0, i64 %75
  store i32 %73, ptr %76, align 4, !tbaa !8
  br label %77

77:                                               ; preds = %60
  %78 = load i32, ptr %4, align 4, !tbaa !8
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %4, align 4, !tbaa !8
  br label %32, !llvm.loop !14

80:                                               ; preds = %35
  br label %81

81:                                               ; preds = %85, %80
  %82 = load i32, ptr %2, align 4, !tbaa !8
  %83 = add nsw i32 %82, -1
  store i32 %83, ptr %2, align 4, !tbaa !8
  %84 = icmp ne i32 %82, 0
  br i1 %84, label %85, label %86

85:                                               ; preds = %81
  call void @_Z5solvev()
  br label %81, !llvm.loop !15

86:                                               ; preds = %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %87 = load i32, ptr %1, align 4
  ret i32 %87
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #4 = { 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 #5 = { 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 = !{!"int", !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}


; 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 i32, align 4
@dp = external dso_local local_unnamed_addr global [15 x [200010 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() local_unnamed_addr #0

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
.preheader18:
  %0 = alloca i32, align 4
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #5
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %0)
  store i32 1, ptr @dp, align 16, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 800040), align 8, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 1600080), align 16, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 2400120), align 8, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 3200160), align 16, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 4000200), align 8, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 4800240), align 16, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 5600280), align 8, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 6400320), align 16, !tbaa !8
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 7200360), align 8, !tbaa !8
  %13 = load i32, ptr @mod, align 4, !tbaa !8
  %load_initial26 = load i32, ptr @dp, align 16
  %load_initial28 = load i32, ptr getelementptr inbounds (i8, ptr @dp, i64 800040), align 8
  br label %.preheader17

.preheader17:                                     ; preds = %.preheader18, %.preheader17
  %store_forwarded29 = phi i32 [ %load_initial28, %.preheader18 ], [ %20, %.preheader17 ]
  %store_forwarded27 = phi i32 [ %load_initial26, %.preheader18 ], [ %21, %.preheader17 ]
  %store_forwarded = phi i32 [ 1, %.preheader18 ], [ %32, %.preheader17 ]
  %14 = phi i32 [ 1, %.preheader18 ], [ %store_forwarded, %.preheader17 ]
  %15 = phi i32 [ 1, %.preheader18 ], [ %14, %.preheader17 ]
  %16 = phi i32 [ 1, %.preheader18 ], [ %15, %.preheader17 ]
  %17 = phi i32 [ 1, %.preheader18 ], [ %16, %.preheader17 ]
  %18 = phi i32 [ 1, %.preheader18 ], [ %17, %.preheader17 ]
  %19 = phi i32 [ 1, %.preheader18 ], [ %18, %.preheader17 ]
  %20 = phi i32 [ 1, %.preheader18 ], [ %19, %.preheader17 ]
  %21 = phi i32 [ 1, %.preheader18 ], [ %20, %.preheader17 ]
  %indvars.iv = phi i64 [ 1, %.preheader18 ], [ %indvars.iv.next, %.preheader17 ]
  %22 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 0, i64 %indvars.iv
  store i32 %21, ptr %22, align 4, !tbaa !8
  %23 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 1, i64 %indvars.iv
  store i32 %20, ptr %23, align 4, !tbaa !8
  %24 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 2, i64 %indvars.iv
  store i32 %19, ptr %24, align 4, !tbaa !8
  %25 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 3, i64 %indvars.iv
  store i32 %18, ptr %25, align 4, !tbaa !8
  %26 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 4, i64 %indvars.iv
  store i32 %17, ptr %26, align 4, !tbaa !8
  %27 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 5, i64 %indvars.iv
  store i32 %16, ptr %27, align 4, !tbaa !8
  %28 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 6, i64 %indvars.iv
  store i32 %15, ptr %28, align 4, !tbaa !8
  %29 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 7, i64 %indvars.iv
  store i32 %14, ptr %29, align 4, !tbaa !8
  %30 = getelementptr inbounds [15 x [200010 x i32]], ptr @dp, i64 0, i64 8, i64 %indvars.iv
  store i32 %store_forwarded, ptr %30, align 4, !tbaa !8
  %31 = add nsw i32 %store_forwarded29, %store_forwarded27
  %32 = srem i32 %31, %13
  %33 = getelementptr inbounds [200010 x i32], ptr getelementptr inbounds (i8, ptr @dp, i64 7200360), i64 0, i64 %indvars.iv
  store i32 %32, ptr %33, align 4, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 200001
  br i1 %exitcond.not, label %.preheader, label %.preheader17, !llvm.loop !11

.preheader:                                       ; preds = %.preheader17
  %34 = load i32, ptr %0, align 4, !tbaa !8
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %0, align 4, !tbaa !8
  %.not22 = icmp eq i32 %34, 0
  br i1 %.not22, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  call void @_Z5solvev()
  %36 = load i32, ptr %0, align 4, !tbaa !8
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr %0, align 4, !tbaa !8
  %.not = icmp eq i32 %36, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #5
  ret i32 0
}

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #4 = { 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 #5 = { 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 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass