// File: /workspace/github_c_makefile_star2_O1/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 %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movl 0x2c(%rdi), %ecx
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
je 0x3bd6
incq %rax
movq %rax, 0x38(%rbx)
jmp 0x3bdc
movq %rax, 0x38(%rbx)
movl %ecx, %edx
movl %edx, 0x30(%rbx)
movq 0x38(%rbx), %rsi
movq 0xd0(%rbx), %rdi
movq %rsi, 0x40(%rbx)
imull $0x1f40, %ecx, %eax     # imm = 0x1F40
xorl %edx, %edx
divl 0x28(%rbx)
movl %eax, 0x58(%rbx)
shrq $0x3, %rsi
addq $0x2, %rsi
movq %rsi, 0xd8(%rbx)
testq %rdi, %rdi
je 0x3c20
callq 0x2040
movq $0x0, 0xd0(%rbx)
movq 0xd8(%rbx), %rdi
addq $0x1e, %rdi
callq 0x22e0
movq %rax, 0xd0(%rbx)
testq %rax, %rax
je 0x3ca3
movq 0xc8(%rbx), %rdi
testq %rdi, %rdi
je 0x3c58
callq 0x2040
movq $0x0, 0xc8(%rbx)
movq 0x38(%rbx), %rdi
shlq $0x3, %rdi
callq 0x22e0
movq %rax, 0xc8(%rbx)
testq %rax, %rax
je 0x3ccb
movq $0x0, 0x50(%rbx)
movl $0x1, 0xe0(%rbx)
movq 0x38(%rbx), %rcx
testq %rcx, %rcx
je 0x3c9a
xorl %edx, %edx
movq %rdx, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x3c8e
movq %rbx, %rdi
popq %rbx
jmp 0x2be2
movq 0xe8(%rbx), %rbx
callq 0x2060
movl (%rax), %edi
callq 0x2450
leaq 0x299b(%rip), %rsi      # 0x6658
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
popq %rbx
jmp 0x3741
movq 0xe8(%rbx), %rdi
leaq 0x2991(%rip), %rsi      # 0x666a
xorl %eax, %eax
popq %rbx
jmp 0x3741