program main
      implicit none
      integer(4) :: n, k, i, j, d
      integer(4), allocatable :: cnt(:), a(:)

      read *, n, k

      allocate( cnt(n) )
      cnt = 0

      do i = 1, k
        read *, d
        allocate( a(d) )
        read *, a

        do j = 1, d
          cnt(a(j)) = cnt(a(j)) + 1
        end do

        deallocate( a )
      end do
     
      j = 0
      do i = 1, n
        if( cnt(i) == 0 ) then
          j = j + 1
        end if
      end do 
      print *, j

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"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.8 = internal unnamed_addr global i64 0
@_QFEcnt.0 = internal unnamed_addr global ptr null
@_QFEcnt.7 = internal unnamed_addr global i64 1
@_QQcl.ba5c5c7c349b303cae83682e8102faae = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1498/source.f\00"
@_QQcl.16373402fa3425c6e46827601abb88fa = linkonce constant [76 x i8] c"array left hand side must be allocated when the right hand side is a scalar\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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ba5c5c7c349b303cae83682e8102faae, i32 6)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %4, i32 4)
  %7 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %3, i32 4)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %9 = load i32, ptr %4, align 4, !tbaa !3
  %10 = call i32 @llvm.smax.i32(i32 %9, i32 0)
  %11 = zext i32 %10 to i64
  %12 = shl nuw nsw i64 %11, 2
  %13 = call ptr @malloc(i64 %12)
  store ptr %13, ptr @_QFEcnt.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEcnt.7, align 8, !tbaa !7
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %16, label %.preheader

.preheader:                                       ; preds = %0
  %.not444 = icmp slt i32 %9, 1
  br i1 %.not444, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %14 = call i64 @llvm.smax.i64(i64 %11, i64 1)
  %15 = shl nuw nsw i64 %14, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 %13, i8 0, i64 %15, i1 false), !tbaa !3
  br label %.loopexit

16:                                               ; preds = %0
  %17 = call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.ba5c5c7c349b303cae83682e8102faae, i32 9)
  %.unpack422.unpack.unpack = load i64, ptr @_QFEcnt.7, align 8, !tbaa !7
  %18 = icmp slt i32 %9, 1
  %19 = select i1 %18, i64 1, i64 %.unpack422.unpack.unpack
  store ptr null, ptr @_QFEcnt.0, align 8, !tbaa !7
  store i64 %19, ptr @_QFEcnt.7, align 8, !tbaa !7
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.preheader, %.preheader, %16
  %20 = load i32, ptr %3, align 4, !tbaa !3
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph438, label %._crit_edge439

.lr.ph438:                                        ; preds = %.loopexit
  %22 = zext i32 %20 to i64
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  %.fca.7.0.0.gep = 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.gep = 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.gep = 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 %23

23:                                               ; preds = %.lr.ph438, %._crit_edge
  %24 = phi i64 [ %22, %.lr.ph438 ], [ %64, %._crit_edge ]
  %25 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ba5c5c7c349b303cae83682e8102faae, i32 12)
  %26 = call i1 @_FortranAioInputInteger(ptr %25, ptr nonnull %2, i32 4)
  %27 = call i32 @_FortranAioEndIoStatement(ptr %25)
  %28 = load i32, ptr %2, align 4, !tbaa !3
  %29 = call i32 @llvm.smax.i32(i32 %28, i32 0)
  %30 = zext i32 %29 to i64
  %31 = shl nuw nsw i64 %30, 2
  %32 = call ptr @malloc(i64 %31)
  store ptr %32, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %30, ptr @_QFEa.8, align 8, !tbaa !7
  %33 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ba5c5c7c349b303cae83682e8102faae, i32 14)
  %.unpack367 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack374.unpack.unpack376 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  store ptr %.unpack367, ptr %1, align 8, !tbaa !7
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  store i64 %.unpack374.unpack.unpack376, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %34 = call i1 @_FortranAioInputDescriptor(ptr %33, ptr nonnull %1)
  %35 = call i32 @_FortranAioEndIoStatement(ptr %33)
  %36 = load i32, ptr %2, align 4, !tbaa !3
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %.lr.ph436, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %23
  %.unpack379.pre = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  br label %._crit_edge

.lr.ph436:                                        ; preds = %23
  %38 = zext i32 %36 to i64
  %.unpack391 = load ptr, ptr @_QFEcnt.0, align 8, !tbaa !7
  %.unpack398.unpack.unpack = load i64, ptr @_QFEcnt.7, align 8, !tbaa !7
  %.unpack403 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %xtraiter = and i64 %38, 1
  %39 = icmp eq i32 %36, 1
  br i1 %39, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph436.new

.lr.ph436.new:                                    ; preds = %.lr.ph436
  %unroll_iter = and i64 %38, 4294967294
  br label %40

