#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 Leste(char **, char *, int *, int *);
int Nordeste(char **, char *, int *, int *);
int Noroeste(char **, char *, int *, int *);
int Norte(char **, char *, int *, int *);
int Oeste(char **, char *, int *, int *);
int Sudeste(char **, char *, int *, int *);
int Sudoeste(char **, char *, int *, int *);
int Sul(char **, char *, int *, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char cacapalavra[100][100];
  char palavra[100];
  int k = 0, n, *pc = 0, *pl = 0, aux;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      scanf("%c", &cacapalavra[i][j]);
  scanf("%s", palavra);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (palavra[k] == cacapalavra[i][j]) {
        *pc = j;
        *pl = i;
        aux = Norte(cacapalavra, palavra, pc, pl);
        aux = Sul(cacapalavra, palavra, pc, pl);
        aux = Leste(cacapalavra, palavra, pc, pl);
        aux = Oeste(cacapalavra, palavra, pc, pl);
        aux = Nordeste(cacapalavra, palavra, pc, pl);
        aux = Noroeste(cacapalavra, palavra, pc, pl);
        aux = Sudeste(cacapalavra, palavra, pc, pl);
        aux = Sudoeste(cacapalavra, palavra, pc, pl);
        printf("%d", aux);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2794(%rbp)
movq   $0x0,-0x27a0(%rbp)
movq   $0x0,-0x27a8(%rbp)
lea    0xe27(%rip),%rdi
lea    -0x2798(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
movl   $0x0,-0x27b0(%rbp)
mov    -0x27b0(%rbp),%eax
cmp    -0x2798(%rbp),%eax
jge    1279 <main+0xd9>
movl   $0x0,-0x27b4(%rbp)
mov    -0x27b4(%rbp),%eax
cmp    -0x2798(%rbp),%eax
jge    1260 <main+0xc0>
movslq -0x27b0(%rbp),%rax
lea    -0x2720(%rbp),%rsi
imul   $0x64,%rax,%rax
add    %rax,%rsi
movslq -0x27b4(%rbp),%rax
add    %rax,%rsi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x27b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x27b4(%rbp)
jmp    120d <main+0x6d>
jmp    1265 <main+0xc5>
mov    -0x27b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x27b0(%rbp)
jmp    11f1 <main+0x51>
lea    -0x2790(%rbp),%rsi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
movl   $0x0,-0x27b8(%rbp)
mov    -0x27b8(%rbp),%eax
cmp    -0x2798(%rbp),%eax
jge    1497 <main+0x2f7>
movl   $0x0,-0x27bc(%rbp)
mov    -0x27bc(%rbp),%eax
cmp    -0x2798(%rbp),%eax
jge    147e <main+0x2de>
movslq -0x2794(%rbp),%rax
movsbl -0x2790(%rbp,%rax,1),%eax
ff
movslq -0x27b8(%rbp),%rdx
lea    -0x2720(%rbp),%rcx
imul   $0x64,%rdx,%rdx
add    %rdx,%rcx
movslq -0x27bc(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1465 <main+0x2c5>
mov    -0x27bc(%rbp),%ecx
mov    -0x27a0(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x27b8(%rbp),%ecx
mov    -0x27a8(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   1050 <Norte@plt>
mov    %eax,-0x27ac(%rbp)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   10b0 <Sul@plt>
mov    %eax,-0x27ac(%rbp)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   1030 <Leste@plt>
mov    %eax,-0x27ac(%rbp)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   1070 <Oeste@plt>
mov    %eax,-0x27ac(%rbp)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   1060 <Nordeste@plt>
mov    %eax,-0x27ac(%rbp)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   1080 <Noroeste@plt>
mov    %eax,-0x27ac(%rbp)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   10c0 <Sudeste@plt>
mov    %eax,-0x27ac(%rbp)
lea    -0x2720(%rbp),%rdi
lea    -0x2790(%rbp),%rsi
mov    -0x27a0(%rbp),%rdx
mov    -0x27a8(%rbp),%rcx
call   1090 <Sudoeste@plt>
mov    %eax,-0x27ac(%rbp)
mov    -0x27ac(%rbp),%esi
lea    0xba0(%rip),%rdi
call   1040 <printf@plt>
jmp    146a <main+0x2ca>
mov    -0x27bc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x27bc(%rbp)
jmp    12b4 <main+0x114>
jmp    1483 <main+0x2e3>
mov    -0x27b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x27b8(%rbp)
jmp    1298 <main+0xf8>
mov    -0x4(%rbp),%eax
add    $0x27c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2798,%rsp
lea    0xedb(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    118e <main+0x7e>
lea    0x80(%rsp),%r12
lea    0xebb(%rip),%r14
xor    %r15d,%r15d
jmp    1160 <main+0x50>
nopl   (%rax)
movslq %eax,%rcx
add    $0x1,%r15
add    $0x64,%r12
cmp    %rcx,%r15
jge    118e <main+0x7e>
test   %eax,%eax
jle    1150 <main+0x40>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1170 <main+0x60>
jmp    1150 <main+0x40>
lea    0xe71(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
xor    %eax,%eax
add    $0x2798,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x [100 x i8]]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32* null, i32** %6
store i32* null, i32** %7
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 0, i32* %9
br label %14
14: ; preds = %35, %0
%15 = load i32, i32* %9
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %38
18: ; preds = %14
store i32 0, i32* %10
br label %19
19: ; preds = %31, %18
%20 = load i32, i32* %10
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 %25
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %26, i64 0, i64 %28
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %23
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %19
34: ; preds = %19
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %14
38: ; preds = %14
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %39)
store i32 0, i32* %11
br label %41
41: ; preds = %125, %38
%42 = load i32, i32* %11
%43 = load i32, i32* %5
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %128
45: ; preds = %41
store i32 0, i32* %12
br label %46
46: ; preds = %121, %45
%47 = load i32, i32* %12
%48 = load i32, i32* %5
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %124
50: ; preds = %46
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = load i32, i32* %11
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 %57
%59 = load i32, i32* %12
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %58, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %55, %63
br i1 %64, label %65, label %120
65: ; preds = %50
%66 = load i32, i32* %12
%67 = load i32*, i32** %6
store i32 %66, i32* %67
%68 = load i32, i32* %11
%69 = load i32*, i32** %7
store i32 %68, i32* %69
%70 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%71 = bitcast [100 x i8]* %70 to i8**
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%73 = load i32*, i32** %6
%74 = load i32*, i32** %7
%75 = call i32 @Norte(i8** %71, i8* %72, i32* %73, i32* %74)
store i32 %75, i32* %8
%76 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%77 = bitcast [100 x i8]* %76 to i8**
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%79 = load i32*, i32** %6
%80 = load i32*, i32** %7
%81 = call i32 @Sul(i8** %77, i8* %78, i32* %79, i32* %80)
store i32 %81, i32* %8
%82 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%83 = bitcast [100 x i8]* %82 to i8**
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%85 = load i32*, i32** %6
%86 = load i32*, i32** %7
%87 = call i32 @Leste(i8** %83, i8* %84, i32* %85, i32* %86)
store i32 %87, i32* %8
%88 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%89 = bitcast [100 x i8]* %88 to i8**
%90 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%91 = load i32*, i32** %6
%92 = load i32*, i32** %7
%93 = call i32 @Oeste(i8** %89, i8* %90, i32* %91, i32* %92)
store i32 %93, i32* %8
%94 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%95 = bitcast [100 x i8]* %94 to i8**
%96 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%97 = load i32*, i32** %6
%98 = load i32*, i32** %7
%99 = call i32 @Nordeste(i8** %95, i8* %96, i32* %97, i32* %98)
store i32 %99, i32* %8
%100 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%101 = bitcast [100 x i8]* %100 to i8**
%102 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%103 = load i32*, i32** %6
%104 = load i32*, i32** %7
%105 = call i32 @Noroeste(i8** %101, i8* %102, i32* %103, i32* %104)
store i32 %105, i32* %8
%106 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%107 = bitcast [100 x i8]* %106 to i8**
%108 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%109 = load i32*, i32** %6
%110 = load i32*, i32** %7
%111 = call i32 @Sudeste(i8** %107, i8* %108, i32* %109, i32* %110)
store i32 %111, i32* %8
%112 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %2, i64 0, i64 0
%113 = bitcast [100 x i8]* %112 to i8**
%114 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%115 = load i32*, i32** %6
%116 = load i32*, i32** %7
%117 = call i32 @Sudoeste(i8** %113, i8* %114, i32* %115, i32* %116)
store i32 %117, i32* %8
%118 = load i32, i32* %8
%119 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %118)
br label %120
120: ; preds = %65, %50
br label %121
121: ; preds = %120
%122 = load i32, i32* %12
%123 = add nsw i32 %122, 1
store i32 %123, i32* %12
br label %46
124: ; preds = %46
br label %125
125: ; preds = %124
%126 = load i32, i32* %11
%127 = add nsw i32 %126, 1
store i32 %127, i32* %11
br label %41
128: ; preds = %41
%129 = load i32, i32* %1
ret i32 %129
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [100 x [100 x i8]]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %1, i64 0, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %0, %16
%11 = phi i32 [ %17, %16 ], [ %8, %0 ]
%12 = phi i64 [ %19, %16 ], [ 0, %0 ]
%13 = icmp sgt i32 %11, 0
br i1 %13, label %21, label %16
14: ; preds = %16, %0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret i32 0
16: ; preds = %21, %10
%17 = phi i32 [ %11, %10 ], [ %26, %21 ]
%18 = sext i32 %17 to i64
%19 = add nuw nsw i64 %12, 1
%20 = icmp slt i64 %19, %18
br i1 %20, label %10, label %14
21: ; preds = %10, %21
%22 = phi i64 [ %25, %21 ], [ 0, %10 ]
%23 = getelementptr inbounds [100 x [100 x i8]], [100 x [100 x i8]]* %1, i64 0, i64 %12, i64 %22
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = add nuw nsw i64 %22, 1
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %21, label %16
}