// File: /workspace/github_cpp_makefile_star2_O2/syky27[P]TicTacToe/src/DNDumbBotPlayer.cpp
// Function: DNDumbBotPlayer::triggerTurn(int, int)
bool DNDumbBotPlayer::triggerTurn(int y, int x)
{
    
    struct winsize w;
    ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
    int x_rand = 0;
    int y_rand = 0;
    DNCellState state;
    srand(time(0));
        while(true){
        x_rand =  rand() % w.ws_col;
        y_rand = rand()  % (w.ws_row -3 );

        

        y_rand += 3;
        
    
    
        if (this->game_map->recordMove(this->getSymbol(),  x_rand, y_rand - 3 , state)) {
            DNWindow::getInstance().drawSymbolBetter(this->getSymbol(),  x_rand, y_rand);
               
                std::stringstream ss("fekal");
                ss << string("x_rand = ") << x_rand << " " << string("y_rand = ") << y_rand << endl;
                std::string to_log;
                std::getline(ss, to_log, '\n');
                DNLogService::sharedObject().log(to_log);
                this->game_map->debugToFile();
            if (state != EMPTY) {
                if (state == this->getSymbol()) {
                    cout << this->getNick() << " is WINNER!!!" << endl;
                }
                sleep(2);
                DNWindow::getInstance().terminate();
            }else{
                
                return true;
            }
        }else{
            DNWindow::getInstance().sound();
            DNWindow::getInstance().sound();
        }
    }
            
           
        
    
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
pushq $0x1
popq %rdi
leaq 0x18(%rsp), %rdx
movl $0x5413, %esi           # imm = 0x5413
xorl %eax, %eax
callq 0x3400
leaq 0xc(%rsp), %rax
andl $0x0, (%rax)
leaq 0x8(%rsp), %rax
andl $0x0, (%rax)
xorl %edi, %edi
callq 0x3290
movl %eax, %edi
callq 0x32b0
leaq 0x20(%rsp), %r14
leaq 0x40(%rsp), %r15
leaq 0x60(%rsp), %rbp
callq 0x30a0
movzwl 0x1a(%rsp), %ecx
cltd
idivl %ecx
movl %edx, 0xc(%rsp)
callq 0x30a0
movzwl 0x18(%rsp), %ecx
addl $-0x3, %ecx
cltd
idivl %ecx
addl $0x3, %edx
movl %edx, 0x8(%rsp)
movq 0x48(%rbx), %r13
movq %rbx, %rdi
callq 0x557c
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
addl $-0x3, %ecx
movq %r13, %rdi
movl %eax, %esi
leaq 0x14(%rsp), %r8
callq 0x4a92
movl %eax, %r12d
callq 0x381e
movq %rax, %r13
testb %r12b, %r12b
je 0x3b65
movq %rbx, %rdi
callq 0x557c
movq %r13, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x76be
movq %r14, %rdi
leaq 0x4621(%rip), %rsi      # 0x8004
movq %r15, %rdx
callq 0x3c1e
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
pushq $0x18
popq %rdx
callq 0x3470
movq %r14, %rdi
callq 0x3170
movq %r14, %rdi
leaq 0x45fa(%rip), %rsi      # 0x800a
leaq 0x13(%rsp), %rdx
callq 0x3c1e
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x3280
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x34b0
movq %rax, %rdi
leaq 0x4997(%rip), %rsi      # 0x83d7
callq 0x32c0
movq %rax, %r13
movq %r15, %rdi
leaq 0x45c2(%rip), %rsi      # 0x8014
leaq 0x12(%rsp), %rdx
callq 0x3c1e
movq %r13, %rdi
movq %r15, %rsi
callq 0x3280
movl 0x8(%rsp), %esi
movq %rax, %rdi
callq 0x34b0
movq %rax, %rdi
callq 0x3190
movq %r15, %rdi
callq 0x3170
movq %r14, %rdi
callq 0x3170
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
pushq $0xa
popq %rdx
callq 0x3500
callq 0x3c5a
movq %rax, %r13
movq %rbp, %rdi
movq %r14, %rsi
callq 0x33f0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x44b0
movq %rbp, %rdi
callq 0x3170
movq 0x48(%rbx), %rdi
callq 0x477c
movl 0x14(%rsp), %r12d
testl %r12d, %r12d
je 0x3b7f
movq %rbx, %rdi
callq 0x557c
cmpl %eax, %r12d
jne 0x3b36
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5580
movq 0x84c9(%rip), %rdi      # 0xbfd8
movq %r15, %rsi
callq 0x3280
movq %rax, %rdi
leaq 0x44fd(%rip), %rsi      # 0x801e
callq 0x32c0
movq %rax, %rdi
callq 0x3190
movq %r15, %rdi
callq 0x3170
pushq $0x2
popq %rdi
callq 0x3220
callq 0x381e
movq %rax, %rdi
callq 0x7052
movq %r14, %rdi
callq 0x3170
leaq 0x80(%rsp), %rdi
callq 0x3210
jmp 0x395b
movq %r13, %rdi
callq 0x7850
callq 0x381e
movq %rax, %rdi
callq 0x7850
jmp 0x395b
leaq 0x20(%rsp), %rdi
callq 0x3170
leaq 0x80(%rsp), %rdi
callq 0x3210
movb $0x1, %al
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3be4
movq %rax, %rbx
jmp 0x3bfe
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3170
jmp 0x3bfe
movq %rax, %rbx
jmp 0x3bf1
jmp 0x3be4
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x3bdb
jmp 0x3bd3
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3170
jmp 0x3be7
jmp 0x3be4
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3170
leaq 0x80(%rsp), %rdi
callq 0x3210
movq %rbx, %rdi
callq 0x34d0