// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
leaq -0x2a0(%rbp), %r13
leaq -0x100(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x6279(%rip), %r15      # 0xafd8
leaq 0x6542(%rip), %rdi      # 0xb2a8
callq 0x6130
cmpl $0xfffffe6c, %eax       # imm = 0xFFFFFE6C
je 0x5575
movl %eax, %r12d
cmpl 0x65d1(%rip), %eax      # 0xb350
jne 0x4f72
leaq -0x2b0(%rbp), %rdi
callq 0x781d
movq -0x2b0(%rbp), %rsi
movq -0x2a8(%rbp), %rdx
movq %r15, %rdi
callq 0x3360
movl $0xf, %edx
movq %rax, %rdi
leaq 0x33a2(%rip), %rsi      # 0x8158
callq 0x3360
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
leaq -0x88(%rbp), %r15
je 0x4dd3
callq 0x32b0
movl 0x6577(%rip), %edi      # 0xb350
leaq 0x6574(%rip), %rsi      # 0xb354
leaq 0x66c1(%rip), %rdx      # 0xb4a8
callq 0x30d0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
leaq -0x1a0(%rbp), %r13
je 0x5587
movl $0xff, %edx
movl %eax, %edi
leaq -0x2b0(%rbp), %r14
movq %r14, %rsi
callq 0x33d0
movq %r13, -0x1b0(%rbp)
movq %r14, %rdi
callq 0x3110
leaq (%rax,%rbp), %rdx
addq $-0x2b0, %rdx           # imm = 0xFD50
leaq -0x1b0(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x68ca
movq %r15, %rdi
movq %rbx, %rsi
movl $0x40, %edx
callq 0x7ab4
movq -0x1b0(%rbp), %rdi
cmpq %r13, %rdi
je 0x4e62
callq 0x32b0
movl $0xff, %edx
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
callq 0x31b0
movq -0x88(%rbp), %rax
movq -0x80(%rbp), %r13
subq %rax, %r13
movb $0x1, %r14b
cmpq $0x40, %r13
movq 0x6147(%rip), %r15      # 0xafd8
jne 0x4efc
leaq -0x100(%rbp), %rcx
movq %rcx, -0x110(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %rdi
callq 0x66b6
movq -0x88(%rbp), %rax
leaq -0x160(%rbp), %rcx
movq %rcx, -0x170(%rbp)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0x170(%rbp), %r14
movq %r14, %rdi
callq 0x66b6
leaq -0x110(%rbp), %rdi
movq %r14, %rsi
callq 0x473f
movl %eax, %r14d
xorb $0x1, %r14b
cmpq $0x40, %r13
jne 0x4f32
movq -0x170(%rbp), %rdi
leaq -0x160(%rbp), %rax
cmpq %rax, %rdi
je 0x4f1a
callq 0x32b0
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x4f32
callq 0x32b0
testb %r14b, %r14b
je 0x5037
movl -0x2c(%rbp), %edi
movl $0x1, %edx
leaq 0x322c(%rip), %rsi      # 0x8176
xorl %ecx, %ecx
callq 0x3160
movl $0x6, %edx
movq %r15, %rdi
leaq 0x3218(%rip), %rsi      # 0x8178
callq 0x3360
movl -0x2c(%rbp), %edi
callq 0x34e0
jmp 0x51bf
movq 0x64df(%rip), %rcx      # 0xb458
leaq 0x64d0(%rip), %rax      # 0xb450
testq %rcx, %rcx
je 0x4fa3
leaq 0x64c4(%rip), %rax      # 0xb450
xorl %edx, %edx
cmpl %r12d, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x4f8c
leaq 0x64a6(%rip), %rcx      # 0xb450
cmpq %rcx, %rax
je 0x51d2
cmpl 0x20(%rax), %r12d
jl 0x51d2
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
movq 0x6428(%rip), %r14      # 0xb400
leaq 0x6411(%rip), %rax      # 0xb3f0
cmpq %rax, %r14
je 0x5205
movq %r13, -0x2b0(%rbp)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
leaq -0x2b0(%rbp), %rdi
callq 0x66b6
movl 0x40(%r14), %eax
movl %eax, -0x290(%rbp)
cmpl %r12d, %eax
je 0x51e4
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
je 0x502a
callq 0x32b0
movq %r14, %rdi
callq 0x3200
movq %rax, %r14
jmp 0x4fd8
movq -0x88(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x3360
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31f0
movl $0xb, %edx
movq %r15, %rdi
leaq 0x30f9(%rip), %rsi      # 0x817f
callq 0x3360
movq -0x88(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x3360
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31f0
movq -0x88(%rbp), %rax
leaq -0x180(%rbp), %r13
movq %r13, -0x190(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x190(%rbp), %r14
movq %r14, %rdi
callq 0x66b6
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0x37bc
movq -0x190(%rbp), %rdi
cmpq %r13, %rdi
je 0x5116
callq 0x32b0
movq -0x68(%rbp), %r14
movq -0x60(%rbp), %r13
cmpq %r13, %r14
je 0x518c
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x50(%rbp), %rdi
callq 0x66b6
movl $0x4, %edx
movq %r15, %rdi
leaq 0x303e(%rip), %rsi      # 0x818b
callq 0x3360
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r15, %rdi
callq 0x3360
movl -0x2c(%rbp), %edi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3160
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x5186
callq 0x32b0
addq $0x20, %r14
jmp 0x511e
leaq 0x62b5(%rip), %rdi      # 0xb448
leaq -0x2c(%rbp), %rsi
callq 0x6d58
movl -0x2c(%rbp), %r14d
movq -0x88(%rbp), %rsi
leaq 0x623a(%rip), %rdi      # 0xb3e8
callq 0x61b0
movl %r14d, (%rax)
leaq -0x68(%rbp), %rdi
callq 0x60e2
leaq -0x88(%rbp), %rdi
callq 0x60e2
leaq -0x2a0(%rbp), %r13
cmpl $0xfffffe6c, %r12d      # imm = 0xFFFFFE6C
jne 0x4d5f
jmp 0x5575
leaq -0x50(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x31a0
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
je 0x5205
callq 0x32b0
movl $0xff, %edx
movl %r12d, %edi
leaq -0x3b0(%rbp), %rsi
callq 0x33d0
testq %rax, %rax
jle 0x53e2
leaq -0x140(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0x3b0(%rbp), %r14
movq %r14, %rdi
callq 0x3110
leaq (%rax,%rbp), %rdx
addq $-0x3b0, %rdx           # imm = 0xFC50
leaq -0x150(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x68ca
leaq -0x68(%rbp), %rdi
movq %rbx, %rsi
movl $0x3e, %edx
callq 0x7ab4
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0x5285
callq 0x32b0
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
je 0x54fe
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x66b6
movq -0x68(%rbp), %rax
leaq -0xa0(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xb0(%rbp), %rdi
callq 0x66b6
movq -0x68(%rbp), %rax
leaq -0x120(%rbp), %rcx
movq %rcx, -0x130(%rbp)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0x130(%rbp), %rbx
movq %rbx, %rdi
callq 0x66b6
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movq %rbx, %rdx
callq 0x3dfb
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x533a
callq 0x32b0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x5352
callq 0x32b0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x536a
callq 0x32b0
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rbx
movq %rbx, %rdi
callq 0x66b6
movq %rbx, %rdi
leaq 0x2e87(%rip), %rsi      # 0x8220
callq 0x34d0
movq -0x68(%rbp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
movq %rbx, %rdi
callq 0x30c0
movq %r13, -0x2b0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x547d
movq %rdx, -0x2b0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x2a0(%rbp)
jmp 0x5485
leaq -0xe0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x66b6
leaq -0xf0(%rbp), %rdi
callq 0x43c8
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x542b
callq 0x32b0
leaq 0x5fb6(%rip), %rdi      # 0xb3e8
leaq -0x50(%rbp), %rsi
callq 0x61b0
leaq 0x6006(%rip), %rdi      # 0xb448
movq %rax, %rsi
callq 0x7202
leaq 0x5ff7(%rip), %rdi      # 0xb448
movq %rax, %rsi
callq 0x727e
leaq 0x5f88(%rip), %rdi      # 0xb3e8
leaq -0x50(%rbp), %rsi
callq 0x7338
leaq 0x5f78(%rip), %rdi      # 0xb3e8
movq %rax, %rsi
callq 0x73ea
jmp 0x555a
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, -0x2a8(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x68(%rbp), %rdi
addq $0x20, %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x33a0
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
je 0x54c4
callq 0x32b0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x54d9
callq 0x32b0
movq -0x68(%rbp), %rsi
leaq 0x5f04(%rip), %rdi      # 0xb3e8
callq 0x61b0
movl (%rax), %edi
movq -0x68(%rbp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
xorl %ecx, %ecx
callq 0x3160
leaq -0x2b0(%rbp), %rdi
callq 0x781d
movq -0x2b0(%rbp), %rsi
movq -0x2a8(%rbp), %rdx
movq %r15, %rdi
callq 0x3360
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
je 0x5531
callq 0x32b0
leaq 0x2c58(%rip), %rdi      # 0x8190
movq %r14, %rsi
xorl %eax, %eax
callq 0x3050
movl $0xff, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x31b0
leaq -0x68(%rbp), %rdi
callq 0x60e2
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x51d2
callq 0x32b0
jmp 0x51d2
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5a4a(%rip), %rdi      # 0xafd8
leaq 0x2bd3(%rip), %rsi      # 0x8168
callq 0x32e0
movq %rax, %rdi
callq 0x3140
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3390
movq %rax, %r14
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
jne 0x5675
jmp 0x5708
movq %rax, %r14
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
jmp 0x566c
jmp 0x55dc
movq %rax, %r14
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
jmp 0x563c
jmp 0x5684
movq %rax, %r14
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x5611
callq 0x32b0
jmp 0x5611
movq %rax, %r14
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x562e
callq 0x32b0
jmp 0x562e
movq %rax, %r14
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
jne 0x5652
jmp 0x5687
movq %rax, %r14
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
je 0x5687
callq 0x32b0
jmp 0x5687
jmp 0x5684
movq %rax, %r14
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0x5708
callq 0x32b0
jmp 0x5708
jmp 0x5705
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x60e2
jmp 0x5708
movq %rax, %r14
movq -0x190(%rbp), %rdi
cmpq %r13, %rdi
jne 0x56d8
jmp 0x5744
jmp 0x571c
movq %rax, %r14
movq -0x170(%rbp), %rdi
leaq -0x160(%rbp), %rax
cmpq %rax, %rdi
je 0x56c8
callq 0x32b0
jmp 0x56c8
movq %rax, %r14
movq -0x110(%rbp), %rdi
cmpq -0x90(%rbp), %rdi
je 0x5744
callq 0x32b0
jmp 0x5744
jmp 0x5721
movq %rax, %r14
movq -0x1b0(%rbp), %rdi
jmp 0x56fe
movq %rax, %r14
jmp 0x5750
jmp 0x5705
movq %rax, %r14
movq -0x2b0(%rbp), %rdi
cmpq %r13, %rdi
jne 0x5715
jmp 0x5750
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x5750
callq 0x32b0
jmp 0x5750
movq %rax, %r14
jmp 0x5744
movq %rax, %r14
jmp 0x573b
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x573b
callq 0x32b0
leaq -0x68(%rbp), %rdi
callq 0x60e2
leaq -0x88(%rbp), %rdi
callq 0x60e2
movq %r14, %rdi
callq 0x3480