// File: /workspace/github_cpp_makefile_star2_O1/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 0x3240
movl %eax, %edi
callq 0x3280
callq 0x3de0
callq 0x3dfd
callq 0x384c
testl %eax, %eax
je 0xa142
movq 0x6ed3(%rip), %rbx      # 0x10fd0
leaq 0x2a4c(%rip), %rsi      # 0xcb50
movl $0x18, %edx
movq %rbx, %rdi
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31d0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xa54e
movb $0x1, %r12b
movq 0x6e84(%rip), %rbx      # 0x10fd0
leaq 0x681d(%rip), %rax      # 0x10970
addq $0x10, %rax
movq %rax, -0x40(%rbp)
leaq 0x6856(%rip), %rax      # 0x109b8
addq $0x10, %rax
movq %rax, -0x38(%rbp)
leaq 0x688f(%rip), %rax      # 0x10a00
addq $0x10, %rax
movq %rax, -0x30(%rbp)
leaq 0x29bc(%rip), %r13      # 0xcb3c
xorl %r14d, %r14d
callq 0x3de0
movq $0x0, -0x48(%rbp)
movq %rbx, %rdi
leaq -0x48(%rbp), %rsi
callq 0x3e7e
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x711b(%rip), %rsi      # 0x112c4
callq 0x3e37
movl $0x12, %edx
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x29a9(%rip), %rsi      # 0xcb69
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x3030
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x31d0
movl $0xf, %edx
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x2975(%rip), %rsi      # 0xcb7c
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x3030
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x31d0
movl $0xf, %edx
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x293e(%rip), %rsi      # 0xcb8c
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x3030
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x31d0
movl $0x1a, %edx
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x2907(%rip), %rsi      # 0xcb9c
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x3030
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x31d0
movl $0x20, %edx
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x28db(%rip), %rsi      # 0xcbb7
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x3030
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x31d0
movl $0xc, %edx
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x28b5(%rip), %rsi      # 0xcbd8
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x3030
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x31d0
xorl %r14d, %r14d
callq 0x3d5f
addl $-0x30, %eax
cmpl $0x4, %eax
ja 0xa510
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
xorl %r14d, %r14d
callq 0xa583
jmp 0xa513
xorl %r14d, %r14d
xorl %r12d, %r12d
jmp 0xa513
movl $0xa0, %edi
callq 0x32a0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x6948(%rip), %rax      # 0x10cf8
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movl $0x90, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x3190
movq -0x38(%rbp), %rax
movq %rax, 0x10(%r14)
movb $0x0, 0x18(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x60(%r14)
movups %xmm0, 0x70(%r14)
movups %xmm0, 0x80(%r14)
movups %xmm0, 0x90(%r14)
jmp 0xa4ef
movl $0xb8, %edi
callq 0x32a0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x691a(%rip), %rax      # 0x10d48
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movl $0xa8, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x3190
movb $0x0, 0x18(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x60(%r14)
movups %xmm0, 0x70(%r14)
movups %xmm0, 0x80(%r14)
movups %xmm0, 0x90(%r14)
movq -0x30(%rbp), %rax
movq %rax, 0x10(%r14)
movups %xmm0, 0xa0(%r14)
movq $0x0, 0xb0(%r14)
jmp 0xa4ef
movl $0x60, %edi
callq 0x32a0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x67ec(%rip), %rax      # 0x10ca8
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movq -0x40(%rbp), %rax
movq %rax, 0x10(%r14)
movb $0x0, 0x18(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x20(%r14)
movq 0x10(%r14), %rax
movq %r15, %rdi
callq *(%rax)
testb %al, %al
je 0xa513
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
jmp 0xa513
xorl %r14d, %r14d
testq %r14, %r14
je 0xa520
movq %r14, %rdi
callq 0x7fac
testb $0x1, %r12b
jne 0xa180
movq 0x6a9f(%rip), %rdi      # 0x10fd0
leaq 0x6d6c(%rip), %rsi      # 0x112a4
callq 0x3e37
callq 0x3e1a
callq 0x3de0
callq 0x3854
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa563
jmp 0xa563
jmp 0xa563
movq %rax, %rbx
xorl %r14d, %r14d
jmp 0xa56e
movq %rax, %rbx
testq %r14, %r14
je 0xa57b
movq %r14, %rdi
callq 0x7fac
movq %rbx, %rdi
callq 0x3480