// File: /workspace/github_cpp_makefile_star2_O2/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 0x1eec
leaq 0x14e0(%rip), %rdi      # 0x3331
callq 0x10b0
leaq 0x7(%rsp), %rbx
movb $0x30, (%rbx)
movq 0x3163(%rip), %r14      # 0x4fc8
leaq 0x1548(%rip), %rsi      # 0x33b4
movq %r14, %rdi
callq 0x10f0
leaq 0x1560(%rip), %rsi      # 0x33db
movq %rax, %rdi
callq 0x10f0
leaq 0x1556(%rip), %rsi      # 0x33e0
movq %r14, %rdi
callq 0x10f0
leaq 0x156e(%rip), %rsi      # 0x3407
movq %r14, %rdi
callq 0x10f0
leaq 0x1578(%rip), %rsi      # 0x3420
movq %r14, %rdi
callq 0x10f0
leaq 0x158f(%rip), %rsi      # 0x3446
movq %r14, %rdi
callq 0x10f0
leaq 0x15ad(%rip), %rsi      # 0x3473
movq %r14, %rdi
callq 0x10f0
movb $0x30, %al
movq 0x3101(%rip), %r14      # 0x4fd8
cmpb $0xa, %al
je 0x1f06
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1120
movb 0x7(%rsp), %al
jmp 0x1ed7
movq 0x30fd(%rip), %rdi      # 0x4ff0
leaq 0x149e(%rip), %rsi      # 0x3398
callq 0x10f0
pushq $-0x2
jmp 0x1fe1
leaq 0x1424(%rip), %rdi      # 0x3331
callq 0x10b0
movl %eax, %ebp
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x139a
movq %r14, %rdi
callq 0x237c
callq 0x1110
movq %rax, %r15
movq 0x3090(%rip), %rbx      # 0x4fc8
leaq 0x14e2(%rip), %r13      # 0x3421
leaq 0x1501(%rip), %r12      # 0x3447
testl %ebp, %ebp
je 0x1f5d
movq 0x309f(%rip), %rdi      # 0x4ff0
leaq 0x13e6(%rip), %rsi      # 0x333e
callq 0x10f0
pushq $0x2
popq %rdi
callq 0x10a0
leaq 0x13c5(%rip), %rdi      # 0x3331
callq 0x10b0
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1698
movsd 0x8(%rsp), %xmm0
ucomisd 0x1402(%rip), %xmm0     # 0x3390
ja 0x1ff4
movq %rbx, %rdi
leaq 0x146e(%rip), %rsi      # 0x3408
callq 0x10f0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x10f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10f0
movq %r14, %rdi
callq 0x1ba6
movq %r14, %rdi
callq 0x173c
cmpl $-0x1, %eax
je 0x1fdf
movq %r14, %rdi
callq 0x1c88
cmpl $0x1, %eax
jne 0x1f46
xorl %eax, %eax
jmp 0x1fe2
pushq $-0x1
popq %rax
addq $0x668, %rsp            # imm = 0x668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2fcd(%rip), %rdi      # 0x4fc8
leaq 0x1491(%rip), %rsi      # 0x3493
callq 0x10f0
movq %rax, %rdi
callq 0x1080
pushq $-0x1
popq %rdi
callq 0x1100
nop