// File: /workspace/github_cpp_makefile_star2_O1/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
xorl %r14d, %r14d
leaq 0x58(%rsp), %rdx
movl $0x5413, %esi           # imm = 0x5413
movl $0x1, %edi
xorl %eax, %eax
callq 0x33e0
leaq 0xc(%rsp), %rax
movl %r14d, (%rax)
leaq 0x8(%rsp), %rax
movl %r14d, (%rax)
xorl %edi, %edi
callq 0x3290
movl %eax, %edi
callq 0x32b0
leaq 0x20(%rsp), %r13
leaq 0x10(%rsp), %r14
leaq 0x80(%rsp), %r15
callq 0x30b0
movzwl 0x5a(%rsp), %ecx
cltd
idivl %ecx
movl %edx, 0xc(%rsp)
callq 0x30b0
movzwl 0x58(%rsp), %ecx
addl $-0x3, %ecx
cltd
idivl %ecx
addl $0x3, %edx
movl %edx, 0x8(%rsp)
movq 0x48(%rbx), %r12
movq %rbx, %rdi
callq 0x6234
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
addl $-0x3, %ecx
movq %r12, %rdi
movl %eax, %esi
leaq 0x54(%rsp), %r8
callq 0x53c6
movl %eax, %ebp
callq 0x39ee
movq %rax, %r12
testb %bpl, %bpl
je 0x3e7f
movq %rbx, %rdi
callq 0x6234
movq %r12, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x8be6
movq %r13, 0x10(%rsp)
movq %r14, %rdi
leaq 0x540d(%rip), %rsi      # 0x9004
leaq 0x540b(%rip), %rdx      # 0x9009
callq 0x4048
movq %r15, %rdi
movq %r14, %rsi
movl $0x18, %edx
callq 0x3450
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3c2a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %r13, 0x10(%rsp)
movq %r14, %rdi
leaq 0x53d1(%rip), %rsi      # 0x900a
leaq 0x53d3(%rip), %rdx      # 0x9013
callq 0x4048
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x90(%rsp), %rdi
callq 0x3360
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x3490
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x575d(%rip), %rsi      # 0x93d7
callq 0x3360
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x537f(%rip), %rsi      # 0x9014
leaq 0x5381(%rip), %rdx      # 0x901d
callq 0x4048
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r12, %rdi
callq 0x3360
movl 0x8(%rsp), %esi
movq %rax, %rdi
callq 0x3490
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x32c0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3d05
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3d1c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %r13, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0x34e0
callq 0x3f9a
movq %rax, %r12
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x3fb8
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
callq 0x4b88
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3d91
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x48(%rbx), %rdi
callq 0x4f8e
movl 0x54(%rsp), %ebp
testl %ebp, %ebp
je 0x3e99
movq %rbx, %rdi
callq 0x6234
cmpl %eax, %ebp
jne 0x3e30
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x6238
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x9208(%rip), %rdi      # 0xcfd8
callq 0x3360
movq %rax, %r12
movl $0xd, %edx
movq %rax, %rdi
leaq 0x5237(%rip), %rsi      # 0x901e
callq 0x3360
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x32c0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3e30
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32f0
movl $0x2, %edi
callq 0x3230
callq 0x39ee
movq %rax, %rdi
callq 0x82b2
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3e5e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %r15, %rdi
movq 0x9140(%rip), %rsi      # 0xcfa8
callq 0x3220
leaq 0x100(%rsp), %rdi
callq 0x3130
jmp 0x3b6b
movq %r12, %rdi
callq 0x8dac
callq 0x39ee
movq %rax, %rdi
callq 0x8dac
jmp 0x3b6b
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3eb0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x90f1(%rip), %rsi      # 0xcfa8
leaq 0x80(%rsp), %rdi
callq 0x3220
leaq 0x100(%rsp), %rdi
callq 0x3130
movb $0x1, %al
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3f57
movq %rax, %rbx
jmp 0x3f92
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3f92
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x3f92
movq %rax, %rbx
jmp 0x3f71
jmp 0x3f57
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3f5a
movq 0x70(%rsp), %rsi
jmp 0x3f4d
jmp 0x3f36
jmp 0x3f57
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3f5a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x3f5a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3f71
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x9030(%rip), %rsi      # 0xcfa8
leaq 0x80(%rsp), %rdi
callq 0x3220
leaq 0x100(%rsp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x34b0