program main
  implicit none
  integer(16) :: n,i,m=1000000007,p=1
  read(*,*)n
  do i =1, n
    p = mod(p*i,m)
  end do
  write(*,'(i0)')mod(p,m)
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"

@_QFEp = internal unnamed_addr global i128 1
@_QQcl.20cab12c888fa95a2e0435abfeb34896 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7478/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 i128, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.20cab12c888fa95a2e0435abfeb34896, i32 4)
  %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 = trunc i128 %5 to i64
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %.lr.ph.preheader, label %19

.lr.ph.preheader:                                 ; preds = %0
  %_QFEp.promoted = load i128, ptr @_QFEp, align 8, !tbaa !3
  %xtraiter = and i64 %6, 1
  %8 = icmp eq i64 %6, 1
  br i1 %8, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %6, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %9 = phi i128 [ 1, %.lr.ph.preheader.new ], [ %16, %.lr.ph ]
  %10 = phi i128 [ %_QFEp.promoted, %.lr.ph.preheader.new ], [ %15, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %11 = mul i128 %10, %9
  %12 = srem i128 %11, 1000000007
  %13 = add nuw nsw i128 %9, 1
  %14 = mul i128 %12, %13
  %15 = srem i128 %14, 1000000007
  %16 = add nuw nsw i128 %9, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1.not = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1.not, label %._crit_edge.unr-lcssa, label %.lr.ph

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa.ph = phi i128 [ undef, %.lr.ph.preheader ], [ %15, %.lr.ph ]
  %.unr2 = phi i128 [ 1, %.lr.ph.preheader ], [ %16, %.lr.ph ]
  %.unr3 = phi i128 [ %_QFEp.promoted, %.lr.ph.preheader ], [ %15, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa
  %17 = mul i128 %.unr3, %.unr2
  %18 = srem i128 %17, 1000000007
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph.epil
  %.lcssa = phi i128 [ %.lcssa.ph, %._crit_edge.unr-lcssa ], [ %18, %.lr.ph.epil ]
  store i128 %.lcssa, ptr @_QFEp, align 8, !tbaa !3
  br label %19

19:                                               ; preds = %._crit_edge, %0
  %20 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.20cab12c888fa95a2e0435abfeb34896, i32 8)
  %21 = load i128, ptr @_QFEp, align 8, !tbaa !3
  %22 = srem i128 %21, 1000000007
  %23 = call i1 @_FortranAioOutputInteger128(ptr %20, i128 %22)
  %24 = call i32 @_FortranAioEndIoStatement(ptr %20)
  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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger128(ptr, i128) 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"}
