program prediction_and_restriction
  implicit none
  integer :: n, k, r, s, p, i, x = 0
  character(100000) :: t
  read(*,*) n, k
  read(*,*) r, s, p
  read(*,*) t
  do i = k+1, n
    if (t(i:i) == t(i-k:i-k)) then
      t(i:i) = 'x'
    end if
  end do
  do i = 1, n
    select case (t(i:i))
    case ('r')
      x = x+p
    case ('s')
      x = x+r
    case ('p')
      x = x+s
    end select
  end do
  write(*,'(i0)') x
end program prediction_and_restriction
; 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"

@_QFEt = internal global [100000 x i8] undef
@_QFEx = internal unnamed_addr global i32 0
@_QQcl.b3572ee526af923d62aa2ad56701c5e7 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2744/source.f\00"
@_QQcl.78 = linkonce local_unnamed_addr constant [1 x i8] c"x"
@_QQcl.72 = linkonce constant [1 x i8] c"r"
@_QQcl.73 = linkonce constant [1 x i8] c"s"
@_QQcl.70 = linkonce constant [1 x i8] c"p"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %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.b3572ee526af923d62aa2ad56701c5e7, i32 5)
  %7 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %2, i32 4)
  %8 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %1, i32 4)
  %9 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %10 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.b3572ee526af923d62aa2ad56701c5e7, i32 6)
  %11 = call i1 @_FortranAioInputInteger(ptr %10, ptr nonnull %4, i32 4)
  %12 = call i1 @_FortranAioInputInteger(ptr %10, ptr nonnull %5, i32 4)
  %13 = call i1 @_FortranAioInputInteger(ptr %10, ptr nonnull %3, i32 4)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %15 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.b3572ee526af923d62aa2ad56701c5e7, i32 7)
  %16 = call i1 @_FortranAioInputAscii(ptr %15, ptr nonnull @_QFEt, i64 100000)
  %17 = call i32 @_FortranAioEndIoStatement(ptr %15)
  %18 = load i32, ptr %1, align 4, !tbaa !3
  %19 = add i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = load i32, ptr %2, align 4, !tbaa !3
  %22 = sext i32 %21 to i64
  %23 = sub nsw i64 1, %20
  %24 = add nsw i64 %23, %22
  %25 = icmp sgt i64 %24, 0
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %26 = load i8, ptr @_QQcl.78, align 1
  br label %27

27:                                               ; preds = %.lr.ph, %41
  %28 = phi i64 [ %24, %.lr.ph ], [ %43, %41 ]
  %29 = phi i32 [ %19, %.lr.ph ], [ %42, %41 ]
  %30 = sext i32 %29 to i64
  %31 = add nsw i64 %30, -1
  %32 = getelementptr [100000 x [1 x i8]], ptr @_QFEt, i64 0, i64 %31
  %33 = load i32, ptr %1, align 4, !tbaa !3
  %34 = sub i32 %29, %33
  %35 = sext i32 %34 to i64
  %36 = add nsw i64 %35, -1
  %37 = getelementptr [100000 x [1 x i8]], ptr @_QFEt, i64 0, i64 %36
  %38 = call i32 @_FortranACharacterCompareScalar1(ptr %32, ptr %37, i64 1, i64 1)
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %27
  store i8 %26, ptr %32, align 1
  br label %41

41:                                               ; preds = %40, %27
  %42 = add i32 %29, 1
  %43 = add nsw i64 %28, -1
  %44 = icmp sgt i64 %28, 1
  br i1 %44, label %27, label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %41
  %.pre = load i32, ptr %2, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %45 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %21, %0 ]
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %.lr.ph13.preheader, label %._crit_edge14

.lr.ph13.preheader:                               ; preds = %._crit_edge
  %47 = add nuw i32 %45, 1
  %wide.trip.count = zext i32 %47 to i64
  br label %.lr.ph13

.lr.ph13:                                         ; preds = %.lr.ph13.preheader, %63
  %indvars.iv = phi i64 [ 1, %.lr.ph13.preheader ], [ %indvars.iv.next, %63 ]
  %48 = add nsw i64 %indvars.iv, -1
  %49 = getelementptr [100000 x [1 x i8]], ptr @_QFEt, i64 0, i64 %48
  %50 = call i32 @_FortranACharacterCompareScalar1(ptr %49, ptr nonnull @_QQcl.72, i64 1, i64 1)
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %55, label %52

52:                                               ; preds = %.lr.ph13
  %53 = call i32 @_FortranACharacterCompareScalar1(ptr %49, ptr nonnull @_QQcl.73, i64 1, i64 1)
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %60

55:                                               ; preds = %60, %52, %.lr.ph13
  %56 = phi ptr [ %5, %60 ], [ %4, %52 ], [ %3, %.lr.ph13 ]
  %57 = load i32, ptr @_QFEx, align 4, !tbaa !3
  %58 = load i32, ptr %56, align 4, !tbaa !3
  %59 = add i32 %58, %57
  store i32 %59, ptr @_QFEx, align 4, !tbaa !3
  br label %63

60:                                               ; preds = %52
  %61 = call i32 @_FortranACharacterCompareScalar1(ptr %49, ptr nonnull @_QQcl.70, i64 1, i64 1)
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %55, label %63

63:                                               ; preds = %55, %60
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge14, label %.lr.ph13

._crit_edge14:                                    ; preds = %63, %._crit_edge
  %64 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.b3572ee526af923d62aa2ad56701c5e7, i32 23)
  %65 = load i32, ptr @_QFEx, align 4, !tbaa !3
  %66 = call i1 @_FortranAioOutputInteger32(ptr %64, i32 %65)
  %67 = call i32 @_FortranAioEndIoStatement(ptr %64)
  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 @_FortranAioInputAscii(ptr, ptr, i64) 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

!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"}
