// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x10b7(%rip), %rsi      # 0x4e21
movl $0xd, %edi
callq 0x2230
movq %rbx, %rdi
callq 0x2b1d
xorps %xmm0, %xmm0
movups %xmm0, 0x553a(%rip)     # 0x92c0
movups %xmm0, 0x5523(%rip)     # 0x92b0
movups %xmm0, 0x550c(%rip)     # 0x92a0
movq $0x0, 0x5531(%rip) # 0x92d0
movl 0x9c(%rbx), %eax
movl %eax, 0x98(%rbx)
incl %eax
movl %eax, 0xa0(%rbx)
movq 0x1b0(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
testl %eax, %eax
je 0x3e41
movl $0x1e, %edi
callq 0x23a0
cmpl $0x0, 0x1a4(%rbx)
je 0x3e67
movq $0x0, 0x10(%rbx)
movl %ebp, %edi
imull %eax, %edi
shll $0x6, %edi
movq %rdi, 0x8(%rbx)
callq 0x22e0
movq %rax, (%rbx)
movl $0x0, 0x1a0(%rbx)
testq %rax, %rax
jne 0x3ebf
movq 0xe8(%rbx), %rbx
callq 0x2060
movl (%rax), %edi
callq 0x2450
leaq 0x28b6(%rip), %rsi      # 0x66d9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x374a
movq 0xe8(%rbx), %rdi
leaq 0x2854(%rip), %rsi      # 0x66a3
xorl %eax, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x374a
cmpq $0x0, 0xf0(%rbx)
je 0x3ebf
movl %ebp, %esi
imull %eax, %esi
shll $0x8, %esi
movq 0x10(%rbx), %rcx
cmpq %rsi, %rcx
jae 0x3ea2
movslq %eax, %rdi
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movq %rcx, %rsi
testq %rdx, %rdx
jne 0x3ea2
incq %rax
imulq %rdi, %rax
movq %rax, %rsi
movq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq %rcx, 0x18(%rbx)
movq %rsi, 0x8(%rbx)
movq $0x0, (%rbx)
movl $0x1, 0x1a0(%rbx)
movl %r14d, 0x28(%rbx)
movl %ebp, 0x2c(%rbx)
addl $0xc, %ebp
movl %ebp, 0x34(%rbx)
movq %rbx, %rdi
callq 0x3b94
movl $0x1, 0x1a8(%rbx)
movq 0xe8(%rbx), %rdi
leaq 0x2807(%rip), %rsi      # 0x66f3
xorl %eax, %eax
callq 0x374a
cmpl $0x2, 0x5c(%rbx)
jl 0x3f20
movq 0xe8(%rbx), %rdi
movq 0x70(%rbx), %rcx
movl 0x9c(%rbx), %r8d
leaq 0x2832(%rip), %rsi      # 0x6744
leaq 0x2845(%rip), %rdx      # 0x675e
xorl %eax, %eax
callq 0x374a
movq 0x70(%rbx), %rdi
movl 0x9c(%rbx), %esi
leaq 0xb4(%rbx), %rdx
callq 0x32f6
movl %eax, 0x6c(%rbx)
movq 0xe8(%rbx), %rdi
leaq 0x2826(%rip), %rsi      # 0x676d
xorl %eax, %eax
callq 0x374a
cmpl $-0x1, 0x6c(%rbx)
je 0x423b
leaq 0xb8(%rbx), %rsi
leaq 0x78(%rbx), %rdx
movl $0x2, %edi
movl $0x20, %ecx
callq 0x2030
leaq 0x46b(%rip), %rdx       # 0x43e4
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x2340
leaq 0x985(%rip), %rdx       # 0x4914
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x2340
movl 0x6c(%rbx), %r12d
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
leal 0x3f(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
movl %eax, %edx
andl $-0x40, %edx
movl %r12d, %ecx
subl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
sarl $0x6, %eax
cltq
orq %rdx, 0x60(%rsp,%rax,8)
leaq 0x120(%rbx), %rbp
leaq 0x100(%rbx), %r15
cmpl $0x0, 0x1a8(%rbx)
je 0x4279
incl %r12d
leaq 0xe8(%rsp), %r13
leaq 0x20(%rsp), %r14
movq %r15, 0x8(%rsp)
movq %rbp, (%rsp)
movq $0x5, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movl $0x10, %ecx
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %r12d, %edi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x22a0
testl %eax, %eax
js 0x4252
je 0x422c
movl 0x6c(%rbx), %edi
leal 0x3f(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
sarl $0x6, %eax
cltq
movq 0xe8(%rsp,%rax,8), %rax
btq %rdi, %rax
jae 0x422c
xorps %xmm0, %xmm0
movups %xmm0, 0x3e(%rsp)
movaps %xmm0, 0x30(%rsp)
movl $0x1e, %edx
leaq 0x30(%rsp), %rsi
callq 0x345f
cmpq $0x1e, %rax
jne 0x437e
movl 0x30(%rsp), %edx
cmpl $0x5, %edx
je 0x41aa
cmpl $0x3, %edx
je 0x4190
cmpl $0x1, %edx
jne 0x41e7
cmpl $0x2, 0x5c(%rbx)
jl 0x40ff
movq 0xe8(%rbx), %rdi
leaq 0x297a(%rip), %rsi      # 0x6a72
xorl %eax, %eax
callq 0x374a
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movl 0x4a(%rsp), %ebp
bswapl %ebp
testl %ebp, %ebp
leaq 0x50(%rsp), %r14
jle 0x4130
movl 0x6c(%rbx), %edi
movl %ebp, %r15d
movq %r14, %rsi
movq %r15, %rdx
callq 0x345f
cmpq %r15, %rax
jne 0x43c1
movq 0x60(%rbx), %r15
movslq %ebp, %rdx
addq $-0x4, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2070
testl %eax, %eax
jne 0x43a2
movq (%rsp), %rbp
movq %rbp, %rdi
callq 0x21e0
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x21e0
cmpl $0x2, 0x5c(%rbx)
leaq 0x20(%rsp), %r14
jl 0x422c
movq 0xe8(%rbx), %rdi
leaq 0x293f(%rip), %rsi      # 0x6ac3
xorl %eax, %eax
callq 0x374a
jmp 0x422c
cmpl $0x2, 0x5c(%rbx)
jl 0x4224
movq 0xe8(%rbx), %rdi
leaq 0x294d(%rip), %rsi      # 0x6af5
jmp 0x421d
cmpl $0x2, 0x5c(%rbx)
jl 0x41c5
movq 0xe8(%rbx), %rdi
leaq 0x2954(%rip), %rsi      # 0x6b12
xorl %eax, %eax
callq 0x374a
movl 0x4a(%rsp), %eax
testl %eax, %eax
je 0x41fe
bswapl %eax
movl 0x6c(%rbx), %edi
movq 0xd0(%rbx), %rsi
addq $0x1e, %rsi
movslq %eax, %rdx
callq 0x345f
jmp 0x4209
movq 0xe8(%rbx), %rdi
leaq 0x294a(%rip), %rsi      # 0x6b3f
xorl %eax, %eax
callq 0x374a
jmp 0x422c
movq 0xd0(%rbx), %rax
movb $0x1, 0x1e(%rax)
cmpl $0x2, 0x5c(%rbx)
jl 0x4224
movq 0xe8(%rbx), %rdi
leaq 0x2904(%rip), %rsi      # 0x6b21
xorl %eax, %eax
callq 0x374a
movq %rbp, %rdi
callq 0x21e0
cmpl $0x0, 0x1a8(%rbx)
jne 0x403b
jmp 0x4279
movq 0xe8(%rbx), %rdi
leaq 0x24e3(%rip), %rsi      # 0x672c
xorl %eax, %eax
callq 0x374a
jmp 0x42ab
movq 0xe8(%rbx), %r14
callq 0x2060
movl (%rax), %edi
callq 0x2450
leaq 0x27e6(%rip), %rsi      # 0x6a52
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x374a
movl $0x0, 0x1a8(%rbx)
movq %rbp, %rdi
callq 0x21e0
movq %r15, %rdi
callq 0x21e0
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x2430
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x2430
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x42c8
cmpl $0x0, 0x1a0(%rbx)
jne 0x42c1
callq 0x2040
movq $0x0, (%rbx)
movq 0x1b0(%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl 0xfc(%rbx), %edi
cmpl $-0x1, %edi
je 0x42ef
callq 0x21b0
movl $0xffffffff, 0xfc(%rbx) # imm = 0xFFFFFFFF
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x4305
callq 0x2040
movq $0x0, 0x70(%rbx)
movq 0xd0(%rbx), %rdi
testq %rdi, %rdi
je 0x4321
callq 0x2040
movq $0x0, 0xd0(%rbx)
movq 0xc8(%rbx), %rdi
testq %rdi, %rdi
je 0x433d
callq 0x2040
movq $0x0, 0xc8(%rbx)
movq %rbx, %rdi
callq 0x2b80
cmpl $0x0, 0x5c(%rbx)
jle 0x4360
movq 0xe8(%rbx), %rdi
leaq 0x283c(%rip), %rsi      # 0x6b95
xorl %eax, %eax
callq 0x374a
movq 0xe8(%rbx), %rdi
callq 0x37e9
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, 0x5c(%rbx)
jl 0x4279
movq 0xe8(%rbx), %rdi
leaq 0x27e9(%rip), %rsi      # 0x6b7f
xorl %eax, %eax
callq 0x374a
jmp 0x4279
movq 0xe8(%rbx), %rdi
leaq 0x26ef(%rip), %rsi      # 0x6a9f
leaq 0x50(%rsp), %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x374a
jmp 0x43d6
movq 0xe8(%rbx), %rdi
leaq 0x26b3(%rip), %rsi      # 0x6a82
xorl %eax, %eax
callq 0x374a
movq 0x8(%rsp), %r15
movq (%rsp), %rbp
jmp 0x4279