program falling_asleep
  implicit none
  integer :: n, t(50) = 0, i, m = 0
  character(100) :: s(50) = "", x
  logical :: sleeping = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i), t(i)
  end do
  read(*,*) x
  do i = 1, n
    if (sleeping) m = m+t(i)
    if (s(i) == x) sleeping = .true.
  end do
  write(*,'(i0)') m
end program falling_asleep
; 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 unnamed_addr global i32 0
@_QFEs = internal global [50 x [100 x i8]] [[100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    ", [100 x i8] c"                                                                                                    "]
@_QFEsleeping = internal unnamed_addr global i1 false
@_QFEt = internal global [50 x i32] zeroinitializer
@_QFEx = internal global [100 x i8] undef
@_QQcl.9c9857f40af9816572748a0918c5fd65 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2651/source.f\00"
@_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 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.9c9857f40af9816572748a0918c5fd65, i32 6)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i32, ptr %1, align 4, !tbaa !3
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %7 = zext i32 %5 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %8 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.9c9857f40af9816572748a0918c5fd65, i32 8)
  %9 = add nsw i64 %indvars.iv, -1
  %10 = getelementptr [50 x [100 x i8]], ptr @_QFEs, i64 0, i64 %9
  %11 = call i1 @_FortranAioInputAscii(ptr %8, ptr %10, i64 100)
  %12 = getelementptr [50 x i32], ptr @_QFEt, i64 0, i64 %9
  %13 = call i1 @_FortranAioInputInteger(ptr %8, ptr %12, i32 4)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %7
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %15 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.9c9857f40af9816572748a0918c5fd65, i32 10)
  %16 = call i1 @_FortranAioInputAscii(ptr %15, ptr nonnull @_QFEx, i64 100)
  %17 = call i32 @_FortranAioEndIoStatement(ptr %15)
  %18 = load i32, ptr %1, align 4, !tbaa !3
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph8.preheader, label %._crit_edge9

.lr.ph8.preheader:                                ; preds = %._crit_edge
  %20 = zext i32 %18 to i64
  br label %.lr.ph8

.lr.ph8:                                          ; preds = %.lr.ph8.preheader, %32
  %indvars.iv11 = phi i64 [ 1, %.lr.ph8.preheader ], [ %indvars.iv.next12, %32 ]
  %.b = load i1, ptr @_QFEsleeping, align 1
  br i1 %.b, label %21, label %.lr.ph8._crit_edge

.lr.ph8._crit_edge:                               ; preds = %.lr.ph8
  %.pre = add nsw i64 %indvars.iv11, -1
  br label %27

21:                                               ; preds = %.lr.ph8
  %22 = load i32, ptr @_QFEm, align 4, !tbaa !3
  %23 = add nsw i64 %indvars.iv11, -1
  %24 = getelementptr [50 x i32], ptr @_QFEt, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !3
  %26 = add i32 %25, %22
  store i32 %26, ptr @_QFEm, align 4, !tbaa !3
  br label %27

27:                                               ; preds = %.lr.ph8._crit_edge, %21
  %.pre-phi = phi i64 [ %.pre, %.lr.ph8._crit_edge ], [ %23, %21 ]
  %28 = getelementptr [50 x [100 x i8]], ptr @_QFEs, i64 0, i64 %.pre-phi
  %29 = call i32 @_FortranACharacterCompareScalar1(ptr %28, ptr nonnull @_QFEx, i64 100, i64 100)
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  store i1 true, ptr @_QFEsleeping, align 1
  br label %32

32:                                               ; preds = %31, %27
  %indvars.iv.next12 = add nuw nsw i64 %indvars.iv11, 1
  %exitcond14.not = icmp eq i64 %indvars.iv11, %20
  br i1 %exitcond14.not, label %._crit_edge9, label %.lr.ph8

._crit_edge9:                                     ; preds = %32, %._crit_edge
  %33 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.9c9857f40af9816572748a0918c5fd65, i32 15)
  %34 = load i32, ptr @_QFEm, align 4, !tbaa !3
  %35 = call i1 @_FortranAioOutputInteger32(ptr %33, i32 %34)
  %36 = call i32 @_FortranAioEndIoStatement(ptr %33)
  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"}
