// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x8c75(%rip), %eax      # 0xe1b0
jge 0x5858
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x5848
movq 0x8edd(%rip), %rax      # 0xe438
movl -0x38(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x8c2f(%rip), %ecx      # 0xe19c
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x8d76(%rip), %rcx      # 0xe2f0
addl (%rcx,%rdx,4), %eax
movq -0x8(%rbp), %rcx
movl -0xc(%rbp), %edx
addl -0x2c(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x5776
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x5771
movq 0x8e89(%rip), %rax      # 0xe438
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x8bdb(%rip), %ecx      # 0xe19c
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x8d22(%rip), %rcx      # 0xe2f0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x40(%rbp)
movq 0x8e5d(%rip), %rax      # 0xe438
movl -0x34(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x8baf(%rip), %ecx      # 0xe19c
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x8cf6(%rip), %rcx      # 0xe2f0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movq 0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x40(%rbp), %rcx
movl 0x8b85(%rip), %r8d      # 0xe19c
subl $0x1, %r8d
callq 0x3520
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x5736
movq 0x8e04(%rip), %rax      # 0xe438
movl -0x34(%rbp), %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x8b56(%rip), %ecx      # 0xe19c
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x8c9d(%rip), %rcx      # 0xe2f0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x50(%rbp)
movq 0x8dd8(%rip), %rax      # 0xe438
movl -0x34(%rbp), %ecx
addl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x8b27(%rip), %ecx      # 0xe19c
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x8c6e(%rip), %rcx      # 0xe2f0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x4c(%rbp)
movq 0x8da9(%rip), %rax      # 0xe438
movl -0x34(%rbp), %ecx
addl -0x10(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x8af8(%rip), %ecx      # 0xe19c
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x8c3f(%rip), %rcx      # 0xe2f0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq 0x28(%rbp), %rsi
movq 0x10(%rbp), %rdx
leaq -0x50(%rbp), %rcx
movl 0x8ace(%rip), %r8d      # 0xe19c
subl $0x1, %r8d
callq 0x3990
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x5734
movl -0x30(%rbp), %esi
subl 0xc2b7(%rip), %esi      # 0x119a0
leaq 0x5e7b(%rip), %rdi      # 0xb56b
movb $0x0, %al
callq 0x2030
cmpl $0x3e8, 0x8d27(%rip)    # imm = 0x3E8
jge 0x5725
xorl %eax, %eax
testb $0x1, %al
jne 0x570b
jmp 0x5725
movl -0x30(%rbp), %edx
subl 0xc28c(%rip), %edx      # 0x119a0
movslq 0x8d0d(%rip), %rcx      # 0xe428
leaq 0x8dbe(%rip), %rax      # 0xe4e0
movl %edx, (%rax,%rcx,4)
movl 0x8cfd(%rip), %eax      # 0xe428
addl $0x1, %eax
movl %eax, 0x8cf4(%rip)      # 0xe428
jmp 0x5736
movq 0x8cfb(%rip), %rax      # 0xe438
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movl 0x8a52(%rip), %eax      # 0xe19c
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x8b99(%rip), %rax      # 0xe2f0
addl (%rax,%rcx,4), %edi
callq 0x46f0
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x5848
jmp 0x5838
cmpl $0x0, -0x2c(%rbp)
je 0x5802
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rdx
movslq -0x2c(%rbp), %rsi
subl (%rdx,%rsi,4), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x57de
movq 0x8c92(%rip), %rax      # 0xe438
movl -0x54(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edi
movl 0x89e4(%rip), %eax      # 0xe19c
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x8b2b(%rip), %rax      # 0xe2f0
addl (%rax,%rcx,4), %edi
callq 0x46f0
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x5787
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
jmp 0x5836
movq 0x8c2f(%rip), %rax      # 0xe438
movl -0x38(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edi
movl 0x8981(%rip), %eax      # 0xe19c
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x8ac8(%rip), %rax      # 0xe2f0
addl (%rax,%rcx,4), %edi
callq 0x46f0
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x5848
jmp 0x583a
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5548
jmp 0x584a
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5532
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq