// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $-0x1, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $-0x1, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $-0x1, (%rax)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $-0x1, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
movslq -0x14(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq (%rax), %r8
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
addq -0x10(%rbp), %rax
xorl %r9d, %r9d
movq %rax, (%rsp)
callq 0x1c23c0
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x212e95
jmp 0x212f7f
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
movslq -0x14(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq (%rax), %r8
movq -0x38(%rbp), %r9
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
addq -0x10(%rbp), %rax
movq %rax, (%rsp)
callq 0x1c23c0
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x212f02
jmp 0x212f7f
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
movq -0x38(%rbp), %rdx
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
movq -0x38(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rcx
movq -0x40(%rbp), %r8
movq -0x20(%rbp), %rax
movq 0x40(%rax), %r9
movq -0x10(%rbp), %rax
shlq $0x5, %rax
addq %rax, %r9
movq -0x20(%rbp), %rax
movq 0x20(%rax), %r10
addq -0x10(%rbp), %r10
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x214fd0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop