// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/syncmer.c
// Function: collect_syncmer_from_reads
syncmer_db_t *collect_syncmer_from_reads(sr_db_t *sr_db)
{
    size_t i, j;
    uint64_t n1, n2;
    sr_t *s;
    kvec_t(uint128_t) scm;
    kv_init(scm);
    n1 = 0;
    for (i = 0; i < sr_db->n; ++i) {
        s = &sr_db->a[i];
        assert(s->sid == i);
        n1 += s->n;
        for (j = 0; j < s->n; ++j) {
            uint128_t s1 = (uint128_t) s->k_mer[j] << 64 | ((s->sid << 32) | (j << 1) | (s->m_pos[j] & 1));
            kv_push(uint128_t, scm, s1);
        }
    }
    if (scm.n == 0) {
        kv_destroy(scm);
        return 0;
    }

    qsort(scm.a, scm.n, sizeof(uint128_t), uint128_cmpfunc);

    // pack syncmers by kmer hash
    // check hash collisions
    syncmer_db_t *scm_db;
    size_t last;
    uint64_t h64;
    MYMALLOC(scm_db, 1);
    syncmer_db_init(scm_db);
    h64 = (uint64_t) (scm.a[0] >> 64);
    for (i = 1, last = 0; i < scm.n; ++i) {
        if ((uint64_t) (scm.a[i] >> 64) != h64) {
            // process kmer cluster
            process_kmer_cluster(&scm.a[last], i - last, scm_db, sr_db);

            last = i;
            h64 = (uint64_t) (scm.a[i] >> 64);
        }
    }
    process_kmer_cluster(&scm.a[last], i - last, scm_db, sr_db);
    kv_destroy(scm);

    MYREALLOC(scm_db->a, scm_db->n);
    scm_db->m = scm_db->n;
    MYMALLOC(scm_db->c, scm_db->n);
    for (i = 0; i < scm_db->n; ++i) scm_db->c[i] = 1;

    n2 = 0;
    for (i = 0; i < scm_db->n; ++i) n2 += scm_db->a[i].cov;
    assert(n1 == n2);

    return scm_db;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x149dd
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x58, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x148cb
jmp 0x148ea
leaq 0x19977(%rip), %rdi     # 0x2e249
leaq 0x196dd(%rip), %rsi     # 0x2dfb6
movl $0x57f, %edx            # imm = 0x57F
leaq 0x19970(%rip), %rcx     # 0x2e255
callq 0x21e0
movq -0x38(%rbp), %rax
movl 0x38(%rax), %eax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movl 0x38(%rcx), %ecx
cmpq %rcx, %rax
jae 0x149ca
movq -0x38(%rbp), %rdx
movq 0x50(%rdx), %rax
movq -0x20(%rbp), %rsi
movq (%rax,%rsi,8), %rcx
movq (%rdx), %rax
movq 0x40(%rdx), %rdx
shlq $0x20, %rax
movq %rsi, %rdi
addq %rdi, %rdi
orq %rdi, %rax
movl (%rdx,%rsi,4), %edx
andl $0x1, %edx
orq %rdx, %rax
movq %rcx, -0x58(%rbp)
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x14990
cmpq $0x0, -0x48(%rbp)
je 0x14968
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x80(%rbp)
jmp 0x14973
movl $0x2, %eax
movq %rax, -0x80(%rbp)
jmp 0x14973
movq -0x80(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x4, %rsi
callq 0x2360
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, %rdi
incq %rdi
movq %rdi, -0x50(%rbp)
shlq $0x4, %rcx
movq %rsi, 0x8(%rax,%rcx)
movq %rdx, (%rax,%rcx)
jmp 0x149b9
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x14901
jmp 0x149cc
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x14897
cmpq $0x0, -0x50(%rbp)
jne 0x149fa
movq -0x40(%rbp), %rdi
callq 0x2060
movq $0x0, -0x8(%rbp)
jmp 0x14beb
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdi
leaq 0x1f7(%rip), %rcx       # 0x14c00
movl $0x10, %edx
callq 0x20d0
movl $0x28, %edi
callq 0x2320
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x13ce0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq $0x1, -0x18(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x14ab8
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
cmpq -0x78(%rbp), %rax
je 0x14aa8
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, %rcx
shlq $0x4, %rcx
addq %rcx, %rdi
movl -0x18(%rbp), %esi
subl %eax, %esi
movq -0x68(%rbp), %rdx
movq -0x10(%rbp), %rcx
callq 0x14c70
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
movq %rax, -0x78(%rbp)
jmp 0x14aaa
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x14a46
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
subq -0x70(%rbp), %rax
movl %eax, %esi
movq -0x68(%rbp), %rdx
movq -0x10(%rbp), %rcx
callq 0x14c70
movq -0x40(%rbp), %rdi
callq 0x2060
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x68(%rbp), %rax
movq (%rax), %rsi
shlq $0x5, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rax
movq (%rax), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x68(%rbp), %rax
movq (%rax), %rdi
shlq %rdi
callq 0x2320
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x18(%rax)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x14b68
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
movw $0x1, (%rax,%rcx,2)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x14b3b
movq $0x0, -0x30(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x14bb8
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x14b78
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x14bc4
jmp 0x14be3
leaq 0x196be(%rip), %rdi     # 0x2e289
leaq 0x193e4(%rip), %rsi     # 0x2dfb6
movl $0x5a8, %edx            # imm = 0x5A8
leaq 0x19677(%rip), %rcx     # 0x2e255
callq 0x21e0
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)