#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 alphabetaAV(int **, int, int *, int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ moveAV(int **, int, int, int *, int *);
int /*<<< orphan*/ undoAV(int **, int, int);
int nxtMoveAV(int mygrid[6][7], int myMove, int *lastX, int *lastY) {
  int moveScore[7], width = 7, height = 6, invalidScore = 1000000, m;
  for (m = 0; m < width; m++)
    moveScore[m] = 0;
  if (myMove == 1) {
    int maxScore = -invalidScore;
    int maxMove = 0;
    for (m = 0; m < width; ++m)
      if (mygrid[height - 1][m] == 0) {
        moveAV(mygrid, m, 1, lastX, lastY);
        int score = alphabetaAV(mygrid, -1, lastX, lastY, -1000000, 1000000, 0);
        moveScore[m] = score;
        if (score >= maxScore) {
          maxScore = score;
          maxMove = m;
        }
        undoAV(mygrid, m, 1);
      } else
        moveScore[m] = invalidScore;
    return maxMove;
  } else if (myMove == -1) {
    int minScore = invalidScore;
    int minMove = 0;
    for (m = 0; m < width; ++m) {
      if (mygrid[height - 1][m] == 0) {
        moveAV(mygrid, m, -1, lastX, lastY);
        int score = alphabetaAV(mygrid, 1, lastX, lastY, -1000000, 1000000, 0);
        moveScore[m] = score;
        if (score < minScore) {
          minScore = score;
          minMove = m;
        }
        undoAV(mygrid, m, -1);
      } else
        moveScore[m] = invalidScore;
    }
    return minMove;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<nxtMoveAV>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x7,-0x54(%rbp)
movl   $0x6,-0x58(%rbp)
movl   $0xf4240,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    118c <nxtMoveAV+0x5c>
movslq -0x60(%rbp),%rax
movl   $0x0,-0x50(%rbp,%rax,4)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1166 <nxtMoveAV+0x36>
cmpl   $0x1,-0x14(%rbp)
jne    1283 <nxtMoveAV+0x153>
xor    %eax,%eax
sub    -0x5c(%rbp),%eax
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1278 <nxtMoveAV+0x148>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
movslq -0x60(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    125a <nxtMoveAV+0x12a>
mov    -0x10(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    $0x1,%edx
call   1040 <moveAV@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0xffffffff,%esi
mov    $0xfff0bdc0,%r8d
mov    $0xf4240,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1030 <alphabetaAV@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%ecx
movslq -0x60(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x6c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jl     1244 <nxtMoveAV+0x114>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    $0x1,%edx
call   1050 <undoAV@plt>
jmp    1265 <nxtMoveAV+0x135>
mov    -0x5c(%rbp),%ecx
movslq -0x60(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
jmp    126a <nxtMoveAV+0x13a>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11ac <nxtMoveAV+0x7c>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    137f <nxtMoveAV+0x24f>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1378 <nxtMoveAV+0x248>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    136d <nxtMoveAV+0x23d>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
movslq -0x60(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    134f <nxtMoveAV+0x21f>
mov    -0x10(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    $0xffffffff,%edx
call   1040 <moveAV@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
mov    $0xfff0bdc0,%r8d
mov    $0xf4240,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1030 <alphabetaAV@plt>
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%ecx
movslq -0x60(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x78(%rbp),%eax
cmp    -0x70(%rbp),%eax
jge    1339 <nxtMoveAV+0x209>
mov    -0x78(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    $0xffffffff,%edx
call   1050 <undoAV@plt>
jmp    135a <nxtMoveAV+0x22a>
mov    -0x5c(%rbp),%ecx
movslq -0x60(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
jmp    135f <nxtMoveAV+0x22f>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    12a1 <nxtMoveAV+0x171>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    137f <nxtMoveAV+0x24f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nxtMoveAV>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
cmp    $0x1,%esi
je     11df <nxtMoveAV+0xaf>
xor    %r12d,%r12d
cmp    $0xffffffff,%esi
jne    125b <nxtMoveAV+0x12b>
mov    $0xf4240,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    117e <nxtMoveAV+0x4e>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    $0x7,%rbp
je     125b <nxtMoveAV+0x12b>
cmpl   $0x0,0x8c(%rbx,%rbp,4)
jne    1170 <nxtMoveAV+0x40>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0xffffffff,%edx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <moveAV@plt>
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    $0xfff0bdc0,%r8d
mov    $0xf4240,%r9d
call   1030 <alphabetaAV@plt>
cmp    %r13d,%eax
cmovl  %eax,%r13d
cmovl  %ebp,%r12d
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0xffffffff,%edx
call   1050 <undoAV@plt>
jmp    1170 <nxtMoveAV+0x40>
mov    $0xfff0bdc0,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    11fa <nxtMoveAV+0xca>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    $0x7,%rbp
je     125b <nxtMoveAV+0x12b>
cmpl   $0x0,0x8c(%rbx,%rbp,4)
jne    11f0 <nxtMoveAV+0xc0>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <moveAV@plt>
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    $0xfff0bdc0,%r8d
mov    $0xf4240,%r9d
call   1030 <alphabetaAV@plt>
cmp    %r13d,%eax
cmovge %eax,%r13d
cmovge %ebp,%r12d
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1050 <undoAV@plt>
jmp    11f0 <nxtMoveAV+0xc0>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @nxtMoveAV([7 x i32]* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca [7 x i32]*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca [7 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store [7 x i32]* %0, [7 x i32]** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 7, i32* %11
store i32 6, i32* %12
store i32 1000000, i32* %13
store i32 0, i32* %14
br label %21
21: ; preds = %29, %4
%22 = load i32, i32* %14
%23 = load i32, i32* %11
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i32, i32* %14
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [7 x i32], [7 x i32]* %10, i64 0, i64 %27
store i32 0, i32* %28
br label %29
29: ; preds = %25
%30 = load i32, i32* %14
%31 = add nsw i32 %30, 1
store i32 %31, i32* %14
br label %21
32: ; preds = %21
%33 = load i32, i32* %7
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %91
35: ; preds = %32
%36 = load i32, i32* %13
%37 = sub nsw i32 0, %36
store i32 %37, i32* %15
store i32 0, i32* %16
store i32 0, i32* %14
br label %38
38: ; preds = %86, %35
%39 = load i32, i32* %14
%40 = load i32, i32* %11
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %89
42: ; preds = %38
%43 = load [7 x i32]*, [7 x i32]** %6
%44 = load i32, i32* %12
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [7 x i32], [7 x i32]* %43, i64 %46
%48 = load i32, i32* %14
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [7 x i32], [7 x i32]* %47, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %80
53: ; preds = %42
%54 = load [7 x i32]*, [7 x i32]** %6
%55 = bitcast [7 x i32]* %54 to i32**
%56 = load i32, i32* %14
%57 = load i32*, i32** %8
%58 = load i32*, i32** %9
%59 = call i32 @moveAV(i32** %55, i32 %56, i32 1, i32* %57, i32* %58)
%60 = load [7 x i32]*, [7 x i32]** %6
%61 = bitcast [7 x i32]* %60 to i32**
%62 = load i32*, i32** %8
%63 = load i32*, i32** %9
%64 = call i32 @alphabetaAV(i32** %61, i32 -1, i32* %62, i32* %63, i32 -1000000, i32 1000000, i32 0)
store i32 %64, i32* %17
%65 = load i32, i32* %17
%66 = load i32, i32* %14
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [7 x i32], [7 x i32]* %10, i64 0, i64 %67
store i32 %65, i32* %68
%69 = load i32, i32* %17
%70 = load i32, i32* %15
%71 = icmp sge i32 %69, %70
br i1 %71, label %72, label %75
72: ; preds = %53
%73 = load i32, i32* %17
store i32 %73, i32* %15
%74 = load i32, i32* %14
store i32 %74, i32* %16
br label %75
75: ; preds = %72, %53
%76 = load [7 x i32]*, [7 x i32]** %6
%77 = bitcast [7 x i32]* %76 to i32**
%78 = load i32, i32* %14
%79 = call i32 @undoAV(i32** %77, i32 %78, i32 1)
br label %85
80: ; preds = %42
%81 = load i32, i32* %13
%82 = load i32, i32* %14
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [7 x i32], [7 x i32]* %10, i64 0, i64 %83
store i32 %81, i32* %84
br label %85
85: ; preds = %80, %75
br label %86
86: ; preds = %85
%87 = load i32, i32* %14
%88 = add nsw i32 %87, 1
store i32 %88, i32* %14
br label %38
89: ; preds = %38
%90 = load i32, i32* %16
store i32 %90, i32* %5
br label %150
91: ; preds = %32
%92 = load i32, i32* %7
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %149
94: ; preds = %91
%95 = load i32, i32* %13
store i32 %95, i32* %18
store i32 0, i32* %19
store i32 0, i32* %14
br label %96
96: ; preds = %144, %94
%97 = load i32, i32* %14
%98 = load i32, i32* %11
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %147
100: ; preds = %96
%101 = load [7 x i32]*, [7 x i32]** %6
%102 = load i32, i32* %12
%103 = sub nsw i32 %102, 1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [7 x i32], [7 x i32]* %101, i64 %104
%106 = load i32, i32* %14
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [7 x i32], [7 x i32]* %105, i64 0, i64 %107
%109 = load i32, i32* %108
%110 = icmp eq i32 %109, 0
br i1 %110, label %111, label %138
111: ; preds = %100
%112 = load [7 x i32]*, [7 x i32]** %6
%113 = bitcast [7 x i32]* %112 to i32**
%114 = load i32, i32* %14
%115 = load i32*, i32** %8
%116 = load i32*, i32** %9
%117 = call i32 @moveAV(i32** %113, i32 %114, i32 -1, i32* %115, i32* %116)
%118 = load [7 x i32]*, [7 x i32]** %6
%119 = bitcast [7 x i32]* %118 to i32**
%120 = load i32*, i32** %8
%121 = load i32*, i32** %9
%122 = call i32 @alphabetaAV(i32** %119, i32 1, i32* %120, i32* %121, i32 -1000000, i32 1000000, i32 0)
store i32 %122, i32* %20
%123 = load i32, i32* %20
%124 = load i32, i32* %14
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [7 x i32], [7 x i32]* %10, i64 0, i64 %125
store i32 %123, i32* %126
%127 = load i32, i32* %20
%128 = load i32, i32* %18
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %133
130: ; preds = %111
%131 = load i32, i32* %20
store i32 %131, i32* %18
%132 = load i32, i32* %14
store i32 %132, i32* %19
br label %133
133: ; preds = %130, %111
%134 = load [7 x i32]*, [7 x i32]** %6
%135 = bitcast [7 x i32]* %134 to i32**
%136 = load i32, i32* %14
%137 = call i32 @undoAV(i32** %135, i32 %136, i32 -1)
br label %143
138: ; preds = %100
%139 = load i32, i32* %13
%140 = load i32, i32* %14
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [7 x i32], [7 x i32]* %10, i64 0, i64 %141
store i32 %139, i32* %142
br label %143
143: ; preds = %138, %133
br label %144
144: ; preds = %143
%145 = load i32, i32* %14
%146 = add nsw i32 %145, 1
store i32 %146, i32* %14
br label %96
147: ; preds = %96
%148 = load i32, i32* %19
store i32 %148, i32* %5
br label %150
149: ; preds = %91
store i32 0, i32* %5
br label %150
150: ; preds = %149, %147, %89
%151 = load i32, i32* %5
ret i32 %151
}

LLVM IR (-O2):
define i32 @nxtMoveAV([7 x i32]* %0, i32 %1, i32* %2, i32* %3) {
switch i32 %1, label %49 [
i32 1, label %7
i32 -1, label %5
]
5: ; preds = %4
%6 = bitcast [7 x i32]* %0 to i32**
br label %29
7: ; preds = %4
%8 = bitcast [7 x i32]* %0 to i32**
br label %9
9: ; preds = %7, %24
%10 = phi i64 [ 0, %7 ], [ %27, %24 ]
%11 = phi i32 [ 0, %7 ], [ %26, %24 ]
%12 = phi i32 [ -1000000, %7 ], [ %25, %24 ]
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %0, i64 5, i64 %10
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %9
%17 = trunc i64 %10 to i32
%18 = tail call i32 @moveAV(i32** %8, i32 %17, i32 1, i32* %2, i32* %3)
%19 = tail call i32 @alphabetaAV(i32** %8, i32 -1, i32* %2, i32* %3, i32 -1000000, i32 1000000, i32 0)
%20 = icmp slt i32 %19, %12
%21 = select i1 %20, i32 %12, i32 %19
%22 = select i1 %20, i32 %11, i32 %17
%23 = tail call i32 @undoAV(i32** %8, i32 %17, i32 1)
br label %24
24: ; preds = %9, %16
%25 = phi i32 [ %21, %16 ], [ %12, %9 ]
%26 = phi i32 [ %22, %16 ], [ %11, %9 ]
%27 = add nuw nsw i64 %10, 1
%28 = icmp eq i64 %27, 7
br i1 %28, label %49, label %9
29: ; preds = %5, %44
%30 = phi i64 [ 0, %5 ], [ %47, %44 ]
%31 = phi i32 [ 0, %5 ], [ %46, %44 ]
%32 = phi i32 [ 1000000, %5 ], [ %45, %44 ]
%33 = getelementptr inbounds [7 x i32], [7 x i32]* %0, i64 5, i64 %30
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %29
%37 = trunc i64 %30 to i32
%38 = tail call i32 @moveAV(i32** %6, i32 %37, i32 -1, i32* %2, i32* %3)
%39 = tail call i32 @alphabetaAV(i32** %6, i32 1, i32* %2, i32* %3, i32 -1000000, i32 1000000, i32 0)
%40 = icmp slt i32 %39, %32
%41 = select i1 %40, i32 %39, i32 %32
%42 = select i1 %40, i32 %37, i32 %31
%43 = tail call i32 @undoAV(i32** %6, i32 %37, i32 -1)
br label %44
44: ; preds = %29, %36
%45 = phi i32 [ %41, %36 ], [ %32, %29 ]
%46 = phi i32 [ %42, %36 ], [ %31, %29 ]
%47 = add nuw nsw i64 %30, 1
%48 = icmp eq i64 %47, 7
br i1 %48, label %49, label %29
49: ; preds = %44, %24, %4
%50 = phi i32 [ 0, %4 ], [ %26, %24 ], [ %46, %44 ]
ret i32 %50
}