implicit none
character(10**5+5) s,s_rev
character(5):: a
character(5):: b
character(6):: c
character(7):: d
integer:: s_len,i,count
 
a='maerd'
b='esare'
c='resare'
d='remaerd'
s_rev=''
 
read(*,*) s
s_len=len_trim(s)
 
do i=1,s_len
s_rev(s_len+1-i:s_len+1-i)=s(i:i)
end do
 
count=0
do while (count<s_len)
if(index(s_rev,a)==1)then
count=count+len(a)
s_rev=s_rev(len(a)+1:)
 
else if(index(s_rev,b)==1)then
count=count+len(b)
s_rev=s_rev(len(b)+1:)
 
else if(index(s_rev,c)==1)then
count=count+len(c)
s_rev=s_rev(len(c)+1:)
 
else if(index(s_rev,d)==1)then
count=count+len(d)
s_rev=s_rev(len(d)+1:)
 
else
write(*,*) 'NO'
goto 100
endif
end do
 
write(*,*) 'YES'
 
100 end
; 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"

@_QFEs = internal global [100005 x i8] undef
@_QFEs_rev = internal global [100005 x i8] undef
@_QQcl.6D61657264 = linkonce local_unnamed_addr constant [5 x i8] c"maerd"
@_QQcl.6573617265 = linkonce local_unnamed_addr constant [5 x i8] c"esare"
@_QQcl.726573617265 = linkonce local_unnamed_addr constant [6 x i8] c"resare"
@_QQcl.72656D61657264 = linkonce local_unnamed_addr constant [7 x i8] c"remaerd"
@_QQcl.f28564626b257e58ec550aafab6cdc7e = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7680/source.f\00"
@_QQcl.4E4F = linkonce constant [2 x i8] c"NO"
@_QQcl.594553 = linkonce constant [3 x i8] c"YES"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca [5 x i8], align 1
  %2 = alloca [5 x i8], align 1
  %3 = alloca [6 x i8], align 1
  %4 = alloca [7 x i8], align 1
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(5) %1, ptr noundef nonnull align 1 dereferenceable(5) @_QQcl.6D61657264, i64 5, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(5) %2, ptr noundef nonnull align 1 dereferenceable(5) @_QQcl.6573617265, i64 5, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(6) %3, ptr noundef nonnull align 1 dereferenceable(6) @_QQcl.726573617265, i64 6, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(7) %4, ptr noundef nonnull align 1 dereferenceable(7) @_QQcl.72656D61657264, i64 7, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(100005) @_QFEs_rev, i8 32, i64 100005, i1 false), !tbaa !3
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.f28564626b257e58ec550aafab6cdc7e, i32 15)
  %6 = tail call i1 @_FortranAioInputAscii(ptr %5, ptr nonnull @_QFEs, i64 100005)
  %7 = tail call i32 @_FortranAioEndIoStatement(ptr %5)
  br label %8

8:                                                ; preds = %0, %8
  %9 = phi i64 [ 100004, %0 ], [ %13, %8 ]
  %10 = getelementptr [100005 x [1 x i8]], ptr @_QFEs, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !3
  %12 = icmp eq i8 %11, 32
  %13 = add nsw i64 %9, -1
  %14 = icmp ne i64 %9, 0
  %15 = and i1 %12, %14
  br i1 %15, label %8, label %16

16:                                               ; preds = %8
  %17 = trunc i64 %9 to i32
  %18 = add i32 %17, 1
  %19 = select i1 %12, i32 0, i32 %18
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %iter.check, label %._crit_edge

iter.check:                                       ; preds = %16
  %21 = zext i32 %19 to i64
  %22 = add nuw i32 %19, 1
  %min.iters.check = icmp ult i32 %19, 8
  br i1 %min.iters.check, label %vec.epilog.scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %iter.check
  %23 = add nsw i64 %21, -1
  %24 = trunc i64 %23 to i32
  %25 = sub i32 %19, %24
  %26 = icmp sgt i32 %25, %19
  %27 = icmp ugt i64 %23, 4294967295
  %28 = or i1 %26, %27
  br i1 %28, label %vec.epilog.scalar.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %vector.scevcheck
  %min.iters.check32 = icmp ult i32 %19, 32
  br i1 %min.iters.check32, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %21, 4294967264
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %29 = trunc i64 %index to i32
  %30 = getelementptr [100005 x [1 x i8]], ptr @_QFEs, i64 0, i64 %index
  %31 = sub i32 %19, %29
  %32 = sext i32 %31 to i64
  %33 = add nsw i64 %32, -1
  %34 = getelementptr [100005 x [1 x i8]], ptr @_QFEs_rev, i64 0, i64 %33
  %wide.load = load <16 x i8>, ptr %30, align 16
  %35 = getelementptr i8, ptr %30, i64 16
  %wide.load34 = load <16 x i8>, ptr %35, align 16
  %reverse = shufflevector <16 x i8> %wide.load, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
  %36 = getelementptr i8, ptr %34, i64 -15
  store <16 x i8> %reverse, ptr %36, align 1
  %reverse35 = shufflevector <16 x i8> %wide.load34, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
  %37 = getelementptr i8, ptr %34, i64 -31
  store <16 x i8> %reverse35, ptr %37, align 1
  %index.next = add nuw i64 %index, 32
  %38 = icmp eq i64 %index.next, %n.vec
  br i1 %38, label %middle.block, label %vector.body, !llvm.loop !7

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %21
  br i1 %cmp.n, label %.preheader, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end38 = or i64 %n.vec, 1
  %n.vec.remaining = and i64 %21, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %vec.epilog.scalar.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec37 = and i64 %21, 4294967288
  %ind.end = or i64 %n.vec37, 1
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index40 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next45, %vec.epilog.vector.body ]
  %39 = trunc i64 %index40 to i32
  %40 = getelementptr [100005 x [1 x i8]], ptr @_QFEs, i64 0, i64 %index40
  %41 = sub i32 %19, %39
  %42 = sext i32 %41 to i64
  %43 = add nsw i64 %42, -1
  %44 = getelementptr [100005 x [1 x i8]], ptr @_QFEs_rev, i64 0, i64 %43
  %wide.load43 = load <8 x i8>, ptr %40, align 8
  %reverse44 = shufflevector <8 x i8> %wide.load43, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
  %45 = getelementptr i8, ptr %44, i64 -7
  store <8 x i8> %reverse44, ptr %45, align 1
  %index.next45 = add nuw i64 %index40, 8
  %46 = icmp eq i64 %index.next45, %n.vec37
  br i1 %46, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !10

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n39 = icmp eq i64 %n.vec37, %21
  br i1 %cmp.n39, label %.preheader, label %vec.epilog.scalar.ph.preheader

vec.epilog.scalar.ph.preheader:                   ; preds = %vector.scevcheck, %iter.check, %vec.epilog.iter.check, %vec.epilog.middle.block
  %indvars.iv.ph = phi i64 [ 1, %iter.check ], [ 1, %vector.scevcheck ], [ %ind.end38, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %xtraiter = and i64 %21, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %vec.epilog.scalar.ph.prol.loopexit, label %vec.epilog.scalar.ph.prol

vec.epilog.scalar.ph.prol:                        ; preds = %vec.epilog.scalar.ph.preheader
  %47 = add nsw i64 %indvars.iv.ph, -1
  %48 = getelementptr [100005 x [1 x i8]], ptr @_QFEs, i64 0, i64 %47
  %49 = trunc i64 %indvars.iv.ph to i32
  %50 = sub i32 %22, %49
  %51 = sext i32 %50 to i64
  %52 = add nsw i64 %51, -1
  %53 = getelementptr [100005 x [1 x i8]], ptr @_QFEs_rev, i64 0, i64 %52
  %54 = load i8, ptr %48, align 2
  store i8 %54, ptr %53, align 1
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.ph, 1
  br label %vec.epilog.scalar.ph.prol.loopexit

vec.epilog.scalar.ph.prol.loopexit:               ; preds = %vec.epilog.scalar.ph.prol, %vec.epilog.scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %vec.epilog.scalar.ph.preheader ], [ %indvars.iv.next.prol, %vec.epilog.scalar.ph.prol ]
  %55 = icmp eq i64 %indvars.iv.ph, %21
  br i1 %55, label %.preheader, label %vec.epilog.scalar.ph

.preheader:                                       ; preds = %vec.epilog.scalar.ph.prol.loopexit, %vec.epilog.scalar.ph, %vec.epilog.middle.block, %middle.block
  br i1 %20, label %.lr.ph23, label %._crit_edge

vec.epilog.scalar.ph:                             ; preds = %vec.epilog.scalar.ph.prol.loopexit, %vec.epilog.scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %vec.epilog.scalar.ph ], [ %indvars.iv.unr, %vec.epilog.scalar.ph.prol.loopexit ]
  %56 = add nsw i64 %indvars.iv, -1
  %57 = getelementptr [100005 x [1 x i8]], ptr @_QFEs, i64 0, i64 %56
  %58 = trunc i64 %indvars.iv to i32
  %59 = sub i32 %22, %58
  %60 = sext i32 %59 to i64
  %61 = add nsw i64 %60, -1
  %62 = getelementptr [100005 x [1 x i8]], ptr @_QFEs_rev, i64 0, i64 %61
  %63 = load i8, ptr %57, align 1
  store i8 %63, ptr %62, align 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %64 = getelementptr [100005 x [1 x i8]], ptr @_QFEs, i64 0, i64 %indvars.iv
  %65 = trunc i64 %indvars.iv.next to i32
  %66 = sub i32 %22, %65
  %67 = sext i32 %66 to i64
  %68 = add nsw i64 %67, -1
  %69 = getelementptr [100005 x [1 x i8]], ptr @_QFEs_rev, i64 0, i64 %68
  %70 = load i8, ptr %64, align 1
  store i8 %70, ptr %69, align 1
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next, %21
  br i1 %exitcond.not.1, label %.preheader, label %vec.epilog.scalar.ph, !llvm.loop !11

