program sample
    implicit none
    character(50)::s,t
    character::a
    integer(8) :: i,j,m,n,h,w
    integer(8),allocatable :: x(:,:),y(:)
    read(*,*)h,w
    allocate(x(0:h+1,0:w+1))
    x(:, :)=0
    do i=1,h
        read(*,*) s
        do j=1,w
            if (s(j:j) .eq. '#')then
                x(i,j)=-10
                x(i-1,j-1)=x(i-1,j-1)+1
                x(i,j-1)=x(i,j-1)+1
                x(i+1,j-1)=x(i+1,j-1)+1
                x(i-1,j)=x(i-1,j)+1
                x(i+1,j)=x(i+1,j)+1
                x(i-1,j+1)=x(i-1,j+1)+1
                x(i,j+1)=x(i,j+1)+1
                x(i+1,j+1)=x(i+1,j+1)+1
            end if
        end do
    end do
    do i=1,h
        t='0'
        do j=1,w
            if(x(i,j)<0)then
                t(j:j)='#'
            else
                write(a,'(i1)')x(i,j)
                t(j:j)=a
            end if

        end do
        write(*,'(a)') t

    end do

    
   
  
    stop
end program sample
  


; 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 global [50 x i8] undef
@_QFEt = internal global [50 x i8] undef
@_QFEx.0 = internal unnamed_addr global ptr null
@_QFEx.7 = internal unnamed_addr global i64 1
@_QFEx.8 = internal unnamed_addr global i64 0
@_QFEx.10 = internal unnamed_addr global i64 1
@_QQcl.9c68fe154ab1bfde29b4d76a3da7f0af = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6827/source.f\00"
@_QQcl.23 = linkonce constant [1 x i8] c"#"
@_QQcl.30 = linkonce local_unnamed_addr constant [1 x i8] c"0"
@_QQcl.28693129 = linkonce constant [4 x i8] c"(i1)"
@_QQcl.286129 = linkonce constant [3 x i8] c"(a)"
@_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: noreturn
define void @_QQmain() local_unnamed_addr #1 {
  %1 = alloca [1 x i8], align 1
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.9c68fe154ab1bfde29b4d76a3da7f0af, i32 7)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 8)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 8)
  %7 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %8 = load i64, ptr %2, align 8, !tbaa !3
  %9 = add i64 %8, 2
  %10 = load i64, ptr %3, align 8, !tbaa !3
  %11 = add i64 %10, 2
  %12 = call i64 @llvm.smax.i64(i64 %9, i64 0)
  %13 = call i64 @llvm.smax.i64(i64 %11, i64 0)
  %14 = shl i64 %12, 3
  %15 = mul i64 %14, %13
  %16 = call ptr @malloc(i64 %15)
  %17 = icmp slt i64 %9, 1
  %18 = zext i1 %17 to i64
  %19 = icmp slt i64 %11, 1
  %20 = zext i1 %19 to i64
  store ptr %16, ptr @_QFEx.0, align 8, !tbaa !7
  store i64 %18, ptr @_QFEx.7, align 8, !tbaa !7
  store i64 %12, ptr @_QFEx.8, align 8, !tbaa !7
  store i64 %20, ptr @_QFEx.10, align 8, !tbaa !7
  %brmerge = select i1 %19, i1 true, i1 %17
  br i1 %brmerge, label %.preheader, label %.preheader545.us.preheader

.preheader545.us.preheader:                       ; preds = %0
  %21 = mul i64 %12, %13
  %22 = shl i64 %21, 3
  call void @llvm.memset.p0.i64(ptr align 8 %16, i8 0, i64 %22, i1 false), !tbaa !3
  br label %.preheader

.preheader:                                       ; preds = %0, %.preheader545.us.preheader
  %23 = icmp sgt i64 %8, 0
  br i1 %23, label %.lr.ph546, label %._crit_edge553

.lr.ph546:                                        ; preds = %.preheader, %._crit_edge
  %24 = phi i64 [ %30, %._crit_edge ], [ 1, %.preheader ]
  %25 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.9c68fe154ab1bfde29b4d76a3da7f0af, i32 11)
  %26 = call i1 @_FortranAioInputAscii(ptr %25, ptr nonnull @_QFEs, i64 50)
  %27 = call i32 @_FortranAioEndIoStatement(ptr %25)
  %28 = load i64, ptr %3, align 8, !tbaa !3
  %29 = icmp sgt i64 %28, 0
  %30 = add nuw i64 %24, 1
  br i1 %29, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph546
  %31 = add nuw i64 %28, 1
  br label %32

32:                                               ; preds = %.lr.ph, %84
  %33 = phi i64 [ 1, %.lr.ph ], [ %.pre-phi, %84 ]
  %34 = add nsw i64 %33, -1
  %35 = getelementptr [50 x [1 x i8]], ptr @_QFEs, i64 0, i64 %34
  %36 = call i32 @_FortranACharacterCompareScalar1(ptr %35, ptr nonnull @_QQcl.23, i64 1, i64 1)
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %._crit_edge571

._crit_edge571:                                   ; preds = %32
  %.pre572 = add nuw i64 %33, 1
  br label %84

