program gcd_on_blackboard
  implicit none
  integer :: n, a(100000), i, g, m
  integer :: l(0:100000), r(1:100001)
  a = 0
  l = 0
  r = 0
  read(*,*) n
  read(*,*) a(1:n)
  m = 1
  do i = 1, n
    l(i) = gcd(l(i-1),a(i-1))
  end do
  do i = n, 1, -1
    r(i) = gcd(r(i+1),a(i))
  end do
  do i = 1, n
    g = gcd(l(i),r(i+1))
    if (m.lt.g) m = g
  end do
  write(*,'(i0)') m
  stop
contains
  recursive function gcd(n,m) result(g)
    implicit none
    integer, intent(in) :: n, m
    integer :: g
    if (n.eq.0) then
      g = m
    else if (m.eq.0) then
      g = n
    else if (n.lt.m) then
      g = gcd(m,n)
    else if (mod(n,m).eq.0) then
      g = m
    else
      g = gcd(m,mod(n,m))
    end if
  end function gcd
end program gcd_on_blackboard
; 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"

@_QFEa = internal global [100000 x i32] undef
@_QFEl = internal global [100001 x i32] undef
@_QFEr = internal global [100001 x i32] undef
@_QQcl.929050b068af8aa6ffea73e521fa49b7 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4386/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 {
.preheader21.preheader:
  %0 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %1 = alloca i32, align 4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400000) @_QFEa, i8 0, i64 400000, i1 false), !tbaa !3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400004) @_QFEl, i8 0, i64 400004, i1 false), !tbaa !3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400004) @_QFEr, i8 0, i64 400004, i1 false), !tbaa !3
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.929050b068af8aa6ffea73e521fa49b7, i32 8)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.929050b068af8aa6ffea73e521fa49b7, i32 9)
  %6 = load i32, ptr %1, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %8 = zext i32 %7 to i64
  store ptr @_QFEa, ptr %0, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 1
  store i64 4, 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 %0, 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 %0, 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 %0, i64 0, i32 4
  store i8 9, 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 %0, 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 %0, 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 %0, 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 %0, i64 0, i32 7, i64 0, i64 1
  store i64 %8, 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 %0, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %9 = call i1 @_FortranAioInputDescriptor(ptr %5, ptr nonnull %0)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %11 = load i32, ptr %1, align 4, !tbaa !3
  %12 = sext i32 %11 to i64
  %13 = icmp sgt i32 %11, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.preheader19:                                     ; preds = %.lr.ph
  br i1 %13, label %.lr.ph22, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader21.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.preheader21.preheader ]
  %14 = add nsw i64 %indvars.iv, -1
  %15 = getelementptr [100001 x i32], ptr @_QFEl, i64 0, i64 %14
  %16 = add nsw i64 %indvars.iv, -2
  %17 = getelementptr [100000 x i32], ptr @_QFEa, i64 0, i64 %16
  %18 = call i32 @_QFPgcd(ptr %15, ptr %17)
  %19 = getelementptr [100001 x i32], ptr @_QFEl, i64 0, i64 %indvars.iv
  store i32 %18, ptr %19, align 4, !tbaa !3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %12
  br i1 %exitcond.not, label %.preheader19, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph22
  br i1 %13, label %.lr.ph24, label %._crit_edge

.lr.ph22:                                         ; preds = %.preheader19, %.lr.ph22
  %20 = phi i64 [ %30, %.lr.ph22 ], [ %12, %.preheader19 ]
  %21 = shl i64 %20, 32
  %sext31 = add i64 %21, 4294967296
  %22 = ashr exact i64 %sext31, 32
  %23 = add nsw i64 %22, -1
  %24 = getelementptr [100001 x i32], ptr @_QFEr, i64 0, i64 %23
  %sext32 = shl i64 %20, 32
  %25 = ashr exact i64 %sext32, 32
  %26 = add nsw i64 %25, -1
  %27 = getelementptr [100000 x i32], ptr @_QFEa, i64 0, i64 %26
  %28 = call i32 @_QFPgcd(ptr %24, ptr %27)
  %29 = getelementptr [100001 x i32], ptr @_QFEr, i64 0, i64 %26
  store i32 %28, ptr %29, align 4, !tbaa !3
  %30 = add nsw i64 %20, -1
  %31 = icmp sgt i64 %20, 1
  br i1 %31, label %.lr.ph22, label %.preheader

.lr.ph24:                                         ; preds = %.preheader, %.lr.ph24
  %indvars.iv27 = phi i64 [ %indvars.iv.next28, %.lr.ph24 ], [ 1, %.preheader ]
  %.023 = phi i32 [ %spec.select, %.lr.ph24 ], [ 1, %.preheader ]
  %32 = getelementptr [100001 x i32], ptr @_QFEl, i64 0, i64 %indvars.iv27
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %sext = shl i64 %indvars.iv.next28, 32
  %33 = ashr exact i64 %sext, 32
  %34 = add nsw i64 %33, -1
  %35 = getelementptr [100001 x i32], ptr @_QFEr, i64 0, i64 %34
  %36 = call i32 @_QFPgcd(ptr %32, ptr %35)
  %spec.select = call i32 @llvm.smax.i32(i32 %.023, i32 %36)
  %exitcond30.not = icmp eq i64 %indvars.iv27, %12
  br i1 %exitcond30.not, label %._crit_edge, label %.lr.ph24

._crit_edge:                                      ; preds = %.lr.ph24, %.preheader21.preheader, %.preheader19, %.preheader
  %.0.lcssa = phi i32 [ 1, %.preheader ], [ 1, %.preheader19 ], [ 1, %.preheader21.preheader ], [ %spec.select, %.lr.ph24 ]
  %37 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.929050b068af8aa6ffea73e521fa49b7, i32 21)
  %38 = call i1 @_FortranAioOutputInteger32(ptr %37, i32 %.0.lcssa)
  %39 = call i32 @_FortranAioEndIoStatement(ptr %37)
  %40 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

; Function Attrs: nofree nosync nounwind memory(argmem: read)
define i32 @_QFPgcd(ptr nocapture readonly %0, ptr nocapture readonly %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %.pre = load i32, ptr %0, align 4, !tbaa !3
  br label %tailrecurse

tailrecurse:                                      ; preds = %9, %2
  %4 = phi i32 [ %.pre, %2 ], [ %6, %9 ]
  %.tr = phi ptr [ %0, %2 ], [ %.tr4, %9 ]
  %.tr4 = phi ptr [ %1, %2 ], [ %.tr, %9 ]
  %5 = icmp eq i32 %4, 0
  %6 = load i32, ptr %.tr4, align 4, !tbaa !3
  br i1 %5, label %.loopexit, label %7

7:                                                ; preds = %tailrecurse
  %8 = icmp eq i32 %6, 0
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %7
  %10 = icmp slt i32 %4, %6
  br i1 %10, label %tailrecurse, label %11

11:                                               ; preds = %9
  %12 = srem i32 %4, %6
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %11
  store i32 %12, ptr %3, align 4, !tbaa !3
  %15 = call i32 @_QFPgcd(ptr nonnull %.tr4, ptr nonnull %3)
  br label %.loopexit

.loopexit:                                        ; preds = %7, %tailrecurse, %11, %14
  %.0 = phi i32 [ %15, %14 ], [ %6, %11 ], [ %4, %7 ], [ %6, %tailrecurse ]
  ret i32 %.0
}

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 @_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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { noreturn }
attributes #1 = { nofree nosync nounwind memory(argmem: read) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }

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