// File: /workspace/github_cpp_makefile_star2_O2/Leeingnyo[P]newPuyoC/main.cpp
// Function: main
int main() {
    srand(time(NULL));
    Console::ScreenClear();
    Console::HideCursor();
    if (Socket::StartUp()) {
        std::cout << "Winsock 초기화 실패" << std::endl;
        return -1;
    }
    
    bool app_alive = true;
    while (app_alive) {
        int choice;
        std::shared_ptr<Game> game;
        
        Console::ScreenClear();
        std::cout << Console::GotoXY(X(0), Y(0));
        std::cout << Console::white;
        std::cout << "선택해주세요" << std::endl;
        std::cout << "0. 게임설명" << std::endl;
        std::cout << "1. 혼자하기" << std::endl;
        std::cout << "2. 둘이하기(같은컴)" << std::endl;
        std::cout << "3. 둘이하기(멀티플레이)" << std::endl;
        std::cout << "4. 끝내기" << std::endl;
        
        choice = getch();
        switch(choice) {
            case '0': {
                help();
            }   continue;
            case '1': {
                game = std::make_shared<SingleGame>();
            }   break;
            case '2': {
                game = std::make_shared<VSGame>();
            }   break;
            case '3': {
                game = std::make_shared<VSRemoteGame>();
            }   break;
            case '4': {
                app_alive = false;
            }   continue;
            default: continue;
        }
        
        if (game->GameInit()) {
            game->GameLoop();
            game->GameResult();
        }
    }
    
    std::cout << Console::gray;
    Console::ShowCursor();
    Console::ScreenClear();
    Socket::CleanUp();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %edi, %edi
callq 0x3230
movl %eax, %edi
callq 0x3270
callq 0x3bca
callq 0x3be2
callq 0x3734
testl %eax, %eax
je 0x9191
movq 0x6e53(%rip), %rdi      # 0xffc8
leaq 0x1948(%rip), %rsi      # 0xaac4
callq 0x3280
movq %rax, %rdi
callq 0x3150
pushq $-0x1
popq %rax
jmp 0x9320
movq 0x6e30(%rip), %r13      # 0xffc8
leaq -0x50(%rbp), %r14
leaq 0x1988(%rip), %rbx      # 0xab2b
leaq 0x19a2(%rip), %r15      # 0xab4c
leaq 0x18ff(%rip), %r12      # 0xaab0
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
callq 0x3bca
andq $0x0, -0x50(%rbp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x3c46
movq %r13, %rdi
leaq 0x70e5(%rip), %rsi      # 0x102bc
callq 0x3c12
movq %r13, %rdi
leaq 0x18f7(%rip), %rsi      # 0xaadd
callq 0x3280
movq %rax, %rdi
callq 0x3150
movq %r13, %rdi
leaq 0x18f3(%rip), %rsi      # 0xaaf0
callq 0x3280
movq %rax, %rdi
callq 0x3150
movq %r13, %rdi
leaq 0x18ec(%rip), %rsi      # 0xab00
callq 0x3280
movq %rax, %rdi
callq 0x3150
movq %r13, %rdi
leaq 0x18e5(%rip), %rsi      # 0xab10
callq 0x3280
movq %rax, %rdi
callq 0x3150
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3280
movq %rax, %rdi
callq 0x3150
movq %r13, %rdi
movq %r15, %rsi
callq 0x3280
movq %rax, %rdi
callq 0x3150
callq 0x3b49
addl $-0x30, %eax
cmpl $0x4, %eax
ja 0x92e5
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
callq 0x934b
jmp 0x92e5
movq %r14, %rdi
callq 0x9789
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x9b9c
jmp 0x92bb
movq %r14, %rdi
callq 0x97a5
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x9da6
jmp 0x92bb
movq %r14, %rdi
callq 0x976d
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x9978
leaq -0x48(%rbp), %rdi
callq 0x6896
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
testb %al, %al
je 0x92e5
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq -0x38(%rbp), %rdi
callq 0x6896
jmp 0x91b1
leaq -0x38(%rbp), %rdi
callq 0x6896
movq 0x6cc5(%rip), %rdi      # 0xffc8
leaq 0x6f92(%rip), %rsi      # 0x1029c
callq 0x3c12
callq 0x3bfa
callq 0x3bca
callq 0x373c
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9337
jmp 0x9337
jmp 0x9337
jmp 0x9337
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x6896
movq %rbx, %rdi
callq 0x3470