.backedge:                                        ; preds = %.backedge.loopexit26, %.backedge.loopexit25, %.backedge.loopexit24, %.backedge.loopexit
  %.sink = phi i32 [ 7, %.backedge.loopexit26 ], [ 6, %.backedge.loopexit25 ], [ 5, %.backedge.loopexit24 ], [ 5, %.backedge.loopexit ]
  %71 = add i32 %.022, %.sink
  %72 = icmp slt i32 %71, %19
  br i1 %72, label %.lr.ph23, label %._crit_edge

.lr.ph23:                                         ; preds = %.preheader, %.backedge
  %.022 = phi i32 [ %71, %.backedge ], [ 0, %.preheader ]
  %73 = call i64 @_FortranAIndex1(ptr nonnull @_QFEs_rev, i64 100005, ptr nonnull %1, i64 5, i1 false)
  %74 = and i64 %73, 4294967295
  %75 = icmp eq i64 %74, 1
  br i1 %75, label %.backedge.loopexit, label %76

.backedge.loopexit:                               ; preds = %.lr.ph23
  call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(100000) @_QFEs_rev, ptr noundef nonnull align 1 dereferenceable(100000) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 5), i64 100000, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(5) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 100000), i8 32, i64 5, i1 false), !tbaa !3
  br label %.backedge

76:                                               ; preds = %.lr.ph23
  %77 = call i64 @_FortranAIndex1(ptr nonnull @_QFEs_rev, i64 100005, ptr nonnull %2, i64 5, i1 false)
  %78 = and i64 %77, 4294967295
  %79 = icmp eq i64 %78, 1
  br i1 %79, label %.backedge.loopexit24, label %80

.backedge.loopexit24:                             ; preds = %76
  call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(100000) @_QFEs_rev, ptr noundef nonnull align 1 dereferenceable(100000) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 5), i64 100000, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(5) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 100000), i8 32, i64 5, i1 false), !tbaa !3
  br label %.backedge

80:                                               ; preds = %76
  %81 = call i64 @_FortranAIndex1(ptr nonnull @_QFEs_rev, i64 100005, ptr nonnull %3, i64 6, i1 false)
  %82 = and i64 %81, 4294967295
  %83 = icmp eq i64 %82, 1
  br i1 %83, label %.backedge.loopexit25, label %84

.backedge.loopexit25:                             ; preds = %80
  call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(99999) @_QFEs_rev, ptr noundef nonnull align 2 dereferenceable(99999) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 6), i64 99999, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(6) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 99999), i8 32, i64 6, i1 false), !tbaa !3
  br label %.backedge

84:                                               ; preds = %80
  %85 = call i64 @_FortranAIndex1(ptr nonnull @_QFEs_rev, i64 100005, ptr nonnull %4, i64 7, i1 false)
  %86 = and i64 %85, 4294967295
  %87 = icmp eq i64 %86, 1
  br i1 %87, label %.backedge.loopexit26, label %88

.backedge.loopexit26:                             ; preds = %84
  call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(99998) @_QFEs_rev, ptr noundef nonnull align 1 dereferenceable(99998) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 7), i64 99998, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(7) getelementptr inbounds ([100005 x i8], ptr @_QFEs_rev, i64 0, i64 99998), i8 32, i64 7, i1 false), !tbaa !3
  br label %.backedge

88:                                               ; preds = %84
  %89 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.f28564626b257e58ec550aafab6cdc7e, i32 41)
  %90 = call i1 @_FortranAioOutputAscii(ptr %89, ptr nonnull @_QQcl.4E4F, i64 2)
  br label %93

._crit_edge:                                      ; preds = %.backedge, %16, %.preheader
  %91 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.f28564626b257e58ec550aafab6cdc7e, i32 46)
  %92 = call i1 @_FortranAioOutputAscii(ptr %91, ptr nonnull @_QQcl.594553, i64 3)
  br label %93

93:                                               ; preds = %88, %._crit_edge
  %.sink30 = phi ptr [ %89, %88 ], [ %91, %._crit_edge ]
  %94 = call i32 @_FortranAioEndIoStatement(ptr %.sink30)
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #0

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 i64 @_FortranAIndex1(ptr, i64, ptr, i64, i1) local_unnamed_addr

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

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