// File: /workspace/github_cpp_makefile_star2_O3/bestcoder12[P]Sudoku_Game/main.cpp
// Function: main
int main(int argc, char const *argv[])
{
    if (argc != 1)
    {
        cerr << "Usage: ./game\n Or game.exe\n"; 
        return -2;
    }

    int err_chk = 0;

    #ifdef __linux__
        err_chk = system("clear");
    #elif defined(_WIN32)
        err_chk = system("cls");
    #endif

    char new_game = '0';
    
    cout << "\n\n\n\n\n\n\t\t\t\tWelcome to the SUDOKU GAME!!" << "\n\n\n\n";

    cout << "\n\n\n\n\nAfter the game starts -> \nEnter:\n";
	cout << "\t#!Q (to quit the game)\n";
	cout << "\tdel (to delete the entry in a cell)\n";
	cout << "\tsolve (to solve the puzzle automatically)\n\n";

    cout << "Press Enter to start the game: ";
    while (new_game != '\n')
    {
        cin.get(new_game);
    }

    #ifdef __linux__
        err_chk = system("clear");
    #elif defined(_WIN32)
        err_chk = system("cls");
    #endif

    /* Board is contained within the Sudoku class */
    Sudoku game_Board;
    game_Board.cell_remover();
    
    int ext_cd = 0;

    /* Player class used to conceptualize the idea of time taken by the user */
    Player p1;
    std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
    
    /* calling the functions sudoku,input and print */
    for (;;)
    {
        if (err_chk != 0)
        {
            cerr << "Unable to clear the screen.";
        }
    
        #ifdef __linux__
            sleep(2);
        #elif defined (_WIN32)
            Sleep(2000);
        #endif

        #ifdef __linux__
            err_chk = system("clear");
        #elif defined(_WIN32)
            err_chk = system("cls");
        #endif

        p1.timer(start);
        
        if (p1.show_Time() > 900.0)
        {
            cout << "Game lost!" << endl;
            exit(-1);
        }

        cout << "#!Q (to quit the game)\n";
	    cout << "del (to delete the entry in a cell)\n";
	    cout << "solve (to solve the puzzle automatically)\n\n";

        game_Board.print_board();
        ext_cd = game_Board.input();
        
        if (ext_cd == -1)
        {
            return -1;
        }

        ext_cd = game_Board.chk_win();

        if (ext_cd == 1)
        {
            break;
        }
    }
    
    return 0;	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x668, %rsp            # imm = 0x668
cmpl $0x1, %edi
jne 0x3309
leaq 0x121c(%rip), %rdi      # 0x4379
callq 0x20c0
leaq 0x7(%rsp), %rbx
movb $0x30, (%rbx)
movq 0x2e57(%rip), %r14      # 0x5fc8
leaq 0x1284(%rip), %rsi      # 0x43fc
movl $0x26, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x1297(%rip), %rsi      # 0x4423
movl $0x4, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x1288(%rip), %rsi      # 0x4428
movl $0x26, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x129b(%rip), %rsi      # 0x444f
movl $0x18, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x12a0(%rip), %rsi      # 0x4468
movl $0x25, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x12b2(%rip), %rsi      # 0x448e
movl $0x2c, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x12cb(%rip), %rsi      # 0x44bb
movl $0x1f, %edx
movq %r14, %rdi
callq 0x2130
movq 0x2dd4(%rip), %r14      # 0x5fd8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2160
cmpb $0xa, 0x7(%rsp)
jne 0x3204
leaq 0x115c(%rip), %rdi      # 0x4379
callq 0x20c0
movl %eax, %ebx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x23e2
movq %r14, %rdi
callq 0x37f0
callq 0x2150
movq %rax, %r15
movq 0x2d80(%rip), %r13      # 0x5fc8
leaq 0x121a(%rip), %r12      # 0x4469
leaq 0x1239(%rip), %rbp      # 0x448f
testl %ebx, %ebx
je 0x3272
movl $0x1b, %edx
movq 0x2d8a(%rip), %rdi      # 0x5ff0
leaq 0x1119(%rip), %rsi      # 0x4386
callq 0x2130
movl $0x2, %edi
callq 0x20a0
leaq 0x10f6(%rip), %rdi      # 0x4379
callq 0x20c0
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2872
movsd 0x8(%rsp), %xmm0
ucomisd 0x1133(%rip), %xmm0     # 0x43d8
ja 0x333f
movl $0x17, %edx
movq %r13, %rdi
leaq 0x1196(%rip), %rsi      # 0x4450
callq 0x2130
movl $0x24, %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x2130
movl $0x2b, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2130
movq %r14, %rdi
callq 0x2ec6
movq %r14, %rdi
callq 0x294a
cmpl $-0x1, %eax
je 0x3328
movq %r14, %rdi
callq 0x2ff4
cmpl $0x1, %eax
jne 0x3256
xorl %eax, %eax
jmp 0x332d
movq 0x2ce0(%rip), %rdi      # 0x5ff0
leaq 0x10c9(%rip), %rsi      # 0x43e0
movl $0x1b, %edx
callq 0x2130
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x332d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x668, %rsp            # imm = 0x668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2c82(%rip), %rdi      # 0x5fc8
leaq 0x118e(%rip), %rsi      # 0x44db
callq 0x2110
movq %rax, %rdi
callq 0x2070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2140