// File: /workspace/github_cpp_makefile_star2_O2/nanjiangshu[P]calSOV/calSOV.cpp
// Function: ProofReading(char*, int, int)
int ProofReading(char *predSec, int seqLength, int method_ProofReading = 0)/*{{{*/
{
    //proof reading for predicted result, for 1 long strand (sheet)
    int Part1;
    int Part2;
    int ik;
    int ij;
    if (method_ProofReading == 0)/*{{{*/
    {
        int NShe = 0;
        for (ik=0; ik<seqLength; ik++)
        {
            if (  predSec[ik] == 'S'  )
            {
                NShe++;
            }
            else
            {
                if (  NShe == 1  )
                {
                    //previous
                    Part1 = ik-3;
                    Part2 = ik +1 ;
                    if (  (Part1>=0) && (predSec[Part1]=='S')  )
                    {
                        predSec[Part1+1] = 'S';
                    }
                    else if (  (Part2<seqLength) && (predSec[Part2]=='S')  )
                    {
                        predSec[Part2-1] = 'S';
                    }
                    else
                    {
                        for (ij=ik-NShe; ij<ik; ij++)
                        {
                            predSec[ij] = 'R';
                        }
                    }
                }
                NShe = 0;
            }
        }


        //proof reading for predicted result, for 1 or 2 long helix
        int NHel = 0;
        for (ik=0; ik<seqLength; ik++)
        {
            if (  predSec[ik] == 'H'  )
            {
                NHel++;
            }
            else
            {
                if  (   (NHel>=1) &&  (NHel<=2)   )
                {
                    //previous
                    Part1 = ik-NHel-2;
                    Part2 = ik +1 ;
                    if (  (Part1>=0) && (predSec[Part1]=='H')  )
                    {
                        predSec[Part1+1] = 'H';
                    }
                    else if (  (Part2<seqLength) && (predSec[Part2]=='H')  )
                    {
                        predSec[Part2-1] = 'H';
                    }
                    else
                    {
                        for (ij=ik-NHel; ij<ik; ij++)
                        {
                            predSec[ij] = 'R';
                        }
                    }
                }
                NHel = 0;
            }
        } 
    }/*}}}*/
    else if (method_ProofReading == 1)/*{{{*/
    {  /*do not proof reading single residue sheet, when using the DSSP8to3 scheme BE --> Sheet, 2009-10-29*/
        //proof reading for predicted result, for 1 or 2 long helix
        int NHel = 0;
        for (ik=0; ik<seqLength; ik++)
        {
            if (  predSec[ik] == 'H'  )
            {
                NHel++;
            }
            else
            {
                if  (   (NHel>=1) &&  (NHel<=2)   )
                {
                    //previous
                    Part1 = ik-NHel-2;
                    Part2 = ik +1 ;
                    if (  (Part1>=0) && (predSec[Part1]=='H')  )
                    {
                        predSec[Part1+1] = 'H';
                    }
                    else if (  (Part2<seqLength) && (predSec[Part2]=='H')  )
                    {
                        predSec[Part2-1] = 'H';
                    }
                    else
                    {
                        for (ij=ik-NHel; ij<ik; ij++)
                        {
                            predSec[ij] = 'R';
                        }
                    }
                }
                NHel = 0;
            }
        } 
    }/*}}}*/
    return seqLength;
}

// Assembly:
movl %esi, %eax
testl %edx, %edx
je 0x31f2
cmpl $0x1, %edx
jne 0x32de
movslq %eax, %rcx
xorl %edx, %edx
testl %ecx, %ecx
movl $0x0, %esi
cmovgl %eax, %esi
xorl %r9d, %r9d
cmpq %rsi, %rdx
je 0x32de
cmpb $0x48, (%rdi,%rdx)
jne 0x3198
incl %r9d
movl %r9d, %r8d
jmp 0x31d8
leal -0x1(%r9), %r10d
xorl %r8d, %r8d
cmpl $0x1, %r10d
ja 0x31d8
movl %edx, %r10d
subl %r9d, %r10d
cmpl $0x2, %r10d
jl 0x31c4
movl %r10d, %r9d
cmpb $0x48, -0x2(%rdi,%r9)
jne 0x31c4
movb $0x48, -0x1(%rdi,%r9)
jmp 0x31d8
leaq 0x1(%rdx), %r9
cmpq %rcx, %r9
jge 0x31e0
cmpb $0x48, (%rdi,%r9)
jne 0x31e0
movb $0x48, (%rdi,%rdx)
incq %rdx
movl %r8d, %r9d
jmp 0x3181
movslq %r10d, %r9
cmpq %rdx, %r9
jge 0x31d8
movb $0x52, (%rdi,%r9)
incq %r9
jmp 0x31e3
xorl %esi, %esi
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movslq %eax, %rdx
pushq $-0x1
popq %r8
movq %rdi, %r9
xorl %r11d, %r11d
cmpq %rcx, %rsi
je 0x326c
cmpb $0x53, (%rdi,%rsi)
jne 0x321e
incl %r11d
movl %r11d, %r10d
jmp 0x324f
xorl %r10d, %r10d
cmpl $0x1, %r11d
jne 0x324f
cmpq $0x3, %rsi
jb 0x323b
cmpb $0x53, -0x3(%rdi,%rsi)
jne 0x323b
movb $0x53, -0x2(%rdi,%rsi)
jmp 0x324f
leaq 0x1(%rsi), %r11
cmpq %rdx, %r11
jge 0x325a
cmpb $0x53, (%rdi,%r11)
jne 0x325a
movb $0x53, (%rdi,%rsi)
incq %rsi
incq %r9
movl %r10d, %r11d
jmp 0x320b
movq %r8, %r11
testq %r11, %r11
je 0x324f
movb $0x52, (%r9,%r11)
incq %r11
jmp 0x325d
xorl %esi, %esi
xorl %r9d, %r9d
cmpq %rcx, %rsi
je 0x32de
cmpb $0x48, (%rdi,%rsi)
jne 0x3284
incl %r9d
movl %r9d, %r8d
jmp 0x32c4
leal -0x1(%r9), %r10d
xorl %r8d, %r8d
cmpl $0x1, %r10d
ja 0x32c4
movl %esi, %r10d
subl %r9d, %r10d
cmpl $0x2, %r10d
jl 0x32b0
movl %r10d, %r9d
cmpb $0x48, -0x2(%rdi,%r9)
jne 0x32b0
movb $0x48, -0x1(%rdi,%r9)
jmp 0x32c4
leaq 0x1(%rsi), %r9
cmpq %rdx, %r9
jge 0x32cc
cmpb $0x48, (%rdi,%r9)
jne 0x32cc
movb $0x48, (%rdi,%rsi)
incq %rsi
movl %r8d, %r9d
jmp 0x3271
movslq %r10d, %r9
cmpq %rsi, %r9
jge 0x32c4
movb $0x52, (%rdi,%r9)
incq %r9
jmp 0x32cf
retq