// File: /workspace/github_c_makefile_star2_O3/c-zhou[P]oatk/syncasm.c
// Function: scg_scm_utg_index
static void scg_scm_utg_index(scg_t *g)
{
    if (g->idx_u) {
        free(g->idx_u);
        g->idx_u = 0;
    }
    if (g->scm_u) {
        free(g->scm_u);
        g->scm_u = 0;
    }

    kvec_t(uint128_t) scm_u;

    if (!g->utg_asmg) return;

    size_t i, j, m, n;
    uint64_t *a;
    scg_utg_t *utg;
    
    utg = scg_a_vtx(g);
    kv_init(scm_u);
    for (i = 0, n = scg_n_vtx(g); i < n; ++i) {
        if (utg[i].del)
            continue;
        a = utg[i].a;
        for (j = 0, m = utg[i].n; j < m; ++j)
            kv_push(uint128_t, scm_u, ((uint128_t) a[j] << 78) | ((uint128_t) i << 36) | j);
    }

    if (scm_u.n == 0)
        return;

    // scm position array sorting
    qsort(scm_u.a, scm_u.n, sizeof(uint128_t), uint128_cmpfunc);

    // scm position array indexing
    uint128_t **idx_u, *p, *p_n;
    uint64_t s0, s;
    n = scg_n_scm(g);
    MYMALLOC(idx_u, n + 1);
    p = scm_u.a;
    s = scm_utg_sid(p[0]);
    p_n = p + scm_u.n;
    i = 0;
    while (i < n && p < p_n) {
        while (i <= s)
            idx_u[i++] = p;
        s0 = s;
        while (s0 == s && ++p < p_n)
            s = scm_utg_sid(p[0]);
    }
    while (i <= n)
        idx_u[i++] = p;

    assert(scm_u.a + scm_u.n == idx_u[n]);

    g->idx_u = idx_u;
    g->scm_u = scm_u.a;

#ifdef DEBUG_SCM_UTG_INDEX
    for (i = 0; i < n; ++i) {
        m = scm_utg_n(g, i);
        if (m > 0) {
            p = idx_u[i];
            s = scm_utg_sid(p[0]);
            for (j = 1; j < m; ++j) {
                if (s != scm_utg_sid(p[j])) {
                    fprintf(stderr, "[DEBUG_SCM_UTG_INDEX::%s] syncmer unitigging index error!\n", __func__);
                    exit(EXIT_FAILURE);
                }
            }
        }
    }
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rax
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
movq %rax, 0x8(%rsp)
je 0x516c
callq 0x2060
movq 0x8(%rsp), %rax
movq $0x0, 0x18(%rax)
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x5187
callq 0x2060
movq 0x8(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x5493
movq (%rax), %rdx
testq %rdx, %rdx
je 0x5493
movq 0x10(%rax), %rsi
xorl %edi, %edi
xorl %eax, %eax
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
testb $0x40, 0x23(%rsi,%rcx,8)
jne 0x5272
leaq (%rsi,%rcx,8), %rcx
movq (%rcx), %rbx
testq %rbx, %rbx
je 0x5272
movq 0x8(%rcx), %rsi
movq %rbp, %r12
shrq $0x1c, %r12
movq %rbp, 0x20(%rsp)
shlq $0x24, %rbp
movq %r13, %r15
shlq $0x4, %r15
xorl %r14d, %r14d
movq %r13, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
leaq (%r14,%r13), %rcx
cmpq %rax, %rcx
jne 0x523a
leaq (%rax,%rax), %r13
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r13
movq %r13, %rsi
shlq $0x4, %rsi
callq 0x2350
movq 0x28(%rsp), %rsi
movq %rax, %rdi
movq %r13, %rax
movq 0x30(%rsp), %r13
movq (%rsi,%r14,8), %rcx
shlq $0xe, %rcx
orq %r12, %rcx
movq %rbp, %rdx
orq %r14, %rdx
movq %rdx, (%rdi,%r15)
movq %rcx, 0x8(%rdi,%r15)
incq %r14
addq $0x10, %r15
cmpq %r14, %rbx
jne 0x5205
addq %r14, %r13
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rbp
incq %rbp
cmpq %rdx, %rbp
jne 0x51b7
testq %r13, %r13
je 0x5493
leaq 0x7f8b(%rip), %rcx      # 0xd219
movl $0x10, %edx
movq %r13, %rsi
movq %rdi, %r14
callq 0x20d0
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %r12
leaq 0x8(,%r12,8), %rdi
callq 0x2310
movq %r14, %r11
movq %r13, %rcx
shlq $0x4, %rcx
addq %r14, %rcx
testq %r12, %r12
sete %dl
testq %r13, %r13
setle %sil
orb %dl, %sil
jne 0x53cf
movq 0x8(%r11), %rsi
shrq $0xf, %rsi
leaq 0x8(%rax), %rdx
xorl %r9d, %r9d
movdqa 0x1a4e0(%rip), %xmm0    # 0x1f7d0
movdqa 0x1a4e8(%rip), %xmm1    # 0x1f7e0
pcmpeqd %xmm2, %xmm2
movq %r11, %r8
cmpq %rsi, %r9
ja 0x5393
leaq 0x1(%rsi), %rdi
movq %rdi, %r11
subq %r9, %r11
leaq 0x1(%r11), %r10
andq $-0x2, %r10
decq %r11
movq %r11, %xmm3
pshufd $0x44, %xmm3, %xmm3     # xmm3 = xmm3[0,1,0,1]
leaq (%rdx,%r9,8), %r9
pxor %xmm1, %xmm3
xorl %r11d, %r11d
movq %r11, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm0, %xmm4
pxor %xmm1, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm3, %xmm5
pcmpeqd %xmm3, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %ebx
notl %ebx
testb $0x1, %bl
je 0x5372
movq %r8, -0x8(%r9,%r11,8)
pxor %xmm2, %xmm4
pextrw $0x4, %xmm4, %ebx
testb $0x1, %bl
je 0x5384
movq %r8, (%r9,%r11,8)
addq $0x2, %r11
cmpq %r11, %r10
jne 0x5332
movq %rdi, %r9
movq %r14, %r11
addq $0x10, %r8
movq %r8, %rdi
cmpq %rcx, %r8
jae 0x53c5
movq 0x8(%rdi), %r10
shrq $0xf, %r10
leaq 0x10(%rdi), %r8
cmpq %r10, %rsi
je 0x5397
cmpq %r12, %r9
jae 0x53c5
addq $-0x10, %r8
movq %r10, %rsi
cmpq %rcx, %rdi
jb 0x52ff
cmpq %r12, %r9
jbe 0x53d5
jmp 0x5480
xorl %r9d, %r9d
movq %r11, %rdi
leaq 0x1(%r9), %rdx
leaq 0x1(%r12), %rsi
cmpq %rsi, %rdx
cmovaq %rdx, %rsi
subq %r9, %rsi
leaq 0x1(%rsi), %rdx
andq $-0x2, %rdx
decq %rsi
movq %rsi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq (%rax,%r9,8), %rsi
addq $0x8, %rsi
xorl %r8d, %r8d
movdqa 0x1a3c0(%rip), %xmm1    # 0x1f7d0
movdqa 0x1a3c8(%rip), %xmm2    # 0x1f7e0
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movq %r8, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm1, %xmm4
pxor %xmm2, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm0, %xmm5
pcmpeqd %xmm0, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %r9d
notl %r9d
testb $0x1, %r9b
je 0x5463
movq %rdi, -0x8(%rsi,%r8,8)
pxor %xmm3, %xmm4
pextrw $0x4, %xmm4, %r9d
testb $0x1, %r9b
je 0x5477
movq %rdi, (%rsi,%r8,8)
addq $0x2, %r8
cmpq %r8, %rdx
jne 0x5420
cmpq (%rax,%r12,8), %rcx
jne 0x54a2
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rcx)
movq %r11, 0x10(%rcx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a83b(%rip), %rdi     # 0x1fce4
leaq 0x1a59b(%rip), %rsi     # 0x1fa4b
leaq 0x1a84b(%rip), %rcx     # 0x1fd02
movl $0xaa, %edx
callq 0x21d0