// File: /workspace/github_c_makefile_star2_O3/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 0x3bf9
movq %rax, %rdi
callq 0x2040
movq 0xd8(%rbx), %rdi
addq $0x1e, %rdi
callq 0x22e0
movq %rax, 0xd0(%rbx)
testq %rax, %rax
je 0x3d00
movq 0xc8(%rbx), %rdi
testq %rdi, %rdi
je 0x3c23
callq 0x2040
movq 0x38(%rbx), %r14
leaq (,%r14,8), %rdi
callq 0x22e0
movq %rax, 0xc8(%rbx)
testq %rax, %rax
je 0x3d2e
movq $0x0, 0x50(%rbx)
movl $0x1, 0xe0(%rbx)
testq %r14, %r14
je 0x3cf1
leaq 0x1(%r14), %rcx
andq $-0x2, %rcx
decq %r14
movq %r14, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x29a4(%rip), %xmm1     # 0x6620
xorl %edx, %edx
movdqa 0x29aa(%rip), %xmm2     # 0x6630
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x29aa(%rip), %xmm4     # 0x6640
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %esi
notl %esi
testb $0x1, %sil
je 0x3ccc
movq %rdx, (%rax,%rdx,8)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0x3ce4
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rax,%rdx,8)
addq $0x2, %rdx
paddq %xmm4, %xmm1
cmpq %rdx, %rcx
jne 0x3c96
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2bce
movq 0xe8(%rbx), %rbx
callq 0x2060
movl (%rax), %edi
callq 0x2450
leaq 0x295e(%rip), %rsi      # 0x6678
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x374a
movq 0xe8(%rbx), %rdi
leaq 0x294e(%rip), %rsi      # 0x668a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x374a