program Digit_Sum_Replace
  implicit none
  integer :: m, i
  integer(8) :: d, c, tot = 0_8, cnt = -1_8, rup = 0_8
  read(*,*) m
  do i = 1, m
    read(*,*) d, c
    tot = tot+d*c
    cnt = cnt+c
  end do
  do while (tot > 9_8)
    rup = rup+tot/10_8
    tot = tot/10_8+mod(tot,10_8)
  end do
  write(*,'(i0)') cnt+rup
end program Digit_Sum_Replace
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEcnt = internal unnamed_addr global i64 -1
@_QFErup = internal unnamed_addr global i64 0
@_QFEtot = internal unnamed_addr global i64 0
@_QQcl.a97e688aa6f21fffbb5d987faf2b0bcd = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2960/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a97e688aa6f21fffbb5d987faf2b0bcd, i32 5)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %7 = load i32, ptr %3, align 4, !tbaa !3
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph.preheader, label %.thread-pre-split_crit_edge

.thread-pre-split_crit_edge:                      ; preds = %0
  %.pr.pre = load i64, ptr @_QFEtot, align 8, !tbaa !3
  br label %thread-pre-split

.lr.ph.preheader:                                 ; preds = %0
  %9 = zext i32 %7 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %10 = phi i64 [ %22, %.lr.ph ], [ %9, %.lr.ph.preheader ]
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a97e688aa6f21fffbb5d987faf2b0bcd, i32 7)
  %12 = call i1 @_FortranAioInputInteger(ptr %11, ptr nonnull %2, i32 8)
  %13 = call i1 @_FortranAioInputInteger(ptr %11, ptr nonnull %1, i32 8)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %15 = load i64, ptr @_QFEtot, align 8, !tbaa !3
  %16 = load i64, ptr %2, align 8, !tbaa !3
  %17 = load i64, ptr %1, align 8, !tbaa !3
  %18 = mul i64 %17, %16
  %19 = add i64 %18, %15
  store i64 %19, ptr @_QFEtot, align 8, !tbaa !3
  %20 = load i64, ptr @_QFEcnt, align 8, !tbaa !3
  %21 = add i64 %20, %17
  store i64 %21, ptr @_QFEcnt, align 8, !tbaa !3
  %22 = add nsw i64 %10, -1
  %23 = icmp ugt i64 %10, 1
  br i1 %23, label %.lr.ph, label %thread-pre-split

thread-pre-split:                                 ; preds = %.lr.ph, %.thread-pre-split_crit_edge
  %.pr = phi i64 [ %.pr.pre, %.thread-pre-split_crit_edge ], [ %19, %.lr.ph ]
  %24 = icmp sgt i64 %.pr, 9
  br i1 %24, label %.lr.ph2.preheader, label %32

.lr.ph2.preheader:                                ; preds = %thread-pre-split
  %_QFErup.promoted = load i64, ptr @_QFErup, align 8, !tbaa !3
  br label %.lr.ph2

.lr.ph2:                                          ; preds = %.lr.ph2.preheader, %.lr.ph2
  %25 = phi i64 [ %30, %.lr.ph2 ], [ %.pr, %.lr.ph2.preheader ]
  %26 = phi i64 [ %28, %.lr.ph2 ], [ %_QFErup.promoted, %.lr.ph2.preheader ]
  %27 = udiv i64 %25, 10
  %28 = add i64 %26, %27
  %29 = urem i64 %25, 10
  %30 = add nuw nsw i64 %27, %29
  %31 = icmp ugt i64 %30, 9
  br i1 %31, label %.lr.ph2, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph2
  store i64 %28, ptr @_QFErup, align 8, !tbaa !3
  store i64 %30, ptr @_QFEtot, align 8, !tbaa !3
  br label %32

32:                                               ; preds = %._crit_edge, %thread-pre-split
  %33 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.a97e688aa6f21fffbb5d987faf2b0bcd, i32 15)
  %34 = load i64, ptr @_QFEcnt, align 8, !tbaa !3
  %35 = load i64, ptr @_QFErup, align 8, !tbaa !3
  %36 = add i64 %35, %34
  %37 = call i1 @_FortranAioOutputInteger64(ptr %33, i64 %36)
  %38 = call i32 @_FortranAioEndIoStatement(ptr %33)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
