#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*/ nextMove(int, int, int, char **);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int n, r, c;
  scanf("%d", &n);
  scanf("%d", &r);
  scanf("%d", &c);
  char grid[101][101];
  for (int i = 0; i < n; i++) {
    scanf("%s[^\n]%*c", grid[i]);
  }
  nextMove(n, r, c, grid);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2800,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb5(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xea3(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x27f4(%rbp)
mov    -0x27f4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b8 <main+0x98>
movslq -0x27f4(%rbp),%rax
lea    -0x27f0(%rbp),%rsi
imul   $0x65,%rax,%rax
add    %rax,%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x27f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x27f4(%rbp)
jmp    1172 <main+0x52>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    -0x27f0(%rbp),%rcx
call   1030 <nextMove@plt>
xor    %eax,%eax
add    $0x2800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x27f0,%rsp
lea    0xecd(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
jle    119f <main+0x7f>
lea    0x10(%rsp),%r15
lea    0xe8f(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rdi
add    $0x65,%r15
cmp    %rdi,%rbx
jl     1180 <main+0x60>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0x10(%rsp),%rcx
call   1030 <nextMove@plt>
xor    %eax,%eax
add    $0x27f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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