// File: /workspace/github_cpp_makefile_star2_O3/tlaloc1313[P]chess-project/draw.cpp
// Function: draw(Board*, bool)
int draw(Board* gameBoard, bool isWhiteTurn) {

  int currentSquare;

  //Clears the screen
  for (int n=0; n<100; n++) {
    cout<<std::endl;
  }

  //Game board is displayed from White's POV
  if (isWhiteTurn == 1) {

    //Iterating through rows
    for (int row=7; row>=0; row--) {

      //Row numbering is displayed alongside the board
      cout<<row+1<<SPACINGH;

      //Iterating through columns
      for (int column=0; column<8; column++) {
        currentSquare = (column*8) + row;

        //Where the square is occupied, print that piece
        if (gameBoard->spaceOccupied(currentSquare) == 1) {
          cout<<gameBoard->getPiece(currentSquare)<<SPACINGH;
        } else { //Where the square is unoccupied, print either a black or white square
          if ((column+row)%2 == 0) {
            cout<<u8"\u25A0"<<SPACINGH;
          } else {
            cout<<u8"\u25A1"<<SPACINGH;
          }
        }
      }
      //Spacing between rows:
      cout<<SPACINGV;
    }
    // Column numbers are displayed below the board
    cout<<" "<<SPACINGH<<"a"<<SPACINGH<<"b"<<SPACINGH<<"c"<<SPACINGH<<"d"<<SPACINGH<<"e"<<SPACINGH<<"f"<<SPACINGH<<"g"<<SPACINGH<<"h \n\n";

  } else { //Game board is displayed from Black's POV

    //Iterating through rows
    for (int row=0; row<8; row++){

      //Row numbering is displayed alongside the board
      cout<<row+1<<SPACINGH;

      //Iterating through columns
      for (int column=7; column>=0; column--){
        currentSquare = (column*8) + row;

        //Where the square is occupied, print that piece
        if (gameBoard->spaceOccupied(currentSquare) == 1){
          cout<<gameBoard->getPiece(currentSquare)<<SPACINGH;
        } else { //Where the square is unoccupied, print either a black or white square
          if ((column+row)%2 == 0){
            cout<<u8"\u25A0"<<SPACINGH;
          } else {
            cout<<u8"\u25A1"<<SPACINGH;
          }
        }
      }
      //Spacing between rows:
      cout<<SPACINGV;
    }
    // Column numbers are displayed below the board
    cout<<" "<<SPACINGH<<"h"<<SPACINGH<<"g"<<SPACINGH<<"f"<<SPACINGH<<"e"<<SPACINGH<<"d"<<SPACINGH<<"c"<<SPACINGH<<"b"<<SPACINGH<<"a \n\n";
  }

  drawMoves(gameBoard);

return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %r14d
movq %rdi, %r15
movl $0x64, %ebx
movq 0x62c7(%rip), %r13      # 0x8fd0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20a0
decl %ebx
jne 0x2d09
movq %r15, -0x30(%rbp)
testb %r14b, %r14b
je 0x2e9f
movl $0x7, %r12d
leaq 0x34e5(%rip), %rax      # 0x6234
movq %rax, -0x78(%rbp)
leaq 0x34d8(%rip), %rax      # 0x6232
movq %rax, -0x70(%rbp)
leaq 0x34cb(%rip), %rax      # 0x6230
movq %rax, -0x68(%rbp)
leaq 0x34be(%rip), %rax      # 0x622e
movq %rax, -0x60(%rbp)
leaq 0x357b(%rip), %rax      # 0x62f6
movq %rax, -0x58(%rbp)
leaq 0x34a6(%rip), %rax      # 0x622c
movq %rax, -0x50(%rbp)
leaq 0x3499(%rip), %rax      # 0x622a
movq %rax, -0x48(%rbp)
leaq 0x348c(%rip), %rax      # 0x6228
movq %rax, -0x40(%rbp)
leal 0x1(%r12), %esi
movq %r13, %rdi
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3462(%rip), %rsi      # 0x621e
callq 0x2120
xorl %r15d, %r15d
movl %r12d, %ebx
leal (%r12,%r15), %r14d
movq -0x30(%rbp), %r13
movq %r13, %rdi
movl %r14d, %esi
callq 0x3d84
testb %al, %al
je 0x2e0b
movq %r13, %rdi
movl %r14d, %esi
callq 0x4092
testq %rax, %rax
je 0x2e5a
movq %rax, %r14
movq %rax, %rdi
callq 0x2080
movq 0x61d0(%rip), %r13      # 0x8fd0
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
jmp 0x2e2f
movl $0x3, %edx
movq 0x61b9(%rip), %r13      # 0x8fd0
movq %r13, %rdi
testb $0x1, %bl
jne 0x2e28
leaq 0x33fa(%rip), %rsi      # 0x6220
jmp 0x2e2f
leaq 0x33f5(%rip), %rsi      # 0x6224
callq 0x2120
movl $0x1, %edx
movq %r13, %rdi
leaq 0x33db(%rip), %rsi      # 0x621e
callq 0x2120
incl %ebx
addl $0x8, %r15d
cmpl $0x40, %r15d
jne 0x2dc7
jmp 0x2e7c
movq 0x616f(%rip), %r13      # 0x8fd0
movq (%r13), %rax
movq -0x18(%rax), %rax
leaq (%rax,%r13), %rdi
movl 0x20(%r13,%rax), %esi
orl $0x1, %esi
callq 0x21a0
jmp 0x2e34
movl $0x1, %edx
movq %r13, %rdi
leaq 0x3182(%rip), %rsi      # 0x600d
callq 0x2120
subl $0x1, %r12d
jae 0x2da0
jmp 0x3008
xorl %r14d, %r14d
movl $0x7, %ebx
leaq 0x338d(%rip), %rax      # 0x623b
movq %rax, -0x78(%rbp)
leaq 0x3371(%rip), %rax      # 0x622a
movq %rax, -0x70(%rbp)
leaq 0x3368(%rip), %rax      # 0x622c
movq %rax, -0x68(%rbp)
leaq 0x3427(%rip), %rax      # 0x62f6
movq %rax, -0x60(%rbp)
leaq 0x3354(%rip), %rax      # 0x622e
movq %rax, -0x58(%rbp)
leaq 0x334b(%rip), %rax      # 0x6230
movq %rax, -0x50(%rbp)
leaq 0x3342(%rip), %rax      # 0x6232
movq %rax, -0x48(%rbp)
leaq 0x333e(%rip), %rax      # 0x6239
movq %rax, -0x40(%rbp)
leal 0x1(%r14), %esi
movq %r13, %rdi
movl %esi, -0x34(%rbp)
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3301(%rip), %rsi      # 0x621e
callq 0x2120
movl $0x38, %r15d
movl %ebx, -0x38(%rbp)
leal (%r14,%r15), %r12d
movq -0x30(%rbp), %r13
movq %r13, %rdi
movl %r12d, %esi
callq 0x3d84
testb %al, %al
je 0x2f6f
movq %r13, %rdi
movl %r12d, %esi
callq 0x4092
testq %rax, %rax
je 0x2fbe
movq %rax, %r12
movq %rax, %rdi
callq 0x2080
movq 0x606c(%rip), %r13      # 0x8fd0
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
jmp 0x2f93
movl $0x3, %edx
movq 0x6055(%rip), %r13      # 0x8fd0
movq %r13, %rdi
testb $0x1, %bl
jne 0x2f8c
leaq 0x3296(%rip), %rsi      # 0x6220
jmp 0x2f93
leaq 0x3291(%rip), %rsi      # 0x6224
callq 0x2120
movl $0x1, %edx
movq %r13, %rdi
leaq 0x3277(%rip), %rsi      # 0x621e
callq 0x2120
addl $-0x8, %r15d
decl %ebx
cmpl $-0x8, %r15d
jne 0x2f2b
jmp 0x2fe0
movq 0x600b(%rip), %r13      # 0x8fd0
movq (%r13), %rax
movq -0x18(%rax), %rax
leaq (%rax,%r13), %rdi
movl 0x20(%r13,%rax), %esi
orl $0x1, %esi
callq 0x21a0
jmp 0x2f98
movl $0x1, %edx
movq %r13, %rdi
leaq 0x301e(%rip), %rsi      # 0x600d
callq 0x2120
movl -0x38(%rbp), %ebx
incl %ebx
movl -0x34(%rbp), %eax
movl %eax, %r14d
cmpl $0x8, %eax
jne 0x2eff
movq 0x5fc1(%rip), %r14      # 0x8fd0
leaq 0x3208(%rip), %r15      # 0x621e
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq -0x40(%rbp), %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq -0x48(%rbp), %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq -0x50(%rbp), %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq -0x58(%rbp), %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq -0x60(%rbp), %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq -0x68(%rbp), %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq -0x70(%rbp), %rsi
callq 0x2120
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movl $0x4, %edx
movq %r14, %rdi
movq -0x78(%rbp), %rsi
callq 0x2120
movq -0x30(%rbp), %rdi
callq 0x2b60
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq