// File: /workspace/github_cpp_makefile_star2_O3/billDrett[P]Bulletin-Boards/boardServer.cpp
// Function: BoardServer::readFromC2S()
bool BoardServer::readFromC2S() //diavasma apo pipe client to server
{
    char buffer[BUFFERSIZE];
    char* tmp;
    int nread;
    string tmpTag;
    int state;
    void (BoardServer::*f)(char* buffer, int nread, int state, string& previousRead);

    while((nread = read(pipeClient2Server, buffer + tmpTag.size(), BUFFERSIZE - tmpTag.size())) > 0) //an exw lavei meros ena tag entolis tote ksanadiavazw gia na parw to ypoleipo
    {
        strncpy(buffer, tmpTag.c_str(), tmpTag.size());
        nread += tmpTag.size();
        tmp = buffer;
        tmpTag = "";
        while(1) //se ena read mporei na exw panw apo mia entoli gia auto mpainei se loop while 1 pou termatizetai otan dn yparxoun alloi xaraktires gia epeksergasia 'h parw meros tag
        {
            if(nread == 0) return true;
            strncpy(buffer, tmpTag.c_str(), tmpTag.size());
            tmpTag = "";
            state = this->nextState(tmp, nread, "<Chanel>", "<Message>", "<Shutdown>", tmpTag) -1; //ta states ksekinan apo 0 oxi apo 1

            if(state == -2) //exei kopei entoli sthn mesh ara na ksanadiavasw
            {
                if(tmpTag.size() == 0) return true;
                break;
            }
            else if(state==createChanel)
            {
                f = &BoardServer::parseAddChanel;
                this->parseCommandPrototype(tmp, nread, "<Chanel>", f, pipeClient2Server);
            }
            else if(state == getMessages)
            {
                f = &BoardServer::parseSendMessage;
                this->parseCommandPrototype(tmp, nread, "<Message>", f, pipeClient2Server);
            }
            else //shutdown
            {
                tmp = getAfterTag(tmp, "<Shutdown>", nread); //dn mporei na einai null afou me thn prohpothesh oti yparxei vrethike edw
                this->shutDown();
                return false;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
movq %rdi, %rbx
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %eax, %eax
leaq -0x4f0(%rbp), %r14
movl (%rbx), %edi
leaq (%rax,%rbp), %rsi
addq $-0x4f0, %rsi           # imm = 0xFB10
movl $0x400, %edx            # imm = 0x400
subq %rax, %rdx
callq 0x2300
movq %rax, %r15
movl %r15d, -0x2c(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %r13
movq %r14, %rdi
movq %r13, %rdx
callq 0x2160
addl %r13d, %r15d
movl %r15d, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
leaq 0x2f4b(%rip), %rcx      # 0x8233
xorl %r8d, %r8d
callq 0x2360
cmpl $0x0, -0x2c(%rbp)
leaq -0xa0(%rbp), %r13
je 0x54fb
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x2160
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movq %r15, %rdx
leaq 0x2f0f(%rip), %rcx      # 0x8233
xorl %r8d, %r8d
callq 0x2360
movl -0x2c(%rbp), %r15d
movq %r13, -0xb0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq 0x2da5(%rip), %rsi      # 0x80ea
leaq 0x2da6(%rip), %rdx      # 0x80f2
callq 0x651a
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
leaq 0x2dc3(%rip), %rsi      # 0x8127
leaq 0x2dc5(%rip), %rdx      # 0x8130
callq 0x651a
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %r12
movq %r12, %rdi
leaq 0x2e18(%rip), %rsi      # 0x81a4
leaq 0x2e1b(%rip), %rdx      # 0x81ae
callq 0x651a
leaq -0x50(%rbp), %rax
movq %rax, (%rsp)
movq %r14, %rsi
movl %r15d, %edx
leaq -0xb0(%rbp), %rcx
leaq -0x70(%rbp), %r8
movq %r12, %r9
callq 0x5a34
movl %eax, %r15d
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x53d8
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x53f1
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x540c
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2230
cmpl $0x1, %r15d
je 0x5471
cmpl $0x2, %r15d
jne 0x54e3
leaq -0xc0(%rbp), %r15
movq %r15, -0xd0(%rbp)
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
leaq 0x2cec(%rip), %rsi      # 0x8127
leaq 0x2cee(%rip), %rdx      # 0x8130
callq 0x651a
movl (%rbx), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x2c(%rbp), %rdx
movq %r12, %rcx
leaq 0xb20(%rip), %r8        # 0x5f80
xorl %r9d, %r9d
callq 0x5cc4
movq -0xd0(%rbp), %rdi
jmp 0x54c4
leaq -0xe0(%rbp), %r15
movq %r15, -0xf0(%rbp)
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
leaq 0x2c5a(%rip), %rsi      # 0x80ea
leaq 0x2c5b(%rip), %rdx      # 0x80f2
callq 0x651a
movl (%rbx), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x2c(%rbp), %rdx
movq %r12, %rcx
leaq 0x659(%rip), %r8        # 0x5b0e
xorl %r9d, %r9d
callq 0x5cc4
movq -0xf0(%rbp), %rdi
movq %r15, %rax
cmpq %r15, %rdi
je 0x54d7
movq (%rax), %rsi
incq %rsi
callq 0x2230
cmpl $0x0, -0x2c(%rbp)
jne 0x5301
jmp 0x54fb
cmpl $-0x1, %r15d
jne 0x5500
movq -0x48(%rbp), %rax
testq %rax, %rax
movb $0x1, %r15b
jne 0x529d
jmp 0x5522
movb $0x1, %r15b
jmp 0x5522
leaq 0x2c9d(%rip), %rsi      # 0x81a4
leaq -0x4f0(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x6616
movq %rbx, %rdi
callq 0x491a
xorl %r15d, %r15d
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x553b
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2230
movl %r15d, %eax
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x55cd
jmp 0x55cd
jmp 0x55cd
jmp 0x55cd
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x55f7
movq -0xc0(%rbp), %rsi
jmp 0x55ef
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0x55f7
movq -0xe0(%rbp), %rsi
jmp 0x55ef
movq %rax, %rbx
jmp 0x55b2
jmp 0x55cd
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x55b2
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x55d5
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2230
jmp 0x55d5
movq %rax, %rbx
jmp 0x55f7
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x55f7
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2230
leaq -0x40(%rbp), %rax
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0x5610
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0