program main
  implicit none

  integer(8) :: n, i, j, k, l, p
  character(len=6) :: s, r

  read(*,*) n

  i = 0
     
  write(*,*) i
  read(*,*) s

  if (s == 'Vacant') then
     stop
  end if

  r = s

  j = i
  i = n / 2

  do p = 1, 19
     s = ''
     write(*,*) i
     read(*,*) s

     if(s == 'Vacant') then
        stop
     end if

     if(mod(j-i,2) == 0) then
        if(s == r) then
           l = i
           k = i + (n-i) / 2
        else
           l = i
           k = i - (i-j) / 2
           n = j
        end if

     else
        if(s /= r) then
           l = i
           k = i + (n-i) / 2
        else
           l = i
           k = i - (i-j) / 2
           n = j
        end if
     end if

     r = s
     i = k
     j = l
  end do

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"

@_QQcl.245ea5c938905823a52607736e2d7be0 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6292/source.f\00"
@_QQcl.566163616E74 = linkonce constant [6 x i8] c"Vacant"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = alloca [6 x i8], align 1
  %3 = alloca [6 x i8], align 1
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.245ea5c938905823a52607736e2d7be0, i32 7)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %1, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %7 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.245ea5c938905823a52607736e2d7be0, i32 11)
  %8 = call i1 @_FortranAioOutputInteger64(ptr %7, i64 0)
  %9 = call i32 @_FortranAioEndIoStatement(ptr %7)
  %10 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.245ea5c938905823a52607736e2d7be0, i32 12)
  %11 = call i1 @_FortranAioInputAscii(ptr %10, ptr nonnull %3, i64 6)
  %12 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %13 = call i32 @_FortranACharacterCompareScalar1(ptr nonnull %3, ptr nonnull @_QQcl.566163616E74, i64 6, i64 6)
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %.loopexit, label %16

.loopexit:                                        ; preds = %.preheader, %0
  %15 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

16:                                               ; preds = %0
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(6) %2, ptr noundef nonnull align 1 dereferenceable(6) %3, i64 6, i1 false)
  %17 = load i64, ptr %1, align 8, !tbaa !3
  %18 = sdiv i64 %17, 2
  br label %.preheader

.preheader:                                       ; preds = %16, %47
  %.02431 = phi i64 [ 0, %16 ], [ %.02530, %47 ]
  %.02530 = phi i64 [ %18, %16 ], [ %.023, %47 ]
  %.02629 = phi i64 [ 19, %16 ], [ %48, %47 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(6) %3, i8 32, i64 6, i1 false), !tbaa !3
  %19 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.245ea5c938905823a52607736e2d7be0, i32 25)
  %20 = call i1 @_FortranAioOutputInteger64(ptr %19, i64 %.02530)
  %21 = call i32 @_FortranAioEndIoStatement(ptr %19)
  %22 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.245ea5c938905823a52607736e2d7be0, i32 26)
  %23 = call i1 @_FortranAioInputAscii(ptr %22, ptr nonnull %3, i64 6)
  %24 = call i32 @_FortranAioEndIoStatement(ptr %22)
  %25 = call i32 @_FortranACharacterCompareScalar1(ptr nonnull %3, ptr nonnull @_QQcl.566163616E74, i64 6, i64 6)
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %.loopexit, label %27

27:                                               ; preds = %.preheader
  %28 = sub i64 %.02431, %.02530
  %29 = and i64 %28, 1
  %30 = icmp eq i64 %29, 0
  %31 = call i32 @_FortranACharacterCompareScalar1(ptr nonnull %3, ptr nonnull %2, i64 6, i64 6)
  %32 = icmp eq i32 %31, 0
  br i1 %30, label %33, label %40

33:                                               ; preds = %27
  br i1 %32, label %34, label %38

34:                                               ; preds = %33
  %35 = load i64, ptr %1, align 8, !tbaa !3
  %36 = sub i64 %35, %.02530
  %37 = sdiv i64 %36, 2
  br label %47

38:                                               ; preds = %33
  %39 = sub i64 %.02530, %.02431
  %.neg28 = sdiv i64 %39, -2
  store i64 %.02431, ptr %1, align 8, !tbaa !3
  br label %47

40:                                               ; preds = %27
  br i1 %32, label %45, label %41

41:                                               ; preds = %40
  %42 = load i64, ptr %1, align 8, !tbaa !3
  %43 = sub i64 %42, %.02530
  %44 = sdiv i64 %43, 2
  br label %47

45:                                               ; preds = %40
  %46 = sub i64 %.02530, %.02431
  %.neg = sdiv i64 %46, -2
  store i64 %.02431, ptr %1, align 8, !tbaa !3
  br label %47

47:                                               ; preds = %34, %38, %41, %45
  %.pn = phi i64 [ %37, %34 ], [ %.neg28, %38 ], [ %44, %41 ], [ %.neg, %45 ]
  %.023 = add i64 %.pn, %.02530
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(6) %2, ptr noundef nonnull align 1 dereferenceable(6) %3, i64 6, i1 false)
  %48 = add nsw i64 %.02629, -1
  %.not32 = icmp eq i64 %48, 0
  br i1 %.not32, label %49, label %.preheader

49:                                               ; preds = %47
  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 ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

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

; 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

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

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