program ABC_092_B_Chocolate
   implicit none
   integer(8) N, D, X, total, i, j, k
   integer(8), allocatable :: A(:), countA(:), dayAk(:, :) 
   read(*, *) N
   read(*, *) D, X
   allocate (A(1:N))
   allocate (countA(1:N))
   allocate (dayAk(1:N,1:D))
   do i = 1, N
      read(*, *) A(i)
   end do
   countA(:) = 0
   do k = 1, N
      do j = 1, D
	     dayAk(k, j) = (j - 1) * A(k) + 1
         if(dayAk(k, j) <= D) then
	          countA(k) = countA(k) + 1
	     end if
      end do
   end do
   total = 0
   total = sum(countA) + X
   write(*, *)total
end program ABC_092_B_Chocolate
; 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"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEcounta.0 = internal unnamed_addr global ptr null
@_QFEcounta.8 = internal unnamed_addr global i64 0
@_QFEdayak.0 = internal unnamed_addr global ptr null
@_QFEdayak.8 = internal unnamed_addr global i64 0
@_QQcl.10076000be37fade6d44c6b8523bf697 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6143/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.10076000be37fade6d44c6b8523bf697, i32 5)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %7 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.10076000be37fade6d44c6b8523bf697, i32 6)
  %8 = call i1 @_FortranAioInputInteger(ptr %7, ptr nonnull %1, i32 8)
  %9 = call i1 @_FortranAioInputInteger(ptr %7, ptr nonnull %3, i32 8)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %7)
  %11 = load i64, ptr %2, align 8, !tbaa !3
  %12 = call i64 @llvm.smax.i64(i64 %11, i64 0)
  %13 = shl i64 %12, 3
  %14 = call ptr @malloc(i64 %13)
  store ptr %14, ptr @_QFEa.0, align 8, !tbaa !7
  %15 = call ptr @malloc(i64 %13)
  store ptr %15, ptr @_QFEcounta.0, align 8, !tbaa !7
  store i64 %12, ptr @_QFEcounta.8, align 8, !tbaa !7
  %16 = load i64, ptr %1, align 8, !tbaa !3
  %17 = call i64 @llvm.smax.i64(i64 %16, i64 0)
  %18 = mul i64 %17, %13
  %19 = call ptr @malloc(i64 %18)
  store ptr %19, ptr @_QFEdayak.0, align 8, !tbaa !7
  store i64 %12, ptr @_QFEdayak.8, align 8, !tbaa !7
  %20 = icmp sgt i64 %11, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %21 = phi i64 [ %27, %.lr.ph ], [ 1, %0 ]
  %22 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.10076000be37fade6d44c6b8523bf697, i32 11)
  %.unpack424 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %23 = add i64 %21, -1
  %24 = getelementptr i64, ptr %.unpack424, i64 %23
  %25 = call i1 @_FortranAioInputInteger(ptr %22, ptr %24, i32 8)
  %26 = call i32 @_FortranAioEndIoStatement(ptr %22)
  %27 = add nuw i64 %21, 1
  %exitcond.not = icmp eq i64 %21, %11
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.unpack.pre = load ptr, ptr @_QFEcounta.0, align 8, !tbaa !7
  %.unpack351.unpack.unpack353.pre = load i64, ptr @_QFEcounta.8, align 8, !tbaa !7
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.unpack351.unpack.unpack353 = phi i64 [ %.unpack351.unpack.unpack353.pre, %._crit_edge.loopexit ], [ %12, %0 ]
  %.unpack = phi ptr [ %.unpack.pre, %._crit_edge.loopexit ], [ %15, %0 ]
  %.not445 = icmp slt i64 %.unpack351.unpack.unpack353, 1
  br i1 %.not445, label %._crit_edge438, label %.lr.ph437.preheader

.lr.ph437.preheader:                              ; preds = %._crit_edge
  %28 = shl nuw i64 %.unpack351.unpack.unpack353, 3
  call void @llvm.memset.p0.i64(ptr align 8 %.unpack, i8 0, i64 %28, i1 false), !tbaa !3
  br label %._crit_edge438

._crit_edge438:                                   ; preds = %.lr.ph437.preheader, %._crit_edge
  %29 = load i64, ptr %2, align 8, !tbaa !3
  %30 = icmp sgt i64 %29, 0
  br i1 %30, label %.lr.ph443, label %._crit_edge444

.lr.ph443:                                        ; preds = %._crit_edge438
  %.unpack368 = load ptr, ptr @_QFEa.0, align 8
  %.unpack380 = load ptr, ptr @_QFEdayak.0, align 8
  %.unpack387.unpack.unpack390 = load i64, ptr @_QFEdayak.8, align 8
  %31 = load i64, ptr %1, align 8, !tbaa !3
  %32 = icmp sgt i64 %31, 0
  br i1 %32, label %.lr.ph443.split, label %._crit_edge444

.lr.ph443.splitthread-pre-split:                  ; preds = %._crit_edge441
  %33 = add nuw i64 %35, 1
  %.pr = load i64, ptr %1, align 8, !tbaa !3
  br label %.lr.ph443.split

