// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: worker_for_alignment(void*, long, int)
static void worker_for_alignment(void *data, long i, int tid) // callback for kt_for()
{
    stepdat_t *s = (stepdat_t*)data;
    ///s->pos[i].id = (uint64_t)-1; s->pos[i].occ1 = s->pos[i].occ2 = 0; s->pos[i].a = NULL;
    s->pos[i].id = s->pos[i].s = s->pos[i].e = s->pos[i].len = (uint64_t)-1;

    /*******************************for debug************************************/
    // if(!if_debug_read(s->id+i)) return;
    // fprintf(stderr, "work-rid: %lu\n", (uint64_t)(s->id+i));
    /*******************************for debug************************************/

    uint64_t len1 = s->len[i]>>32, len2 = (uint32_t)s->len[i], occ1, occ2;
    char *r1 = s->seq[i], *r2 = s->seq[i] + len1;


    // fprintf(stderr, "**********R1**********\n");
    s->pos_buf[tid].a.n = 0;
    get_alignment(r1, len1, s->idx->k, &s->pos_buf[tid], s->idx, 0, s->id+i);
    occ1 = s->pos_buf[tid].a.n;
    if(occ1 == 0) return;


    // fprintf(stderr, "**********R2**********\n");
    get_alignment(r2, len2, s->idx->k, &s->pos_buf[tid], s->idx, occ1, s->id+i);
    occ2 = s->pos_buf[tid].a.n - occ1;
    if(occ2 == 0) return;   
    
    set_pe_pos((ha_ug_index*)s->idx, s->pos_buf[tid].a.a, occ1, s->pos_buf[tid].a.a + occ1, occ2, &(s->pos[i]), s->id+i, s->t_ch);

    /*******************************for debug************************************/
    // if(memcmp(r1, R1.r.a + R1.r_Len.a[s->id+i], len1) != 0)
    // {
    //     fprintf(stderr, "haha1\n");
    // }
    // if(memcmp(r2, R2.r.a + R2.r_Len.a[s->id+i], len2) != 0)
    // {
    //     fprintf(stderr, "haha2\n");
    // }
    // uint64_t j, rev, uID, ref_p, self_p, eLen, tLen;
    // char dir[2] = {'+', '-'};
    // fprintf(stderr, "(R1) %.*s\n", (int)(R1.name_Len.a[s->id + i + 1] - R1.name_Len.a[s->id+i]), 
    // R1.name.a + R1.name_Len.a[s->id+i]);
    // for (j = 0; j < occ1; j++)
    // {
    //     interpret_pos(s->idx, &s->pos_buf[tid].a.a[j], &rev, &uID, &ref_p, &self_p, &eLen, &tLen);
    //     fprintf(stderr, "utg%.6lu\t%c\t%lu\t%lu-%lu\n", uID+1, dir[rev], ref_p, self_p + 1 - tLen, self_p);
    // }
    // fprintf(stderr, "(R2) %.*s\n", (int)(R2.name_Len.a[s->id + i + 1] - R2.name_Len.a[s->id+i]), 
    // R2.name.a + R2.name_Len.a[s->id+i]);
    // for (j = 0; j < occ2; j++)
    // {
    //     interpret_pos(s->idx, &s->pos_buf[tid].a.a[j+occ1], &rev, &uID, &ref_p, &self_p, &eLen, &tLen);
    //     fprintf(stderr, "utg%.6lu\t%c\t%lu\t%lu-%lu\n", uID+1, dir[rev], ref_p, self_p + 1 - tLen, self_p);
    // }
    // fprintf(stderr, "\n");
    /*******************************for debug************************************/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
movq 0x40(%rdi), %rax
movq %rsi, %rbx
shlq $0x5, %rbx
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x10(%rax,%rbx)
movdqu %xmm0, (%rax,%rbx)
movq 0x18(%rdi), %rax
movq 0x28(%rdi), %rcx
movq (%rax,%rsi,8), %rbp
movq %rbp, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq (%rcx,%rsi,8), %r13
movq 0x38(%rdi), %rcx
movslq %edx, %rax
imulq $0x18, %rax, %r14
andq $0x0, (%rcx,%r14)
shrq $0x20, %rbp
addq %r14, %rcx
movq (%rdi), %r8
movq 0x40(%r8), %rdx
movq %r13, %rdi
movq %rbp, %rsi
xorl %r9d, %r9d
callq 0xf542d
movq 0x38(%r15), %rcx
movq (%rcx,%r14), %r12
testq %r12, %r12
je 0x120a62
addq %r14, %rcx
addq %rbp, %r13
movl 0x20(%rsp), %esi
movq (%r15), %r8
movq 0x40(%r8), %rdx
movq %r13, %rdi
movq %r12, %r9
callq 0xf542d
movq 0x38(%r15), %rax
movq (%rax,%r14), %r8
subq %r12, %r8
je 0x120a62
addq %r14, %rax
movq 0x10(%rax), %rsi
movq %r12, %rcx
shlq $0x4, %rcx
addq %rsi, %rcx
addq 0x40(%r15), %rbx
movq 0x18(%rsp), %rdx
addq 0x20(%r15), %rdx
movq (%r15), %rdi
movq 0x48(%r15), %rax
movq %rax, 0x8(%rsp)
movq %rdx, (%rsp)
movq %r12, %rdx
movq %rbx, %r9
callq 0x121b03
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq