user: Demonstrate the C code that generates the assembly output below:

```asm
<bot>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r15
  cmp    $0x1,%esi
  je     L243
  cmp    $0xffffffff,%esi
  je     L786
L1641:
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L243:
  lea    0x38(%rdi),%rbx
  lea    0x1c(%rdi),%r14
  lea    -0x38(%rdi),%rax
  lea    -0x1c(%rdi),%rdx
  mov    %rdx,-0x38(%rsp)
  lea    0x54(%rdi),%rdx
  mov    %rdx,-0x30(%rsp)
  lea    -0x54(%rdi),%rdx
  mov    %rdx,-0x28(%rsp)
  mov    $0x0,%r12d
  mov    %rdi,-0x8(%rsp)
  mov    %rax,%r15
L37:
  mov    %r14,%rcx
  mov    %rbx,%rbp
  mov    -0x30(%rsp),%rax
  mov    %rax,-0x20(%rsp)
  mov    -0x38(%rsp),%r10
  mov    %r15,%r13
  mov    -0x28(%rsp),%rax
  mov    %rax,-0x18(%rsp)
  lea    -0x38(%rbx),%rdx
  mov    $0xfffffffd,%r9d
  mov    $0x3,%r8d
  mov    $0x0,%eax
  mov    %rbx,-0x10(%rsp)
  jmp    L1435
L1561:
  cmpl   $0x1,(%rcx,%rax,4)
  je     L463
L644:
  cmpl   $0x1,0x4(%rdi)
  je     L2038
L113:
  cmpl   $0x1,0x4(%rcx,%rax,4)
  je     L1287
L655:
  cmpl   $0x1,-0x4(%r10,%rax,4)
  je     L252
L819:
  cmpl   $0x1,0x4(%r10,%rax,4)
  je     L1934
L400:
  cmpl   $0x1,-0x4(%rcx,%rax,4)
  je     L1075
L1864:
  cmpl   $0x1,(%rcx,%rax,4)
  je     L931
L539:
  cmpl   $0x1,0x4(%rdi)
  je     L1473
L546:
  cmpl   $0x1,0x4(%rcx,%rax,4)
  je     L1930
L1740:
  cmpl   $0x1,-0x4(%r10,%rax,4)
  je     L1347
L864:
  cmpl   $0x1,0x4(%r10,%rax,4)
  je     L1919
L63:
  cmpl   $0x1,-0x4(%rcx,%rax,4)
  je     L1151
L1095:
  add    $0x1,%rax
  add    $0x4,%rdx
  add    $0x1,%r8d
  add    $0x1,%r9d
  cmp    $0x7,%rax
  je     L1670
L1435:
  mov    %eax,%r11d
  mov    %eax,-0x3c(%rsp)
  mov    %rdx,%rdi
  mov    (%rdx),%esi
  cmp    $0x1,%esi
  je     L1561
  cmp    $0xffffffff,%esi
  jne    L1095
  cmpl   $0xffffffff,(%rcx,%rax,4)
  je     L1709
L2067:
  cmpl   $0xffffffff,0x4(%rdi)
  je     L995
L1188:
  cmpl   $0xffffffff,0x4(%rcx,%rax,4)
  je     L1886
L2017:
  cmpl   $0xffffffff,-0x4(%r10,%rax,4)
  je     L191
L1565:
  cmpl   $0xffffffff,0x4(%r10,%rax,4)
  je     L1301
L853:
  cmpl   $0xffffffff,-0x4(%rcx,%rax,4)
  jne    L1095
  cmpl   $0xffffffff,-0x8(%rbp,%rax,4)
  jne    L1095
  mov    -0x20(%rsp),%rbx
  cmpl   $0x0,-0xc(%rbx,%rax,4)
  jne    L1095
  cmp    $0x2,%r12d
  jg     L1095
  cmp    $0x2,%eax
  jle    L1095
  mov    %r9d,%r13d
  jmp    L1641
L463:
  cmpl   $0x1,0x0(%rbp,%rax,4)
  jne    L644
  mov    -0x20(%rsp),%rsi
  cmpl   $0x0,(%rsi,%rax,4)
  jne    L644
  cmp    $0x2,%r12d
  jg     L644
  mov    -0x3c(%rsp),%r13d
  jmp    L1641
L2038:
  cmpl   $0x1,0x8(%rdi)
  jne    L113
  cmpl   $0x0,0xc(%rdi)
  jne    L113
  cmp    $0x3,%eax
  jg     L113
  mov    %r8d,%r13d
  jmp    L1641
L1287:
  cmpl   $0x1,0x8(%rbp,%rax,4)
  jne    L655
  mov    -0x20(%rsp),%rbx
  cmpl   $0x0,0xc(%rbx,%rax,4)
  jne    L655
  cmp    $0x2,%r12d
  jg     L655
  cmp    $0x3,%eax
  jg     L655
  mov    %r8d,%r13d
  jmp    L1641
L252:
  cmpl   $0x1,-0x8(%r13,%rax,4)
  jne    L819
  mov    -0x18(%rsp),%rbx
  cmpl   $0x0,-0xc(%rbx,%rax,4)
  jne    L819
  cmp    $0x2,%r12d
  jle    L819
  cmp    $0x2,%eax
  jle    L819
  mov    %r9d,%r13d
  jmp    L1641
L1934:
  cmpl   $0x1,0x8(%r13,%rax,4)
  jne    L400
  mov    -0x18(%rsp),%rbx
  cmpl   $0x0,0xc(%rbx,%rax,4)
  jne    L400
  cmp    $0x2,%r12d
  jle    L400
  cmp    $0x3,%eax
  jg     L400
  mov    %r8d,%r13d
  jmp    L1641
L1075:
  cmpl   $0x1,-0x8(%rbp,%rax,4)
  jne    L1864
  mov    -0x20(%rsp),%rbx
  cmpl   $0x0,-0xc(%rbx,%rax,4)
  jne    L1864
  cmp    $0x2,%r12d
  jg     L1864
  cmp    $0x2,%eax
  jle    L1864
  mov    %r9d,%r13d
  jmp    L1641
L1709:
  cmpl   $0xffffffff,0x0(%rbp,%rax,4)
  jne    L2067
  mov    -0x20(%rsp),%rbx
  cmpl   $0x0,(%rbx,%rax,4)
  jne    L2067
  cmp    $0x2,%r12d
  jg     L2067
  mov    -0x3c(%rsp),%r13d
  jmp    L1641
L995:
  cmpl   $0xffffffff,0x8(%rdi)
  jne    L1188
  cmpl   $0x0,0xc(%rdi)
  jne    L1188
  cmp    $0x3,%eax
  jg     L1188
  mov    %r8d,%r13d
  jmp    L1641
L1886:
  cmpl   $0xffffffff,0x8(%rbp,%rax,4)
  jne    L2017
  mov    -0x20(%rsp),%rbx
  cmpl   $0x0,0xc(%rbx,%rax,4)
  jne    L2017
  cmp    $0x2,%r12d
  jg     L2017
  cmp    $0x3,%eax
  jg     L2017
  mov    %r8d,%r13d
  jmp    L1641
L191:
  cmpl   $0xffffffff,-0x8(%r13,%rax,4)
  jne    L1565
  mov    -0x18(%rsp),%rbx
  cmpl   $0x0,-0xc(%rbx,%rax,4)
  jne    L1565
  cmp    $0x2,%r12d
  jle    L1565
  cmp    $0x2,%eax
  jle    L1565
  mov    %r9d,%r13d
  jmp    L1641
L1301:
  cmpl   $0xffffffff,0x8(%r13,%rax,4)
  jne    L853
  mov    -0x18(%rsp),%rbx
  cmpl   $0x0,0xc(%rbx,%rax,4)
  jne    L853
  cmp    $0x2,%r12d
  jle    L853
  cmp    $0x3,%eax
  jg     L853
  mov    %r8d,%r13d
  jmp    L1641
L931:
  cmpl   $0x0,0x0(%rbp,%rax,4)
  jne    L539
  cmp    $0x3,%r12d
  jg     L539
  mov    -0x3c(%rsp),%r13d
  jmp    L1641
L1473:
  lea    0x2(%r11),%esi
  cmpl   $0x0,0x8(%rdi)
  jne    L546
  cmp    $0x4,%eax
  jg     L546
  mov    %esi,%r13d
  jmp    L1641
L1930:
  lea    0x2(%r11),%esi
  cmpl   $0x0,0x8(%rbp,%rax,4)
  jne    L1740
  cmp    $0x3,%r12d
  jg     L1740
  cmp    $0x4,%eax
  jg     L1740
  mov    %esi,%r13d
  jmp    L1641
L1347:
  lea    -0x2(%r11),%esi
  cmpl   $0x0,-0x8(%r13,%rax,4)
  jne    L864
  cmp    $0x1,%eax
  jle    L864
  cmp    $0x1,%r12d
  jle    L864
  mov    %esi,%r13d
  jmp    L1641
L1919:
  lea    0x2(%r11),%esi
  cmpl   $0x0,0x8(%r13,%rax,4)
  jne    L63
  cmp    $0x1,%r12d
  jle    L63
  cmp    $0x4,%eax
  jg     L63
  mov    %esi,%r13d
  jmp    L1641
L1151:
  lea    -0x2(%r11),%esi
  cmpl   $0x0,-0x8(%rbp,%rax,4)
  jne    L1095
  cmp    $0x3,%r12d
  jg     L1095
  cmp    $0x1,%eax
  jle    L1095
  mov    %esi,%r13d
  jmp    L1641
L1670:
  mov    -0x10(%rsp),%rbx
  add    $0x1,%r12d
  add    $0x1c,%rbx
  add    $0x1c,%r14
  add    $0x1c,%r15
  addq   $0x1c,-0x38(%rsp)
  addq   $0x1c,-0x30(%rsp)
  addq   $0x1c,-0x28(%rsp)
  cmp    $0x6,%r12d
  jne    L37
  mov    -0x8(%rsp),%r15
  mov    $0x0,%eax
L2061:
  mov    %eax,%r13d
  cmpl   $0x0,(%r15,%rax,4)
  je     L1641
  add    $0x1,%rax
  cmp    $0x6,%rax
  jne    L2061
  mov    $0x0,%r13d
  jmp    L1641
L389:
  lea    0x1c(%r15,%rax,1),%r11
  movslq %r14d,%r10
  cmpl   $0xffffffff,(%r11,%r10,4)
  je     L1841
L1181:
  mov    %edx,%r10d
  movslq %edx,%rbx
  cmpl   $0xffffffff,(%rdi,%rbx,4)
  je     L2001
L1867:
  movslq %r10d,%rbx
  cmpl   $0xffffffff,(%r11,%rbx,4)
  je     L966
L1313:
  lea    -0x1c(%r15,%rax,1),%rbx
  mov    %esi,-0x28(%rsp)
  movslq %esi,%rbp
  cmpl   $0xffffffff,(%rbx,%rbp,4)
  je     L1602
L1111:
  movslq %r10d,%r10
  cmpl   $0xffffffff,(%rbx,%r10,4)
  je     L1212
L385:
  movslq -0x28(%rsp),%r10
  cmpl   $0xffffffff,(%r11,%r10,4)
  je     L939
L1041:
  lea    0x1c(%r15,%rax,1),%r10
  movslq %r14d,%r11
  cmpl   $0xffffffff,(%r10,%r11,4)
  je     L2089
L1377:
  mov    %edx,%eax
  movslq %edx,%r11
  cmpl   $0xffffffff,(%rdi,%r11,4)
  je     L921
L1068:
  movslq %eax,%rdi
  cmpl   $0xffffffff,(%r10,%rdi,4)
  je     L143
L890:
  mov    -0x38(%rsp),%rbx
  lea    -0x1c(%r15,%rbx,1),%r10
  mov    %esi,%edi
  movslq %esi,%r11
  cmpl   $0xffffffff,(%r10,%r11,4)
  je     L122
L1057:
  cltq
  cmpl   $0xffffffff,(%r10,%rax,4)
  je     L1456
L460:
  add    $0x1,%rcx
  lea    0x0(,%rcx,8),%rax
  sub    %rcx,%rax
  lea    (%r15,%rax,4),%rax
  movslq %edi,%rdi
  cmpl   $0xffffffff,(%rax,%rdi,4)
  jne    L1337
  mov    %r9d,-0x30(%rsp)
  movslq %r9d,%rax
  lea    (%r15,%rax,4),%rax
  mov    -0x38(%rsp),%rbx
  cmpl   $0x0,0x38(%rbx,%rax,1)
  jne    L1337
  cmpl   $0x3,-0x3c(%rsp)
  jg     L1337
  cmp    $0x1,%r14d
  jle    L1337
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L1841:
  lea    (%r15,%r10,4),%r10
  cmpl   $0xffffffff,0x38(%rax,%r10,1)
  jne    L1181
  movslq %r14d,%r10
  lea    (%r15,%r10,4),%r10
  cmpl   $0x0,0x54(%rax,%r10,1)
  jne    L1181
  cmpl   $0x2,-0x3c(%rsp)
  jg     L1181
  mov    %r14d,%r13d
  jmp    L1641
L2001:
  movslq %r8d,%rbx
  cmpl   $0xffffffff,(%rdi,%rbx,4)
  jne    L1867
  mov    %r12d,-0x30(%rsp)
  movslq %r12d,%rbx
  cmpl   $0x0,(%rdi,%rbx,4)
  jne    L1867
  cmp    $0x3,%r14d
  jg     L1867
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L966:
  movslq %r8d,%rbx
  lea    (%r15,%rbx,4),%rbx
  cmpl   $0xffffffff,0x38(%rax,%rbx,1)
  jne    L1313
  mov    %r12d,-0x30(%rsp)
  movslq %r12d,%rbx
  lea    (%r15,%rbx,4),%rbx
  cmpl   $0x0,0x54(%rax,%rbx,1)
  jne    L1313
  cmpl   $0x2,-0x3c(%rsp)
  jg     L1313
  cmp    $0x3,%r14d
  jg     L1313
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L1602:
  movslq %r9d,%rbp
  lea    (%r15,%rbp,4),%rbp
  cmpl   $0xffffffff,-0x38(%rax,%rbp,1)
  jne    L1111
  mov    %r13d,-0x30(%rsp)
  movslq %r13d,%rbp
  lea    (%r15,%rbp,4),%rbp
  cmpl   $0x0,-0x54(%rax,%rbp,1)
  jne    L1111
  cmpl   $0x2,-0x3c(%rsp)
  jle    L1111
  cmp    $0x2,%r14d
  jle    L1111
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L1212:
  movslq %r8d,%r10
  lea    (%r15,%r10,4),%r10
  cmpl   $0xffffffff,-0x38(%rax,%r10,1)
  jne    L385
  mov    %r12d,-0x30(%rsp)
  movslq %r12d,%r10
  lea    (%r15,%r10,4),%r10
  cmpl   $0x0,-0x54(%rax,%r10,1)
  jne    L385
  cmpl   $0x2,-0x3c(%rsp)
  jle    L385
  cmp    $0x3,%r14d
  jg     L385
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L939:
  movslq %r9d,%r10
  lea    (%r15,%r10,4),%r10
  cmpl   $0xffffffff,0x38(%rax,%r10,1)
  jne    L1041
  mov    %r13d,-0x30(%rsp)
  movslq %r13d,%r10
  lea    (%r15,%r10,4),%r10
  cmpl   $0x0,0x54(%rax,%r10,1)
  jne    L1041
  cmpl   $0x2,-0x3c(%rsp)
  jg     L1041
  cmp    $0x2,%r14d
  jle    L1041
  jmp    L1641
L1763:
  lea    (%r15,%rcx,4),%rcx
  cmpl   $0x1,0x38(%rax,%rcx,1)
  jne    L1131
  movslq %r14d,%rcx
  lea    (%r15,%rcx,4),%rcx
  cmpl   $0x0,0x54(%rax,%rcx,1)
  jne    L1131
  cmpl   $0x2,-0x3c(%rsp)
  jg     L1131
  mov    %r14d,%r13d
  jmp    L1641
L1516:
  movslq %r8d,%r11
  cmpl   $0x1,(%rdi,%r11,4)
  jne    L988
  mov    %r12d,-0x30(%rsp)
  movslq %r12d,%r11
  cmpl   $0x0,(%rdi,%r11,4)
  jne    L988
  cmp    $0x3,%r14d
  jg     L988
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L1869:
  movslq %r8d,%rdi
  lea    (%r15,%rdi,4),%rdi
  cmpl   $0x1,0x38(%rax,%rdi,1)
  jne    L1826
  mov    %r12d,-0x30(%rsp)
  movslq %r12d,%rdi
  lea    (%r15,%rdi,4),%rdi
  cmpl   $0x0,0x54(%rax,%rdi,1)
  jne    L1826
  cmpl   $0x2,-0x3c(%rsp)
  jg     L1826
  cmp    $0x3,%r14d
  jg     L1826
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L1220:
  movslq %r9d,%rbx
  lea    (%r15,%rbx,4),%rbx
  cmpl   $0x1,-0x38(%rax,%rbx,1)
  jne    L1162
  mov    %r13d,-0x30(%rsp)
  movslq %r13d,%rbx
  lea    (%r15,%rbx,4),%rbx
  cmpl   $0x0,-0x54(%rax,%rbx,1)
  jne    L1162
  cmpl   $0x2,-0x3c(%rsp)
  jle    L1162
  cmp    $0x2,%r14d
  jle    L1162
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L601:
  movslq %r8d,%rcx
  lea    (%r15,%rcx,4),%rcx
  cmpl   $0x1,-0x38(%rax,%rcx,1)
  jne    L2082
  mov    %r12d,-0x30(%rsp)
  movslq %r12d,%rcx
  lea    (%r15,%rcx,4),%rcx
  cmpl   $0x0,-0x54(%rax,%rcx,1)
  jne    L2082
  cmpl   $0x2,-0x3c(%rsp)
  jle    L2082
  cmp    $0x3,%r14d
  jg     L2082
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L2089:
  lea    (%r15,%r11,4),%r11
  cmpl   $0x0,0x38(%rax,%r11,1)
  jne    L1377
  cmpl   $0x3,-0x3c(%rsp)
  jg     L1377
  mov    %r14d,%r13d
  jmp    L1641
L921:
  mov    %r8d,-0x30(%rsp)
  movslq %r8d,%r11
  cmpl   $0x0,(%rdi,%r11,4)
  jne    L1068
  cmp    $0x4,%r14d
  jg     L1068
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L143:
  mov    %r8d,-0x30(%rsp)
  cmpl   $0x0,0x3c(%r15,%rdx,4)
  jne    L980
  cmp    $0x4,%r14d
  jg     L980
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L980:
  movl   $0x2,-0x3c(%rsp)
  cmpl   $0xffffffff,0x34(%r15,%rdx,4)
  je     L874
L1337:
  add    $0x1,%r14d
  add    $0x1,%rdx
  add    $0x1,%r13d
  add    $0x1,%r9d
  add    $0x1,%esi
  add    $0x1,%r8d
  add    $0x1,%r12d
  cmp    $0x7,%r14d
  je     L783
L1339:
  movslq -0x3c(%rsp),%rcx
  lea    0x0(,%rcx,8),%rax
  sub    %rcx,%rax
  shl    $0x2,%rax
  mov    %rax,-0x38(%rsp)
  lea    (%r15,%rax,1),%rdi
  movslq %r14d,%r10
  mov    (%rdi,%r10,4),%r10d
  cmp    $0xffffffff,%r10d
  je     L389
  cmp    $0x1,%r10d
  jne    L1337
  lea    0x1c(%r15,%rax,1),%r10
  movslq %r14d,%rcx
  cmpl   $0x1,(%r10,%rcx,4)
  je     L1763
L1131:
  mov    %edx,%ecx
  movslq %edx,%r11
  cmpl   $0x1,(%rdi,%r11,4)
  je     L1516
L988:
  movslq %ecx,%rdi
  cmpl   $0x1,(%r10,%rdi,4)
  je     L1869
L1826:
  lea    -0x1c(%r15,%rax,1),%r11
  mov    %esi,%edi
  movslq %esi,%rbx
  cmpl   $0x1,(%r11,%rbx,4)
  je     L1220
L1162:
  movslq %ecx,%rcx
  cmpl   $0x1,(%r11,%rcx,4)
  je     L601
L2082:
  movslq %edi,%rcx
  cmpl   $0x1,(%r10,%rcx,4)
  jne    L1337
  movslq %r9d,%rcx
  lea    (%r15,%rcx,4),%rcx
  cmpl   $0x1,0x38(%rax,%rcx,1)
  jne    L1337
  mov    %r13d,-0x30(%rsp)
  movslq %r13d,%rcx
  lea    (%r15,%rcx,4),%rcx
  cmpl   $0x0,0x54(%rax,%rcx,1)
  jne    L1337
  cmpl   $0x2,-0x3c(%rsp)
  jg     L1337
  cmp    $0x2,%r14d
  jle    L1337
  jmp    L1641
L874:
  movq   $0x38,-0x38(%rsp)
  mov    $0x2,%ecx
  jmp    L890
L122:
  mov    %r9d,-0x30(%rsp)
  movslq %r9d,%r11
  lea    (%r15,%r11,4),%r11
  cmpl   $0x0,-0x38(%rbx,%r11,1)
  jne    L1057
  cmpl   $0x1,-0x3c(%rsp)
  jle    L1057
  cmp    $0x1,%r14d
  jle    L1057
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L1456:
  mov    %r8d,-0x30(%rsp)
  movslq %r8d,%rax
  lea    (%r15,%rax,4),%rax
  mov    -0x38(%rsp),%rbx
  cmpl   $0x0,-0x38(%rbx,%rax,1)
  jne    L460
  cmpl   $0x1,-0x3c(%rsp)
  jle    L460
  cmp    $0x4,%r14d
  jg     L460
  mov    -0x30(%rsp),%r13d
  jmp    L1641
L783:
  addl   $0x1,-0x3c(%rsp)
  mov    -0x3c(%rsp),%eax
  cmp    $0x5,%eax
  jle    L142
  mov    $0x0,%eax
L167:
  mov    %eax,%r13d
  cmpl   $0x0,(%r15,%rax,4)
  je     L1641
  add    $0x1,%rax
  cmp    $0x6,%rax
  jne    L167
  mov    $0x0,%r13d
  jmp    L1641
L786:
  movl   $0x0,-0x3c(%rsp)
L142:
  mov    $0x3,%r12d
  mov    $0x2,%r8d
  mov    $0xffffffff,%esi
  mov    $0xfffffffe,%r9d
  mov    $0xfffffffd,%r13d
  mov    $0x1,%edx
  mov    $0x0,%r14d
  jmp    L1339
```

