      MODULE gcdMod
! 最小公倍数GCDを求めるモジュール
! ユークリッドの互除法を使用する．
! MODはとっていない.
      IMPLICIT NONE
      
      interface gcd
        module procedure :: intGcd
      end interface
      
      integer(16),parameter,private :: precision = 16
      
      contains
      function intGcd( a,b ) result( gcd )
        implicit none
        integer(precision),intent(in) :: a,b
        integer(precision) :: gcd, smaller, bigger, remain
        
        bigger  = max( a,b )
        smaller = min( a,b )
        
        do while(.true.)
          remain = mod( bigger,smaller )
          if( remain==0 )then
            gcd = smaller; return
          else
            bigger  = smaller
            smaller = remain
          end if
        end do
      end function
      end MODULE gcdMod
      
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      

      PROGRAM piyo
      use gcdMod
      IMPLICIT NONE
      integer(16) :: n,ans
      integer(16),allocatable :: a(:)
      integer(16) :: i
      
      read*,n
      allocate( a(n) )
      read*,a(1:n)
      
      ans = a(1)
      
      do i = 2,n
        ans = gcd( ans,a(i) )
      end do
      
      print*,ans
      
      
      
      
      END PROGRAM
; 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"

@_QMgcdmodECprecision = local_unnamed_addr constant i128 16
@_QFEa.0 = internal unnamed_addr global ptr null
@_QQcl.409c2dc7c6c2974ba83f7a1b3ba2d0ca = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4946/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nosync nounwind memory(argmem: read)
define i128 @_QMgcdmodPintgcd(ptr nocapture readonly %0, ptr nocapture readonly %1) local_unnamed_addr #1 {
  %3 = load i128, ptr %0, align 8, !tbaa !3
  %4 = load i128, ptr %1, align 8, !tbaa !3
  %5 = tail call i128 @llvm.smax.i128(i128 %3, i128 %4)
  %6 = tail call i128 @llvm.smin.i128(i128 %3, i128 %4)
  br label %7

7:                                                ; preds = %7, %2
  %.07 = phi i128 [ %5, %2 ], [ %.0, %7 ]
  %.0 = phi i128 [ %6, %2 ], [ %8, %7 ]
  %8 = srem i128 %.07, %.0
  %9 = icmp eq i128 %8, 0
  br i1 %9, label %10, label %7

10:                                               ; preds = %7
  ret i128 %.0
}

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i128, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.409c2dc7c6c2974ba83f7a1b3ba2d0ca, i32 44)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 16)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i128, ptr %2, align 8, !tbaa !3
  %7 = trunc i128 %6 to i64
  %8 = call i64 @llvm.smax.i64(i64 %7, i64 0)
  %9 = shl i64 %8, 4
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEa.0, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.409c2dc7c6c2974ba83f7a1b3ba2d0ca, i32 46)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %12 = load i128, ptr %2, align 8, !tbaa !3
  %13 = trunc i128 %12 to i64
  %14 = call i64 @llvm.smax.i64(i64 %13, i64 0)
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 16, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 11, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %14, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 16, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %15 = call i1 @_FortranAioInputDescriptor(ptr %11, ptr nonnull %1)
  %16 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %.unpack119 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %17 = load i128, ptr %.unpack119, align 8, !tbaa !3
  %18 = load i128, ptr %2, align 8, !tbaa !3
  %19 = trunc i128 %18 to i64
  %20 = add i64 %19, -1
  %21 = icmp sgt i64 %20, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %_QMgcdmodPintgcd.exit
  %22 = phi i64 [ %31, %_QMgcdmodPintgcd.exit ], [ 2, %0 ]
  %.0144 = phi i128 [ %.0.i, %_QMgcdmodPintgcd.exit ], [ %17, %0 ]
  %23 = add i64 %22, -1
  %24 = getelementptr i128, ptr %.unpack119, i64 %23
  %25 = load i128, ptr %24, align 8, !tbaa !3
  %26 = call i128 @llvm.smax.i128(i128 %.0144, i128 %25)
  %27 = call i128 @llvm.smin.i128(i128 %.0144, i128 %25)
  br label %28

28:                                               ; preds = %28, %.lr.ph
  %.07.i = phi i128 [ %26, %.lr.ph ], [ %.0.i, %28 ]
  %.0.i = phi i128 [ %27, %.lr.ph ], [ %29, %28 ]
  %29 = srem i128 %.07.i, %.0.i
  %30 = icmp eq i128 %29, 0
  br i1 %30, label %_QMgcdmodPintgcd.exit, label %28

_QMgcdmodPintgcd.exit:                            ; preds = %28
  %31 = add nuw i64 %22, 1
  %exitcond.not = icmp eq i64 %22, %19
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %_QMgcdmodPintgcd.exit, %0
  %.0.lcssa = phi i128 [ %17, %0 ], [ %.0.i, %_QMgcdmodPintgcd.exit ]
  %32 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.409c2dc7c6c2974ba83f7a1b3ba2d0ca, i32 54)
  %33 = call i1 @_FortranAioOutputInteger128(ptr %32, i128 %.0.lcssa)
  %34 = call i32 @_FortranAioEndIoStatement(ptr %32)
  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 i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger128(ptr, i128) local_unnamed_addr

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

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

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nofree nosync nounwind memory(argmem: read) }
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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
