// File: /workspace/github_c_makefile_star2_O0/pencode-lab[P]Shoit/shoit_sender.c
// Function: sender_run_loop
void sender_run_loop(shoit_core_t *sender,uint32_t sendRate,uint32_t packetSize)
{                                                                                                                                    

    catch_signal_init();
    shoit_init_synch(sender);

    memset(&progress,0,sizeof(progress_t));
    progress.total =0;

    sender->udpRemotePort = sender->tcpPort;
    sender->udpLocalPort = sender->udpRemotePort +1;

    /*ready for sender init
    *assignment value to sender                                                                                               
    */

    if(sender->callbacks->on_open_data(sender)==false){                                                                  
        SHOIT_LOG("callbacks open data storage return false,will return.");                                                                    
        return;                                                                                                                  
    }  

    int pageSize = (int)sysconf(_SC_PAGESIZE);//4096 or 8192..
    if(sender->iStream){
        sender->fileSize =0;/*stream,don't know file size*/
        sender->bucketSize = packetSize*pageSize*64;
        sender->bucket= (char *)malloc(sender->bucketSize);                                                                                  
        sender->useMmap=false;    

        if(sender->bucket==NULL){                                                                                                        
            SHOIT_LOG("bucket is NULL,error(%s)\n",strerror(errno));                                                                     
            return;                                                                                                                      
        }   

    }else if(sender->fileName!=NULL){
        uint64_t bucketSize = pageSize*packetSize*256*1;/*1G, pageSize 4096*/                                                        
        uint64_t fileSize = sender->fileSize;                                                                                        
        if(fileSize < bucketSize){                                                                                                       
            if(fileSize%pageSize)                                                                                                        
                bucketSize = fileSize;                                                                                                   
            else{                                                                                                                        
                bucketSize = pageSize*((fileSize/pageSize)+1);                                                                           
            }                                                                                                                            
            fileSize = bucketSize;                                                                                                       
        }                                                                                                                            
                                                                                                                                     
        sender->fileSize = fileSize;                                                                                                 
        sender->leftSize = sender->fileSize;                                                                                         
        sender->bucketSize = bucketSize;

        sender->bucket=NULL;                                                                                                         
        sender->useMmap=true; 

            
    }

    sender->sendRate = sendRate;
    sender->payloadSize =packetSize;
    sender->packetSize = sender->payloadSize + sizeof(shoit_udp_hdr);


    update_sender_bucket_infomation(sender);

    /*core loop*/
    _sender_run_loop(sender);                                                                           


    /*                                                                                                                               
    *free sender and return                                                                                                          
    */                                                                                                                               
    sender_free(sender);                                                                                                             
                                                                                                                                     
    return;                                                                                                                          
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
callq 0x6590
movq -0x8(%rbp), %rdi
callq 0x2b20
leaq 0x78e9(%rip), %rdi      # 0xc2a0
xorl %esi, %esi
movl $0x38, %edx
callq 0x21a0
movq $0x0, 0x78fa(%rip) # 0xc2c8
movq -0x8(%rbp), %rax
movl 0x9c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x98(%rax)
movq -0x8(%rbp), %rax
movl 0x98(%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x8(%rbp), %rax
movq 0x1b0(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
jne 0x4a32
jmp 0x4a14
movq -0x8(%rbp), %rax
movq 0xe8(%rax), %rdi
leaq 0x4d0d(%rip), %rsi      # 0x9733
movb $0x0, %al
callq 0x3df0
jmp 0x4beb
movl $0x1e, %edi
callq 0x23a0
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1a4(%rax)
je 0x4add
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
movl -0x10(%rbp), %eax
imull -0x14(%rbp), %eax
shll $0x6, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x22e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x1a0(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x4ad8
jmp 0x4aa3
movq -0x8(%rbp), %rax
movq 0xe8(%rax), %rax
movq %rax, -0x30(%rbp)
callq 0x2060
movl (%rax), %edi
callq 0x2450
movq -0x30(%rbp), %rdi
movq %rax, %rdx
leaq 0x4c9d(%rip), %rsi      # 0x9769
movb $0x0, %al
callq 0x3df0
jmp 0x4beb
jmp 0x4ba8
movq -0x8(%rbp), %rax
cmpq $0x0, 0xf0(%rax)
je 0x4ba6
movl -0x14(%rbp), %eax
imull -0x10(%rbp), %eax
shll $0x8, %eax
shll $0x0, %eax
movl %eax, %eax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x4b65
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
je 0x4b35
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x4b5d
movslq -0x14(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0x38(%rbp), %rax
addq $0x1, %rcx
imulq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0x1a0(%rax)
jmp 0x4ba8
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %eax
addq $0xc, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x8(%rbp), %rdi
callq 0x4730
movq -0x8(%rbp), %rdi
callq 0x4c00
movq -0x8(%rbp), %rdi
callq 0x4d10
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)