// File: QZzcoder[P]LiveChat/server.cpp
// Function: oneLoop()
void oneLoop(){
    while(1){
        char recv_buff[255];
        int sock = bq.take();
        if(sock == -404){
            break;
        }else if(sock == socket_fd){
            cout<<getTime()<<"User sign up：";
            int client_fd = accept(socket_fd,(struct sockaddr*)&client,&len);
            if (client_fd == -1)
            {
                cout << "accept错误\n" << endl;
                exit(-1);
            }
            char signMsg[255];

            ssize_t recv_size = read(client_fd,signMsg,255);
            vector<string> vec = splitString(signMsg,'@');
            ::memset(signMsg,0,255);

            if(vec.size() != 2 ||!userCheck(vec[0],vec[1])){//登录失败
                send(client_fd,"N",1,0);
                cout<<" fail\n";
                close(client_fd);
            }else{
                cout<<vec[0]<<endl;
                cout<<"old msg to "<<vec[0]<<endl;
                vector<string> oldMsg = getOldMsg(vec[0]);
                for(string s:oldMsg){
                    cout<<"    "<<s;
                    send(client_fd,s.c_str(),s.size(),0);
                }
                clientSelectSet.insert(client_fd);
                name2sock[vec[0]] = client_fd;
            }
        }else if(clientSelectSet.count(sock) == 1){
            int activeClient = sock;
            string oriName;
            for(auto it:name2sock){
                if(it.second == activeClient){
                    oriName = it.first;
                    break;
                }
            }
            ssize_t recv_size = read(activeClient,recv_buff,255);
            if(recv_size<=0){//客户端退出
                updateTime(oriName);
                clientSelectSet.erase(name2sock[oriName]);
                name2sock.erase(oriName);
                continue;
            }
            vector<string> msg = splitString(recv_buff,'>');
            if(msg.size() != 0){
                storeMessage(oriName,msg[0],msg[1]);
                msg[1] = oriName + ":" + msg[1];
                send(name2sock[msg[0]],msg[1].c_str(),msg[1].size(),0);
            }
            cout<<getTime();
            ::printf("message:%s",recv_buff);
            ::memset(recv_buff,0,sizeof(recv_buff));
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5c0, %rsp            # imm = 0x5C0
leaq 0x107ee(%rip), %rdi     # 0x152e0
callq 0x6810
movl %eax, -0x104(%rbp)
cmpl $0xfffffe6c, -0x104(%rbp) # imm = 0xFFFFFE6C
jne 0x4b0e
jmp 0x5769
movl -0x104(%rbp), %eax
cmpl 0x1086e(%rip), %eax     # 0x15388
jne 0x515d
leaq -0x128(%rbp), %rdi
movq %rdi, -0x500(%rbp)
callq 0xcf10
movq -0x500(%rbp), %rsi
movq 0x10497(%rip), %rdi     # 0x14fd8
callq 0x32c0
movq %rax, -0x4f8(%rbp)
jmp 0x4b4f
movq -0x4f8(%rbp), %rdi
leaq 0x95df(%rip), %rsi      # 0xe13c
callq 0x3310
jmp 0x4b64
leaq -0x128(%rbp), %rdi
callq 0x3200
movl 0x10812(%rip), %edi     # 0x15388
leaq 0x1080f(%rip), %rsi     # 0x1538c
leaq 0x1095c(%rip), %rdx     # 0x154e0
callq 0x30e0
movl %eax, -0x138(%rbp)
cmpl $-0x1, -0x138(%rbp)
jne 0x4be7
movq 0x10439(%rip), %rdi     # 0x14fd8
leaq 0x95a6(%rip), %rsi      # 0xe14c
callq 0x3310
movq %rax, %rdi
movq 0x1040b(%rip), %rsi     # 0x14fc0
callq 0x3370
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x33b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x3200
jmp 0x5772
movl -0x138(%rbp), %edi
leaq -0x240(%rbp), %rsi
movq %rsi, -0x510(%rbp)
movl $0xff, %edx
callq 0x3420
movq %rax, -0x248(%rbp)
leaq -0x281(%rbp), %rdi
movq %rdi, -0x508(%rbp)
callq 0x34e0
movq -0x510(%rbp), %rsi
movq -0x508(%rbp), %rdx
leaq -0x280(%rbp), %rdi
callq 0x33f0
jmp 0x4c3b
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
movl $0x40, %edx
callq 0xd360
jmp 0x4c55
leaq -0x280(%rbp), %rdi
callq 0x3200
leaq -0x281(%rbp), %rdi
callq 0x3380
leaq -0x240(%rbp), %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0x31c0
leaq -0x260(%rbp), %rdi
callq 0x68b0
movq %rax, %rcx
movb $0x0, -0x2a9(%rbp)
movb $0x0, -0x2d1(%rbp)
movb $0x1, %al
cmpq $0x2, %rcx
movb %al, -0x511(%rbp)
jne 0x4d25
xorl %eax, %eax
movl %eax, %esi
leaq -0x260(%rbp), %rdi
callq 0x6560
movq %rax, %rsi
leaq -0x2a8(%rbp), %rdi
callq 0x3130
jmp 0x4ccc
movb $0x1, -0x2a9(%rbp)
leaq -0x260(%rbp), %rdi
movl $0x1, %esi
callq 0x6560
movq %rax, %rsi
leaq -0x2d0(%rbp), %rdi
callq 0x3130
jmp 0x4cf5
movb $0x1, -0x2d1(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x4520
movb %al, -0x512(%rbp)
jmp 0x4d17
movb -0x512(%rbp), %al
xorb $-0x1, %al
movb %al, -0x511(%rbp)
movb -0x511(%rbp), %al
movb %al, -0x513(%rbp)
testb $0x1, -0x2d1(%rbp)
jne 0x4d3c
jmp 0x4d48
leaq -0x2d0(%rbp), %rdi
callq 0x3200
testb $0x1, -0x2a9(%rbp)
jne 0x4d53
jmp 0x4d5f
leaq -0x2a8(%rbp), %rdi
callq 0x3200
movb -0x513(%rbp), %al
testb $0x1, %al
jne 0x4d6e
jmp 0x4e65
movl -0x138(%rbp), %edi
leaq 0x93df(%rip), %rsi      # 0xe15a
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x3180
jmp 0x4d89
movq 0x10248(%rip), %rdi     # 0x14fd8
leaq 0x93c5(%rip), %rsi      # 0xe15c
callq 0x3310
jmp 0x4d9e
movl -0x138(%rbp), %edi
callq 0x3540
jmp 0x4dab
jmp 0x513b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x4de2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x3200
leaq -0x281(%rbp), %rdi
callq 0x3380
jmp 0x5772
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x514c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x4e49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
testb $0x1, -0x2d1(%rbp)
jne 0x4e3b
jmp 0x4e47
leaq -0x2d0(%rbp), %rdi
callq 0x3200
jmp 0x4e49
testb $0x1, -0x2a9(%rbp)
jne 0x4e54
jmp 0x4e60
leaq -0x2a8(%rbp), %rdi
callq 0x3200
jmp 0x514c
xorl %eax, %eax
movl %eax, %esi
leaq -0x260(%rbp), %rdi
callq 0x6560
movq %rax, %rsi
movq 0x10159(%rip), %rdi     # 0x14fd8
callq 0x32c0
movq %rax, -0x520(%rbp)
jmp 0x4e8d
movq -0x520(%rbp), %rdi
movq 0x10125(%rip), %rsi     # 0x14fc0
callq 0x3370
jmp 0x4ea2
movq 0x1012f(%rip), %rdi     # 0x14fd8
leaq 0x92b3(%rip), %rsi      # 0xe163
callq 0x3310
movq %rax, -0x528(%rbp)
jmp 0x4ebe
xorl %eax, %eax
movl %eax, %esi
leaq -0x260(%rbp), %rdi
callq 0x6560
movq -0x528(%rbp), %rdi
movq %rax, %rsi
callq 0x32c0
movq %rax, -0x530(%rbp)
jmp 0x4ee6
movq -0x530(%rbp), %rdi
movq 0x100cc(%rip), %rsi     # 0x14fc0
callq 0x3370
jmp 0x4efb
xorl %eax, %eax
movl %eax, %esi
leaq -0x260(%rbp), %rdi
callq 0x6560
movq %rax, %rsi
leaq -0x310(%rbp), %rdi
callq 0x3130
jmp 0x4f1c
leaq -0x2f0(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x37f0
jmp 0x4f31
leaq -0x310(%rbp), %rdi
callq 0x3200
leaq -0x2f0(%rbp), %rax
movq %rax, -0x318(%rbp)
movq -0x318(%rbp), %rdi
callq 0x68d0
movq %rax, -0x320(%rbp)
movq -0x318(%rbp), %rdi
callq 0x6900
movq %rax, -0x328(%rbp)
leaq -0x320(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x6930
testb $0x1, %al
jne 0x4f8d
jmp 0x50a0
leaq -0x320(%rbp), %rdi
callq 0x6970
movq %rax, %rsi
leaq -0x348(%rbp), %rdi
callq 0x3130
jmp 0x4faa
movq 0x10027(%rip), %rdi     # 0x14fd8
leaq 0x91b7(%rip), %rsi      # 0xe16f
callq 0x3310
movq %rax, -0x538(%rbp)
jmp 0x4fc6
movq -0x538(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x32c0
jmp 0x4fdb
movl -0x138(%rbp), %eax
movl %eax, -0x544(%rbp)
leaq -0x348(%rbp), %rdi
movq %rdi, -0x550(%rbp)
callq 0x3120
movq -0x550(%rbp), %rdi
movq %rax, -0x540(%rbp)
callq 0x3250
movl -0x544(%rbp), %edi
movq -0x540(%rbp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x3180
jmp 0x5026
leaq -0x348(%rbp), %rdi
callq 0x3200
leaq -0x320(%rbp), %rdi
callq 0x6990
jmp 0x4f71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x3200
jmp 0x514c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x512d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x3200
jmp 0x512d
leaq 0x103d9(%rip), %rdi     # 0x15480
leaq -0x138(%rbp), %rsi
callq 0x69b0
movb %dl, -0x559(%rbp)
movq %rax, -0x558(%rbp)
jmp 0x50c2
movb -0x559(%rbp), %al
movq -0x558(%rbp), %rcx
movq %rcx, -0x358(%rbp)
movb %al, -0x350(%rbp)
movl -0x138(%rbp), %eax
movl %eax, -0x56c(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x260(%rbp), %rdi
callq 0x6560
movq %rax, %rsi
leaq 0x1031e(%rip), %rdi     # 0x15420
callq 0x6a00
movq %rax, -0x568(%rbp)
jmp 0x5110
movq -0x568(%rbp), %rax
movl -0x56c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x2f0(%rbp), %rdi
callq 0x6630
jmp 0x513b
leaq -0x2f0(%rbp), %rdi
callq 0x6630
jmp 0x514c
leaq -0x260(%rbp), %rdi
callq 0x6630
jmp 0x5762
leaq -0x260(%rbp), %rdi
callq 0x6630
jmp 0x5772
leaq 0x1031c(%rip), %rdi     # 0x15480
leaq -0x104(%rbp), %rsi
callq 0x6ae0
cmpq $0x1, %rax
jne 0x5760
movl -0x104(%rbp), %eax
movl %eax, -0x35c(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x3400
leaq 0x10287(%rip), %rax     # 0x15420
movq %rax, -0x388(%rbp)
leaq 0x10279(%rip), %rdi     # 0x15420
callq 0x6b40
movq %rax, -0x390(%rbp)
leaq 0x10266(%rip), %rdi     # 0x15420
callq 0x6b70
movq %rax, -0x398(%rbp)
leaq -0x390(%rbp), %rdi
leaq -0x398(%rbp), %rsi
callq 0x6ba0
testb $0x1, %al
jne 0x51e2
jmp 0x529f
leaq -0x390(%rbp), %rdi
callq 0x6bd0
movq %rax, %rsi
leaq -0x3c0(%rbp), %rdi
callq 0x6bf0
jmp 0x51ff
movl -0x3a0(%rbp), %eax
cmpl -0x35c(%rbp), %eax
jne 0x5268
leaq -0x380(%rbp), %rdi
leaq -0x3c0(%rbp), %rsi
callq 0x3040
jmp 0x5222
movl $0x6, -0x3c4(%rbp)
jmp 0x5272
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x5752
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x3c0(%rbp), %rdi
callq 0x6c30
jmp 0x5752
movl $0x0, -0x3c4(%rbp)
leaq -0x3c0(%rbp), %rdi
callq 0x6c30
movl -0x3c4(%rbp), %eax
testl %eax, %eax
je 0x528c
jmp 0x528a
jmp 0x529f
jmp 0x528e
leaq -0x390(%rbp), %rdi
callq 0x6c50
jmp 0x51c6
movl -0x35c(%rbp), %edi
leaq -0x100(%rbp), %rsi
movl $0xff, %edx
callq 0x3420
movq %rax, -0x578(%rbp)
jmp 0x52bf
movq -0x578(%rbp), %rax
movq %rax, -0x3d0(%rbp)
cmpq $0x0, -0x3d0(%rbp)
jg 0x5382
leaq -0x3f0(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x3130
jmp 0x52f0
leaq -0x3f0(%rbp), %rdi
callq 0x42d0
jmp 0x52fe
leaq -0x3f0(%rbp), %rdi
callq 0x3200
leaq 0x1010f(%rip), %rdi     # 0x15420
leaq -0x380(%rbp), %rsi
callq 0x6a00
movq %rax, -0x580(%rbp)
jmp 0x5326
movq -0x580(%rbp), %rsi
leaq 0x1014c(%rip), %rdi     # 0x15480
callq 0x6c80
jmp 0x533b
leaq 0x100de(%rip), %rdi     # 0x15420
leaq -0x380(%rbp), %rsi
callq 0x6cb0
jmp 0x5350
movl $0x2, -0x3c4(%rbp)
jmp 0x5709
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x3200
jmp 0x5752
leaq -0x429(%rbp), %rdi
movq %rdi, -0x588(%rbp)
callq 0x34e0
movq -0x588(%rbp), %rdx
leaq -0x428(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x33f0
jmp 0x53b1
leaq -0x408(%rbp), %rdi
leaq -0x428(%rbp), %rsi
movl $0x3e, %edx
callq 0xd360
jmp 0x53cb
leaq -0x428(%rbp), %rdi
callq 0x3200
leaq -0x429(%rbp), %rdi
callq 0x3380
leaq -0x408(%rbp), %rdi
callq 0x68b0
cmpq $0x0, %rax
je 0x569a
leaq -0x450(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x3130
jmp 0x540e
xorl %eax, %eax
movl %eax, %esi
leaq -0x408(%rbp), %rdi
callq 0x6560
movq %rax, %rsi
leaq -0x470(%rbp), %rdi
callq 0x3130
jmp 0x542f
leaq -0x408(%rbp), %rdi
movl $0x1, %esi
callq 0x6560
movq %rax, %rsi
leaq -0x490(%rbp), %rdi
callq 0x3130
jmp 0x5451
leaq -0x450(%rbp), %rdi
leaq -0x470(%rbp), %rsi
leaq -0x490(%rbp), %rdx
callq 0x3f50
jmp 0x546d
leaq -0x490(%rbp), %rdi
callq 0x3200
leaq -0x470(%rbp), %rdi
callq 0x3200
leaq -0x450(%rbp), %rdi
callq 0x3200
leaq 0x8d6c(%rip), %rdx      # 0xe204
leaq -0x4d0(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x65b0
jmp 0x54ad
leaq -0x408(%rbp), %rdi
movl $0x1, %esi
callq 0x6560
movq %rax, %rdx
leaq -0x4b0(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
callq 0x6450
jmp 0x54d6
leaq -0x408(%rbp), %rdi
movq %rdi, -0x598(%rbp)
movl $0x1, %esi
callq 0x6560
movq %rax, %rdi
leaq -0x4b0(%rbp), %rsi
movq %rsi, -0x5a0(%rbp)
callq 0x33c0
movq -0x5a0(%rbp), %rdi
callq 0x3200
leaq -0x4d0(%rbp), %rdi
callq 0x3200
movq -0x598(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x6560
movq %rax, %rsi
leaq 0xfeea(%rip), %rdi      # 0x15420
callq 0x6a00
movq %rax, -0x590(%rbp)
jmp 0x5544
movq -0x590(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x5ac(%rbp)
leaq -0x408(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
movl $0x1, %esi
movq %rsi, -0x5b8(%rbp)
callq 0x6560
movq %rax, %rdi
callq 0x3120
movq -0x5c0(%rbp), %rdi
movq -0x5b8(%rbp), %rsi
movq %rax, -0x5a8(%rbp)
callq 0x6560
movq %rax, %rdi
callq 0x3250
movl -0x5ac(%rbp), %edi
movq -0x5a8(%rbp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x3180
jmp 0x55b5
jmp 0x569a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x55ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x3200
leaq -0x429(%rbp), %rdi
callq 0x3380
jmp 0x5752
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x5746
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x5666
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x565a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x490(%rbp), %rdi
callq 0x3200
leaq -0x470(%rbp), %rdi
callq 0x3200
leaq -0x450(%rbp), %rdi
callq 0x3200
jmp 0x5746
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x3200
jmp 0x5746
leaq -0x4f0(%rbp), %rdi
callq 0xcf10
jmp 0x56a8
movq 0xf929(%rip), %rdi      # 0x14fd8
leaq -0x4f0(%rbp), %rsi
callq 0x32c0
jmp 0x56bd
leaq -0x4f0(%rbp), %rdi
callq 0x3200
leaq 0x8aa4(%rip), %rdi      # 0xe174
xorl %eax, %eax
leaq -0x100(%rbp), %rsi
callq 0x3050
jmp 0x56e0
leaq -0x100(%rbp), %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0x31c0
leaq -0x408(%rbp), %rdi
callq 0x6630
movl $0x0, -0x3c4(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x3200
movl -0x3c4(%rbp), %eax
testl %eax, %eax
je 0x5726
jmp 0x5721
jmp 0x4aeb
jmp 0x5760
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x3200
leaq -0x408(%rbp), %rdi
callq 0x6630
leaq -0x380(%rbp), %rdi
callq 0x3200
jmp 0x5772
jmp 0x5762
jmp 0x5764
jmp 0x4aeb
addq $0x5c0, %rsp            # imm = 0x5C0
popq %rbp
retq
movq -0x130(%rbp), %rdi
callq 0x34d0
nop