// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path_finder.c
// Function: minicircle_analysis_thread
static void minicircle_analysis_thread(void *_data, long i, int tid) // kt_for() callback
{
    uint32_t j, k, beg, end, rev, nfrg;
    uint64_t sid, uid;
    scg_ra_t *ra;
    ra_frg_t *frgs;
    
    ra = &(((mc_shared_t *)_data)->ra->a[i]);
    sid = ((mc_shared_t *)_data)->sid;
    nfrg = ra->n;
    frgs = ra->a;

    if (nfrg < 2) {
        ((mc_shared_t *)_data)->mcs[i] = UINT64_MAX;
        return;
    }

    // find begin and end position
    beg = end = rev = UINT32_MAX;
    for (j = 0; j < nfrg; ++j) {
        uid = frgs[j].uid;
        if (uid>>1 != sid)
            continue;
        if (beg == UINT32_MAX)
            beg = j;
        else if (end == UINT32_MAX)
            end = j - 1;
        if (rev == UINT32_MAX) {
            rev = uid & 1;
        } else if (rev != (uid & 1)) {
            // inconsistent alignment orientation found
            rev = UINT32_MAX;
            break;
        }
    }

    if (beg == UINT32_MAX || end == UINT32_MAX || rev == UINT32_MAX) {
        // either no repeat unit or inconsistent orientation
        ((mc_shared_t *)_data)->mcs[i] = UINT64_MAX;
        return;
    }
    
    // check repeat unit consistency across the entire alignment path
    int valid = 1;
    if (beg > 0 || end < nfrg - 2) {
        uint32_t r = end - beg;
        if (beg > r) {
            valid = 0;
        } else {
            k = r - beg;
            if (++k > r) k = 0;
            for (j = 0; j < nfrg; ++j) {
                if (frgs[j].uid != frgs[beg+k].uid) {
                    valid = 0;
                    break;
                }
                if (++k > r) k = 0;
            }
        }
    }

    ((mc_shared_t *)_data)->mcs[i] = valid? ((uint64_t) beg<<33 | (uint64_t) end<<1 | rev) : UINT64_MAX;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
cmpl $0x2, -0x2c(%rbp)
jae 0xb04a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq $-0x1, (%rax,%rcx,8)
jmp 0xb221
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0xb0f3
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
shrq %rax
cmpq -0x38(%rbp), %rax
je 0xb096
jmp 0xb0e5
cmpl $-0x1, -0x20(%rbp)
jne 0xb0a4
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0xb0b5
cmpl $-0x1, -0x24(%rbp)
jne 0xb0b3
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xb0b5
cmpl $-0x1, -0x28(%rbp)
jne 0xb0c8
movq -0x40(%rbp), %rax
andq $0x1, %rax
movl %eax, -0x28(%rbp)
jmp 0xb0e3
movl -0x28(%rbp), %eax
movq -0x40(%rbp), %rcx
andq $0x1, %rcx
cmpq %rcx, %rax
je 0xb0e1
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
jmp 0xb0f3
jmp 0xb0e3
jmp 0xb0e5
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xb066
cmpl $-0x1, -0x20(%rbp)
je 0xb105
cmpl $-0x1, -0x24(%rbp)
je 0xb105
cmpl $-0x1, -0x28(%rbp)
jne 0xb11e
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq $-0x1, (%rax,%rcx,8)
jmp 0xb221
movl $0x1, -0x54(%rbp)
cmpl $0x0, -0x20(%rbp)
ja 0xb13c
movl -0x24(%rbp), %eax
movl -0x2c(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jae 0xb1de
movl -0x24(%rbp), %eax
subl -0x20(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x58(%rbp), %eax
jbe 0xb159
movl $0x0, -0x54(%rbp)
jmp 0xb1dc
movl -0x58(%rbp), %eax
subl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl -0x58(%rbp), %eax
jbe 0xb177
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0xb1da
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x50(%rbp), %rcx
movl -0x20(%rbp), %edx
addl -0x1c(%rbp), %edx
movl %edx, %edx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
je 0xb1b8
movl $0x0, -0x54(%rbp)
jmp 0xb1da
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl -0x58(%rbp), %eax
jbe 0xb1cd
movl $0x0, -0x1c(%rbp)
jmp 0xb1cf
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xb17e
jmp 0xb1dc
jmp 0xb1de
cmpl $0x0, -0x54(%rbp)
je 0xb200
movl -0x20(%rbp), %eax
shlq $0x21, %rax
movl -0x24(%rbp), %ecx
shlq %rcx
orq %rcx, %rax
movl -0x28(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x60(%rbp)
jmp 0xb20d
movq $-0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xb20d
movq -0x60(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
popq %rbp
retq
nopw %cs:(%rax,%rax)