// File: /workspace/github_c_makefile_star2_O0/pencode-lab[P]Shoit/shoit_sender.c
// Function: echo_to_receiver_on_tcp
static bool echo_to_receiver_on_tcp(shoit_core_t *sender, 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;
    tcpCrl->iStream = sender->iStream;

    if(sender->verbose>1) SHOIT_LOG("call %s:%d\n",__func__,type);

    switch(type){
        case ROUND:
        {
            tcpCrl->payloadSize = htonl(sender->payloadSize);
            tcpCrl->bucketSize = shoit_misc_htonll(sender->bucketSize);                                                                      
            tcpCrl->fileSize = shoit_misc_htonll(sender->fileSize);

            if(tcpCrl->iStream)
                tcpCrl->dataSize = htonl(0);                                                                                                  
            else if(sender->fileName!=NULL){
                char *notIncludePathFileName = shoit_misc_from_path_get_filename(sender->fileName);                                        
                if(notIncludePathFileName==NULL) {
                    SHOIT_LOG("echo_to_receiver_on_tcp error(0x010)\n");
                    return false;
                }
                dataSize = strlen(notIncludePathFileName);                                                                                  
                tcpCrl->dataSize = htonl(dataSize);                                                                                                    
                memcpy(tcpCrl->data,notIncludePathFileName,dataSize);
            } 

        }break;
        case UDPEND:
        case HEART:
        case CLOSE:
            tcpCrl->payloadSize = htonl(sender->payloadSize);
            tcpCrl->bucketSize = shoit_misc_htonll(sender->bucketSize);
            tcpCrl->dataSize = htonl(0); 
            break;
        default:
            return false;
    }

    if(shoit_network_writen(sender->tcpSockfd, buffer, sizeof(shoit_control_t)+dataSize) != (sizeof(shoit_control_t)+dataSize))              
    {                                                                                                                                
        SHOIT_LOG("tcp send failed(%s).\n",__func__);                                                                     
        return false;
    }              

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x590, %rsp            # imm = 0x590
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
leaq -0x570(%rbp), %rdi
xorl %esi, %esi
movl $0x550, %edx            # imm = 0x550
callq 0x21a0
movl $0x0, -0x574(%rbp)
leaq -0x570(%rbp), %rax
movq %rax, -0x580(%rbp)
leaq -0x570(%rbp), %rdi
xorl %esi, %esi
movl $0x550, %edx            # imm = 0x550
callq 0x21a0
movl -0x14(%rbp), %ecx
movq -0x580(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x1a4(%rax), %eax
movw %ax, %cx
movq -0x580(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x5c(%rax)
jle 0x5e25
jmp 0x5e00
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
movl -0x14(%rbp), %ecx
leaq 0x3b75(%rip), %rsi      # 0x998a
leaq 0x3b7a(%rip), %rdx      # 0x9996
movb $0x0, %al
callq 0x3df0
jmp 0x5e25
movl -0x14(%rbp), %eax
movl %eax, -0x58c(%rbp)
subl $0x2, %eax
je 0x5e5d
jmp 0x5e35
movl -0x58c(%rbp), %eax
subl $0x4, %eax
je 0x5f76
jmp 0x5e46
movl -0x58c(%rbp), %eax
addl $-0x6, %eax
subl $0x2, %eax
jb 0x5f76
jmp 0x5fbe
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %edi
callq 0x2190
movl %eax, %ecx
movq -0x580(%rbp), %rax
movl %ecx, 0x6(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3ef0
movq %rax, %rcx
movq -0x580(%rbp), %rax
movq %rcx, 0xa(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3ef0
movq %rax, %rcx
movq -0x580(%rbp), %rax
movq %rcx, 0x12(%rax)
movq -0x580(%rbp), %rax
cmpw $0x0, 0x4(%rax)
je 0x5ed1
xorl %edi, %edi
callq 0x2190
movl %eax, %ecx
movq -0x580(%rbp), %rax
movl %ecx, 0x1a(%rax)
jmp 0x5f74
movq -0x10(%rbp), %rax
cmpq $0x0, 0xf0(%rax)
je 0x5f72
movq -0x10(%rbp), %rax
movq 0xf0(%rax), %rdi
callq 0x3d50
movq %rax, -0x588(%rbp)
cmpq $0x0, -0x588(%rbp)
jne 0x5f2b
jmp 0x5f06
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
leaq 0x3a96(%rip), %rsi      # 0x99ae
movb $0x0, %al
callq 0x3df0
movl $0x0, -0x4(%rbp)
jmp 0x6027
movq -0x588(%rbp), %rdi
callq 0x20d0
movl %eax, -0x574(%rbp)
movl -0x574(%rbp), %edi
callq 0x2190
movl %eax, %ecx
movq -0x580(%rbp), %rax
movl %ecx, 0x1a(%rax)
movq -0x580(%rbp), %rdi
addq $0x1e, %rdi
movq -0x588(%rbp), %rsi
movslq -0x574(%rbp), %rdx
callq 0x2280
jmp 0x5f74
jmp 0x5fc7
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %edi
callq 0x2190
movl %eax, %ecx
movq -0x580(%rbp), %rax
movl %ecx, 0x6(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3ef0
movq %rax, %rcx
movq -0x580(%rbp), %rax
movq %rcx, 0xa(%rax)
xorl %edi, %edi
callq 0x2190
movl %eax, %ecx
movq -0x580(%rbp), %rax
movl %ecx, 0x1a(%rax)
jmp 0x5fc7
movl $0x0, -0x4(%rbp)
jmp 0x6027
movq -0x10(%rbp), %rax
movl 0x6c(%rax), %edi
leaq -0x570(%rbp), %rsi
movslq -0x574(%rbp), %rdx
addq $0x1e, %rdx
callq 0x39f0
movslq -0x574(%rbp), %rcx
addq $0x1e, %rcx
cmpq %rcx, %rax
je 0x6020
jmp 0x5ff7
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
leaq 0x39cb(%rip), %rsi      # 0x99d4
leaq 0x3986(%rip), %rdx      # 0x9996
movb $0x0, %al
callq 0x3df0
movl $0x0, -0x4(%rbp)
jmp 0x6027
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x590, %rsp            # imm = 0x590
popq %rbp
retq
nopw %cs:(%rax,%rax)