#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ processTile(char **, int, int);
int main(void) {
  int cases, caseNum = 0;
  int rows, cols, r, c;
  FILE *fp = fopen("fire.in", "r");
  fscanf(fp, "%d", &cases);
  char map[21][21];
  while (caseNum++ < cases) {
    fscanf(fp, "%d %d", &rows, &cols);
    for (r = 0; r < rows; r++) {
      fscanf(fp, "%s", map[r]);
    }
    for (c = 0; c <= cols; c++) {
      map[rows][c] = '\0';
    }
    for (r = 0; r < rows; r++) {
      for (c = 0; c < cols; c++) {
        processTile(map, r, c);
      }
    }
    printf("Map #%d:\n", caseNum);
    for (r = 0; r < rows; r++) {
      printf("%s\n", map[r]);
    }
    printf("\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe90(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe82(%rip),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cmp    -0x8(%rbp),%eax
jge    1302 <main+0x1b2>
mov    -0x28(%rbp),%rdi
lea    0xe55(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1050 <fscanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1209 <main+0xb9>
mov    -0x28(%rbp),%rdi
movslq -0x18(%rbp),%rax
lea    -0x1f0(%rbp),%rdx
imul   $0x15,%rax,%rax
add    %rax,%rdx
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11cb <main+0x7b>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1244 <main+0xf4>
movslq -0x10(%rbp),%rcx
lea    -0x1f0(%rbp),%rax
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1210 <main+0xc0>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    129d <main+0x14d>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128a <main+0x13a>
lea    -0x1f0(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <processTile@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    125e <main+0x10e>
jmp    128f <main+0x13f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    124b <main+0xfb>
mov    -0xc(%rbp),%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12ef <main+0x19f>
movslq -0x18(%rbp),%rax
lea    -0x1f0(%rbp),%rsi
imul   $0x15,%rax,%rax
add    %rax,%rsi
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12b5 <main+0x165>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1196 <main+0x46>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e8,%rsp
lea    0xe68(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xe5f(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1080 <fscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    132f <main+0x1af>
mov    $0x1,%eax
lea    0x20(%rsp),%r12
lea    0xe37(%rip),%r13
mov    %r14,0x10(%rsp)
jmp    1205 <main+0x85>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%eax
cmp    0xc(%rsp),%r14d
mov    0x10(%rsp),%r14
lea    0xe11(%rip),%r13
jge    132f <main+0x1af>
mov    %rax,0x18(%rsp)
mov    %r14,%rdi
lea    0xdf6(%rip),%rsi
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1080 <fscanf@plt>
mov    0x4(%rsp),%r15d
test   %r15d,%r15d
jle    1262 <main+0xe2>
mov    %r12,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fscanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%r15
add    $0x15,%rbp
cmp    %r15,%rbx
jl     1240 <main+0xc0>
mov    0x8(%rsp),%r14d
test   %r14d,%r14d
js     128a <main+0x10a>
movslq %r15d,%rax
lea    (%rax,%rax,4),%rcx
lea    (%rax,%rcx,4),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
lea    0x1(%r14),%rdx
xor    %esi,%esi
call   1070 <memset@plt>
test   %r15d,%r15d
jle    12e0 <main+0x160>
xor    %r13d,%r13d
jmp    12a9 <main+0x129>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13d
cmp    %r15d,%r13d
jge    12e0 <main+0x160>
test   %r14d,%r14d
jle    12a0 <main+0x120>
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
call   10a0 <processTile@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%r14d
cmp    %r14d,%ebp
jl     12b0 <main+0x130>
mov    0x4(%rsp),%r15d
jmp    12a0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd2c(%rip),%rdi
mov    0x18(%rsp),%r14
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11e0 <main+0x60>
mov    %r12,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x15,%rbp
cmp    %rax,%rbx
jl     1310 <main+0x190>
jmp    11e0 <main+0x60>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"fire.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [10 x i8] c"Map #%d:\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [21 x [21 x i8]]
store i32 0, i32* %1
store i32 0, i32* %3
%10 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %8
%11 = load i32*, i32** %8
%12 = call i32 (i32*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %13
13: ; preds = %89, %0
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %91
18: ; preds = %13
%19 = load i32*, i32** %8
%20 = call i32 (i32*, i8*, ...) @fscanf(i32* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %4, i32* %5)
store i32 0, i32* %6
br label %21
21: ; preds = %32, %18
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i32*, i32** %8
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [21 x [21 x i8]], [21 x [21 x i8]]* %9, i64 0, i64 %28
%30 = getelementptr inbounds [21 x i8], [21 x i8]* %29, i64 0, i64 0
%31 = call i32 (i32*, i8*, ...) @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %21
35: ; preds = %21
store i32 0, i32* %7
br label %36
36: ; preds = %47, %35
%37 = load i32, i32* %7
%38 = load i32, i32* %5
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [21 x [21 x i8]], [21 x [21 x i8]]* %9, i64 0, i64 %42
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [21 x i8], [21 x i8]* %43, i64 0, i64 %45
store i8 0, i8* %46
br label %47
47: ; preds = %40
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %36
50: ; preds = %36
store i32 0, i32* %6
br label %51
51: ; preds = %70, %50
%52 = load i32, i32* %6
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %73
55: ; preds = %51
store i32 0, i32* %7
br label %56
56: ; preds = %66, %55
%57 = load i32, i32* %7
%58 = load i32, i32* %5
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %69
60: ; preds = %56
%61 = getelementptr inbounds [21 x [21 x i8]], [21 x [21 x i8]]* %9, i64 0, i64 0
%62 = bitcast [21 x i8]* %61 to i8**
%63 = load i32, i32* %6
%64 = load i32, i32* %7
%65 = call i32 @processTile(i8** %62, i32 %63, i32 %64)
br label %66
66: ; preds = %60
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
br label %56
69: ; preds = %56
br label %70
70: ; preds = %69
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %51
73: ; preds = %51
%74 = load i32, i32* %3
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %74)
store i32 0, i32* %6
br label %76
76: ; preds = %86, %73
%77 = load i32, i32* %6
%78 = load i32, i32* %4
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %89
80: ; preds = %76
%81 = load i32, i32* %6
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [21 x [21 x i8]], [21 x [21 x i8]]* %9, i64 0, i64 %82
%84 = getelementptr inbounds [21 x i8], [21 x i8]* %83, i64 0, i64 0
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %80
%87 = load i32, i32* %6
%88 = add nsw i32 %87, 1
store i32 %88, i32* %6
br label %76
89: ; preds = %76
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %13
91: ; preds = %13
%92 = load i32*, i32** %8
%93 = call i32 @fclose(i32* %92)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"fire.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [10 x i8] c"Map #%d:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [21 x [21 x i8]]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = getelementptr inbounds [21 x [21 x i8]], [21 x [21 x i8]]* %4, i64 0, i64 0, i64 0
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %74
13: ; preds = %0
%14 = bitcast [21 x [21 x i8]]* %4 to i8**
br label %15
15: ; preds = %13, %69
%16 = phi i32 [ 1, %13 ], [ %71, %69 ]
%17 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %3)
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %29, %15
%21 = phi i32 [ %18, %15 ], [ %34, %29 ]
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %20
%25 = sext i32 %21 to i64
%26 = getelementptr [21 x [21 x i8]], [21 x [21 x i8]]* %4, i64 0, i64 %25, i64 0
%27 = zext i32 %22 to i64
%28 = add nuw nsw i64 %27, 1
br label %37
29: ; preds = %15, %29
%30 = phi i64 [ %33, %29 ], [ 0, %15 ]
%31 = getelementptr inbounds [21 x [21 x i8]], [21 x [21 x i8]]* %4, i64 0, i64 %30, i64 0
%32 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = add nuw nsw i64 %30, 1
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %29, label %20
37: ; preds = %24, %20
%38 = icmp sgt i32 %21, 0
br i1 %38, label %39, label %57
39: ; preds = %37, %52
%40 = phi i32 [ %53, %52 ], [ %21, %37 ]
%41 = phi i32 [ %54, %52 ], [ %22, %37 ]
%42 = phi i32 [ %55, %52 ], [ 0, %37 ]
%43 = icmp sgt i32 %41, 0
br i1 %43, label %44, label %52
44: ; preds = %39, %44
%45 = phi i32 [ %47, %44 ], [ 0, %39 ]
%46 = call i32 @processTile(i8** %14, i32 %42, i32 %45)
%47 = add nuw nsw i32 %45, 1
%48 = load i32, i32* %3
%49 = icmp slt i32 %47, %48
br i1 %49, label %44, label %50
50: ; preds = %44
%51 = load i32, i32* %2
br label %52
52: ; preds = %50, %39
%53 = phi i32 [ %51, %50 ], [ %40, %39 ]
%54 = phi i32 [ %48, %50 ], [ %41, %39 ]
%55 = add nuw nsw i32 %42, 1
%56 = icmp slt i32 %55, %53
br i1 %56, label %39, label %57
57: ; preds = %52, %37
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%59 = load i32, i32* %2
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %69
61: ; preds = %57, %61
%62 = phi i64 [ %65, %61 ], [ 0, %57 ]
%63 = getelementptr inbounds [21 x [21 x i8]], [21 x [21 x i8]]* %4, i64 0, i64 %62, i64 0
%64 = call i32 @puts(i8* %63)
%65 = add nuw nsw i64 %62, 1
%66 = load i32, i32* %2
%67 = sext i32 %66 to i64
%68 = icmp slt i64 %65, %67
br i1 %68, label %61, label %69
69: ; preds = %61, %57
%70 = call i32 @putchar(i32 10)
%71 = add nuw nsw i32 %16, 1
%72 = load i32, i32* %1
%73 = icmp slt i32 %16, %72
br i1 %73, label %15, label %74
74: ; preds = %69, %0
%75 = call i32 @fclose(i32* %8)
ret i32 0
}