program main
  implicit none
  integer :: n, m, c, i, res
  integer, allocatable :: b(:), ai(:)
  read (*, *) n, m, c
  allocate (b(m), ai(m))
  read (*, *) b(:)
  res = 0
  do i = 1, n
    read (*, *) ai(:)
    if (dot_product(ai, b) > -c) res = res + 1
  end do

  write (*, "(i0)") res
end program main

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

@_QFEai.0 = internal unnamed_addr global ptr null
@_QFEai.8 = internal unnamed_addr global i64 0
@_QFEb.0 = internal unnamed_addr global ptr null
@_QFEb.8 = internal unnamed_addr global i64 0
@_QQcl.a4acef4814146ccbb23925520936c03d = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4739/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_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 { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a4acef4814146ccbb23925520936c03d, i32 5)
  %7 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %5, i32 4)
  %8 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %4, i32 4)
  %9 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %3, i32 4)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %11 = load i32, ptr %4, align 4, !tbaa !3
  %12 = call i32 @llvm.smax.i32(i32 %11, i32 0)
  %13 = zext i32 %12 to i64
  %14 = shl nuw nsw i64 %13, 2
  %15 = call ptr @malloc(i64 %14)
  store ptr %15, ptr @_QFEb.0, align 8, !tbaa !7
  store i64 %13, ptr @_QFEb.8, align 8, !tbaa !7
  %16 = call ptr @malloc(i64 %14)
  store ptr %16, ptr @_QFEai.0, align 8, !tbaa !7
  store i64 %13, ptr @_QFEai.8, align 8, !tbaa !7
  %17 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a4acef4814146ccbb23925520936c03d, i32 7)
  %.unpack = load ptr, ptr @_QFEb.0, align 8, !tbaa !7
  %.unpack255.unpack.unpack257 = load i64, ptr @_QFEb.8, align 8, !tbaa !7
  %18 = call i64 @llvm.smax.i64(i64 %.unpack255.unpack.unpack257, i64 0)
  store ptr %.unpack, ptr %2, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 1
  store i64 %18, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %19 = call i1 @_FortranAioInputDescriptor(ptr %17, ptr nonnull %2)
  %20 = call i32 @_FortranAioEndIoStatement(ptr %17)
  %21 = load i32, ptr %5, align 4, !tbaa !3
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %23 = zext i32 %21 to i64
  %.fca.1.gep113 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  %.fca.2.gep115 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  %.fca.3.gep117 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  %.fca.4.gep119 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  %.fca.5.gep121 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  %.fca.6.gep123 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  %.fca.7.0.0.gep125 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  %.fca.7.0.1.gep127 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  %.fca.7.0.2.gep129 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  br label %24

24:                                               ; preds = %.lr.ph, %_FortranADotProductInteger4_contract_i32_i32_simplified.exit
  %25 = phi i64 [ %23, %.lr.ph ], [ %56, %_FortranADotProductInteger4_contract_i32_i32_simplified.exit ]
  %.0305 = phi i32 [ 0, %.lr.ph ], [ %spec.select, %_FortranADotProductInteger4_contract_i32_i32_simplified.exit ]
  %26 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a4acef4814146ccbb23925520936c03d, i32 10)
  %.unpack260 = load ptr, ptr @_QFEai.0, align 8, !tbaa !7
  %.unpack267.unpack.unpack269 = load i64, ptr @_QFEai.8, align 8, !tbaa !7
  %27 = call i64 @llvm.smax.i64(i64 %.unpack267.unpack.unpack269, i64 0)
  store ptr %.unpack260, ptr %1, align 8, !tbaa !7
  store i64 4, ptr %.fca.1.gep113, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep115, align 8, !tbaa !7
  store i8 1, ptr %.fca.3.gep117, align 4, !tbaa !7
  store i8 9, ptr %.fca.4.gep119, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep121, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep123, align 1, !tbaa !7
  store i64 1, ptr %.fca.7.0.0.gep125, align 8, !tbaa !7
  store i64 %27, ptr %.fca.7.0.1.gep127, align 8, !tbaa !7
  store i64 4, ptr %.fca.7.0.2.gep129, align 8, !tbaa !7
  %28 = call i1 @_FortranAioInputDescriptor(ptr %26, ptr nonnull %1)
  %29 = call i32 @_FortranAioEndIoStatement(ptr %26)
  %.unpack272 = load ptr, ptr @_QFEai.0, align 8, !tbaa !7
  %.unpack279.unpack.unpack281 = load i64, ptr @_QFEai.8, align 8, !tbaa !7
  %.unpack284 = load ptr, ptr @_QFEb.0, align 8, !tbaa !7
  %30 = icmp sgt i64 %.unpack279.unpack.unpack281, 0
  br i1 %30, label %.lr.ph.i.preheader, label %_FortranADotProductInteger4_contract_i32_i32_simplified.exit

.lr.ph.i.preheader:                               ; preds = %24
  %min.iters.check = icmp ult i64 %.unpack279.unpack.unpack281, 8
  br i1 %min.iters.check, label %.lr.ph.i.preheader310, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %.unpack279.unpack.unpack281, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %38, %vector.body ]
  %vec.phi306 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %39, %vector.body ]
  %31 = shl i64 %index, 2
  %32 = getelementptr i8, ptr %.unpack272, i64 %31
  %wide.load = load <4 x i32>, ptr %32, align 4, !tbaa !3
  %33 = getelementptr i32, ptr %32, i64 4
  %wide.load307 = load <4 x i32>, ptr %33, align 4, !tbaa !3
  %34 = getelementptr i8, ptr %.unpack284, i64 %31
  %wide.load308 = load <4 x i32>, ptr %34, align 4, !tbaa !3
  %35 = getelementptr i32, ptr %34, i64 4
  %wide.load309 = load <4 x i32>, ptr %35, align 4, !tbaa !3
  %36 = mul <4 x i32> %wide.load308, %wide.load
  %37 = mul <4 x i32> %wide.load309, %wide.load307
  %38 = add <4 x i32> %36, %vec.phi
  %39 = add <4 x i32> %37, %vec.phi306
  %index.next = add nuw i64 %index, 8
  %40 = icmp eq i64 %index.next, %n.vec
  br i1 %40, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %39, %38
  %41 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %.unpack279.unpack.unpack281, %n.vec
  br i1 %cmp.n, label %_FortranADotProductInteger4_contract_i32_i32_simplified.exit, label %.lr.ph.i.preheader310

.lr.ph.i.preheader310:                            ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i32 [ 0, %.lr.ph.i.preheader ], [ %41, %middle.block ]
  %.ph311 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader310, %.lr.ph.i
  %42 = phi i32 [ %50, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader310 ]
  %43 = phi i64 [ %51, %.lr.ph.i ], [ %.ph311, %.lr.ph.i.preheader310 ]
  %44 = shl i64 %43, 2
  %45 = getelementptr i8, ptr %.unpack272, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !3
  %47 = getelementptr i8, ptr %.unpack284, i64 %44
  %48 = load i32, ptr %47, align 4, !tbaa !3
  %49 = mul i32 %48, %46
  %50 = add i32 %49, %42
  %51 = add nuw nsw i64 %43, 1
  %exitcond.not.i = icmp eq i64 %51, %.unpack279.unpack.unpack281
  br i1 %exitcond.not.i, label %_FortranADotProductInteger4_contract_i32_i32_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranADotProductInteger4_contract_i32_i32_simplified.exit: ; preds = %.lr.ph.i, %middle.block, %24
  %.lcssa.i = phi i32 [ 0, %24 ], [ %41, %middle.block ], [ %50, %.lr.ph.i ]
  %52 = load i32, ptr %3, align 4, !tbaa !3
  %53 = sub i32 0, %52
  %54 = icmp sgt i32 %.lcssa.i, %53
  %55 = zext i1 %54 to i32
  %spec.select = add i32 %.0305, %55
  %56 = add nsw i64 %25, -1
  %57 = icmp sgt i64 %25, 1
  br i1 %57, label %24, label %._crit_edge

._crit_edge:                                      ; preds = %_FortranADotProductInteger4_contract_i32_i32_simplified.exit, %0
  %.0.lcssa = phi i32 [ 0, %0 ], [ %spec.select, %_FortranADotProductInteger4_contract_i32_i32_simplified.exit ]
  %58 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.a4acef4814146ccbb23925520936c03d, i32 14)
  %59 = call i1 @_FortranAioOutputInteger32(ptr %58, i32 %.0.lcssa)
  %60 = call i32 @_FortranAioEndIoStatement(ptr %58)
  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 i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) 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 nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

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

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 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, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
