! 2019.10.27
!
      program answer
      implicit none
      integer(16) :: N
      integer(16) :: ans
      real :: ru_N
      integer(16) :: S
      integer(16) :: T
      intrinsic dble,sqrt,mod
      read(*,*) N
!
      ru_N = sqrt(dble(N))
      S = ru_N+1
      do
        if(mod(N,S) == 0) then
          T=N/S
          exit
        end if
        S = S-1
      end do
!
      write(*,*) T+S-2
      end program answer

; 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.105e1ea95e5f01ffa0a7c19e718224ce = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3075/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i128, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.105e1ea95e5f01ffa0a7c19e718224ce, i32 11)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 16)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i128, ptr %1, align 8, !tbaa !3
  %6 = sitofp i128 %5 to double
  %7 = call contract double @llvm.sqrt.f64(double %6)
  %8 = fptrunc double %7 to float
  %9 = fadd contract float %8, 1.000000e+00
  %10 = fptosi float %9 to i128
  br label %11

11:                                               ; preds = %11, %0
  %.0 = phi i128 [ %10, %0 ], [ %15, %11 ]
  %.frozen = freeze i128 %5
  %.0.frozen = freeze i128 %.0
  %12 = sdiv i128 %.frozen, %.0.frozen
  %13 = mul i128 %12, %.0.frozen
  %.decomposed = sub i128 %.frozen, %13
  %14 = icmp eq i128 %.decomposed, 0
  %15 = add i128 %.0, -1
  br i1 %14, label %16, label %11

16:                                               ; preds = %11
  %17 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.105e1ea95e5f01ffa0a7c19e718224ce, i32 23)
  %18 = add i128 %.0, -2
  %19 = add i128 %18, %12
  %20 = call i1 @_FortranAioOutputInteger128(ptr %17, i128 %19)
  %21 = call i32 @_FortranAioEndIoStatement(ptr %17)
  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 @_FortranAioOutputInteger128(ptr, i128) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #0

attributes #0 = { mustprogress 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"}
