// File: /workspace/github_c_makefile_star2_O2/pencode-lab[P]Shoit/shoit_sender.c
// Function: update_sender_bucket_infomation
void update_sender_bucket_infomation(shoit_core_t *sender)
{
    if (sender->bucketSize % sender->payloadSize == 0)                                                                               
    {                                                                                                                                
        sender->totalNumberOfPackets = sender->bucketSize/sender->payloadSize;                                                       
        sender->lastPayloadSize = sender->payloadSize;                                                                               
    }                                                                                                                                
    else                                                                                                                             
    {                                                                                                                                
        sender->totalNumberOfPackets = sender->bucketSize/sender->payloadSize + 1; /* the last packet is not full */                 
        sender->lastPayloadSize = sender->bucketSize - sender->payloadSize * (sender->totalNumberOfPackets - 1);                     
    }                                                                                                                                
    sender->remainNumberOfPackets = sender->totalNumberOfPackets;                                                                    
                                                                                                                                     
    /*this control send rate*/                                                                                                       
    sender->usecsPerPacket = 8 * sender->payloadSize * 1000 / sender->sendRate;                                                      
    sender->sizeofErrorBitmap = sender->totalNumberOfPackets/8 + 2;                                                                  

    if(sender->errorBitmap){
        free(sender->errorBitmap);
        sender->errorBitmap = NULL;
    } 
    sender->errorBitmap = (char *)malloc(sender->sizeofErrorBitmap+sizeof(shoit_control_t));                                                        
    if (sender->errorBitmap == NULL)
    {                                                   
        SHOIT_LOG("malloc error(%s)\n",strerror(errno));
        return;
    } 

    if(sender->hashTable){
        free(sender->hashTable);
        sender->hashTable = NULL;
    }
    sender->hashTable = (uint64_t *)malloc(sender->totalNumberOfPackets * sizeof(uint64_t));                                         
    if (sender->hashTable == NULL)                                                                                                   
    {                                                                                                                                
        SHOIT_LOG("malloc hashTable failed\n");                                                                                      
        return ;                                                                                                                     
    }                                                                                                                                

    sender->sentNumberOfPackets = 0;
    sender->isFirstBlast = true;
    for (uint64_t i=0; i<sender->totalNumberOfPackets; i++)
    {                            
        sender->hashTable[i] = i;
    }
    shoit_init_error_bitmap(sender);

                     
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movl 0x2c(%rdi), %ecx
xorl %edx, %edx
divq %rcx
xorl %edi, %edi
testq %rdx, %rdx
setne %dil
cmovel %ecx, %edx
addq %rax, %rdi
movq %rdi, 0x38(%rbx)
movl %edx, 0x30(%rbx)
movq %rdi, 0x40(%rbx)
imull $0x1f40, %ecx, %eax     # imm = 0x1F40
xorl %edx, %edx
divl 0x28(%rbx)
movl %eax, 0x58(%rbx)
shrq $0x3, %rdi
addq $0x2, %rdi
movq %rdi, 0xd8(%rbx)
movq 0xd0(%rbx), %rax
testq %rax, %rax
je 0x3a09
movq %rax, %rdi
callq 0x2040
movq 0xd8(%rbx), %rdi
addq $0x1e, %rdi
callq 0x22e0
movq %rax, 0xd0(%rbx)
testq %rax, %rax
je 0x3a75
movq 0xc8(%rbx), %rdi
callq 0x2040
movq 0x38(%rbx), %r14
leaq (,%r14,8), %rdi
callq 0x22e0
movq %rax, 0xc8(%rbx)
testq %rax, %rax
je 0x3aa3
andq $0x0, 0x50(%rbx)
movl $0x1, 0xe0(%rbx)
xorl %ecx, %ecx
cmpq %r14, %rcx
jae 0x3a66
movq %rcx, (%rax,%rcx,8)
incq %rcx
jmp 0x3a58
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x29bd
movq 0xe8(%rbx), %rbx
callq 0x2060
movl (%rax), %edi
callq 0x2450
leaq 0x2bb9(%rip), %rsi      # 0x6648
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x34b1
movq 0xe8(%rbx), %rdi
leaq 0x2ba9(%rip), %rsi      # 0x665a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x34b1