implicit none
integer :: x
integer :: b
integer :: a, z

read *,x

if (x <= 3) then
   print '(i0)',1
   stop
endif

a = 0
do b = 2, int(sqrt(real(x)))
   z = b * b
   if (z > x) then
      exit
   endif
   do while (z <= x)
      if (a < z) a = z
      z = z * b
   enddo
enddo

print '(i0)',a
stop
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"

@_QQcl.2be57a29a2dc431f725e14fc5eea3344 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5980/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2be57a29a2dc431f725e14fc5eea3344, 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 slt i32 %5, 4
  br i1 %6, label %7, label %12

7:                                                ; preds = %0
  %8 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.2be57a29a2dc431f725e14fc5eea3344, i32 9)
  %9 = call i1 @_FortranAioOutputInteger32(ptr %8, i32 1)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %8)
  %11 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

12:                                               ; preds = %0
  %13 = sitofp i32 %5 to float
  %14 = call contract float @llvm.sqrt.f32(float %13)
  %15 = fptosi float %14 to i32
  %.01421 = add i32 %15, -1
  %16 = icmp slt i32 %.01421, 1
  br i1 %16, label %._crit_edge26, label %.preheader

.preheader:                                       ; preds = %12, %._crit_edge
  %17 = phi i32 [ %21, %._crit_edge ], [ 4, %12 ]
  %.01425 = phi i32 [ %.014, %._crit_edge ], [ %.01421, %12 ]
  %.01224 = phi i32 [ %19, %._crit_edge ], [ 2, %12 ]
  %.01323 = phi i32 [ %.1.lcssa, %._crit_edge ], [ 0, %12 ]
  %.not18 = icmp sgt i32 %17, %5
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.020 = phi i32 [ %18, %.lr.ph ], [ %17, %.preheader ]
  %.119 = phi i32 [ %spec.select, %.lr.ph ], [ %.01323, %.preheader ]
  %spec.select = call i32 @llvm.smax.i32(i32 %.119, i32 %.020)
  %18 = mul i32 %.020, %.01224
  %.not = icmp sgt i32 %18, %5
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.1.lcssa = phi i32 [ %.01323, %.preheader ], [ %spec.select, %.lr.ph ]
  %19 = add nuw i32 %.01224, 1
  %.014 = add i32 %.01425, -1
  %20 = icmp slt i32 %.014, 1
  %21 = mul i32 %19, %19
  %22 = icmp sgt i32 %21, %5
  %or.cond = select i1 %20, i1 true, i1 %22
  br i1 %or.cond, label %._crit_edge26, label %.preheader

._crit_edge26:                                    ; preds = %._crit_edge, %12
  %.013.lcssa = phi i32 [ 0, %12 ], [ %.1.lcssa, %._crit_edge ]
  %23 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.2be57a29a2dc431f725e14fc5eea3344, i32 25)
  %24 = call i1 @_FortranAioOutputInteger32(ptr %23, i32 %.013.lcssa)
  %25 = call i32 @_FortranAioEndIoStatement(ptr %23)
  %26 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

attributes #0 = { noreturn }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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