#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*/ printf(char *, int);
scalar_t__ scanf(char *, ...);
int walk(char **, int, int, int);
int main() {
  char buffer, maze[33][33];
  int n, lin, col;
  if (scanf("%d", &n)) {
    for (lin = 0; lin < n; lin++) {
      for (col = 0; col < n; col++) {
        while (scanf("%c", &buffer) && buffer == '\n')
          ;
        maze[lin][col] = buffer == '#';
      }
    }
    printf("%d\n", 9 * (walk(maze, 0, 0, n) + walk(maze, n - 1, n - 1, n)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x454(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     12a3 <main+0x173>
movl   $0x0,-0x458(%rbp)
mov    -0x458(%rbp),%eax
cmp    -0x454(%rbp),%eax
jge    124a <main+0x11a>
movl   $0x0,-0x45c(%rbp)
mov    -0x45c(%rbp),%eax
cmp    -0x454(%rbp),%eax
jge    1231 <main+0x101>
jmp    119e <main+0x6e>
lea    0xe5e(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x45d(%rbp)
je     11d5 <main+0xa5>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x45d(%rbp)
mov    -0x45d(%rbp),%al
test   $0x1,%al
jne    11e8 <main+0xb8>
jmp    11ed <main+0xbd>
jmp    119e <main+0x6e>
movsbl -0x5(%rbp),%eax
cmp    $0x23,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,%dl
movslq -0x458(%rbp),%rcx
lea    -0x450(%rbp),%rax
imul   $0x21,%rcx,%rcx
add    %rcx,%rax
movslq -0x45c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x45c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x45c(%rbp)
jmp    1187 <main+0x57>
jmp    1236 <main+0x106>
mov    -0x458(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x458(%rbp)
jmp    116b <main+0x3b>
lea    -0x450(%rbp),%rdi
mov    -0x454(%rbp),%ecx
xor    %edx,%edx
mov    %edx,%esi
call   1050 <walk@plt>
mov    %eax,-0x464(%rbp)
lea    -0x450(%rbp),%rdi
mov    -0x454(%rbp),%esi
sub    $0x1,%esi
mov    -0x454(%rbp),%edx
sub    $0x1,%edx
mov    -0x454(%rbp),%ecx
call   1050 <walk@plt>
mov    %eax,%ecx
mov    -0x464(%rbp),%eax
add    %ecx,%eax
imul   $0x9,%eax,%esi
lea    0xd68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x458,%rsp
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %rax,%rax
je     1213 <main+0xe3>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    11de <main+0xae>
lea    0xe9b(%rip),%r14
lea    0xb(%rsp),%rbx
xor    %r15d,%r15d
jmp    118c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %ecx,%rax
add    $0x1,%r15
cmp    %rax,%r15
jge    11de <main+0xae>
test   %ecx,%ecx
jle    1180 <main+0x50>
xor    %ebp,%ebp
jmp    11c0 <main+0x90>
mov    %r15,%rax
shl    $0x5,%rax
add    %r15,%rax
cmp    $0x23,%cl
lea    0x10(%rsp,%rax,1),%rax
sete   0x0(%rbp,%rax,1)
add    $0x1,%rbp
movslq 0xc(%rsp),%rcx
cmp    %rcx,%rbp
jge    1180 <main+0x50>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movzbl 0xb(%rsp),%ecx
test   %rax,%rax
je     1194 <main+0x64>
cmp    $0xa,%cl
je     11c0 <main+0x90>
jmp    1194 <main+0x64>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <walk@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%ecx
lea    -0x1(%rcx),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   1050 <walk@plt>
add    %ebp,%eax
lea    (%rax,%rax,8),%esi
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [33 x [33 x i8]]
%3 = alloca i32
%4 = getelementptr inbounds [33 x [33 x i8]], [33 x [33 x i8]]* %2, i64 0, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %46, label %8
8: ; preds = %0
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %36
11: ; preds = %8, %31
%12 = phi i32 [ %32, %31 ], [ %9, %8 ]
%13 = phi i64 [ %34, %31 ], [ 0, %8 ]
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %31
15: ; preds = %11, %23
%16 = phi i64 [ %27, %23 ], [ 0, %11 ]
br label %17
17: ; preds = %15, %17
%18 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%19 = icmp ne i64 %18, 0
%20 = load i8, i8* %1
%21 = icmp eq i8 %20, 10
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %17, label %23
23: ; preds = %17
%24 = icmp eq i8 %20, 35
%25 = zext i1 %24 to i8
%26 = getelementptr inbounds [33 x [33 x i8]], [33 x [33 x i8]]* %2, i64 0, i64 %13, i64 %16
store i8 %25, i8* %26
%27 = add nuw nsw i64 %16, 1
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %15, label %31
31: ; preds = %23, %11
%32 = phi i32 [ %12, %11 ], [ %28, %23 ]
%33 = sext i32 %32 to i64
%34 = add nuw nsw i64 %13, 1
%35 = icmp slt i64 %34, %33
br i1 %35, label %11, label %36
36: ; preds = %31, %8
%37 = phi i32 [ %9, %8 ], [ %32, %31 ]
%38 = bitcast [33 x [33 x i8]]* %2 to i8**
%39 = call i32 @walk(i8** %38, i32 0, i32 0, i32 %37)
%40 = load i32, i32* %3
%41 = add nsw i32 %40, -1
%42 = call i32 @walk(i8** %38, i32 %41, i32 %41, i32 %40)
%43 = add nsw i32 %42, %39
%44 = mul nsw i32 %43, 9
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %36, %0
ret i32 0
}