// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
testl %edx, %edx
je 0x346a
cmpl $0x1, %edx
jne 0x3571
testl %esi, %esi
jle 0x3571
movl %esi, %edi
xorl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x1, %r12d
xorl %edx, %edx
movq %rdi, 0x10(%rsp)
leaq 0x1(%rax), %r13
cmpb $0x48, (%r14,%rax)
jne 0x33e4
incl %edx
movl %edx, %ebx
jmp 0x3452
leal -0x1(%rdx), %ecx
xorl %ebx, %ebx
cmpl $0x1, %ecx
ja 0x3452
movl %edx, %ecx
negl %ecx
addq %rax, %rcx
cmpl $0x2, %ecx
jl 0x340c
movl %ecx, %ecx
cmpb $0x48, -0x2(%r14,%rcx)
jne 0x340c
movb $0x48, -0x1(%r14,%rcx)
jmp 0x3452
cmpq %rdi, %r13
jae 0x3420
cmpb $0x48, 0x1(%r14,%rax)
jne 0x3420
movb $0x48, (%r14,%rax)
jmp 0x3452
movslq %edx, %rcx
movq %r14, %rdi
subq %rcx, %rdi
addq %rax, %rdi
movl %r12d, %ecx
subl %edx, %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
addl %ebp, %edx
addl %ecx, %edx
incq %rdx
movl %esi, %r15d
movl $0x52, %esi
callq 0x2100
movq 0x10(%rsp), %rdi
movl %r15d, %esi
decl %ebp
incl %r12d
movq %r13, %rax
movl %ebx, %edx
cmpq %r13, %rdi
jne 0x33d3
jmp 0x3571
testl %esi, %esi
jle 0x3571
movl %esi, %r15d
xorl %eax, %eax
xorl %edx, %edx
cmpb $0x53, (%r14,%rax)
jne 0x3486
incl %edx
movl %edx, %ecx
jmp 0x34c1
xorl %ecx, %ecx
cmpl $0x1, %edx
jne 0x34c1
cmpq $0x3, %rax
jb 0x34a3
cmpb $0x53, -0x3(%r14,%rax)
jne 0x34a3
movb $0x53, -0x2(%r14,%rax)
jmp 0x34c1
leaq 0x1(%rax), %rdx
cmpq %r15, %rdx
jae 0x34bb
cmpb $0x53, 0x1(%r14,%rax)
jne 0x34bb
movb $0x53, (%r14,%rax)
jmp 0x34c1
movb $0x52, -0x1(%r14,%rax)
incq %rax
movl %ecx, %edx
cmpq %rax, %r15
jne 0x3479
testl %esi, %esi
jle 0x3571
xorl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x1, %r12d
xorl %edx, %edx
movl %esi, 0xc(%rsp)
leaq 0x1(%rax), %r13
cmpb $0x48, (%r14,%rax)
jne 0x34f7
incl %edx
movl %edx, %ebx
jmp 0x355e
leal -0x1(%rdx), %ecx
xorl %ebx, %ebx
cmpl $0x1, %ecx
ja 0x355e
movl %edx, %ecx
negl %ecx
addq %rax, %rcx
cmpl $0x2, %ecx
jl 0x351f
movl %ecx, %ecx
cmpb $0x48, -0x2(%r14,%rcx)
jne 0x351f
movb $0x48, -0x1(%r14,%rcx)
jmp 0x355e
cmpq %r15, %r13
jae 0x3533
cmpb $0x48, 0x1(%r14,%rax)
jne 0x3533
movb $0x48, (%r14,%rax)
jmp 0x355e
movslq %edx, %rcx
movq %r14, %rdi
subq %rcx, %rdi
addq %rax, %rdi
movl %r12d, %ecx
subl %edx, %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
addl %ebp, %edx
addl %ecx, %edx
incq %rdx
movl $0x52, %esi
callq 0x2100
movl 0xc(%rsp), %esi
decl %ebp
incl %r12d
movq %r13, %rax
movl %ebx, %edx
cmpq %r13, %r15
jne 0x34e6
movl %esi, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq