// File: /workspace/github_cpp_makefile_star2_O2/billDrett[P]Bulletin-Boards/boardPost.cpp
// Function: BoardPost::getChanels()
void BoardPost::getChanels()
{
    int nwrite, nread;
    char buffer[BUFFERSIZE];
    char* tmp;
    char* tmp1;
    string tmpTag;
    statesChanels state = waitingChanel;

    if((nwrite = write(pipeBoardPost2Server, "<Chanels>", 9))== -1) //stelnoume mnm sto server na epistrepsei ta chanels tou
    {
        perror("Cant write to pipe S2BP");
    }

    while((nread = read(pipeServer2BoardPost, buffer + tmpTag.size(), BUFFERSIZE - tmpTag.size())) > 0) //diavazoume thn apanthsh tou server mexri na vroume to <end><Chanel>
    {                                                                                                   //se periptwsh pou diavastike meros tou proigoumenou tag diavazw ligotera bytes kai prostheto to proigoumeno tag sthn arxh
        strncpy(buffer, tmpTag.c_str(), tmpTag.size()); //antigrafw to meros tou proigoumenou tag efoson yparxei
        nread += tmpTag.size();
        tmpTag = ""; //midenizw to proigoumeno tag
        tmp = buffer;

        if(state == waitingChanel)//perimenw na vrw to <Chanel>
        {
            tmp1 = getAfterTag(tmp, "<Chanel>", nread);
            if(tmp1 == NULL) //dn vrethike to chanel tag
            {
                if((tmp1 = getAfterTag(tmp, "<", nread)) != NULL) // mporei na pira meros tou tag, to apothikeuw kai to prosthetw sthn arxh tou neou read
                {
                    tmpTag.assign(tmp1-1, nread+1); // -1 giati thelw na krathsw kai to "< kai +1 sto read gia na to symperilavw
                }
                continue;
            }
            tmp = tmp1;
            state = waitingStart;
        }

        if(state == waitingStart) //perimenw na vrw to <start>
        {
            tmp1 = getAfterTag(tmp, "<start>", nread);
            if(tmp1 == NULL)
            {
                if((tmp1 = getAfterTag(tmp, "<", nread)) != NULL) // mporei na pira meros tou tag, to apothikeuw kai to prosthetw sthn arxh tou neou read
                {
                    tmpTag.assign(tmp1-1, nread+1); // -1 giati thelw na krathsw kai to "< kai +1 sto read gia na to symperilavw
                }
                continue;
            }
            tmp = tmp1;
            state = waitingEnd;
        }
        if(state == waitingEnd) //perimenw na vrw to <end>
        {
            int copyNread = nread;
            if(getBeforeTag(tmp, "<end>", copyNread) != NULL) //emfanizw ta chanels mexri na vrw to tag <end>, an to vrw emfanizw ta bytes mexri to <end>
            {
                state = waitingEndChanel;
            }

            write(1, tmp, copyNread); //grafw ta bytes mexri to copyNread
        }

        if(state == waitingEndChanel) //perimenw na vrw to <Chanel> meta to <end>
        {
            tmp1 = getBeforeTag(tmp, "<Chanel>", nread);
            if(tmp1 == NULL)
            {
                if((tmp1 = getAfterTag(tmp, "<", nread)) != NULL) // mporei na pira meros tou tag, to apothikeuw kai to prosthetw sthn arxh tou neou read
                {
                    tmpTag.assign(tmp1-1, nread+1); // -1 giati thelw na krathsw kai to "< kai +1 sto read gia na to symperilavw
                }
                continue;
            }
            break; //oloklirwthike to mnm
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdi, -0x58(%rbp)
movl (%rdi), %edi
leaq 0x172a(%rip), %rsi      # 0x4063
pushq $0x9
popq %rdx
callq 0x2090
cmpl $-0x1, %eax
je 0x2b36
xorl %r13d, %r13d
movb $0x1, %bl
leaq -0x460(%rbp), %r12
movq -0x58(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x48(%rbp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x460, %rsi           # imm = 0xFBA0
movl $0x400, %edx            # imm = 0x400
subq %rax, %rdx
callq 0x2210
movq %rax, %r14
movl %r14d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x2b1b
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %r15
movq %r12, %rdi
movq %r15, %rdx
callq 0x20f0
addl %r14d, %r15d
movl %r15d, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
leaq 0x1769(%rip), %rsi      # 0x4117
callq 0x2260
testb $0x1, %bl
je 0x2a17
movq %r12, %rdi
leaq 0x16c3(%rip), %rsi      # 0x4085
leaq -0x2c(%rbp), %rdx
callq 0x3271
movq %rax, %r15
testq %rax, %rax
jne 0x2a2c
movq %r12, %rdi
leaq 0x16b1(%rip), %rsi      # 0x408e
leaq -0x2c(%rbp), %rdx
callq 0x3271
movb $0x1, %bl
movl $0x0, %r13d
testq %rax, %rax
je 0x2956
decq %rax
movslq -0x2c(%rbp), %rdx
incq %rdx
leaq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x21f0
movb $0x1, %bl
xorl %r13d, %r13d
jmp 0x2956
movq %r12, %r14
cmpl $0x2, %r13d
je 0x2a4b
movq %r12, %r15
movq %r12, %r14
cmpl $0x1, %r13d
jne 0x2a85
movq %r15, %rdi
leaq 0x1669(%rip), %rsi      # 0x409f
leaq -0x2c(%rbp), %rdx
callq 0x3271
movq %rax, %r14
testq %rax, %rax
je 0x2adc
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq %r14, %rdi
leaq 0x1635(%rip), %rsi      # 0x4090
leaq -0x30(%rbp), %rdx
callq 0x32cf
movq %rax, %r15
movslq -0x30(%rbp), %rdx
pushq $0x1
popq %rdi
movq %r14, %rsi
callq 0x2090
xorl %ebx, %ebx
pushq $0x2
popq %r13
testq %r15, %r15
je 0x2956
movq %r14, %rdi
leaq 0x15f6(%rip), %rsi      # 0x4085
leaq -0x2c(%rbp), %rdx
callq 0x32cf
testq %rax, %rax
jne 0x2b1b
movq %r14, %rdi
leaq 0x15e7(%rip), %rsi      # 0x408e
leaq -0x2c(%rbp), %rdx
callq 0x3271
xorl %ebx, %ebx
pushq $0x3
popq %r13
testq %rax, %rax
je 0x2956
decq %rax
movslq -0x2c(%rbp), %rdx
incq %rdx
xorl %ebx, %ebx
leaq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x21f0
jmp 0x2956
movq %r15, %rdi
leaq 0x15a8(%rip), %rsi      # 0x408e
leaq -0x2c(%rbp), %rdx
callq 0x3271
xorl %ebx, %ebx
pushq $0x1
popq %r13
testq %rax, %rax
je 0x2956
decq %rax
movslq -0x2c(%rbp), %rdx
incq %rdx
xorl %ebx, %ebx
leaq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x21f0
jmp 0x2956
leaq -0x50(%rbp), %rdi
callq 0x20c0
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1530(%rip), %rdi      # 0x406d
callq 0x2130
jmp 0x294a
jmp 0x2b4b
jmp 0x2b4b
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2240
nop