// File: chahk0129[P]hash_bench/./index/extendible_hash.h
// Function: ExtendibleHash<char [32]>::Utilization()
double ExtendibleHash<Key_t>::Utilization(void){
    size_t sum = 0;
    size_t cnt = 0;
    for(size_t i=0; i<dir->capacity; cnt++){
	auto target = dir->_[i];
	auto stride = pow(2, dir->depth - target->local_depth);
	auto pattern = (i >> (dir->depth - target->local_depth));
	for(unsigned j=0; j<Segment<Key_t>::kNumSlot; ++j){
	    size_t key_hash;
	    if constexpr(sizeof(Key_t) > 8){
		key_hash = hash_funcs[0](target->_[j].key, sizeof(Key_t) ,f_seed);
		if(((key_hash >> (8*sizeof(size_t) - target->local_depth)) == pattern) && (memcmp(target->_[j].key, INVALID<Key_t>, sizeof(Key_t)) != 0)){
		    sum++;
		}
	    }
	    else{
		key_hash = hash_funcs[0](&target->_[j].key, sizeof(Key_t), f_seed);
		if(((key_hash >> (8*sizeof(key_hash)-target->local_depth)) == pattern) && (memcmp(&target->_[j].key, &INVALID<Key_t>, sizeof(Key_t)) != 0)){
		    sum++;
		}
	    }
	}
	i += stride;
    }
    return ((double)sum) / ((double)cnt * Segment<Key_t>::kNumSlot)*100.0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rax
movq 0x8(%rcx), %rcx
cmpq 0x10(%rcx), %rax
jae 0x1ca20
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
movq (%rcx), %rcx
movq -0x20(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x28(%rbp)
movq 0x8(%rax), %rax
movq 0x18(%rax), %rsi
movq -0x28(%rbp), %rax
subq 0xa000(%rax), %rsi
movl $0x2, %edi
callq 0x1cb40
movq -0x50(%rbp), %rcx
movsd %xmm0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rcx), %rcx
movq 0x18(%rcx), %rcx
movq -0x28(%rbp), %rdx
subq 0xa000(%rdx), %rcx
shrq %cl, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpq $0x400, %rax            # imm = 0x400
jae 0x1c9b5
movq 0x3db46(%rip), %rax     # 0x5a480
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rdi
movl $0x20, %esi
movl $0xc70697, %edx         # imm = 0xC70697
callq *%rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rdx
movl $0x40, %ecx
subq 0xa000(%rdx), %rcx
shrq %cl, %rax
cmpq -0x38(%rbp), %rax
jne 0x1c9a5
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
leaq 0x3e316(%rip), %rsi     # 0x5aca0
movl $0x20, %edx
callq 0x6190
cmpl $0x0, %eax
je 0x1c9a5
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x1c9a7
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1c924
movsd -0x30(%rbp), %xmm1
movaps 0x2566f(%rip), %xmm2    # 0x42030
movq -0x20(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x2566e(%rip), %xmm2    # 0x42040
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x2561c(%rip), %xmm1    # 0x42018
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1c8ac
movq -0x10(%rbp), %xmm0
movaps 0x25604(%rip), %xmm3    # 0x42030
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x25608(%rip), %xmm2    # 0x42040
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x18(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0x255c1(%rip), %xmm2    # 0x42028
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x255a9(%rip), %xmm1    # 0x42020
mulsd %xmm1, %xmm0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)