38:                                               ; preds = %32
  %.unpack401 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack408.unpack.unpack = load i64, ptr @_QFEx.7, align 8, !tbaa !7
  %.unpack408.unpack.unpack411 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %.unpack408.unpack409.unpack = load i64, ptr @_QFEx.10, align 8, !tbaa !7
  %39 = sub i64 %24, %.unpack408.unpack.unpack
  %40 = sub i64 %33, %.unpack408.unpack409.unpack
  %41 = mul i64 %40, %.unpack408.unpack.unpack411
  %42 = add i64 %41, %39
  %43 = getelementptr i64, ptr %.unpack401, i64 %42
  store i64 -10, ptr %43, align 8, !tbaa !3
  %44 = xor i64 %.unpack408.unpack.unpack, -1
  %45 = add i64 %24, %44
  %46 = sub i64 %34, %.unpack408.unpack409.unpack
  %47 = mul i64 %46, %.unpack408.unpack.unpack411
  %48 = add i64 %47, %45
  %49 = getelementptr i64, ptr %.unpack401, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !3
  %51 = add i64 %50, 1
  store i64 %51, ptr %49, align 8, !tbaa !3
  %52 = add i64 %47, %39
  %53 = getelementptr i64, ptr %.unpack401, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !3
  %55 = add i64 %54, 1
  store i64 %55, ptr %53, align 8, !tbaa !3
  %56 = sub i64 %30, %.unpack408.unpack.unpack
  %57 = add i64 %47, %56
  %58 = getelementptr i64, ptr %.unpack401, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !3
  %60 = add i64 %59, 1
  store i64 %60, ptr %58, align 8, !tbaa !3
  %61 = add i64 %41, %45
  %62 = getelementptr i64, ptr %.unpack401, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !3
  %64 = add i64 %63, 1
  store i64 %64, ptr %62, align 8, !tbaa !3
  %65 = add i64 %41, %56
  %66 = getelementptr i64, ptr %.unpack401, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !3
  %68 = add i64 %67, 1
  store i64 %68, ptr %66, align 8, !tbaa !3
  %69 = add nuw i64 %33, 1
  %70 = sub i64 %69, %.unpack408.unpack409.unpack
  %71 = mul i64 %70, %.unpack408.unpack.unpack411
  %72 = add i64 %71, %45
  %73 = getelementptr i64, ptr %.unpack401, i64 %72
  %74 = load i64, ptr %73, align 8, !tbaa !3
  %75 = add i64 %74, 1
  store i64 %75, ptr %73, align 8, !tbaa !3
  %76 = add i64 %71, %39
  %77 = getelementptr i64, ptr %.unpack401, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !3
  %79 = add i64 %78, 1
  store i64 %79, ptr %77, align 8, !tbaa !3
  %80 = add i64 %71, %56
  %81 = getelementptr i64, ptr %.unpack401, i64 %80
  %82 = load i64, ptr %81, align 8, !tbaa !3
  %83 = add i64 %82, 1
  store i64 %83, ptr %81, align 8, !tbaa !3
  br label %84

84:                                               ; preds = %._crit_edge571, %38
  %.pre-phi = phi i64 [ %.pre572, %._crit_edge571 ], [ %69, %38 ]
  %exitcond.not = icmp eq i64 %.pre-phi, %31
  br i1 %exitcond.not, label %._crit_edge, label %32

._crit_edge:                                      ; preds = %84, %.lr.ph546
  %exitcond556.not = icmp eq i64 %24, %8
  br i1 %exitcond556.not, label %._crit_edge547, label %.lr.ph546

._crit_edge547:                                   ; preds = %._crit_edge
  %.pre = load i64, ptr %2, align 8, !tbaa !3
  %85 = icmp sgt i64 %.pre, 0
  br i1 %85, label %.lr.ph552, label %._crit_edge553

.lr.ph552:                                        ; preds = %._crit_edge547
  %86 = load i8, ptr @_QQcl.30, align 1
  %87 = load i8, ptr @_QQcl.23, align 1
  br label %88

88:                                               ; preds = %.lr.ph552, %._crit_edge550
  %89 = phi i64 [ 1, %.lr.ph552 ], [ %121, %._crit_edge550 ]
  store i8 %86, ptr @_QFEt, align 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(49) getelementptr inbounds ([50 x i8], ptr @_QFEt, i64 0, i64 1), i8 32, i64 49, i1 false), !tbaa !3
  %90 = load i64, ptr %3, align 8, !tbaa !3
  %91 = icmp sgt i64 %90, 0
  br i1 %91, label %.lr.ph549.preheader, label %._crit_edge550

.lr.ph549.preheader:                              ; preds = %88
  %.unpack.pre559 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack376.unpack.unpack.pre562 = load i64, ptr @_QFEx.7, align 8, !tbaa !7
  %.unpack376.unpack.unpack379.pre565 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %.unpack376.unpack377.unpack.pre568 = load i64, ptr @_QFEx.10, align 8, !tbaa !7
  br label %.lr.ph549

.lr.ph549:                                        ; preds = %.lr.ph549.preheader, %116
  %.unpack376.unpack377.unpack = phi i64 [ %.unpack376.unpack377.unpack569, %116 ], [ %.unpack376.unpack377.unpack.pre568, %.lr.ph549.preheader ]
  %.unpack376.unpack.unpack379 = phi i64 [ %.unpack376.unpack.unpack379566, %116 ], [ %.unpack376.unpack.unpack379.pre565, %.lr.ph549.preheader ]
  %.unpack376.unpack.unpack = phi i64 [ %.unpack376.unpack.unpack563, %116 ], [ %.unpack376.unpack.unpack.pre562, %.lr.ph549.preheader ]
  %.unpack = phi ptr [ %.unpack560, %116 ], [ %.unpack.pre559, %.lr.ph549.preheader ]
  %92 = phi i64 [ %117, %116 ], [ 1, %.lr.ph549.preheader ]
  %93 = sub i64 %89, %.unpack376.unpack.unpack
  %94 = sub i64 %92, %.unpack376.unpack377.unpack
  %95 = mul i64 %94, %.unpack376.unpack.unpack379
  %96 = add i64 %93, %95
  %97 = getelementptr i64, ptr %.unpack, i64 %96
  %98 = load i64, ptr %97, align 8, !tbaa !3
  %99 = icmp slt i64 %98, 0
  br i1 %99, label %100, label %103

100:                                              ; preds = %.lr.ph549
  %101 = add nsw i64 %92, -1
  %102 = getelementptr [50 x [1 x i8]], ptr @_QFEt, i64 0, i64 %101
  store i8 %87, ptr %102, align 1
  br label %116

103:                                              ; preds = %.lr.ph549
  %104 = call ptr @_FortranAioBeginInternalFormattedOutput(ptr nonnull %1, i64 1, ptr nonnull @_QQcl.28693129, i64 4, ptr null, ptr null, i64 0, ptr nonnull @_QQcl.9c68fe154ab1bfde29b4d76a3da7f0af, i32 32)
  %.unpack385 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack392.unpack.unpack = load i64, ptr @_QFEx.7, align 8, !tbaa !7
  %.unpack392.unpack.unpack395 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %.unpack392.unpack393.unpack = load i64, ptr @_QFEx.10, align 8, !tbaa !7
  %105 = sub i64 %89, %.unpack392.unpack.unpack
  %106 = sub i64 %92, %.unpack392.unpack393.unpack
  %107 = mul i64 %106, %.unpack392.unpack.unpack395
  %108 = add i64 %105, %107
  %109 = getelementptr i64, ptr %.unpack385, i64 %108
  %110 = load i64, ptr %109, align 8, !tbaa !3
  %111 = call i1 @_FortranAioOutputInteger64(ptr %104, i64 %110)
  %112 = call i32 @_FortranAioEndIoStatement(ptr %104)
  %113 = add nsw i64 %92, -1
  %114 = getelementptr [50 x [1 x i8]], ptr @_QFEt, i64 0, i64 %113
  %115 = load i8, ptr %1, align 1
  store i8 %115, ptr %114, align 1
  %.unpack.pre = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack376.unpack.unpack.pre = load i64, ptr @_QFEx.7, align 8, !tbaa !7
  %.unpack376.unpack.unpack379.pre = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %.unpack376.unpack377.unpack.pre = load i64, ptr @_QFEx.10, align 8, !tbaa !7
  br label %116

116:                                              ; preds = %103, %100
  %.unpack376.unpack377.unpack569 = phi i64 [ %.unpack376.unpack377.unpack.pre, %103 ], [ %.unpack376.unpack377.unpack, %100 ]
  %.unpack376.unpack.unpack379566 = phi i64 [ %.unpack376.unpack.unpack379.pre, %103 ], [ %.unpack376.unpack.unpack379, %100 ]
  %.unpack376.unpack.unpack563 = phi i64 [ %.unpack376.unpack.unpack.pre, %103 ], [ %.unpack376.unpack.unpack, %100 ]
  %.unpack560 = phi ptr [ %.unpack.pre, %103 ], [ %.unpack, %100 ]
  %117 = add nuw i64 %92, 1
  %exitcond557.not = icmp eq i64 %92, %90
  br i1 %exitcond557.not, label %._crit_edge550, label %.lr.ph549

._crit_edge550:                                   ; preds = %116, %88
  %118 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.286129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.9c68fe154ab1bfde29b4d76a3da7f0af, i32 37)
  %119 = call i1 @_FortranAioOutputAscii(ptr %118, ptr nonnull @_QFEt, i64 50)
  %120 = call i32 @_FortranAioEndIoStatement(ptr %118)
  %121 = add nuw i64 %89, 1
  %exitcond558.not = icmp eq i64 %89, %.pre
  br i1 %exitcond558.not, label %._crit_edge553, label %88

._crit_edge553:                                   ; preds = %._crit_edge550, %.preheader, %._crit_edge547
  %122 = 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 i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) local_unnamed_addr

declare ptr @_FortranAioBeginInternalFormattedOutput(ptr, i64, ptr, i64, ptr, ptr, i64, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { noreturn }
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}
