#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*/ next_move(int, int, char **);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(void) {
  int pos[2], i;
  char board[5][5], line[6];
  scanf("%d", &pos[0]);
  scanf("%d", &pos[1]);
  for (i = 0; i < 5; i++) {
    scanf("%s[^\\n]%*c", line);
    strncpy(board[i], line, 5);
  }
  next_move(pos[0], pos[1], board);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0xc(%rbp),%rsi
add    $0x4,%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    11b5 <main+0x85>
lea    -0x36(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movslq -0x10(%rbp),%rax
lea    -0x30(%rbp),%rdi
imul   $0x5,%rax,%rax
add    %rax,%rdi
lea    -0x36(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116e <main+0x3e>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1040 <next_move@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xec0(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9e(%rip),%r15
lea    0x2a(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x15(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x1a(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x1f(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x24(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
mov    %r14,%rdx
call   1040 <next_move@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [11 x i8] c"%s[^\\n]%*c\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [5 x [5 x i8]]
%3 = alloca [6 x i8]
%4 = bitcast [2 x i32]* %1 to i8*
%5 = getelementptr inbounds [5 x [5 x i8]], [5 x [5 x i8]]* %2, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%12 = call i32 @strncpy(i8* %5, i8* %6, i32 5)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = getelementptr inbounds [5 x [5 x i8]], [5 x [5 x i8]]* %2, i64 0, i64 1, i64 0
%15 = call i32 @strncpy(i8* %14, i8* %6, i32 5)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%17 = getelementptr inbounds [5 x [5 x i8]], [5 x [5 x i8]]* %2, i64 0, i64 2, i64 0
%18 = call i32 @strncpy(i8* %17, i8* %6, i32 5)
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%20 = getelementptr inbounds [5 x [5 x i8]], [5 x [5 x i8]]* %2, i64 0, i64 3, i64 0
%21 = call i32 @strncpy(i8* %20, i8* %6, i32 5)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%23 = getelementptr inbounds [5 x [5 x i8]], [5 x [5 x i8]]* %2, i64 0, i64 4, i64 0
%24 = call i32 @strncpy(i8* %23, i8* %6, i32 5)
%25 = load i32, i32* %7
%26 = load i32, i32* %9
%27 = bitcast [5 x [5 x i8]]* %2 to i8**
%28 = call i32 @next_move(i32 %25, i32 %26, i8** %27)
ret i32 0
}