// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
xorl %ebx, %ebx
leaq 0x58(%rsp), %rdx
movl $0x5413, %esi           # imm = 0x5413
movl $0x1, %edi
xorl %eax, %eax
callq 0x33e0
leaq 0xc(%rsp), %rax
movl %ebx, (%rax)
leaq 0x8(%rsp), %rax
movl %ebx, (%rax)
xorl %edi, %edi
callq 0x3290
movl %eax, %edi
callq 0x32b0
leaq 0x20(%rsp), %rbx
leaq 0x10(%rsp), %r15
leaq 0x80(%rsp), %r12
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(%r14), %r13
movq %r14, %rdi
callq 0x6244
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
addl $-0x3, %ecx
movq %r13, %rdi
movl %eax, %esi
leaq 0x54(%rsp), %r8
callq 0x53ce
movl %eax, %ebp
callq 0x39ee
movq %rax, %r13
testb %bpl, %bpl
je 0x3e7c
movq %r14, %rdi
callq 0x6244
movq %r13, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x8bd6
movq %rbx, 0x10(%rsp)
movq %r15, %rdi
leaq 0x5410(%rip), %rsi      # 0x9004
leaq 0x540e(%rip), %rdx      # 0x9009
callq 0x404c
movq %r12, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x3450
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3c27
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, 0x10(%rsp)
movq %r15, %rdi
leaq 0x53d4(%rip), %rsi      # 0x900a
leaq 0x53d6(%rip), %rdx      # 0x9013
callq 0x404c
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, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5760(%rip), %rsi      # 0x93d7
callq 0x3360
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x5382(%rip), %rsi      # 0x9014
leaq 0x5384(%rip), %rdx      # 0x901d
callq 0x404c
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r13, %rdi
callq 0x3360
movl 0x8(%rsp), %esi
movq %rax, %rdi
callq 0x3490
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x32c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3d02
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3d19
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x34e0
callq 0x3f98
movq %rax, %r13
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x3fb6
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
callq 0x4b7c
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3d8e
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x48(%r14), %rdi
callq 0x4f82
movl 0x54(%rsp), %ebp
testl %ebp, %ebp
je 0x3e96
movq %r14, %rdi
callq 0x6244
cmpl %eax, %ebp
jne 0x3e2d
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x6248
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x920b(%rip), %rdi      # 0xcfd8
callq 0x3360
movq %rax, %r13
movl $0xd, %edx
movq %rax, %rdi
leaq 0x523a(%rip), %rsi      # 0x901e
callq 0x3360
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x32c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3e2d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32f0
movl $0x2, %edi
callq 0x3230
callq 0x39ee
movq %rax, %rdi
callq 0x82a2
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3e5b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %r12, %rdi
movq 0x9143(%rip), %rsi      # 0xcfa8
callq 0x3220
leaq 0x100(%rsp), %rdi
callq 0x3130
jmp 0x3b68
movq %r13, %rdi
callq 0x8d9c
callq 0x39ee
movq %rax, %rdi
callq 0x8d9c
jmp 0x3b68
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3ead
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x90f4(%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 0x3f54
movq %rax, %r14
jmp 0x3f8f
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3f8f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x3f8f
movq %rax, %r14
jmp 0x3f6e
jmp 0x3f54
movq %rax, %r14
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3f57
movq 0x70(%rsp), %rsi
jmp 0x3f4a
jmp 0x3f33
jmp 0x3f54
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3f57
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x3f57
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3f6e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x9033(%rip), %rsi      # 0xcfa8
leaq 0x80(%rsp), %rdi
callq 0x3220
leaq 0x100(%rsp), %rdi
callq 0x3130
movq %r14, %rdi
callq 0x34b0
nop