assistant: ```c
int bot(int grid[6][7], int move) {
  int i, j, t;
  if (move == 1) {
    for (i = 0; i < 6; i++) {
      for (j = 0; j < 7; j++) {
        if (grid[i][j] == 1 && grid[i + 1][j] == 1 && grid[i + 2][j] == 1 && grid[i + 3][j] == 0 && i < 3) {
          return j;
        } else if (grid[i][j] == 1 && grid[i][j + 1] == 1 && grid[i][j + 2] == 1 && grid[i][j + 3] == 0 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == 1 && grid[i + 1][j + 1] == 1 && grid[i + 2][j + 2] == 1 && grid[i + 3][j + 3] == 0 && i < 3 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == 1 && grid[i - 1][j - 1] == 1 && grid[i - 2][j - 2] == 1 && grid[i - 3][j - 3] == 0 && i > 2 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == 1 && grid[i - 1][j + 1] == 1 && grid[i - 2][j + 2] == 1 && grid[i - 3][j + 3] == 0 && i > 2 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == 1 && grid[i + 1][j - 1] == 1 && grid[i + 2][j - 2] == 1 && grid[i + 3][j - 3] == 0 && i < 3 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == -1 && grid[i + 1][j] == -1 && grid[i + 2][j] == -1 && grid[i + 3][j] == 0 && i < 3) {
          return j;
        } else if (grid[i][j] == -1 && grid[i][j + 1] == -1 && grid[i][j + 2] == -1 && grid[i][j + 3] == 0 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == -1 && grid[i + 1][j + 1] == -1 && grid[i + 2][j + 2] == -1 && grid[i + 3][j + 3] == 0 && i < 3 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == -1 && grid[i - 1][j - 1] == -1 && grid[i - 2][j - 2] == -1 && grid[i - 3][j - 3] == 0 && i > 2 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == -1 && grid[i - 1][j + 1] == -1 && grid[i - 2][j + 2] == -1 && grid[i - 3][j + 3] == 0 && i > 2 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == -1 && grid[i + 1][j - 1] == -1 && grid[i + 2][j - 2] == -1 && grid[i + 3][j - 3] == 0 && i < 3 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == 1 && grid[i + 1][j] == 1 && grid[i + 2][j] == 0 && i < 4) {
          return j;
        } else if (grid[i][j] == 1 && grid[i][j + 1] == 1 && grid[i][j + 2] == 0 && j < 5) {
          return j + 2;
        } else if (grid[i][j] == 1 && grid[i + 1][j + 1] == 1 && grid[i + 2][j + 2] == 0 && i < 4 && j < 5) {
          return j + 2;
        } else if (grid[i][j] == 1 && grid[i - 1][j - 1] == 1 && grid[i - 2][j - 2] == 0 && j > 1 && i > 1) {
          return j - 2;
        } else if (grid[i][j] == 1 && grid[i - 1][j + 1] == 1 && grid[i - 2][j + 2] == 0 && i > 1 && j < 5) {
          return j + 2;
        } else if (grid[i][j] == 1 && grid[i + 1][j - 1] == 1 && grid[i + 2][j - 2] == 0 && i < 4 && j > 1) {
          return j - 2;
        }
      }
    }
    for (t = 0; t < 6; t++)
      if (grid[0][t] == 0)
        return t;
    return 0;
  } else if (move == -1) {
    for (i = 0; i < 6; i++) {
      for (j = 0; j < 7; j++) {
        if (grid[i][j] == -1 && grid[i + 1][j] == -1 && grid[i + 2][j] == -1 && grid[i + 3][j] == 0 && i < 3) {
          return j;
        } else if (grid[i][j] == -1 && grid[i][j + 1] == -1 && grid[i][j + 2] == -1 && grid[i][j + 3] == 0 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == -1 && grid[i + 1][j + 1] == -1 && grid[i + 2][j + 2] == -1 && grid[i + 3][j + 3] == 0 && i < 3 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == -1 && grid[i - 1][j - 1] == -1 && grid[i - 2][j - 2] == -1 && grid[i - 3][j - 3] == 0 && i > 2 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == -1 && grid[i - 1][j + 1] == -1 && grid[i - 2][j + 2] == -1 && grid[i - 3][j + 3] == 0 && i > 2 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == -1 && grid[i + 1][j - 1] == -1 && grid[i + 2][j - 2] == -1 && grid[i + 3][j - 3] == 0 && i < 3 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == 1 && grid[i + 1][j] == 1 && grid[i + 2][j] == 1 && grid[i + 3][j] == 0 && i < 3) {
          return j;
        } else if (grid[i][j] == 1 && grid[i][j + 1] == 1 && grid[i][j + 2] == 1 && grid[i][j + 3] == 0 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == 1 && grid[i + 1][j + 1] == 1 && grid[i + 2][j + 2] == 1 && grid[i + 3][j + 3] == 0 && i < 3 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == 1 && grid[i - 1][j - 1] == 1 && grid[i - 2][j - 2] == 1 && grid[i - 3][j - 3] == 0 && i > 2 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == 1 && grid[i - 1][j + 1] == 1 && grid[i - 2][j + 2] == 1 && grid[i - 3][j + 3] == 0 && i > 2 && j < 4) {
          return j + 3;
        } else if (grid[i][j] == 1 && grid[i + 1][j - 1] == 1 && grid[i + 2][j - 2] == 1 && grid[i + 3][j - 3] == 0 && i < 3 && j > 2) {
          return j - 3;
        } else if (grid[i][j] == -1 && grid[i + 1][j] == -1 && grid[i + 2][j] == 0 && i < 4) {
          return j;
        } else if (grid[i][j] == -1 && grid[i][j + 1] == -1 && grid[i][j + 2] == 0 && j < 5) {
          return j + 2;
        } else if (grid[i][j] == -1 && grid[i + 1][j + 1] == -1 && grid[i = 2][j + 2] == 0 && i < 4 && j < 5) {
          return j + 2;
        } else if (grid[i][j] == -1 && grid[i - 1][j - 1] == -1 && grid[i - 2][j - 2] == 0 && i > 1 && j > 1) {
          return j - 2;
        } else if (grid[i][j] == -1 && grid[i - 1][j + 1] == -1 && grid[i - 2][j + 2] == 0 && i > 1 && j < 5) {
          return j + 2;
        } else if (grid[i][j] == -1 && grid[i + 1][j - 1] == -1 && grid[i + 2][j - 2] == 0 && i < 4 && j > 1) {
          return j - 2;
        }
      }
    }
    for (t = 0; t < 6; t++)
      if (grid[0][t] == 0)
        return t;
    return 0;
  }
}
```