program caddi2018a
  implicit none
  integer i
  character(4) n
  logical :: m(4) = .false.

  read *, n
  forall(i = 1:len(n), n(i:i) == '2') m(i) = .true.
  print '(i0)', count(m)
end program caddi2018a

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

@_QFEm = internal global [4 x i32] zeroinitializer
@_QQcl.95db4a88d139152a6e52a128a9c74ec2 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5227/source.f\00"
@_QQcl.32 = linkonce constant [1 x i8] c"2"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca [4 x i8], align 1
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.95db4a88d139152a6e52a128a9c74ec2, i32 7)
  %4 = call i1 @_FortranAioInputAscii(ptr %3, ptr nonnull %2, i64 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = call i32 @_FortranACharacterCompareScalar1(ptr nonnull %2, ptr nonnull @_QQcl.32, i64 1, i64 1)
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %0
  store i32 1, ptr @_QFEm, align 4, !tbaa !3
  br label %9

9:                                                ; preds = %8, %0
  %10 = getelementptr inbounds [4 x [1 x i8]], ptr %2, i64 0, i64 1
  %11 = call i32 @_FortranACharacterCompareScalar1(ptr nonnull %10, ptr nonnull @_QQcl.32, i64 1, i64 1)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %9
  store i32 1, ptr getelementptr inbounds ([4 x i32], ptr @_QFEm, i64 0, i64 1), align 4, !tbaa !3
  br label %14

14:                                               ; preds = %13, %9
  %15 = getelementptr inbounds [4 x [1 x i8]], ptr %2, i64 0, i64 2
  %16 = call i32 @_FortranACharacterCompareScalar1(ptr nonnull %15, ptr nonnull @_QQcl.32, i64 1, i64 1)
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i32 1, ptr getelementptr inbounds ([4 x i32], ptr @_QFEm, i64 0, i64 2), align 4, !tbaa !3
  br label %19

19:                                               ; preds = %18, %14
  %20 = getelementptr inbounds [4 x [1 x i8]], ptr %2, i64 0, i64 3
  %21 = call i32 @_FortranACharacterCompareScalar1(ptr nonnull %20, ptr nonnull @_QQcl.32, i64 1, i64 1)
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  store i32 1, ptr getelementptr inbounds ([4 x i32], ptr @_QFEm, i64 0, i64 3), align 4, !tbaa !3
  br label %24

24:                                               ; preds = %23, %19
  %25 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.95db4a88d139152a6e52a128a9c74ec2, i32 9)
  store ptr @_QFEm, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, 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 %1, 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 %1, 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 %1, i64 0, i32 4
  store i8 14, 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 %1, 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 %1, 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 %1, 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 %1, i64 0, i32 7, i64 0, i64 1
  store i64 4, 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 %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %26 = call i64 @_FortranACount(ptr nonnull %1, ptr nonnull @_QQcl.95db4a88d139152a6e52a128a9c74ec2, i32 9, i32 0)
  %27 = trunc i64 %26 to i32
  %28 = call i1 @_FortranAioOutputInteger32(ptr %25, i32 %27)
  %29 = call i32 @_FortranAioEndIoStatement(ptr %25)
  ret void
}

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

declare i1 @_FortranAioInputAscii(ptr, ptr, i64) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

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

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare i64 @_FortranACount(ptr, ptr, i32, i32) 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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
