#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ fillMineInfo(char **, int, int);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  char mineField[100][100 + 1];
  char trash[2];
  int numR, numC, r;
  int caseId = 1;
  while (1) {
    scanf("%d %d", &numR, &numC);
    if (!(numR && numC)) {
      break;
    }
    gets(trash);
    for (r = 0; r < numR; ++r) {
      gets(mineField[r]);
    }
    fillMineInfo(mineField, numR, numC);
    if (caseId > 1) {
      printf("\n");
    }
    printf("Field #%d:\n", caseId);
    for (r = 0; r < numR; ++r) {
      puts(mineField[r]);
    }
    caseId++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27a0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2794(%rbp)
lea    0xe8d(%rip),%rdi
lea    -0x2788(%rbp),%rsi
lea    -0x278c(%rbp),%rdx
call   1070 <scanf@plt>
cmpl   $0x0,-0x2788(%rbp)
je     11a0 <main+0x50>
cmpl   $0x0,-0x278c(%rbp)
jne    11a5 <main+0x55>
jmp    12a0 <main+0x150>
lea    -0x2782(%rbp),%rdi
call   1060 <gets@plt>
movl   $0x0,-0x2790(%rbp)
mov    -0x2790(%rbp),%eax
cmp    -0x2788(%rbp),%eax
jge    11fb <main+0xab>
movslq -0x2790(%rbp),%rax
lea    -0x2780(%rbp),%rdi
imul   $0x65,%rax,%rax
add    %rax,%rdi
call   1060 <gets@plt>
mov    -0x2790(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2790(%rbp)
jmp    11bb <main+0x6b>
lea    -0x2780(%rbp),%rdi
mov    -0x2788(%rbp),%esi
mov    -0x278c(%rbp),%edx
call   1050 <fillMineInfo@plt>
cmpl   $0x1,-0x2794(%rbp)
jle    122e <main+0xde>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2794(%rbp),%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2790(%rbp)
mov    -0x2790(%rbp),%eax
cmp    -0x2788(%rbp),%eax
jge    128c <main+0x13c>
movslq -0x2790(%rbp),%rax
lea    -0x2780(%rbp),%rdi
imul   $0x65,%rax,%rax
add    %rax,%rdi
call   1030 <puts@plt>
mov    -0x2790(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2790(%rbp)
jmp    124c <main+0xfc>
mov    -0x2794(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2794(%rbp)
jmp    116c <main+0x1c>
xor    %eax,%eax
add    $0x27a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2788,%rsp
lea    0xe88(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     1274 <main+0x114>
cmpl   $0x0,0x8(%rsp)
je     1274 <main+0x114>
mov    $0x1,%r13d
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%r14
nopl   (%rax)
lea    0xe(%rsp),%rdi
call   1070 <gets@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11ea <main+0x8a>
mov    %r12,%rbp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1070 <gets@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rsi
add    $0x65,%rbp
cmp    %rsi,%rbx
jl     11d0 <main+0x70>
mov    0x8(%rsp),%edx
mov    %r12,%rdi
call   1060 <fillMineInfo@plt>
cmp    $0x2,%r13d
jb     1206 <main+0xa6>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf9(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    124a <main+0xea>
mov    %r12,%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
add    $0x65,%r15
cmp    %rax,%rbp
jl     1230 <main+0xd0>
lea    0xdaf(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %r14,%rdx
call   1080 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     1274 <main+0x114>
add    $0x1,%r13d
cmpl   $0x0,0x8(%rsp)
jne    11b0 <main+0x50>
xor    %eax,%eax
add    $0x2788,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [12 x i8] c"Field #%d:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x [101 x i8]]
%3 = alloca [2 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %7
br label %8
8: ; preds = %0, %58
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %12, %8
br label %61
16: ; preds = %12
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%18 = call i32 @gets(i8* %17)
store i32 0, i32* %6
br label %19
19: ; preds = %29, %16
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x [101 x i8]], [100 x [101 x i8]]* %2, i64 0, i64 %25
%27 = getelementptr inbounds [101 x i8], [101 x i8]* %26, i64 0, i64 0
%28 = call i32 @gets(i8* %27)
br label %29
29: ; preds = %23
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %19
32: ; preds = %19
%33 = getelementptr inbounds [100 x [101 x i8]], [100 x [101 x i8]]* %2, i64 0, i64 0
%34 = bitcast [101 x i8]* %33 to i8**
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = call i32 @fillMineInfo(i8** %34, i32 %35, i32 %36)
%38 = load i32, i32* %7
%39 = icmp sgt i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %42
42: ; preds = %40, %32
%43 = load i32, i32* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %43)
store i32 0, i32* %6
br label %45
45: ; preds = %55, %42
%46 = load i32, i32* %6
%47 = load i32, i32* %4
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [100 x [101 x i8]], [100 x [101 x i8]]* %2, i64 0, i64 %51
%53 = getelementptr inbounds [101 x i8], [101 x i8]* %52, i64 0, i64 0
%54 = call i32 @puts(i8* %53)
br label %55
55: ; preds = %49
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %45
58: ; preds = %45
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %8
61: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.2 = [12 x i8] c"Field #%d:\0A\00"
define i32 @main() {
%1 = alloca [100 x [101 x i8]]
%2 = alloca [2 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [100 x [101 x i8]], [100 x [101 x i8]]* %1, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %57
15: ; preds = %0
%16 = bitcast [100 x [101 x i8]]* %1 to i8**
br label %17
17: ; preds = %15, %49
%18 = phi i32 [ 1, %15 ], [ %50, %49 ]
%19 = call i32 @gets(i8* %6)
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %17, %22
%23 = phi i64 [ %26, %22 ], [ 0, %17 ]
%24 = getelementptr inbounds [100 x [101 x i8]], [100 x [101 x i8]]* %1, i64 0, i64 %23, i64 0
%25 = call i32 @gets(i8* %24)
%26 = add nuw nsw i64 %23, 1
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %22, label %30
30: ; preds = %22, %17
%31 = phi i32 [ %20, %17 ], [ %27, %22 ]
%32 = load i32, i32* %4
%33 = call i32 @fillMineInfo(i8** %16, i32 %31, i32 %32)
%34 = icmp ugt i32 %18, 1
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 @putchar(i32 10)
br label %37
37: ; preds = %35, %30
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%39 = load i32, i32* %3
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %49
41: ; preds = %37, %41
%42 = phi i64 [ %45, %41 ], [ 0, %37 ]
%43 = getelementptr inbounds [100 x [101 x i8]], [100 x [101 x i8]]* %1, i64 0, i64 %42, i64 0
%44 = call i32 @puts(i8* %43)
%45 = add nuw nsw i64 %42, 1
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = icmp slt i64 %45, %47
br i1 %48, label %41, label %49
49: ; preds = %41, %37
%50 = add nuw nsw i32 %18, 1
%51 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%52 = load i32, i32* %3
%53 = icmp ne i32 %52, 0
%54 = load i32, i32* %4
%55 = icmp ne i32 %54, 0
%56 = select i1 %53, i1 %55, i1 false
br i1 %56, label %17, label %57
57: ; preds = %49, %0
ret i32 0
}