// File: /workspace/github_c_makefile_star2_O2/pencode-lab[P]Shoit/shoit_receiver.c
// Function: echo_to_sender_on_tcp
static bool echo_to_sender_on_tcp(shoit_core_t *receiver, int type)
{
    char buffer[MTU]={0};
    int dataSize =0;
    shoit_control_t *tcpCrl=(shoit_control_t *)buffer;

    memset(buffer,0,sizeof(buffer));
    tcpCrl->status =type;
    switch(type){
        case CONNECT:
        {
            dataSize= strlen(receiver->password);
            tcpCrl->dataSize =htonl(dataSize);
            memcpy(tcpCrl->data,receiver->password,dataSize);
        }break;
        case READY:
        {
            dataSize=0;
            tcpCrl->dataSize = htonl(0);
        }break;
        default:
            return false;                                                                                                            
    }                                                                                                                                
                                                                                                                                     
    if(shoit_network_writen(receiver->tcpSockfd, buffer, sizeof(shoit_control_t)+dataSize) != (sizeof(shoit_control_t)+dataSize))                    
    {                                                                                                                                
        SHOIT_LOG("tcp send failed(%s).\n",__func__);                                                                                
        return false;                                                                                                                
    }                                                                                                                                
                                                                                                                                     
    if(receiver->verbose>1) SHOIT_LOG("echo_to_sender_on_tcp ok....:%d\n",type);
    return true;                                                                                                                     
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x550, %rsp            # imm = 0x550
movl %esi, %ebx
movq %rdi, %r14
movq %rsp, %r15
xorl %ebp, %ebp
movl $0x550, %edx            # imm = 0x550
movq %r15, %rdi
xorl %esi, %esi
callq 0x2190
movl %ebx, (%r15)
cmpl $0x3, %ebx
je 0x5ae1
cmpl $0x1, %ebx
jne 0x5b3a
movq 0x60(%r14), %r12
movq %r12, %rdi
callq 0x20d0
movslq %eax, %r15
bswapl %eax
leaq 0x1e(%rsp), %rdi
movl %eax, -0x4(%rdi)
movq %r12, %rsi
movq %r15, %rdx
callq 0x2280
addq $0x1e, %r15
jmp 0x5ae5
pushq $0x1e
popq %r15
movl 0x6c(%r14), %edi
movq %rsp, %rsi
movq %r15, %rdx
callq 0x325e
cmpq %r15, %rax
jne 0x5b1c
pushq $0x1
popq %rbp
cmpl $0x2, 0x5c(%r14)
jl 0x5b3a
movq 0xe8(%r14), %rdi
leaq 0x11d7(%rip), %rsi      # 0x6ce8
movl %ebx, %edx
xorl %eax, %eax
callq 0x34b1
jmp 0x5b3a
movq 0xe8(%r14), %rdi
leaq 0xdcc(%rip), %rsi       # 0x68f6
leaq 0x11a1(%rip), %rdx      # 0x6cd2
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x34b1
movl %ebp, %eax
addq $0x550, %rsp            # imm = 0x550
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq