// File: chhylp123[P]hifiasm/./Correct.h
// Function: if_is_homopolymer_strict(long long, char*, long long)
inline int if_is_homopolymer_strict(long long site, char* read, long long read_length)
{
    long long beg, end, i;
    long long threshold = 3;

    beg = site - threshold;
    if(beg < 0)
    {
        beg = 0;
    }

    end = site + threshold;

    if(end >= read_length)
    {
        end = read_length - 1;
    }

    char f_homopolymer_ch = 0;
    long long f_homopolymer_len = 0;

    for (i = site + 1; i <= end; i++)
    {
        if(f_homopolymer_ch == 0)
        {
            f_homopolymer_ch = read[i];
            f_homopolymer_len = 1;
        }
        else 
        {
            if(read[i] != f_homopolymer_ch)
            {
                break;
            }
            else
            {
                f_homopolymer_len++;
            }
        }
    }

    char b_homopolymer_ch = 0;
    long long b_homopolymer_len = 0;

    for (i = site - 1; i >= beg; i--)
    {
        if(b_homopolymer_ch == 0)
        {
            b_homopolymer_ch = read[i];
            b_homopolymer_len = 1;
        }
        else
        {
            if(read[i] != b_homopolymer_ch)
            {
                break;
            }
            else
            {
                b_homopolymer_len++;
            }
        }
    }

    if(f_homopolymer_ch == read[site])
    {
        f_homopolymer_len++;
    }
    else if(b_homopolymer_ch == read[site])
    {
        b_homopolymer_len++;
    }

    if(f_homopolymer_len >= threshold || b_homopolymer_len >= threshold)
    {
        return 1;
    }

    if (read[site] == f_homopolymer_ch 
        && 
        b_homopolymer_ch == f_homopolymer_ch 
        && 
        (f_homopolymer_len + b_homopolymer_len >= threshold))
    {
        return 1;
    }
    
    
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x3, -0x40(%rbp)
movq -0x10(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jge 0xa0683
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0xa06a5
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x30(%rbp)
movb $0x0, -0x41(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jg 0xa071c
movsbl -0x41(%rbp), %eax
cmpl $0x0, %eax
jne 0xa06e8
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x41(%rbp)
movq $0x1, -0x50(%rbp)
jmp 0xa070c
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x41(%rbp), %ecx
cmpl %ecx, %eax
je 0xa06fe
jmp 0xa071c
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xa070c
jmp 0xa070e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xa06bd
movb $0x0, -0x51(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jl 0xa0793
movsbl -0x51(%rbp), %eax
cmpl $0x0, %eax
jne 0xa075f
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x51(%rbp)
movq $0x1, -0x60(%rbp)
jmp 0xa0783
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x51(%rbp), %ecx
cmpl %ecx, %eax
je 0xa0775
jmp 0xa0793
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xa0783
jmp 0xa0785
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xa0734
movsbl -0x41(%rbp), %eax
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0xa07b5
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xa07d7
movsbl -0x51(%rbp), %eax
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0xa07d5
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xa07d7
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0xa07eb
movq -0x60(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0xa07f4
movl $0x1, -0x4(%rbp)
jmp 0xa0832
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x41(%rbp), %ecx
cmpl %ecx, %eax
jne 0xa082b
movsbl -0x51(%rbp), %eax
movsbl -0x41(%rbp), %ecx
cmpl %ecx, %eax
jne 0xa082b
movq -0x50(%rbp), %rax
addq -0x60(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0xa082b
movl $0x1, -0x4(%rbp)
jmp 0xa0832
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)