// File: /workspace/github_cpp_makefile_star2_O2/QZzcoder[P]LiveChat/client.cpp
// Function: main
int main()
{
    string name;
    cout<<"输入 用户名@密码:";
    cin>>name;
    int socket_fd = getSocket(8888,"127.0.0.1",false);
    write(socket_fd,name.c_str(),name.size());
    fd_set fds;
    char recv_buff[255];
    set<int> SelectSet,cinSelectSet;
    SelectSet.insert(socket_fd);
    cinSelectSet.insert(STDIN_FILENO);
    while(1){
        if(mySelect(fds,SelectSet,0) == socket_fd){
            ssize_t recv_size = read(socket_fd,recv_buff,255);
            if(recv_size<=0){
                cout<<"服务器关闭"<<endl;
                break;
            }
            if(recv_buff[0] == 'N'){
                cout<<"用户名或密码错误"<<endl;
                break;
            }
            printf("%s",recv_buff);
            memset(recv_buff,0,sizeof(recv_buff));
        }
        if(mySelect(fds,cinSelectSet,0) == STDIN_FILENO){
            ssize_t recv_size = read(STDIN_FILENO,recv_buff,255);
            if(send(socket_fd,recv_buff,sizeof(recv_buff),0)<=0){
                cout<<"write error\n";
                exit(1);
            }
            memset(recv_buff,0,sizeof(recv_buff));
        }
    }

    close(socket_fd);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x3b89(%rip), %rdi      # 0x5fd0
leaq 0x1bb6(%rip), %rsi      # 0x4004
callq 0x2190
movq 0x3b86(%rip), %rdi      # 0x5fe0
leaq -0x50(%rbp), %rsi
callq 0x2210
leaq 0x1bb3(%rip), %rsi      # 0x401d
leaq -0x70(%rbp), %rdi
leaq -0x230(%rbp), %rdx
callq 0x20a0
leaq -0x70(%rbp), %rsi
movl $0x22b8, %edi           # imm = 0x22B8
xorl %edx, %edx
callq 0x2c21
movl %eax, %ebx
leaq -0x70(%rbp), %rdi
callq 0x20c0
movl %ebx, -0x2c(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movl %ebx, %edi
callq 0x2080
leaq -0xc8(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0x98(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0xd0(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x29a8
leaq -0x30(%rbp), %rsi
andl $0x0, (%rsi)
leaq -0xa0(%rbp), %rdi
callq 0x2aba
leaq -0x130(%rbp), %r14
leaq -0x2b0(%rbp), %r12
leaq -0x100(%rbp), %rbx
movq %r14, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x270a
movq %r12, %r13
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2cf1
movl %eax, %r15d
movl -0x2c(%rbp), %r12d
movq %r14, %rdi
callq 0x2990
cmpl %r12d, %r15d
jne 0x259b
movl -0x2c(%rbp), %edi
movl $0xff, %edx
leaq -0x230(%rbp), %rsi
callq 0x2230
testq %rax, %rax
jle 0x2613
cmpb $0x4e, -0x230(%rbp)
je 0x261c
leaq 0x1ad5(%rip), %rdi      # 0x4050
leaq -0x230(%rbp), %r15
movq %r15, %rsi
xorl %eax, %eax
callq 0x2030
movl $0xff, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x2100
movq %rbx, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x270a
movq %r13, %r12
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2cf1
movl %eax, %r15d
movq %rbx, %rdi
callq 0x2990
testl %r15d, %r15d
jne 0x2517
movl $0xff, %edx
xorl %edi, %edi
leaq -0x230(%rbp), %r15
movq %r15, %rsi
callq 0x2230
movl -0x2c(%rbp), %edi
movl $0xff, %edx
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x20e0
testq %rax, %rax
jle 0x2674
movl $0xff, %edx
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
callq 0x2100
jmp 0x2517
leaq 0x1a0d(%rip), %rsi      # 0x4027
jmp 0x2623
leaq 0x1a14(%rip), %rsi      # 0x4037
movq 0x39a6(%rip), %rdi      # 0x5fd0
callq 0x2190
movq %rax, %rdi
callq 0x20d0
movl -0x2c(%rbp), %edi
callq 0x22a0
leaq -0xa0(%rbp), %rdi
callq 0x2990
leaq -0xd0(%rbp), %rdi
callq 0x2990
leaq -0x50(%rbp), %rdi
callq 0x20c0
xorl %eax, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3955(%rip), %rdi      # 0x5fd0
leaq 0x19d1(%rip), %rsi      # 0x4053
callq 0x2190
pushq $0x1
popq %rdi
callq 0x2200
jmp 0x26cf
jmp 0x26a7
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20c0
jmp 0x26ea
jmp 0x26a7
jmp 0x26cf
jmp 0x26cf
movq %rax, %rbx
jmp 0x26ea
jmp 0x26cf
jmp 0x26cf
jmp 0x26cf
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
jmp 0x26c8
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x2990
jmp 0x26d2
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x2990
leaq -0xd0(%rbp), %rdi
callq 0x2990
leaq -0x50(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2280