40:                                               ; preds = %40, %.lr.ph436.new
  %indvars.iv = phi i64 [ 1, %.lr.ph436.new ], [ %indvars.iv.next.1, %40 ]
  %niter = phi i64 [ 0, %.lr.ph436.new ], [ %niter.next.1, %40 ]
  %41 = add nsw i64 %indvars.iv, -1
  %42 = getelementptr i32, ptr %.unpack403, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !3
  %44 = sext i32 %43 to i64
  %45 = sub i64 %44, %.unpack398.unpack.unpack
  %46 = getelementptr i32, ptr %.unpack391, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !3
  %48 = add i32 %47, 1
  store i32 %48, ptr %46, align 4, !tbaa !3
  %49 = getelementptr i32, ptr %.unpack403, i64 %indvars.iv
  %50 = load i32, ptr %49, align 4, !tbaa !3
  %51 = sext i32 %50 to i64
  %52 = sub i64 %51, %.unpack398.unpack.unpack
  %53 = getelementptr i32, ptr %.unpack391, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !3
  %55 = add i32 %54, 1
  store i32 %55, ptr %53, align 4, !tbaa !3
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %40

._crit_edge.loopexit.unr-lcssa:                   ; preds = %40, %.lr.ph436
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph436 ], [ %indvars.iv.next.1, %40 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %56 = add nsw i64 %indvars.iv.unr, -1
  %57 = getelementptr i32, ptr %.unpack403, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !3
  %59 = sext i32 %58 to i64
  %60 = sub i64 %59, %.unpack398.unpack.unpack
  %61 = getelementptr i32, ptr %.unpack391, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !3
  %63 = add i32 %62, 1
  store i32 %63, ptr %61, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.._crit_edge_crit_edge
  %.unpack379 = phi ptr [ %.unpack379.pre, %.._crit_edge_crit_edge ], [ %.unpack403, %._crit_edge.loopexit.unr-lcssa ], [ %.unpack403, %._crit_edge.loopexit.epilog-lcssa ]
  call void @free(ptr %.unpack379)
  store ptr null, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 0, ptr @_QFEa.8, align 8, !tbaa !7
  %64 = add nsw i64 %24, -1
  %65 = icmp sgt i64 %24, 1
  br i1 %65, label %23, label %._crit_edge439

._crit_edge439:                                   ; preds = %._crit_edge, %.loopexit
  %66 = load i32, ptr %4, align 4, !tbaa !3
  %67 = icmp sgt i32 %66, 0
  br i1 %67, label %.lr.ph442, label %._crit_edge443

.lr.ph442:                                        ; preds = %._crit_edge439
  %68 = zext i32 %66 to i64
  %.unpack = load ptr, ptr @_QFEcnt.0, align 8, !tbaa !7
  %.unpack353.unpack.unpack = load i64, ptr @_QFEcnt.7, align 8, !tbaa !7
  %min.iters.check = icmp ult i32 %66, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph442
  %n.vec = and i64 %68, 4294967288
  %ind.end = or i64 %n.vec, 1
  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 ], [ %76, %vector.body ]
  %vec.phi451 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %77, %vector.body ]
  %offset.idx = or i64 %index, 1
  %69 = sub i64 %offset.idx, %.unpack353.unpack.unpack
  %70 = getelementptr i32, ptr %.unpack, i64 %69
  %wide.load = load <4 x i32>, ptr %70, align 4, !tbaa !3
  %71 = getelementptr i32, ptr %70, i64 4
  %wide.load452 = load <4 x i32>, ptr %71, align 4, !tbaa !3
  %72 = icmp eq <4 x i32> %wide.load, zeroinitializer
  %73 = icmp eq <4 x i32> %wide.load452, zeroinitializer
  %74 = zext <4 x i1> %72 to <4 x i32>
  %75 = zext <4 x i1> %73 to <4 x i32>
  %76 = add <4 x i32> %vec.phi, %74
  %77 = add <4 x i32> %vec.phi451, %75
  %index.next = add nuw i64 %index, 8
  %78 = icmp eq i64 %index.next, %n.vec
  br i1 %78, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %77, %76
  %79 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %68
  br i1 %cmp.n, label %._crit_edge443, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.lr.ph442, %middle.block
  %indvars.iv446.ph = phi i64 [ 1, %.lr.ph442 ], [ %ind.end, %middle.block ]
  %.0440.ph = phi i32 [ 0, %.lr.ph442 ], [ %79, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv446 = phi i64 [ %indvars.iv.next447, %scalar.ph ], [ %indvars.iv446.ph, %scalar.ph.preheader ]
  %.0440 = phi i32 [ %spec.select, %scalar.ph ], [ %.0440.ph, %scalar.ph.preheader ]
  %80 = sub i64 %indvars.iv446, %.unpack353.unpack.unpack
  %81 = getelementptr i32, ptr %.unpack, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !3
  %83 = icmp eq i32 %82, 0
  %84 = zext i1 %83 to i32
  %spec.select = add i32 %.0440, %84
  %indvars.iv.next447 = add nuw nsw i64 %indvars.iv446, 1
  %exitcond449.not = icmp eq i64 %indvars.iv446, %68
  br i1 %exitcond449.not, label %._crit_edge443, label %scalar.ph, !llvm.loop !12

._crit_edge443:                                   ; preds = %scalar.ph, %middle.block, %._crit_edge439
  %.0.lcssa = phi i32 [ 0, %._crit_edge439 ], [ %79, %middle.block ], [ %spec.select, %scalar.ph ]
  %85 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.ba5c5c7c349b303cae83682e8102faae, i32 29)
  %86 = call i1 @_FortranAioOutputInteger32(ptr %85, i32 %.0.lcssa)
  %87 = call i32 @_FortranAioEndIoStatement(ptr %85)
  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 {} @_FortranAReportFatalUserError(ptr, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(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) #2

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

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

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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}
