// File: 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
subq $0x360, %rsp            # imm = 0x360
movl $0x0, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2270
movq 0x6b0e(%rip), %rdi      # 0x8fd0
leaq 0x3b3b(%rip), %rsi      # 0x6004
callq 0x21b0
jmp 0x24d0
movq 0x6b09(%rip), %rdi      # 0x8fe0
leaq -0x28(%rbp), %rsi
callq 0x2250
jmp 0x24e2
leaq -0x59(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x22e0
movq -0x2e0(%rbp), %rdx
leaq 0x3b1d(%rip), %rsi      # 0x601d
leaq -0x58(%rbp), %rdi
callq 0x2260
jmp 0x250b
movl $0x22b8, %edi           # imm = 0x22B8
leaq -0x58(%rbp), %rsi
xorl %edx, %edx
callq 0x3fb0
movl %eax, -0x2e4(%rbp)
jmp 0x2523
leaq -0x58(%rbp), %rdi
callq 0x2110
leaq -0x59(%rbp), %rdi
callq 0x2210
movl -0x2e4(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x2f4(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x20c0
movq -0x300(%rbp), %rdi
movq %rax, -0x2f0(%rbp)
callq 0x2120
movl -0x2f4(%rbp), %edi
movq -0x2f0(%rbp), %rsi
movq %rax, %rdx
callq 0x2090
jmp 0x2581
leaq -0x210(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x2930
leaq -0x240(%rbp), %rdi
callq 0x2930
movq -0x318(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2950
movb %dl, -0x309(%rbp)
movq %rax, -0x308(%rbp)
jmp 0x25bf
movb -0x309(%rbp), %al
movq -0x308(%rbp), %rcx
movq %rcx, -0x250(%rbp)
movb %al, -0x248(%rbp)
movl $0x0, -0x254(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x254(%rbp), %rsi
callq 0x29a0
movb %dl, -0x321(%rbp)
movq %rax, -0x320(%rbp)
jmp 0x2605
movb -0x321(%rbp), %al
movq -0x320(%rbp), %rcx
movq %rcx, -0x268(%rbp)
movb %al, -0x260(%rbp)
jmp 0x2621
leaq -0x298(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x29f0
jmp 0x2636
leaq -0xe0(%rbp), %rdi
leaq -0x298(%rbp), %rsi
xorl %edx, %edx
callq 0x40d0
movl %eax, -0x328(%rbp)
jmp 0x2653
movl -0x38(%rbp), %eax
movl %eax, -0x32c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x2a20
movl -0x32c(%rbp), %ecx
movl -0x328(%rbp), %eax
cmpl %ecx, %eax
jne 0x27c7
movl -0x38(%rbp), %edi
leaq -0x1e0(%rbp), %rsi
movl $0xff, %edx
callq 0x2280
movq %rax, -0x338(%rbp)
jmp 0x2699
movq -0x338(%rbp), %rax
movq %rax, -0x2a0(%rbp)
cmpq $0x0, -0x2a0(%rbp)
jg 0x275b
movq 0x6914(%rip), %rdi      # 0x8fd0
leaq 0x3964(%rip), %rsi      # 0x6027
callq 0x21b0
movq %rax, -0x340(%rbp)
jmp 0x26d1
movq -0x340(%rbp), %rdi
movq 0x68e1(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x26e6
jmp 0x28bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2911
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x271f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2110
leaq -0x59(%rbp), %rdi
callq 0x2210
jmp 0x2911
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x28f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x2a20
jmp 0x28f9
movsbl -0x1e0(%rbp), %eax
cmpl $0x4e, %eax
jne 0x279d
movq 0x6862(%rip), %rdi      # 0x8fd0
leaq 0x38c2(%rip), %rsi      # 0x6037
callq 0x21b0
movq %rax, -0x348(%rbp)
jmp 0x2783
movq -0x348(%rbp), %rdi
movq 0x682f(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2798
jmp 0x28bb
leaq 0x38ac(%rip), %rdi      # 0x6050
xorl %eax, %eax
leaq -0x1e0(%rbp), %rsi
callq 0x2030
jmp 0x27b4
leaq -0x1e0(%rbp), %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0x20f0
leaq -0x2d0(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x29f0
jmp 0x27dc
leaq -0xe0(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
xorl %edx, %edx
callq 0x40d0
movl %eax, -0x34c(%rbp)
jmp 0x27f9
leaq -0x2d0(%rbp), %rdi
callq 0x2a20
movl -0x34c(%rbp), %eax
cmpl $0x0, %eax
jne 0x28b6
xorl %edi, %edi
leaq -0x1e0(%rbp), %rsi
movl $0xff, %edx
callq 0x2280
movq %rax, -0x358(%rbp)
jmp 0x2830
movq -0x358(%rbp), %rax
movq %rax, -0x2d8(%rbp)
movl -0x38(%rbp), %edi
leaq -0x1e0(%rbp), %rsi
movl $0xff, %edx
xorl %ecx, %ecx
callq 0x20d0
movq %rax, -0x360(%rbp)
jmp 0x285d
movq -0x360(%rbp), %rax
cmpq $0x0, %rax
jg 0x28a3
movq 0x675f(%rip), %rdi      # 0x8fd0
leaq 0x37db(%rip), %rsi      # 0x6053
callq 0x21b0
jmp 0x287f
movl $0x1, %edi
callq 0x2240
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2d0(%rbp), %rdi
callq 0x2a20
jmp 0x28f9
leaq -0x1e0(%rbp), %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0x20f0
jmp 0x261f
movl -0x38(%rbp), %edi
callq 0x2300
jmp 0x28c5
movl $0x0, -0x4(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x2a20
leaq -0x210(%rbp), %rdi
callq 0x2a20
leaq -0x28(%rbp), %rdi
callq 0x2110
movl -0x4(%rbp), %eax
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
leaq -0x240(%rbp), %rdi
callq 0x2a20
leaq -0x210(%rbp), %rdi
callq 0x2a20
leaq -0x28(%rbp), %rdi
callq 0x2110
movq -0x30(%rbp), %rdi
callq 0x22d0
nopw %cs:(%rax,%rax)
nopl (%rax)