program find_symmetries
  implicit none
  integer :: n, s(600,300), m, a, i, j
  character(300) :: t
  logical :: ng
  s = 0
  read(*,*) n
  do i = 1, n
    read(*,*) t
    t = trim(adjustl(t))
    do j = 1, n
      s(i,j) = ichar(t(j:j))-97
    end do
    s(i+n,1:n) = s(i,1:n)
  end do
  m = 0
  do a = 0, n-1
    ng = .false.
    do i = 1, n
      do j = 1, n
        if (s(i+a,j).ne.s(j+a,i)) then
          ng = .true.
          exit
        end if
      end do
      if (ng) exit
    end do
    if (.not.ng) m = m + 1
  end do
  write(*,'(i0)') n*m
  stop
end program find_symmetries
; 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"

@_QFEs = internal unnamed_addr global [300 x [600 x i32]] undef
@_QFEt = internal global [300 x i8] undef
@_QQcl.9de7b95791c2c971c017eaf91246bec0 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6031/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #1 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %2 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %3 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %4 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %5 = alloca i32, align 4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(720000) @_QFEs, i8 0, i64 720000, i1 false), !tbaa !3
  %6 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.9de7b95791c2c971c017eaf91246bec0, i32 7)
  %7 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %5, i32 4)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %9 = load i32, ptr %5, align 4, !tbaa !3
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph172, label %._crit_edge182

.lr.ph172:                                        ; preds = %0
  %11 = zext i32 %9 to i64
  %.fca.1.gep64 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 1
  %.fca.2.gep65 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 2
  %.fca.3.gep66 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 3
  %.fca.4.gep67 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 4
  %.fca.5.gep68 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 5
  %.fca.6.gep69 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 6
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %4, i64 0, i32 1
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %4, i64 0, i32 2
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %4, i64 0, i32 3
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %4, i64 0, i32 4
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %4, i64 0, i32 5
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %4, i64 0, i32 6
  %.fca.1.gep130 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 1
  %.fca.2.gep132 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 2
  %.fca.3.gep134 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 3
  %.fca.4.gep136 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 4
  %.fca.5.gep138 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 5
  %.fca.6.gep140 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 6
  %.fca.1.gep25 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 1
  %.fca.2.gep27 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 2
  %.fca.3.gep29 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 3
  %.fca.4.gep31 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 4
  %.fca.5.gep33 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 5
  %.fca.6.gep35 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 6
  br label %12

12:                                               ; preds = %.lr.ph172, %._crit_edge170
  %indvars.iv197 = phi i64 [ 1, %.lr.ph172 ], [ %indvars.iv.next198, %._crit_edge170 ]
  %13 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.9de7b95791c2c971c017eaf91246bec0, i32 9)
  %14 = call i1 @_FortranAioInputAscii(ptr %13, ptr nonnull @_QFEt, i64 300)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %13)
  store ptr @_QFEt, ptr %2, align 8, !tbaa !7
  store i64 300, ptr %.fca.1.gep64, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep65, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep66, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep67, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep68, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep69, align 1, !tbaa !7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep, align 1, !tbaa !7
  store i8 2, ptr %.fca.5.gep, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %16 = call {} @_FortranAAdjustl(ptr nonnull %4, ptr nonnull %2, ptr nonnull @_QQcl.9de7b95791c2c971c017eaf91246bec0, i32 10)
  %.fca.0.load = load ptr, ptr %4, align 8, !tbaa !7
  %.fca.1.load = load i64, ptr %.fca.1.gep, align 8, !tbaa !7
  store ptr %.fca.0.load, ptr %1, align 8, !tbaa !7
  store i64 %.fca.1.load, ptr %.fca.1.gep130, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep132, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep134, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep136, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep138, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep140, align 1, !tbaa !7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  store i32 20180515, ptr %.fca.2.gep27, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep29, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep31, align 1, !tbaa !7
  store i8 2, ptr %.fca.5.gep33, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep35, align 1, !tbaa !7
  %17 = call {} @_FortranATrim(ptr nonnull %3, ptr nonnull %1, ptr nonnull @_QQcl.9de7b95791c2c971c017eaf91246bec0, i32 10)
  %.fca.0.load37 = load ptr, ptr %3, align 8, !tbaa !7
  %.fca.1.load40 = load i64, ptr %.fca.1.gep25, align 8, !tbaa !7
  %18 = call i64 @llvm.smin.i64(i64 %.fca.1.load40, i64 300)
  call void @llvm.memmove.p0.p0.i64(ptr nonnull align 16 @_QFEt, ptr align 1 %.fca.0.load37, i64 %18, i1 false)
  %19 = sub i64 300, %18
  %20 = icmp sgt i64 %19, 0
  br i1 %20, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %12
  %uglygep = getelementptr i8, ptr @_QFEt, i64 %18
  call void @llvm.memset.p0.i64(ptr align 1 %uglygep, i8 32, i64 %19, i1 false), !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %12
  call void @free(ptr %.fca.0.load37)
  call void @free(ptr %.fca.0.load)
  %21 = load i32, ptr %5, align 4, !tbaa !3
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph166, label %._crit_edge170

.lr.ph166:                                        ; preds = %._crit_edge
  %23 = zext i32 %21 to i64
  %24 = add nsw i64 %indvars.iv197, -1
  %25 = add nsw i64 %23, -1
  %xtraiter = and i64 %23, 1
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %._crit_edge167.unr-lcssa, label %.lr.ph166.new

.lr.ph166.new:                                    ; preds = %.lr.ph166
  %unroll_iter = and i64 %23, 4294967294
  br label %27

27:                                               ; preds = %27, %.lr.ph166.new
  %indvars.iv = phi i64 [ 1, %.lr.ph166.new ], [ %indvars.iv.next.1, %27 ]
  %niter = phi i64 [ 0, %.lr.ph166.new ], [ %niter.next.1, %27 ]
  %28 = add nsw i64 %indvars.iv, -1
  %29 = getelementptr [300 x [1 x i8]], ptr @_QFEt, i64 0, i64 %28
  %.unpack = load i8, ptr %29, align 1, !tbaa !3
  %30 = zext i8 %.unpack to i32
  %31 = add nsw i32 %30, -97
  %32 = getelementptr [300 x [600 x i32]], ptr @_QFEs, i64 0, i64 %28, i64 %24
  store i32 %31, ptr %32, align 4, !tbaa !3
  %33 = getelementptr [300 x [1 x i8]], ptr @_QFEt, i64 0, i64 %indvars.iv
  %.unpack.1 = load i8, ptr %33, align 1, !tbaa !3
  %34 = zext i8 %.unpack.1 to i32
  %35 = add nsw i32 %34, -97
  %36 = getelementptr [300 x [600 x i32]], ptr @_QFEs, i64 0, i64 %indvars.iv, i64 %24
  store i32 %35, ptr %36, align 4, !tbaa !3
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge167.unr-lcssa, label %27

._crit_edge167.unr-lcssa:                         ; preds = %27, %.lr.ph166
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph166 ], [ %indvars.iv.next.1, %27 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge167, label %._crit_edge167.epilog-lcssa

._crit_edge167.epilog-lcssa:                      ; preds = %._crit_edge167.unr-lcssa
  %37 = add nsw i64 %indvars.iv.unr, -1
  %38 = getelementptr [300 x [1 x i8]], ptr @_QFEt, i64 0, i64 %37
  %.unpack.epil = load i8, ptr %38, align 1, !tbaa !3
  %39 = zext i8 %.unpack.epil to i32
  %40 = add nsw i32 %39, -97
  %41 = getelementptr [300 x [600 x i32]], ptr @_QFEs, i64 0, i64 %37, i64 %24
  store i32 %40, ptr %41, align 4, !tbaa !3
  br label %._crit_edge167

._crit_edge167:                                   ; preds = %._crit_edge167.unr-lcssa, %._crit_edge167.epilog-lcssa
  %42 = trunc i64 %indvars.iv197 to i32
  %43 = add i32 %21, %42
  %44 = sext i32 %43 to i64
  %.not192 = icmp slt i32 %21, 1
  br i1 %.not192, label %._crit_edge170, label %.lr.ph169.preheader

.lr.ph169.preheader:                              ; preds = %._crit_edge167
  %xtraiter217 = and i64 %23, 1
  %45 = icmp eq i64 %25, 0
  br i1 %45, label %._crit_edge170.loopexit.unr-lcssa, label %.lr.ph169.preheader.new

.lr.ph169.preheader.new:                          ; preds = %.lr.ph169.preheader
  %unroll_iter220 = and i64 %23, 4294967294
  br label %.lr.ph169

.lr.ph169:                                        ; preds = %.lr.ph169, %.lr.ph169.preheader.new
  %46 = phi i64 [ 0, %.lr.ph169.preheader.new ], [ %54, %.lr.ph169 ]
  %niter221 = phi i64 [ 0, %.lr.ph169.preheader.new ], [ %niter221.next.1, %.lr.ph169 ]
  %47 = mul nuw nsw i64 %46, 600
  %48 = add nsw i64 %47, -1
  %49 = add nsw i64 %48, %indvars.iv197
  %50 = getelementptr i32, ptr @_QFEs, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !3
  %52 = add nsw i64 %48, %44
  %53 = getelementptr i32, ptr @_QFEs, i64 %52
  store i32 %51, ptr %53, align 4, !tbaa !3
  %54 = add nuw nsw i64 %46, 2
  %55 = mul nuw i64 %46, 600
  %56 = add i64 %55, 599
  %57 = add nsw i64 %56, %indvars.iv197
  %58 = getelementptr i32, ptr @_QFEs, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !3
  %60 = add nsw i64 %56, %44
  %61 = getelementptr i32, ptr @_QFEs, i64 %60
  store i32 %59, ptr %61, align 4, !tbaa !3
  %niter221.next.1 = add i64 %niter221, 2
  %niter221.ncmp.1.not = icmp eq i64 %niter221.next.1, %unroll_iter220
  br i1 %niter221.ncmp.1.not, label %._crit_edge170.loopexit.unr-lcssa, label %.lr.ph169

._crit_edge170.loopexit.unr-lcssa:                ; preds = %.lr.ph169, %.lr.ph169.preheader
  %.unr218 = phi i64 [ 0, %.lr.ph169.preheader ], [ %54, %.lr.ph169 ]
  %lcmp.mod219.not = icmp eq i64 %xtraiter217, 0
  br i1 %lcmp.mod219.not, label %._crit_edge170, label %.lr.ph169.epil

.lr.ph169.epil:                                   ; preds = %._crit_edge170.loopexit.unr-lcssa
  %62 = mul nuw nsw i64 %.unr218, 600
  %63 = add nsw i64 %62, -1
  %64 = add nsw i64 %63, %indvars.iv197
  %65 = getelementptr i32, ptr @_QFEs, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !3
  %67 = add nsw i64 %63, %44
  %68 = getelementptr i32, ptr @_QFEs, i64 %67
  store i32 %66, ptr %68, align 4, !tbaa !3
  br label %._crit_edge170

._crit_edge170:                                   ; preds = %.lr.ph169.epil, %._crit_edge170.loopexit.unr-lcssa, %._crit_edge, %._crit_edge167
  %indvars.iv.next198 = add nuw nsw i64 %indvars.iv197, 1
  %exitcond200.not = icmp eq i64 %indvars.iv197, %11
  br i1 %exitcond200.not, label %._crit_edge173, label %12

._crit_edge173:                                   ; preds = %._crit_edge170
  %69 = icmp sgt i32 %21, 0
  br i1 %69, label %.preheader161, label %._crit_edge182

.preheader161:                                    ; preds = %._crit_edge173, %.loopexit
  %.0148181 = phi i32 [ %spec.select, %.loopexit ], [ 0, %._crit_edge173 ]
  %.0152180 = phi i32 [ %93, %.loopexit ], [ 0, %._crit_edge173 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader161, %..critedge_crit_edge
  %70 = phi i1 [ false, %.preheader161 ], [ %90, %..critedge_crit_edge ]
  %.0151178 = phi i32 [ 1, %.preheader161 ], [ %89, %..critedge_crit_edge ]
  %.0154177 = phi i32 [ %21, %.preheader161 ], [ %88, %..critedge_crit_edge ]
  %71 = add nuw i32 %.0151178, %.0152180
  %72 = sext i32 %71 to i64
  %73 = add nsw i64 %72, -1
  %74 = sext i32 %.0151178 to i64
  %75 = add nsw i64 %74, -1
  br label %76

76:                                               ; preds = %.preheader, %86
  %.0150175 = phi i32 [ 1, %.preheader ], [ %87, %86 ]
  %77 = sext i32 %.0150175 to i64
  %78 = add nsw i64 %77, -1
  %79 = getelementptr [300 x [600 x i32]], ptr @_QFEs, i64 0, i64 %78, i64 %73
  %80 = load i32, ptr %79, align 4, !tbaa !3
  %81 = add nuw i32 %.0150175, %.0152180
  %82 = sext i32 %81 to i64
  %83 = add nsw i64 %82, -1
  %84 = getelementptr [300 x [600 x i32]], ptr @_QFEs, i64 0, i64 %75, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !3
  %.not = icmp eq i32 %80, %85
  br i1 %.not, label %86, label %.loopexit

86:                                               ; preds = %76
  %87 = add nuw i32 %.0150175, 1
  %exitcond201 = icmp eq i32 %.0150175, %21
  br i1 %exitcond201, label %..critedge_crit_edge, label %76

..critedge_crit_edge:                             ; preds = %86
  %88 = add nsw i32 %.0154177, -1
  %89 = add nuw i32 %.0151178, 1
  %90 = icmp slt i32 %.0154177, 2
  %exitcond202 = icmp eq i32 %.0151178, %21
  br i1 %exitcond202, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %..critedge_crit_edge, %76
  %91 = phi i1 [ %70, %76 ], [ %90, %..critedge_crit_edge ]
  %92 = zext i1 %91 to i32
  %spec.select = add i32 %.0148181, %92
  %93 = add nuw i32 %.0152180, 1
  %exitcond203.not = icmp eq i32 %93, %21
  br i1 %exitcond203.not, label %._crit_edge182, label %.preheader161

._crit_edge182:                                   ; preds = %.loopexit, %0, %._crit_edge173
  %.0148.lcssa = phi i32 [ 0, %._crit_edge173 ], [ 0, %0 ], [ %spec.select, %.loopexit ]
  %94 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.9de7b95791c2c971c017eaf91246bec0, i32 30)
  %95 = load i32, ptr %5, align 4, !tbaa !3
  %96 = mul i32 %95, %.0148.lcssa
  %97 = call i1 @_FortranAioOutputInteger32(ptr %94, i32 %96)
  %98 = call i32 @_FortranAioEndIoStatement(ptr %94)
  %99 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 @_FortranAioInputAscii(ptr, ptr, i64) local_unnamed_addr

declare {} @_FortranAAdjustl(ptr, ptr, ptr, i32) local_unnamed_addr

declare {} @_FortranATrim(ptr, ptr, ptr, i32) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

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 i64 @llvm.smin.i64(i64, i64) #3

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

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { noreturn }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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}