.lr.ph443.split:                                  ; preds = %.lr.ph443, %.lr.ph443.splitthread-pre-split
  %34 = phi i64 [ %.pr, %.lr.ph443.splitthread-pre-split ], [ %31, %.lr.ph443 ]
  %35 = phi i64 [ %33, %.lr.ph443.splitthread-pre-split ], [ 1, %.lr.ph443 ]
  %36 = icmp sgt i64 %34, 0
  br i1 %36, label %.lr.ph440, label %._crit_edge441

.lr.ph440:                                        ; preds = %.lr.ph443.split
  %37 = add i64 %35, -1
  %38 = getelementptr i64, ptr %.unpack368, i64 %37
  %39 = add i64 %35, -1
  %40 = add i64 %35, -1
  %41 = getelementptr i64, ptr %.unpack, i64 %40
  br label %42

42:                                               ; preds = %.lr.ph440, %56
  %43 = phi i64 [ 1, %.lr.ph440 ], [ %57, %56 ]
  %44 = add nsw i64 %43, -1
  %45 = load i64, ptr %38, align 8, !tbaa !3
  %46 = mul i64 %45, %44
  %47 = add i64 %46, 1
  %48 = add i64 %43, -1
  %49 = mul i64 %48, %.unpack387.unpack.unpack390
  %50 = add i64 %39, %49
  %51 = getelementptr i64, ptr %.unpack380, i64 %50
  store i64 %47, ptr %51, align 8, !tbaa !3
  %52 = load i64, ptr %1, align 8, !tbaa !3
  %.not = icmp sgt i64 %47, %52
  br i1 %.not, label %56, label %53

53:                                               ; preds = %42
  %54 = load i64, ptr %41, align 8, !tbaa !3
  %55 = add i64 %54, 1
  store i64 %55, ptr %41, align 8, !tbaa !3
  br label %56

56:                                               ; preds = %53, %42
  %57 = add nuw i64 %43, 1
  %exitcond447.not = icmp eq i64 %43, %34
  br i1 %exitcond447.not, label %._crit_edge441, label %42

._crit_edge441:                                   ; preds = %56, %.lr.ph443.split
  %exitcond448.not = icmp eq i64 %35, %29
  br i1 %exitcond448.not, label %._crit_edge444, label %.lr.ph443.splitthread-pre-split, !llvm.loop !9

._crit_edge444:                                   ; preds = %._crit_edge441, %.lr.ph443, %._crit_edge438
  %58 = icmp sgt i64 %.unpack351.unpack.unpack353, 0
  br i1 %58, label %.lr.ph.i.preheader, label %_FortranASumInteger8x1_contract_simplified.exit

.lr.ph.i.preheader:                               ; preds = %._crit_edge444
  %min.iters.check = icmp ult i64 %.unpack351.unpack.unpack353, 4
  br i1 %min.iters.check, label %.lr.ph.i.preheader453, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %.unpack351.unpack.unpack353, -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %62, %vector.body ]
  %vec.phi451 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %63, %vector.body ]
  %59 = shl i64 %index, 3
  %60 = getelementptr i8, ptr %.unpack, i64 %59
  %wide.load = load <2 x i64>, ptr %60, align 8, !tbaa !3
  %61 = getelementptr i64, ptr %60, i64 2
  %wide.load452 = load <2 x i64>, ptr %61, align 8, !tbaa !3
  %62 = add <2 x i64> %wide.load, %vec.phi
  %63 = add <2 x i64> %wide.load452, %vec.phi451
  %index.next = add nuw i64 %index, 4
  %64 = icmp eq i64 %index.next, %n.vec
  br i1 %64, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %63, %62
  %65 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %.unpack351.unpack.unpack353, %n.vec
  br i1 %cmp.n, label %_FortranASumInteger8x1_contract_simplified.exit, label %.lr.ph.i.preheader453

.lr.ph.i.preheader453:                            ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i64 [ 0, %.lr.ph.i.preheader ], [ %65, %middle.block ]
  %.ph454 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader453, %.lr.ph.i
  %66 = phi i64 [ %71, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader453 ]
  %67 = phi i64 [ %72, %.lr.ph.i ], [ %.ph454, %.lr.ph.i.preheader453 ]
  %68 = shl i64 %67, 3
  %69 = getelementptr i8, ptr %.unpack, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !3
  %71 = add i64 %70, %66
  %72 = add nuw nsw i64 %67, 1
  %exitcond.not.i = icmp eq i64 %72, %.unpack351.unpack.unpack353
  br i1 %exitcond.not.i, label %_FortranASumInteger8x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !14

_FortranASumInteger8x1_contract_simplified.exit:  ; preds = %.lr.ph.i, %middle.block, %._crit_edge444
  %.lcssa.i = phi i64 [ 0, %._crit_edge444 ], [ %65, %middle.block ], [ %71, %.lr.ph.i ]
  %73 = load i64, ptr %3, align 8, !tbaa !3
  %74 = add i64 %73, %.lcssa.i
  %75 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.10076000be37fade6d44c6b8523bf697, i32 24)
  %76 = call i1 @_FortranAioOutputInteger64(ptr %75, i64 %74)
  %77 = call i32 @_FortranAioEndIoStatement(ptr %75)
  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 @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(none) }

!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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unswitch.partial.disable"}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !13, !12}
