// File: /workspace/github_c_makefile_star2_O0/pencode-lab[P]Shoit/shoit_sender.c
// Function: blast_udp_sending
static void blast_udp_sending(shoit_core_t *sender)
{
    int  done;
    uint64_t i;
    struct timeval start, now;
    char *msg = (char *) malloc(sender->packetSize);  //include sizeof(shoit_udp_hdr)  
    shoit_udp_hdr *udphdr=(shoit_udp_hdr *)msg;

    done = 0; i = 0;
    gettimeofday(&start, NULL);
    while(!done && sender->runing){

        memset(msg,0,sender->packetSize);
        gettimeofday(&now, NULL);
        uint64_t interval = USEC(&start, &now);

        /*control sendRate*/
        if(interval < sender->usecsPerPacket * i){
            while (interval < sender->usecsPerPacket * i){
                shoit_sleepto(sender,shoit_misc_get_timer()+interval/(sender->usecsPerPacket*8));                                                        
                gettimeofday(&now, NULL);                                                                                        
                interval = USEC(&start, &now);                                                                                   
            }                                                                                                                        
        } 
        /*send a packet*/
        else {
            int payloadSize;                                                                                                         
                                                                                                                                     
            udphdr->seqno = sender->hashTable[i];                                                                              
            if (udphdr->seqno < sender->totalNumberOfPackets - 1)                                                              
                payloadSize = sender->payloadSize;                                                                           
            else
                payloadSize = sender->lastPayloadSize;                                                                       
            udphdr->payloadSize = htonl(payloadSize);                                                                                   

            uint64_t offset = (uint64_t)(udphdr->seqno*sender->payloadSize);                                                 
            memcpy(udphdr->payload,(char*)((char*)sender->bucket+offset),payloadSize);         
            if (sendto(sender->udpSockfd, msg, sizeof(shoit_udp_hdr)+payloadSize, 0,                                               
                        (const struct sockaddr *)&sender->udpServerAddr, sizeof(sender->udpServerAddr)) < 0 ){        

                SHOIT_LOG("sendto error(%s)\n",strerror(errno));                                                                               
                sender->runing  = false;
            }else {                                                                                                                        
                i++;                                                                                                                     
                sender->sentNumberOfPackets++;                                                                                   
                progress.total += sizeof(shoit_udp_hdr)+payloadSize;
                if (i >= sender->remainNumberOfPackets)
                    done = 1;    
            }
        }

    }//while
    free (msg);

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, %edi
callq 0x22e0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
xorl %eax, %eax
cmpl $0x0, -0xc(%rbp)
movb %al, -0x61(%rbp)
jne 0x60e1
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x60ed
jmp 0x630b
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x21a0
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq -0x30(%rbp), %rcx
subq -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x58(%rcx), %ecx
imulq -0x18(%rbp), %rcx
cmpq %rcx, %rax
jae 0x61bd
jmp 0x6143
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x58(%rcx), %ecx
imulq -0x18(%rbp), %rcx
cmpq %rcx, %rax
jae 0x61b8
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movb $0x0, %al
callq 0x3b10
movq -0x70(%rbp), %rdi
movq %rax, %rsi
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x58(%rcx), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
xorl %edx, %edx
divq %rcx
addq %rax, %rsi
callq 0x2ae0
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq -0x30(%rbp), %rcx
subq -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
jmp 0x6143
jmp 0x6306
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x38(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x61fb
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0x6205
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %edi
callq 0x2190
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x2c(%rcx), %ecx
imulq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rdi
addq $0xc, %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
addq -0x60(%rbp), %rsi
movslq -0x54(%rbp), %rdx
callq 0x2280
movq -0x8(%rbp), %rax
movl 0x68(%rax), %edi
movq -0x40(%rbp), %rsi
movslq -0x54(%rbp), %rdx
addq $0xc, %rdx
movq -0x8(%rbp), %r8
addq $0xa4, %r8
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x21b0
cmpq $0x0, %rax
jge 0x62bb
jmp 0x627b
movq -0x8(%rbp), %rax
movq 0xe8(%rax), %rax
movq %rax, -0x78(%rbp)
callq 0x2060
movl (%rax), %edi
callq 0x2450
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x36d4(%rip), %rsi      # 0x9978
movb $0x0, %al
callq 0x3df0
movq -0x8(%rbp), %rax
movl $0x0, 0x1a8(%rax)
jmp 0x6304
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x50(%rax)
movslq -0x54(%rbp), %rax
addq $0xc, %rax
addq 0x5fe2(%rip), %rax      # 0xc2c8
movq %rax, 0x5fdb(%rip)      # 0xc2c8
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jb 0x6302
movl $0x1, -0xc(%rbp)
jmp 0x6304
jmp 0x6306
jmp 0x60c5
movq -0x40(%rbp), %rdi
callq 0x2040
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)