// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: init_ha_ug_index_opt(ha_ug_index*, ma_ug_t*, int, pldat_t*, unsigned long, unsigned long, unsigned long)
void init_ha_ug_index_opt(ha_ug_index* idx, ma_ug_t *ug, int k, pldat_t* p, uint64_t up_occ, 
uint64_t low_occ, uint64_t thread_num)
{
    uint64_t i, n;
    for (idx->uID_bits=1; (uint64_t)(1<<idx->uID_bits)<(uint64_t)ug->u.n; idx->uID_bits++);
    idx->pos_bits = 64 - idx->uID_bits - 1;
    idx->uID_mode = (((uint64_t)-1) << (64-idx->uID_bits))>>1;
    idx->pos_mode = ((uint64_t)-1) >> (64-idx->pos_bits);
    idx->rev_mode = ((uint64_t)1) << 63;
    idx->ug = ug;
    idx->k = k;
    idx->pre = HIC_COUNTER_BITS;
    idx->tot = 1 << idx->pre;
    idx->tot_pos = 0;
    ///idx->up_bound = 1;
    idx->up_bound = up_occ;
    idx->low_bound = low_occ;
    CALLOC(idx->idx_buf, idx->tot);
    for (i = 0; i < idx->tot; i++)
    {
        idx->idx_buf[i].h = hc_pt_init();
    }
    for (i = n = 0; i < ug->u.n; i++)
    {
        n += ug->u.a[i].len;
    }
    n = n << 3;
    p->h = idx;
    p->buf_bytes = n>>7;
    CALLOC(p->cnt, idx->tot);
    CALLOC(p->buf, idx->tot);
    for (i = 0; i < idx->tot; i++)
    {
        kv_init(p->cnt[i].a);
        kv_init(p->buf[i].a);
    }
    p->n_thread = thread_num;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rsi), %rbp
movl $0x1, %eax
movl $0x3f, %esi
movl $0x1, %edi
movl %eax, %ecx
shll %cl, %edi
movslq %edi, %rcx
incq %rax
decq %rsi
cmpq %rcx, %rbp
ja 0x13420d
leaq -0x1(%rax), %rcx
movq %rcx, 0x18(%r14)
movq %rsi, 0x28(%r14)
incb %sil
movq $-0x1, %rdi
movq $-0x1, %r10
movl %esi, %ecx
shlq %cl, %r10
shrq %r10
movl %eax, %ecx
shrq %cl, %rdi
movq %r10, 0x20(%r14)
movq %rdi, 0x30(%r14)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, 0x38(%r14)
movq %r15, (%r14)
movslq %edx, %rax
movq %rax, 0x40(%r14)
movq $0xc, 0x50(%r14)
movq $0x1000, 0x58(%r14)     # imm = 0x1000
movq $0x0, 0x60(%r14)
movq %r8, 0x68(%r14)
movq %r9, 0x70(%r14)
movl $0x1000, %edi           # imm = 0x1000
movl $0x20, %esi
callq 0x2120
movq %rax, %r12
movq %rax, 0x78(%r14)
xorl %r13d, %r13d
movl $0x1, %edi
movl $0x18, %esi
callq 0x2120
movq %rax, (%r12,%r13)
addq $0x20, %r13
cmpq $0x20000, %r13          # imm = 0x20000
jne 0x1342a7
testq %rbp, %rbp
je 0x1342f9
movq 0x10(%r15), %rcx
xorl %eax, %eax
movl (%rcx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
addq %rdx, %rax
addq $0x28, %rcx
decq %rbp
jne 0x1342d2
shrq $0x4, %rax
movabsq $0x1ffffffffffffff, %rcx # imm = 0x1FFFFFFFFFFFFFF
andq %rax, %rcx
jmp 0x1342fb
xorl %ecx, %ecx
movq %r14, 0x10(%rbx)
movq %rcx, 0x8(%rbx)
movl $0x1000, %edi           # imm = 0x1000
movl $0x18, %esi
callq 0x2120
movq %rax, %r14
movq %rax, 0x18(%rbx)
movl $0x1000, %edi           # imm = 0x1000
movl $0x18, %esi
callq 0x2120
movq %rax, %r15
movq %rax, 0x20(%rbx)
movl $0x18000, %edx          # imm = 0x18000
movq %r14, %rdi
xorl %esi, %esi
callq 0x20e0
movl $0x18000, %edx          # imm = 0x18000
movq %r15, %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x40(%rsp), %rax
movq %rax, 0x28(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq