// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: findinNS(unsigned int*, int*, int*, int, int, int, int*, int*, int*, int*, int*, int*)
int findinNS(unsigned int *D,int *D_2,int *D_3,int startm,int mrlen,int round,int *kmpc,int *B1,int *B2,int *B3,int *Ls,int *Rs){
    if(DEBUGFLAG==1){
        printf("\nNSから直接探す[%d](%d)\nkmpc=",mrlen,ocofs);
        for(int i2 = 0;i2<mrlen;i2++){printf("%d ",kmpc[i2]);}
        printf("\n");
        for(int i2 = 0;i2<mrlen;i2++){printf("%d ",m[startm+i2]);}
    }
    int tg,kpofs;
    tg = 0;kpofs=0;
        for(int y8=0;y8<NSsize;y8++){
            //if(y8>=300 && y8<500){printf("\n<%d - %d>",y8,kpofs);}
            for(int y9=0;y9<mrlen;y9++){
                if(NS[y9+y8]+dc2s[fround-1]==m[startm+tg]){
                    tg++;
                    if(DEBUGFLAG==1){printf("\n%d:%d(%d - %d)[+%d]",kpofs,NS[y9+y8]+dc2s[fround-1],y9+y8,tg,D_3[NS[y9+y8]+dc2s[fround-1]]);}
                    if(tg==mrlen){
                        if(DEBUGFLAG==1){printf("[%d]パターン発見[%d]",y8,kpofs-ocofs);}
                        int e2[2] = {NS[y8-1]+dc2s[fround-1],NS[y8-2]+dc2s[fround-1]};
                        int tk = rpsck(D,D_2,Ls,B1,e2,fround-1);
                        if(DEBUGFLAG==1){if(tk==-1){printf("\nこれはコアではない2");}}
                        if(tk==0){
                            int e[3] = {NS[y8+mrlen]+dc2s[fround-1],NS[y8+mrlen+1]+dc2s[fround-1],NS[y8+mrlen+2]+dc2s[fround-1]};
                            tk = psck(D,D_2,Rs,B2,e,fround-1);
                            if(DEBUGFLAG==1){if(tk==-1){printf("\nこれはコアではない");}}
                            if(tk==0){ //左右も完璧に合ってた
                                if(DEBUGFLAG==1){printf("答え");}
                                printf(" %d",kpofs-ocofs);
                                if(ans<1000 && CHECKFLAG==1){checkans[ans]=kpofs-ocofs;}
                                ans++;
                            }
                        }
                        kpofs+=D_3[NS[y8]+dc2s[fround-1]];
                        tg=0;break; //y9 break
                    }
                }
                else{ //不一致
                    if(tg!=0){
                        if(DEBUGFLAG==1){printf("\n%d[%d > %d]",y8,tg,kmpc[tg]);}
                        for(int u=0;u<tg-kmpc[tg]+1;u++){
                            if(DEBUGFLAG==1){printf("(+%d)",D_3[NS[u+y8]+dc2s[fround-1]]);}
                            kpofs+=D_3[NS[u+y8]+dc2s[fround-1]];
                        }
                        y8+=tg - kmpc[tg];
                        tg = kmpc[tg];
                    }
                    else{kpofs+=D_3[NS[y9+y8]+dc2s[fround-1]];}
                    break;
                }
            }
        }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
cmpl $0x0, 0x7ef8(%rip)      # 0xa720
jle 0x2a62
movl %r8d, %r12d
movslq %r8d, %rbp
movslq %ecx, %rax
shlq $0x2, %rax
movq %rax, 0x50(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %ecx, %ecx
movq %r12, (%rsp)
movq %rdx, 0x8(%rsp)
testl %r12d, %r12d
jle 0x28e5
movq 0x7eb7(%rip), %rsi      # 0xa718
movslq 0x7ec0(%rip), %rdx      # 0xa728
leaq 0x7e31(%rip), %rax      # 0xa6a0
movslq -0x4(%rax,%rdx,4), %r14
decq %rdx
movq %rdx, 0x28(%rsp)
movslq %r13d, %rdx
movslq %ecx, %r8
leal (%rcx,%r12), %eax
movl %r8d, %r10d
notl %r10d
addl %r12d, %r10d
movq %rdx, 0x30(%rsp)
movq %rsi, 0x20(%rsp)
leaq (%rsi,%rdx,4), %rsi
movq %r8, %r9
shlq $0x20, %r9
movq 0x7e65(%rip), %rdx      # 0xa710
addq 0x50(%rsp), %rdx
leaq (%rdx,%r8,4), %r11
leal 0x1(%r8), %edi
xorl %ebx, %ebx
movabsq $0x100000000, %rdx      # imm = 0x100000000
movslq (%rsi,%rbx,4), %r12
addq %r14, %r12
cmpl (%r11,%rbx,4), %r12d
jne 0x28ec
cmpq %rbx, %r10
je 0x2909
incq %rbx
addq %rdx, %r9
incl %edi
cmpq %rbx, %rbp
jne 0x28c4
jmp 0x2900
movl %ecx, %eax
jmp 0x2a50
addq %rbx, %r8
jne 0x2a01
movq 0x8(%rsp), %rdx
addl (%rdx,%r12,4), %r15d
xorl %eax, %eax
movq (%rsp), %r12
jmp 0x2a50
movq 0x30(%rsp), %rbx
movq 0x20(%rsp), %rcx
movl -0x4(%rcx,%rbx,4), %eax
addl %r14d, %eax
movl %eax, 0x3c(%rsp)
movl -0x8(%rcx,%rbx,4), %eax
addl %r14d, %eax
movl %eax, 0x40(%rsp)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x98(%rsp), %rcx
leaq 0x3c(%rsp), %r8
movq 0x28(%rsp), %r9
callq 0x15f5
testl %eax, %eax
movq (%rsp), %r12
jne 0x29d3
leal (%r12,%r13), %eax
cltq
movq 0x20(%rsp), %rdx
movl (%rdx,%rax,4), %ecx
addl %r14d, %ecx
movl %ecx, 0x44(%rsp)
movl 0x4(%rdx,%rax,4), %ecx
addl %r14d, %ecx
movl %ecx, 0x48(%rsp)
addl 0x8(%rdx,%rax,4), %r14d
movl %r14d, 0x4c(%rsp)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
leaq 0x44(%rsp), %r8
movq 0x28(%rsp), %r9
callq 0x175f
testl %eax, %eax
jne 0x29ce
movl %r15d, %esi
subl 0x7d52(%rip), %esi      # 0xa70c
leaq 0x3769(%rip), %rdi      # 0x612a
xorl %eax, %eax
callq 0x1030
incl 0x7d22(%rip)            # 0xa6f0
movq 0x30(%rsp), %rbx
movq 0x7d3e(%rip), %rax      # 0xa718
movslq (%rax,%rbx,4), %rax
movslq 0x7d43(%rip), %rcx      # 0xa728
leaq 0x7cb4(%rip), %rdx      # 0xa6a0
movslq -0x4(%rdx,%rcx,4), %rcx
addq %rax, %rcx
movq 0x8(%rsp), %rdx
addl (%rdx,%rcx,4), %r15d
xorl %eax, %eax
jmp 0x2a50
sarq $0x1e, %r9
movq 0x90(%rsp), %rax
movl (%rax,%r9), %eax
movl %ecx, %r8d
subl %eax, %r8d
movl %ebx, %r9d
addl %r8d, %r9d
movq 0x8(%rsp), %rdx
js 0x2a42
subl %eax, %edi
xorl %r8d, %r8d
movq (%rsp), %r12
movslq (%rsi,%r8,4), %r9
addq %r14, %r9
addl (%rdx,%r9,4), %r15d
incq %r8
cmpq %r8, %rdi
jne 0x2a2d
jmp 0x2a46
movq (%rsp), %r12
addl %r13d, %ecx
subl %eax, %ecx
addl %ecx, %ebx
movl %ebx, %r13d
incl %r13d
movl %eax, %ecx
cmpl 0x7cc4(%rip), %r13d     # 0xa720
jl 0x2851
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq