// File: 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:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x3c1a
movl $0x0, -0x24(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3b18
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x53, %eax
jne 0x3a61
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3b08
cmpl $0x1, -0x24(%rbp)
jne 0x3b01
movl -0x1c(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x14(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x3aa7
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x53, %eax
jne 0x3aa7
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x53, (%rax,%rcx)
jmp 0x3aff
movl -0x18(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3ad3
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x53, %eax
jne 0x3ad3
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x53, (%rax,%rcx)
jmp 0x3afd
movl -0x1c(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3afb
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x52, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3adc
jmp 0x3afd
jmp 0x3aff
jmp 0x3b01
movl $0x0, -0x24(%rbp)
jmp 0x3b0a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3a36
movl $0x0, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3c15
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x48, %eax
jne 0x3b51
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3c05
cmpl $0x1, -0x28(%rbp)
jl 0x3bfe
cmpl $0x2, -0x28(%rbp)
jg 0x3bfe
movl -0x1c(%rbp), %eax
subl -0x28(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x14(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x3ba4
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x48, %eax
jne 0x3ba4
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x48, (%rax,%rcx)
jmp 0x3bfc
movl -0x18(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3bd0
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x48, %eax
jne 0x3bd0
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x48, (%rax,%rcx)
jmp 0x3bfa
movl -0x1c(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3bf8
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x52, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3bd9
jmp 0x3bfa
jmp 0x3bfc
jmp 0x3bfe
movl $0x0, -0x28(%rbp)
jmp 0x3c07
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3b26
jmp 0x3d25
cmpl $0x1, -0x10(%rbp)
jne 0x3d23
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3d21
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x48, %eax
jne 0x3c5d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3d11
cmpl $0x1, -0x2c(%rbp)
jl 0x3d0a
cmpl $0x2, -0x2c(%rbp)
jg 0x3d0a
movl -0x1c(%rbp), %eax
subl -0x2c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x14(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x3cb0
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x48, %eax
jne 0x3cb0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x48, (%rax,%rcx)
jmp 0x3d08
movl -0x18(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3cdc
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x48, %eax
jne 0x3cdc
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x48, (%rax,%rcx)
jmp 0x3d06
movl -0x1c(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3d04
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x52, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3ce5
jmp 0x3d06
jmp 0x3d08
jmp 0x3d0a
movl $0x0, -0x2c(%rbp)
jmp 0x3d13
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3c32
jmp 0x3d23
jmp 0x3d25
movl -0xc(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)