// File: /workspace/github_c_makefile_star2_O3/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 0x5e9e
cmpl $0x1, %ebx
jne 0x5efb
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 0x5ea4
movl $0x1e, %r15d
movl 0x6c(%r14), %edi
movq %rsp, %rsi
movq %r15, %rdx
callq 0x34bd
cmpq %r15, %rax
jne 0x5edd
movl $0x1, %ebp
cmpl $0x2, 0x5c(%r14)
jl 0x5efb
movq 0xe8(%r14), %rdi
leaq 0xe46(%rip), %rsi       # 0x6d18
movl %ebx, %edx
xorl %eax, %eax
callq 0x374a
jmp 0x5efb
movq 0xe8(%r14), %rdi
leaq 0xa3b(%rip), %rsi       # 0x6926
leaq 0xe10(%rip), %rdx       # 0x6d02
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x374a
movl %ebp, %eax
addq $0x550, %rsp            # imm = 0x550
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq