// File: /workspace/github_cpp_makefile_star2_O1/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 0x3316
leaq 0x11d0(%rip), %rdi      # 0x4331
callq 0x20c0
movb $0x30, 0x7(%rsp)
movq 0x2e56(%rip), %rbx      # 0x5fc8
leaq 0x123b(%rip), %rsi      # 0x43b4
movl $0x26, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x124e(%rip), %rsi      # 0x43db
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x123f(%rip), %rsi      # 0x43e0
movl $0x26, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x1252(%rip), %rsi      # 0x4407
movl $0x18, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x1257(%rip), %rsi      # 0x4420
movl $0x25, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x1269(%rip), %rsi      # 0x4446
movl $0x2c, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x1282(%rip), %rsi      # 0x4473
movl $0x1f, %edx
movq %rbx, %rdi
callq 0x2130
cmpb $0xa, 0x7(%rsp)
je 0x3223
movq 0x2dcc(%rip), %rbx      # 0x5fd8
leaq 0x7(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2160
cmpb $0xa, 0x7(%rsp)
jne 0x3211
leaq 0x1107(%rip), %rdi      # 0x4331
callq 0x20c0
movl %eax, %ebx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x2426
movq %r14, %rdi
callq 0x380e
callq 0x2150
movq %rax, %r15
movq 0x2d73(%rip), %r13      # 0x5fc8
leaq 0x11c5(%rip), %r12      # 0x4421
leaq 0x11e4(%rip), %rbp      # 0x4447
testl %ebx, %ebx
je 0x327f
movl $0x1b, %edx
movq 0x2d7d(%rip), %rdi      # 0x5ff0
leaq 0x10c4(%rip), %rsi      # 0x433e
callq 0x2130
movl $0x2, %edi
callq 0x20a0
leaq 0x10a1(%rip), %rdi      # 0x4331
callq 0x20c0
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x286c
movsd 0x8(%rsp), %xmm0
ucomisd 0x10de(%rip), %xmm0     # 0x4390
ja 0x334c
movl $0x17, %edx
movq %r13, %rdi
leaq 0x1141(%rip), %rsi      # 0x4408
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 0x2eb6
movq %r14, %rdi
callq 0x2944
cmpl $-0x1, %eax
je 0x3335
movq %r14, %rdi
callq 0x2fe4
cmpl $0x1, %eax
jne 0x3263
xorl %eax, %eax
jmp 0x333a
movq 0x2cd3(%rip), %rdi      # 0x5ff0
leaq 0x1074(%rip), %rsi      # 0x4398
movl $0x1b, %edx
callq 0x2130
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x333a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x668, %rsp            # imm = 0x668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2c75(%rip), %rdi      # 0x5fc8
leaq 0x1139(%rip), %rsi      # 0x4493
callq 0x2110
movq %rax, %rdi
callq 0x2070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2140
nopl (%rax)