// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rdi, 0x28(%rsp)
movl 0x820c(%rip), %eax      # 0xa720
movl %eax, 0xc(%rsp)
testl %eax, %eax
jle 0x2776
movl %r8d, %r12d
movslq %r8d, %rax
movq %rax, 0x50(%rsp)
movslq %ecx, %rax
shlq $0x2, %rax
movq %rax, 0x48(%rsp)
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %ecx, %ecx
movq %r12, (%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
testl %r12d, %r12d
jle 0x25f4
movq 0x81bc(%rip), %rsi      # 0xa718
movslq 0x81c5(%rip), %r13      # 0xa728
leaq 0x8136(%rip), %rax      # 0xa6a0
movslq -0x4(%rax,%r13,4), %r14
decq %r13
movslq %ebp, %rdx
movslq %ecx, %r8
leal (%rcx,%r12), %eax
movl %eax, 0x1c(%rsp)
movl %r8d, %r10d
notl %r10d
addl %r12d, %r10d
movq %rdx, 0x30(%rsp)
movq %rsi, 0x58(%rsp)
leaq (%rsi,%rdx,4), %rsi
movq %r8, %r9
shlq $0x20, %r9
movq 0x816b(%rip), %rdx      # 0xa710
addq 0x48(%rsp), %rdx
leaq (%rdx,%r8,4), %r11
leal 0x1(%r8), %eax
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %rdx
movslq (%rsi,%rbx,4), %r12
addq %r14, %r12
cmpl (%r11,%rbx,4), %r12d
jne 0x25fb
cmpq %rbx, %r10
je 0x2618
incq %rbx
movabsq $0x100000000, %r12      # imm = 0x100000000
addq %r12, %r9
incl %eax
cmpq %rbx, %rdx
jne 0x25be
movq (%rsp), %r12
movl 0x1c(%rsp), %edi
jmp 0x2768
movl %ecx, %edi
jmp 0x2768
addq %rbx, %r8
jne 0x271b
movq 0x10(%rsp), %rdx
addl (%rdx,%r12,4), %r15d
xorl %edi, %edi
movq (%rsp), %r12
jmp 0x2768
movq 0x30(%rsp), %rax
movq 0x58(%rsp), %rbx
movq -0x8(%rbx,%rax,4), %xmm0
movd %r14d, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
paddd %xmm1, %xmm0
movq %xmm0, 0x60(%rsp)
movq 0x20(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x60(%rsp), %r8
movl %r13d, %r9d
callq 0x1587
testl %eax, %eax
movq (%rsp), %r12
jne 0x26f7
leal (%r12,%rbp), %eax
cltq
movl (%rbx,%rax,4), %ecx
addl %r14d, %ecx
movl %ecx, 0x3c(%rsp)
movl 0x4(%rbx,%rax,4), %ecx
addl %r14d, %ecx
movl %ecx, 0x40(%rsp)
addl 0x8(%rbx,%rax,4), %r14d
movl %r14d, 0x44(%rsp)
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xb0(%rsp), %rcx
leaq 0x3c(%rsp), %r8
movl %r13d, %r9d
callq 0x1748
testl %eax, %eax
jne 0x26dc
movl %r15d, %esi
subl 0x8044(%rip), %esi      # 0xa70c
leaq 0x3a53(%rip), %rdi      # 0x6122
xorl %eax, %eax
callq 0x1030
incl 0x8014(%rip)            # 0xa6f0
movq 0x8035(%rip), %rbx      # 0xa718
movslq 0x803e(%rip), %r13      # 0xa728
movl 0x8030(%rip), %eax      # 0xa720
movl %eax, 0xc(%rsp)
decq %r13
movq 0x30(%rsp), %rax
movslq (%rbx,%rax,4), %rax
leaq 0x7f99(%rip), %rcx      # 0xa6a0
movslq (%rcx,%r13,4), %rcx
addq %rax, %rcx
movq 0x10(%rsp), %rdx
addl (%rdx,%rcx,4), %r15d
xorl %edi, %edi
jmp 0x2768
sarq $0x1e, %r9
movq 0xa0(%rsp), %rdx
movl (%rdx,%r9), %edi
movl %ecx, %r8d
subl %edi, %r8d
movl %ebx, %r9d
addl %r8d, %r9d
movq 0x10(%rsp), %rdx
js 0x275c
subl %edi, %eax
xorl %r8d, %r8d
movq (%rsp), %r12
movslq (%rsi,%r8,4), %r9
addq %r14, %r9
addl (%rdx,%r9,4), %r15d
incq %r8
cmpq %r8, %rax
jne 0x2747
jmp 0x2760
movq (%rsp), %r12
addl %ebp, %ecx
subl %edi, %ecx
addl %ecx, %ebx
movl %ebx, %ebp
incl %ebp
movl %edi, %ecx
cmpl 0xc(%rsp), %ebp
jl 0x254c
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq