#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);
long process(int, int, int, char **, int **);
int readArgs(char **, int, char **);
int main(int argc, char *argv[]) {
  int n;
  long wallsToPaint;
  char labyrinth[100][100];
  int wasProcessed[100][100];
  n = readArgs(labyrinth, argc, argv);
  wallsToPaint = process(0, 0, n, labyrinth, wasProcessed);
  if (wasProcessed[n - 1][n - 1] == 0)
    wallsToPaint += process(n - 1, n - 1, n, labyrinth, wasProcessed);
  printf("%ld\n", 3 * 3 * wallsToPaint);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc370,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <readArgs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edx
lea    -0x2730(%rbp),%rcx
lea    -0xc370(%rbp),%r8
xor    %esi,%esi
mov    %esi,%edi
call   1040 <process@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0xc370(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11d4 <main+0xa4>
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%edx
lea    -0x2730(%rbp),%rcx
lea    -0xc370(%rbp),%r8
call   1040 <process@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
imul   $0x9,-0x20(%rbp),%rax
mov    %eax,%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xc358,%rsp
mov    %rsi,%rdx
mov    %edi,%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <readArgs@plt>
mov    %eax,%ebp
lea    0x2710(%rsp),%r8
xor    %edi,%edi
xor    %esi,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1040 <process@plt>
mov    %rax,%rbx
movslq %ebp,%rax
lea    -0x1(%rax),%rcx
imul   $0x190,%rcx,%rcx
add    %rsp,%rcx
add    $0x2710,%rcx
cmpl   $0x0,-0x4(%rcx,%rax,4)
jne    119f <main+0x6f>
mov    %ebp,%edi
add    $0xffffffff,%edi
mov    %rsp,%rcx
lea    0x2710(%rsp),%r8
mov    %edi,%esi
mov    %ebp,%edx
call   1040 <process@plt>
add    %rax,%rbx
lea    (%rbx,%rbx,8),%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc358,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [100 x [100 x i8]]
%4 = alloca [100 x [100 x i32]]
%5 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %3, i64 0, i64 0, i64 0
%6 = bitcast [100 x [100 x i32]]* %4 to i8*
%7 = bitcast [100 x [100 x i8]]* %3 to i8**
%8 = call i32 @readArgs(i8** %7, i32 %0, i8** %1)
%9 = bitcast [100 x [100 x i32]]* %4 to i32**
%10 = call i64 @process(i32 0, i32 0, i32 %8, i8** %7, i32** %9)
%11 = add nsw i32 %8, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %4, i64 0, i64 %12, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i64 @process(i32 %11, i32 %11, i32 %8, i8** %7, i32** %9)
%18 = add nsw i64 %17, %10
br label %19
19: ; preds = %16, %2
%20 = phi i64 [ %18, %16 ], [ %10, %2 ]
%21 = trunc i64 %20 to i32
%22 = mul i32 %21, 9
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
ret i32 0
}