// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/syncmer.c
// Function: kmer_hash64
static uint64_t kmer_hash64(uint8_t *s, uint32_t p, int w, uint8_t *key)
#endif
{
    uint64_t h64;
    int i, j, rev, res, p0, p1, b, c;

    rev = p & 1, p >>= 1;
    p0 = p, p1 = p + w - 1;

    // assert(p0 >= 0 && p1 < l);

    // res = rev? 6 - p1 % 4 * 2 : p0 % 4 * 2; // shift bits
    res = rev? ((p1&3)^3)<<1 : (p0&3)<<1;
    b = p1 / 4 - p0 / 4 + 1; // number bytes holding syncmer sequence
    memcpy(key, s + p0 / 4, b);
    // key[b-1] needs bit shift
    // when the last byte is partially filled
    // if (l < (p1 / 4 + 1) * 4) key[b-1] <<= 8 - l % 4 * 2;
    // do reverse complementary
    if (rev) {
        for (i = 0, j = b - 1; i < j; ++i, --j) {
            c = key[i];
            key[i] = comp_seq8_table[key[j]];
            key[j] = comp_seq8_table[c];
        }
        if (i == j) key[i] = comp_seq8_table[key[i]];
    }
    // do bit shift to align syncmer bytes
    for (i = 0; i < b-1; ++i) {
        key[i] <<= res;
        key[i] |= key[i+1] >> (8-res);
    }
    key[b-1] <<= res;

    // real bytes
    b = (w - 1) / 4 + 1;
    // mask the lower bits
    key[b-1] &= lmask[w&3];

    h64 = MurmurHash64A(key, b, murmur3_seed);

#ifdef DEBUG_KMER_EXTRACTION
    fprintf(stderr, "[DEBUG_KMER_EXTRACTION::%s] sid:%lu p0:%d p1:%d rev:%d bit:%d hash:%lu ", __func__, sid, p0, p1, rev, b, h64);
    for (i = 0; i < p1 - p0 + 1; ++i)
        // fputc(char_nt4_table[(key[i / 4] >> (3 - i % 4) * 2) & 3], stderr);
        fputc(char_nt4_table[(key[i/4]>>(((i&3)^3)<<1)) & 3], stderr);

    fputc('\n', stderr);
#endif

    return h64;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl -0xc(%rbp), %eax
andl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0xc(%rbp), %eax
shrl %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x17fbf
movl -0x38(%rbp), %eax
andl $0x3, %eax
xorl $0x3, %eax
shll %eax
movl %eax, -0x44(%rbp)
jmp 0x17fca
movl -0x34(%rbp), %eax
andl $0x3, %eax
shll %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x38(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, -0x48(%rbp)
movl -0x34(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x48(%rbp), %eax
subl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl -0x34(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cltq
addq %rax, %rsi
movslq -0x3c(%rbp), %rdx
callq 0x22c0
cmpl $0x0, -0x2c(%rbp)
je 0x180c5
movl $0x0, -0x24(%rbp)
movl -0x3c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x18098
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x1c323(%rip), %rax     # 0x34380
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
movslq -0x40(%rbp), %rcx
leaq 0x1c30a(%rip), %rax     # 0x34380
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x18031
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x180c3
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x1c2cb(%rip), %rax     # 0x34380
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x180c5
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1812c
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rdx
movq %rdx, -0x50(%rbp)
movzbl (%rax,%rdx), %edx
shll %cl, %edx
movq -0x50(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %esi
movl $0x8, %ecx
subl -0x30(%rbp), %ecx
sarl %cl, %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
orl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x180cc
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq %rdx, -0x58(%rbp)
movzbl (%rax,%rdx), %edx
shll %cl, %edx
movq -0x58(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x10(%rbp), %eax
andl $0x3, %eax
movslq %eax, %rcx
leaq 0x1c30f(%rip), %rax     # 0x34480
movzbl (%rax,%rcx), %esi
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
andl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq 0x1c2ef(%rip), %rdx     # 0x34488
callq 0x11840
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)