// File: /workspace/github_cpp_makefile_star2_O2/m-wiesner[P]Jotto/Jotto.cpp
// Function: main
int main(int argc, char** argv)
{
    string path_to_dict = "./text_files/wordlist.txt";
    char read_rules;
    char play_to_end;
    int level;
    cout << "========================================";
    cout << "========================================" << endl;
    cout << "                                !!  JOTTO  !!";
    cout << "                                " << endl;
    cout << "========================================";
    cout << "========================================" << endl;

    cout << "Do you want to read the rules? (y)/(n)";
    do
    {   if (!(cin >> read_rules))
        {
            exit (0);
        }
    } while ((read_rules != 'y' && read_rules != 'n') && (cout << "Enter (y) or (n)."));
    
    if (read_rules == 'y')
    {
        print_intro();      
    }



    cout << endl << endl << endl;
    cout << "========================================";
    cout << "========================================" << endl;
    cout << "                                !! START GAME !!";
    cout << "                                " << endl;
    

    print_level();
    do
    {
        if(!(cin >> level))
        {
            exit(0);
        }
        cout << "LEVEL: " << level << endl;
    } while (((level != 1) && (level != 2) && (level !=3)) && (cout << "Enter a level (1-3)"));
    


    // Default names
    string name1 = "AI1";
    string name2 = "AI2";

    srand((int)time(0));
    Guesser *g1;
    Guesser *g2;
  
    g1 = new ManualGuesser(name1, path_to_dict); 
    //switch (level)
    //{
    //    case 0: cout << "Enter your name: ";
    //            cin >> name1;
    //            g1 = new ManualGuesser(name1, path_to_dict);
    //            break;
    //    case 1: g1 = new Guesser(name1, path_to_dict); break;
    //    case 2: g1 = new RandomGuesser(name1, path_to_dict); break;
    //    case 3: g1 = new MaxinfoGuesser(name1, path_to_dict); break;
    //}

    switch (level)
    {
        case 0: cout << "Enter your name: ";
                cin >> name1;
                g2 = new ManualGuesser(name1, path_to_dict);
                break;
        case 1: g2 = new Guesser(name2, path_to_dict); break;
        case 2: g2 = new RandomGuesser(name2, path_to_dict); break;
        case 3: g2 = new MaxinfoGuesser(name2, path_to_dict); break;
    }

    ScoreKeeper sk(g1, g2);
  
    clear_screen(3); 
   
    int turnnumber = 1; 
    cout << " ========= Turn " << turnnumber << " ============== " << endl;
    while (sk.give_turn_to(g1) && sk.give_turn_to(g2))
    {
        clear_screen(3);
        cout << " ========= Turn " << turnnumber << " ============== " << endl;
        g1->update();
        g2->update();
        ++turnnumber;
    }

    cout << "Do you want to keep guessing? (y)/(n)";
    do
    {   if(!(cin >> play_to_end))
        {
            cout << "Codeword were ..." << endl;
            sk.print_codewords();
            exit(0);
        }
    } while ((play_to_end != 'y' && play_to_end != 'n') && (cout << "Enter (y) or (n)."));
    
    if (play_to_end == 'y')
    {
        while(sk.give_turn_to(g1))
        {
            clear_screen(3);
            cout << " ========= Turn " << turnnumber << " ============== " << endl;
            g1->update();
            ++turnnumber;
        }
    } 
    else
    {
        cout << "Codewords were ..." << endl;
        sk.print_codewords();
    } 
    delete g1;
    delete g2;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
leaq 0x3a2d(%rip), %rsi      # 0x6014
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x2ee8
movq 0x79d5(%rip), %rdi      # 0x9fd0
leaq 0x3a2c(%rip), %rsi      # 0x602e
callq 0x2230
movq 0x79c2(%rip), %rdi      # 0x9fd0
leaq 0x3a19(%rip), %rsi      # 0x602e
callq 0x2230
movq %rax, %rdi
callq 0x2110
movq 0x79a7(%rip), %rdi      # 0x9fd0
leaq 0x3a27(%rip), %rsi      # 0x6057
callq 0x2230
movq 0x7994(%rip), %rdi      # 0x9fd0
leaq 0x3a42(%rip), %rsi      # 0x6085
callq 0x2230
movq %rax, %rdi
callq 0x2110
movq 0x7979(%rip), %rdi      # 0x9fd0
leaq 0x39d0(%rip), %rsi      # 0x602e
callq 0x2230
movq 0x7966(%rip), %rdi      # 0x9fd0
leaq 0x39bd(%rip), %rsi      # 0x602e
callq 0x2230
movq %rax, %rdi
callq 0x2110
movq 0x794b(%rip), %rdi      # 0x9fd0
leaq 0x3a1a(%rip), %rsi      # 0x60a6
callq 0x2230
movq 0x7948(%rip), %rbx      # 0x9fe0
leaq -0x2a(%rbp), %r14
movq 0x792d(%rip), %r15      # 0x9fd0
leaq 0x3a23(%rip), %r12      # 0x60cd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2b5f
movzbl -0x2a(%rbp), %eax
cmpl $0x6e, %eax
je 0x26f1
cmpl $0x79, %eax
je 0x26f1
movq %r15, %rdi
movq %r12, %rsi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x26aa
movb -0x2a(%rbp), %al
cmpb $0x79, %al
jne 0x26fa
callq 0x2bdb
movq 0x78cf(%rip), %rdi      # 0x9fd0
callq 0x2110
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2110
movq 0x78b3(%rip), %rdi      # 0x9fd0
leaq 0x390a(%rip), %rsi      # 0x602e
callq 0x2230
movq 0x78a0(%rip), %rdi      # 0x9fd0
leaq 0x38f7(%rip), %rsi      # 0x602e
callq 0x2230
movq %rax, %rdi
callq 0x2110
movq 0x7885(%rip), %rdi      # 0x9fd0
leaq 0x398d(%rip), %rsi      # 0x60df
callq 0x2230
movq 0x7872(%rip), %rdi      # 0x9fd0
leaq 0x3920(%rip), %rsi      # 0x6085
callq 0x2230
movq %rax, %rdi
callq 0x2110
callq 0x2ddd
movq 0x7862(%rip), %rbx      # 0x9fe0
leaq -0x30(%rbp), %r14
movq 0x7847(%rip), %r15      # 0x9fd0
leaq 0x3980(%rip), %r12      # 0x6110
leaq 0x3981(%rip), %r13      # 0x6118
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2b5f
movq %r15, %rdi
movq %r12, %rsi
callq 0x2230
movl -0x30(%rbp), %esi
movq %rax, %rdi
callq 0x2350
movq %rax, %rdi
callq 0x2110
movl -0x30(%rbp), %eax
addl $-0x4, %eax
cmpl $-0x4, %eax
ja 0x27f6
movq %r15, %rdi
movq %r13, %rsi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x2797
leaq 0x392f(%rip), %rsi      # 0x612c
leaq -0xc0(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x2ee8
leaq 0x391c(%rip), %rsi      # 0x6130
leaq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x2ee8
xorl %edi, %edi
callq 0x2210
movl %eax, %edi
callq 0x2220
pushq $0x58
popq %rdi
callq 0x2240
movq %rax, %rbx
leaq -0xc0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq %rax, %rdi
callq 0x42a0
movl -0x30(%rbp), %eax
cmpq $0x3, %rax
ja 0x2913
leaq 0x37a0(%rip), %rcx      # 0x6004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x775c(%rip), %rdi      # 0x9fd0
leaq 0x38b9(%rip), %rsi      # 0x6134
callq 0x2230
movq 0x7759(%rip), %rdi      # 0x9fe0
leaq -0xc0(%rbp), %rsi
callq 0x22c0
pushq $0x58
popq %rdi
callq 0x2240
movq %rax, %r14
leaq -0xc0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq %rax, %rdi
callq 0x42a0
jmp 0x2913
pushq $0x58
popq %rdi
callq 0x2240
movq %rax, %r14
leaq -0xa0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq %rax, %rdi
callq 0x44a8
jmp 0x2913
pushq $0x58
popq %rdi
callq 0x2240
movq %rax, %r14
leaq -0xa0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq %rax, %rdi
callq 0x46b4
jmp 0x2913
pushq $0x58
popq %rdi
callq 0x2240
movq %rax, %r14
leaq -0xa0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq %rax, %rdi
callq 0x3af8
jmp 0x2913
leaq -0x80(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x48f4
pushq $0x3
popq %rdi
callq 0x2ebb
movq 0x769f(%rip), %rdi      # 0x9fd0
leaq 0x380e(%rip), %rsi      # 0x6146
callq 0x2230
pushq $0x1
popq %r15
movq %rax, %rdi
movl %r15d, %esi
callq 0x2350
leaq 0x3804(%rip), %rsi      # 0x6157
movq %rax, %rdi
callq 0x2230
movq %rax, %rdi
callq 0x2110
leaq -0x80(%rbp), %r12
leaq 0x37e9(%rip), %r13      # 0x6157
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4a14
testb %al, %al
je 0x29dc
movq %r12, %rdi
movq %r14, %rsi
callq 0x4a14
testb %al, %al
je 0x29dc
pushq $0x3
popq %rdi
callq 0x2ebb
movq 0x7635(%rip), %rdi      # 0x9fd0
leaq 0x37a4(%rip), %rsi      # 0x6146
callq 0x2230
movq %rax, %rdi
movl %r15d, %esi
callq 0x2350
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
movq %rax, %rdi
callq 0x2110
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
incl %r15d
jmp 0x296e
movq 0x75ed(%rip), %rdi      # 0x9fd0
leaq 0x377e(%rip), %rsi      # 0x6168
callq 0x2230
movq 0x75ea(%rip), %r12      # 0x9fe0
leaq -0x29(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x22e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2b3b
movzbl -0x29(%rbp), %eax
cmpl $0x6e, %eax
je 0x2a49
cmpl $0x79, %eax
je 0x2a49
movq 0x75a4(%rip), %rdi      # 0x9fd0
leaq 0x369a(%rip), %rsi      # 0x60cd
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x29fa
movb -0x29(%rbp), %al
cmpb $0x79, %al
jne 0x2aae
leaq -0x80(%rbp), %r12
leaq 0x36ff(%rip), %r13      # 0x6157
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4a14
testb %al, %al
je 0x2ad2
pushq $0x3
popq %rdi
callq 0x2ebb
movq 0x755a(%rip), %rdi      # 0x9fd0
leaq 0x36c9(%rip), %rsi      # 0x6146
callq 0x2230
movq %rax, %rdi
movl %r15d, %esi
callq 0x2350
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
movq %rax, %rdi
callq 0x2110
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
incl %r15d
jmp 0x2a58
movq 0x751b(%rip), %rdi      # 0x9fd0
leaq 0x36e4(%rip), %rsi      # 0x61a0
callq 0x2230
movq %rax, %rdi
callq 0x2110
leaq -0x80(%rbp), %rdi
callq 0x4c7c
movq %rbx, %rdi
callq 0x2f24
pushq $0x58
popq %rsi
movq %rbx, %rdi
callq 0x2250
testq %r14, %r14
je 0x2af2
movq %r14, %rdi
callq 0x2f24
pushq $0x58
popq %rsi
movq %r14, %rdi
callq 0x2250
leaq -0x80(%rbp), %rdi
callq 0x30ac
leaq -0xa0(%rbp), %rdi
callq 0x2100
leaq -0xc0(%rbp), %rdi
callq 0x2100
leaq -0x50(%rbp), %rdi
callq 0x2100
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x748e(%rip), %rdi      # 0x9fd0
leaq 0x3645(%rip), %rsi      # 0x618e
callq 0x2230
movq %rax, %rdi
callq 0x2110
leaq -0x80(%rbp), %rdi
callq 0x4c7c
xorl %edi, %edi
callq 0x22a0
jmp 0x2b6c
jmp 0x2b6c
jmp 0x2b6c
movq %rax, %r15
pushq $0x58
popq %rsi
movq %r14, %rdi
jmp 0x2b84
jmp 0x2ba6
jmp 0x2b92
movq %rax, %r15
pushq $0x58
popq %rsi
movq %rbx, %rdi
callq 0x2250
jmp 0x2bb2
movq %rax, %r15
jmp 0x2bbe
jmp 0x2b9f
movq %rax, %r15
jmp 0x2bb2
jmp 0x2ba6
jmp 0x2b9f
jmp 0x2ba6
jmp 0x2b9f
movq %rax, %r15
jmp 0x2bca
jmp 0x2ba6
movq %rax, %r15
leaq -0x80(%rbp), %rdi
callq 0x30ac
leaq -0xa0(%rbp), %rdi
callq 0x2100
leaq -0xc0(%rbp), %rdi
callq 0x2100
leaq -0x50(%rbp), %rdi
callq 0x2100
movq %r15, %rdi
callq 0x2360