// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_uni_locate.cpp
// Function: findinNS(int*, int, int, int, int*, int*, int*, int*, int*, int*)
int findinNS(int *m,int startm,int mrlen,int round,int *kmpc,int *B1,int *B2,int *B3,int *Ls,int *Rs){
    if(DEBUGFLAG==1){
        printf("\nNSから探す[%d]\nkmpc=",mrlen);
        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<Sizelist[0];y8++){
            for(int y9=0;y9<mrlen;y9++){
                if(NS[y9+y8]+dc2s[loops-1]==m[startm+tg]){
                    tg++;
                    if(DEBUGFLAG==1){printf("\n%d:%d(%d - %d)[+%d]",kpofs,NS[y9+y8]+dc2s[loops-1],y9+y8,tg,D3access(NS[y9+y8]+dc2s[loops-1]));}
                    if(tg==mrlen){
                        if(DEBUGFLAG==1){printf("パターン発見[%d]",kpofs-ocofs);}
                        int e2[2] = {NS[y8-1]+dc2s[loops-1],NS[y8-2]+dc2s[loops-1]};
                        int tk = rpsck(m,Ls,B1,e2,loops-1);
                        if(DEBUGFLAG==1){if(tk==-1){printf("\nこれはコアではない2");}}
                        if(tk==0){
                            int e[3] = {NS[y8+mrlen]+dc2s[loops-1],NS[y8+mrlen+1]+dc2s[loops-1],NS[y8+mrlen+2]+dc2s[loops-1]};
                            tk = psck(m,Rs,B2,e,loops-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+=D3access(NS[y8]+dc2s[loops-1]);
                        tg=0;break;
                    }
                }
                else{ //不一致
                    if(tg!=0){
                        //printf("\n%d[%d > %d]",y8,tg,kmpc[tg]);
                        for(int u=0;u<tg-kmpc[tg]+1;u++){
                            //printf("(+%d)",D3access(NS[u+y8]+dc2s[loops-1]));
                            kpofs+=D3access(NS[u+y8]+dc2s[loops-1]);
                        }
                        y8+=tg - kmpc[tg];
                        tg = kmpc[tg];
                    }
                    else{kpofs+=D3access(NS[y9+y8]+dc2s[loops-1]);}
                    break;
                }
            }
        }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq %rdi, 0x20(%rsp)
cmpl $0x0, 0x6b66(%rip)      # 0xb1a0
jle 0x4885
movslq %edx, %r11
movslq %esi, %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %esi, %esi
movq %rdx, 0x10(%rsp)
movq %r11, 0x28(%rsp)
testl %edx, %edx
jle 0x46fe
movq 0x6db3(%rip), %rax      # 0xb428
movslq 0x6b10(%rip), %r8       # 0xb18c
leaq 0x6c5d(%rip), %rcx      # 0xb2e0
movl -0x4(%rcx,%r8,4), %ebx
decq %r8
movq %r14, 0x18(%rsp)
movslq %r14d, %rdi
movslq %esi, %rcx
movq %rsi, 0x30(%rsp)
addl %edx, %esi
movl %esi, 0xc(%rsp)
movl %ecx, %esi
notl %esi
addl %edx, %esi
movq %rdi, %r15
leaq (%rax,%rdi,4), %rbp
movq %rcx, %r10
shlq $0x20, %r10
movq 0x60(%rsp), %rdi
leaq (%rdi,%rcx,4), %r9
leal 0x1(%rcx), %r13d
xorl %r14d, %r14d
movl (%rbp,%r14,4), %edi
addl %ebx, %edi
cmpl (%r9,%r14,4), %edi
jne 0x4706
cmpq %r14, %rsi
je 0x472e
incq %r14
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %rdi, %r10
incl %r13d
cmpq %r14, %r11
jne 0x46c5
movq 0x18(%rsp), %r14
movl 0xc(%rsp), %r15d
jmp 0x4872
movl %esi, %r15d
jmp 0x4872
addq %r14, %rcx
jne 0x4818
callq 0x3b6f
movq 0x28(%rsp), %r11
movq 0x10(%rsp), %rdx
addl %eax, %r12d
xorl %r15d, %r15d
movq 0x18(%rsp), %r14
jmp 0x4872
movl -0x4(%rax,%r15,4), %ecx
addl %ebx, %ecx
movl %ecx, 0x3c(%rsp)
addl -0x8(%rax,%r15,4), %ebx
movl %ebx, 0x40(%rsp)
movq 0x20(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
callq 0x2e6b
testl %eax, %eax
movq 0x18(%rsp), %r14
jne 0x47ee
movq 0x6cb6(%rip), %rax      # 0xb428
movq 0x10(%rsp), %rcx
addl %r14d, %ecx
movslq %ecx, %rcx
movslq 0x6a08(%rip), %r8       # 0xb18c
leaq 0x6b55(%rip), %rdx      # 0xb2e0
movl -0x4(%rdx,%r8,4), %edx
decq %r8
movl (%rax,%rcx,4), %esi
addl %edx, %esi
movl %esi, 0x44(%rsp)
movl 0x4(%rax,%rcx,4), %esi
addl %edx, %esi
movl %esi, 0x48(%rsp)
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x4c(%rsp)
movq 0x20(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x44(%rsp), %rcx
callq 0x30de
testl %eax, %eax
jne 0x47ee
movl %r12d, %esi
subl 0xa1b6(%rip), %esi      # 0xe990
leaq 0x3a35(%rip), %rdi      # 0x8216
xorl %eax, %eax
callq 0x2030
incl 0x6c2a(%rip)            # 0xb418
movq 0x6c33(%rip), %rax      # 0xb428
movslq 0x6990(%rip), %rcx      # 0xb18c
leaq 0x6add(%rip), %rdx      # 0xb2e0
movl -0x4(%rdx,%rcx,4), %edi
addl (%rax,%r15,4), %edi
callq 0x3b6f
addl %eax, %r12d
xorl %r15d, %r15d
jmp 0x4868
sarq $0x1e, %r10
movq 0x50(%rsp), %rax
movl (%rax,%r10), %edx
movq 0x30(%rsp), %rax
subl %edx, %eax
movl %r14d, %ecx
addl %eax, %ecx
movl %edx, 0xc(%rsp)
js 0x4854
subl %edx, %r13d
xorl %r15d, %r15d
movl (%rbp,%r15,4), %edi
addl %ebx, %edi
callq 0x3b6f
addl %eax, %r12d
incq %r15
cmpq %r15, %r13
jne 0x483d
movq 0x30(%rsp), %rax
addl 0x18(%rsp), %eax
movl 0xc(%rsp), %r15d
subl %r15d, %eax
addl %eax, %r14d
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %r11
incl %r14d
movl %r15d, %esi
cmpl 0x6921(%rip), %r14d     # 0xb1a0
jl 0x4666
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq