// File: 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
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movl $0x1, %edi
movl $0x5413, %esi           # imm = 0x5413
leaq -0x20(%rbp), %rdx
movb $0x0, %al
callq 0x34f0
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3320
movl %eax, %edi
callq 0x3340
callq 0x30d0
movzwl -0x1e(%rbp), %ecx
cltd
idivl %ecx
movl %edx, -0x24(%rbp)
callq 0x30d0
movq -0x2b0(%rbp), %rdi
movzwl -0x20(%rbp), %ecx
subl $0x3, %ecx
cltd
idivl %ecx
movl %edx, -0x28(%rbp)
movl -0x28(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x28(%rbp)
movq 0x48(%rdi), %rax
movq %rax, -0x2b8(%rbp)
callq 0x71c0
movq -0x2b8(%rbp), %rdi
movl %eax, %esi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
subl $0x3, %ecx
leaq -0x2c(%rbp), %r8
callq 0x5e40
testb $0x1, %al
jne 0x3d98
jmp 0x424b
callq 0x3a90
movq -0x2b0(%rbp), %rdi
movq %rax, -0x2c8(%rbp)
callq 0x71c0
movq -0x2c8(%rbp), %rdi
movl %eax, %esi
leaq -0x24(%rbp), %rdx
leaq -0x28(%rbp), %rcx
callq 0xbab0
leaq -0x1d9(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x35e0
movq -0x2c0(%rbp), %rdx
leaq 0x821d(%rip), %rsi      # 0xc004
leaq -0x1d8(%rbp), %rdi
callq 0x42f0
jmp 0x3df5
movl $0x10, %edi
movl $0x8, %esi
callq 0x43a0
movl %eax, -0x2cc(%rbp)
jmp 0x3e0c
movl -0x2cc(%rbp), %edx
leaq -0x1b8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x3570
jmp 0x3e27
leaq -0x1d8(%rbp), %rdi
callq 0x3200
leaq -0x1d9(%rbp), %rdi
callq 0x3400
leaq -0x1a8(%rbp), %rax
movq %rax, -0x2e0(%rbp)
leaq -0x211(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x35e0
movq -0x2d8(%rbp), %rdx
leaq 0x819c(%rip), %rsi      # 0xc00a
leaq -0x210(%rbp), %rdi
callq 0x42f0
jmp 0x3e7c
movq -0x2e0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x3310
movq %rax, -0x2e8(%rbp)
jmp 0x3e98
movq -0x2e8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x35b0
movq %rax, -0x2f0(%rbp)
jmp 0x3eb0
movq -0x2f0(%rbp), %rdi
leaq 0x854f(%rip), %rsi      # 0xc40d
callq 0x3360
movq %rax, -0x2f8(%rbp)
jmp 0x3ecc
leaq -0x239(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x35e0
movq -0x300(%rbp), %rdx
leaq 0x8127(%rip), %rsi      # 0xc014
leaq -0x238(%rbp), %rdi
callq 0x42f0
jmp 0x3efb
movq -0x2f8(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x3310
movq %rax, -0x308(%rbp)
jmp 0x3f17
movq -0x308(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x35b0
movq %rax, -0x310(%rbp)
jmp 0x3f2f
movq -0x310(%rbp), %rdi
movq 0xd07b(%rip), %rsi      # 0x10fb8
callq 0x33e0
jmp 0x3f44
leaq -0x238(%rbp), %rdi
callq 0x3200
leaq -0x239(%rbp), %rdi
callq 0x3400
leaq -0x210(%rbp), %rdi
callq 0x3200
leaq -0x211(%rbp), %rdi
callq 0x3400
leaq -0x260(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x34e0
movq -0x318(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
movl $0xa, %edx
callq 0x3620
jmp 0x3fa1
callq 0x43c0
movq %rax, -0x320(%rbp)
jmp 0x3faf
leaq -0x280(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x3190
jmp 0x3fc4
movq -0x320(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x53e0
jmp 0x3fd9
leaq -0x280(%rbp), %rdi
callq 0x3200
movq -0x2b0(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x58d0
jmp 0x3ff7
cmpl $0x0, -0x2c(%rbp)
je 0x41ef
movq -0x2b0(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, -0x328(%rbp)
callq 0x71c0
movl %eax, -0x324(%rbp)
jmp 0x401e
movl -0x328(%rbp), %eax
movl -0x324(%rbp), %ecx
cmpl %ecx, %eax
jne 0x41c5
movq -0x2b0(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x71e0
jmp 0x4047
movq 0xcf8a(%rip), %rdi      # 0x10fd8
leaq -0x2a0(%rbp), %rsi
callq 0x3310
movq %rax, -0x330(%rbp)
jmp 0x4063
movq -0x330(%rbp), %rdi
leaq 0x7fad(%rip), %rsi      # 0xc01e
callq 0x3360
movq %rax, -0x338(%rbp)
jmp 0x407f
movq -0x338(%rbp), %rdi
movq 0xcf2b(%rip), %rsi      # 0x10fb8
callq 0x33e0
jmp 0x4094
leaq -0x2a0(%rbp), %rdi
callq 0x3200
jmp 0x41c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0x40d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x3200
leaq -0x1d9(%rbp), %rdi
callq 0x3400
jmp 0x4278
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0x415a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0x414e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0x4142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3200
leaq -0x239(%rbp), %rdi
callq 0x3400
leaq -0x210(%rbp), %rdi
callq 0x3200
leaq -0x211(%rbp), %rdi
callq 0x3400
jmp 0x423d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0x4231
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x3200
jmp 0x4231
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x3200
jmp 0x4231
movl $0x2, %edi
callq 0x32a0
jmp 0x41d1
callq 0x3a90
movq %rax, -0x340(%rbp)
jmp 0x41df
movq -0x340(%rbp), %rdi
callq 0xaf60
jmp 0x41ed
jmp 0x41ff
movb $0x1, -0x1(%rbp)
movl $0x1, -0x2a4(%rbp)
jmp 0x4209
movl $0x0, -0x2a4(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x3200
leaq -0x1b8(%rbp), %rdi
callq 0x3290
movl -0x2a4(%rbp), %eax
testl %eax, %eax
je 0x422f
jmp 0x422d
jmp 0x426a
jmp 0x4265
leaq -0x260(%rbp), %rdi
callq 0x3200
leaq -0x1b8(%rbp), %rdi
callq 0x3290
jmp 0x4278
callq 0x3a90
movq %rax, %rdi
callq 0xbe60
callq 0x3a90
movq %rax, %rdi
callq 0xbe60
jmp 0x3d33
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
movq -0x1e8(%rbp), %rdi
callq 0x35d0
nopw %cs:(%rax,%rax)
nop