program training_camp
  implicit none
  integer(8) :: n, i, f = 1_8, m = 1000000007_8
  read(*,*) n
  do i = 1_8, n
    f = mod(f*i,m)
  end do
  write(*,'(i0)') f
end program training_camp
; 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"

@_QFEf = internal unnamed_addr global i64 1
@_QQcl.3604d6019c9ec93c60ab7da3e53c5dee = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7481/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 i64, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.3604d6019c9ec93c60ab7da3e53c5dee, i32 4)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 8)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i64, ptr %1, align 8, !tbaa !3
  %6 = icmp sgt i64 %5, 0
  br i1 %6, label %.lr.ph.preheader, label %27

.lr.ph.preheader:                                 ; preds = %0
  %_QFEf.promoted = load i64, ptr @_QFEf, align 8, !tbaa !3
  %xtraiter = and i64 %5, 3
  %7 = icmp ult i64 %5, 4
  br i1 %7, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

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

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %8 = phi i64 [ 1, %.lr.ph.preheader.new ], [ %21, %.lr.ph ]
  %9 = phi i64 [ %_QFEf.promoted, %.lr.ph.preheader.new ], [ %20, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %10 = mul i64 %9, %8
  %11 = srem i64 %10, 1000000007
  %12 = add nuw nsw i64 %8, 1
  %13 = mul i64 %11, %12
  %14 = srem i64 %13, 1000000007
  %15 = add nuw nsw i64 %8, 2
  %16 = mul i64 %14, %15
  %17 = srem i64 %16, 1000000007
  %18 = add nuw i64 %8, 3
  %19 = mul i64 %17, %18
  %20 = srem i64 %19, 1000000007
  %21 = add nuw i64 %8, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %.lr.ph

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa.ph = phi i64 [ undef, %.lr.ph.preheader ], [ %20, %.lr.ph ]
  %.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %21, %.lr.ph ]
  %.unr2 = phi i64 [ %_QFEf.promoted, %.lr.ph.preheader ], [ %20, %.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, %.lr.ph.epil
  %22 = phi i64 [ %26, %.lr.ph.epil ], [ %.unr, %._crit_edge.unr-lcssa ]
  %23 = phi i64 [ %25, %.lr.ph.epil ], [ %.unr2, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %24 = mul i64 %23, %22
  %25 = srem i64 %24, 1000000007
  %26 = add nuw i64 %22, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !7

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %.lcssa = phi i64 [ %.lcssa.ph, %._crit_edge.unr-lcssa ], [ %25, %.lr.ph.epil ]
  store i64 %.lcssa, ptr @_QFEf, align 8, !tbaa !3
  br label %27

27:                                               ; preds = %._crit_edge, %0
  %28 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.3604d6019c9ec93c60ab7da3e53c5dee, i32 8)
  %29 = load i64, ptr @_QFEf, align 8, !tbaa !3
  %30 = call i1 @_FortranAioOutputInteger64(ptr %28, i64 %29)
  %31 = call i32 @_FortranAioEndIoStatement(ptr %28)
  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 @_FortranAioOutputInteger64(ptr, i64) 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"}
!7 = distinct !{!7, !8}
!8 = !{!"llvm.loop.unroll.disable"}
