// File: /workspace/github_cpp_makefile_star2_O1/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 0x62bb(%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 0x2d15
movq %r15, -0x30(%rbp)
testb %r14b, %r14b
je 0x2eab
movl $0x7, %r12d
leaq 0x34d9(%rip), %rax      # 0x6234
movq %rax, -0x78(%rbp)
leaq 0x34cc(%rip), %rax      # 0x6232
movq %rax, -0x70(%rbp)
leaq 0x34bf(%rip), %rax      # 0x6230
movq %rax, -0x68(%rbp)
leaq 0x34b2(%rip), %rax      # 0x622e
movq %rax, -0x60(%rbp)
leaq 0x356f(%rip), %rax      # 0x62f6
movq %rax, -0x58(%rbp)
leaq 0x349a(%rip), %rax      # 0x622c
movq %rax, -0x50(%rbp)
leaq 0x348d(%rip), %rax      # 0x622a
movq %rax, -0x48(%rbp)
leaq 0x3480(%rip), %rax      # 0x6228
movq %rax, -0x40(%rbp)
leal 0x1(%r12), %esi
movq %r13, %rdi
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3456(%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 0x3d78
testb %al, %al
je 0x2e17
movq %r13, %rdi
movl %r14d, %esi
callq 0x4090
testq %rax, %rax
je 0x2e66
movq %rax, %r14
movq %rax, %rdi
callq 0x2080
movq 0x61c4(%rip), %r13      # 0x8fd0
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
jmp 0x2e3b
movl $0x3, %edx
movq 0x61ad(%rip), %r13      # 0x8fd0
movq %r13, %rdi
testb $0x1, %bl
jne 0x2e34
leaq 0x33ee(%rip), %rsi      # 0x6220
jmp 0x2e3b
leaq 0x33e9(%rip), %rsi      # 0x6224
callq 0x2120
movl $0x1, %edx
movq %r13, %rdi
leaq 0x33cf(%rip), %rsi      # 0x621e
callq 0x2120
incl %ebx
addl $0x8, %r15d
cmpl $0x40, %r15d
jne 0x2dd3
jmp 0x2e88
movq 0x6163(%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 0x2e40
movl $0x1, %edx
movq %r13, %rdi
leaq 0x3176(%rip), %rsi      # 0x600d
callq 0x2120
subl $0x1, %r12d
jae 0x2dac
jmp 0x3014
xorl %r14d, %r14d
movl $0x7, %ebx
leaq 0x3381(%rip), %rax      # 0x623b
movq %rax, -0x78(%rbp)
leaq 0x3365(%rip), %rax      # 0x622a
movq %rax, -0x70(%rbp)
leaq 0x335c(%rip), %rax      # 0x622c
movq %rax, -0x68(%rbp)
leaq 0x341b(%rip), %rax      # 0x62f6
movq %rax, -0x60(%rbp)
leaq 0x3348(%rip), %rax      # 0x622e
movq %rax, -0x58(%rbp)
leaq 0x333f(%rip), %rax      # 0x6230
movq %rax, -0x50(%rbp)
leaq 0x3336(%rip), %rax      # 0x6232
movq %rax, -0x48(%rbp)
leaq 0x3332(%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 0x32f5(%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 0x3d78
testb %al, %al
je 0x2f7b
movq %r13, %rdi
movl %r12d, %esi
callq 0x4090
testq %rax, %rax
je 0x2fca
movq %rax, %r12
movq %rax, %rdi
callq 0x2080
movq 0x6060(%rip), %r13      # 0x8fd0
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
jmp 0x2f9f
movl $0x3, %edx
movq 0x6049(%rip), %r13      # 0x8fd0
movq %r13, %rdi
testb $0x1, %bl
jne 0x2f98
leaq 0x328a(%rip), %rsi      # 0x6220
jmp 0x2f9f
leaq 0x3285(%rip), %rsi      # 0x6224
callq 0x2120
movl $0x1, %edx
movq %r13, %rdi
leaq 0x326b(%rip), %rsi      # 0x621e
callq 0x2120
addl $-0x8, %r15d
decl %ebx
cmpl $-0x8, %r15d
jne 0x2f37
jmp 0x2fec
movq 0x5fff(%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 0x2fa4
movl $0x1, %edx
movq %r13, %rdi
leaq 0x3012(%rip), %rsi      # 0x600d
callq 0x2120
movl -0x38(%rbp), %ebx
incl %ebx
movl -0x34(%rbp), %eax
movl %eax, %r14d
cmpl $0x8, %eax
jne 0x2f0b
movq 0x5fb5(%rip), %r14      # 0x8fd0
leaq 0x31fc(%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 0x2b6c
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq