// File: /workspace/github_cpp_makefile_star2_O3/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, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %rdi, 0x20(%rsp)
movl 0x6c68(%rip), %edi      # 0xb1a0
testl %edi, %edi
jle 0x47a8
movslq %edx, %r11
movslq %esi, %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x58(%rsp)
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %esi, %esi
movq %rdx, 0x10(%rsp)
movq %r11, 0x28(%rsp)
testl %edx, %edx
jle 0x4606
movl %edi, 0xc(%rsp)
movq 0x6eaf(%rip), %rax      # 0xb428
movslq 0x6c0c(%rip), %r8       # 0xb18c
leaq 0x6d59(%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, 0x8(%rsp)
movl %ecx, %esi
notl %esi
addl %edx, %esi
movq %rdi, %r15
leaq (%rax,%rdi,4), %rbp
movq %rcx, %r10
shlq $0x20, %r10
movq 0x58(%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 0x460e
cmpq %r14, %rsi
je 0x4636
incq %r14
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %rdi, %r10
incl %r13d
cmpq %r14, %r11
jne 0x45c9
movq 0x18(%rsp), %r14
movl 0xc(%rsp), %edi
movl 0x8(%rsp), %r15d
jmp 0x4799
movl %esi, %r15d
jmp 0x4799
addq %r14, %rcx
jne 0x473b
callq 0x3a9f
movq 0x28(%rsp), %r11
movq 0x10(%rsp), %rdx
addl %eax, %r12d
xorl %r15d, %r15d
movq 0x18(%rsp), %r14
jmp 0x4795
movq -0x8(%rax,%r15,4), %xmm0
movd %ebx, %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), %rdi
movq 0xb0(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x2ddb
testl %eax, %eax
movq 0x18(%rsp), %r14
jne 0x4701
movq 0x6da3(%rip), %rax      # 0xb428
movq 0x10(%rsp), %rcx
addl %r14d, %ecx
movslq %ecx, %rcx
movslq 0x6af5(%rip), %r8       # 0xb18c
leaq 0x6c42(%rip), %rdx      # 0xb2e0
movl -0x4(%rdx,%r8,4), %edx
decq %r8
movl (%rax,%rcx,4), %esi
addl %edx, %esi
movl %esi, 0x3c(%rsp)
movl 0x4(%rax,%rcx,4), %esi
addl %edx, %esi
movl %esi, 0x40(%rsp)
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x44(%rsp)
movq 0x20(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
callq 0x3051
testl %eax, %eax
jne 0x4701
movl %r12d, %esi
subl 0xa2a3(%rip), %esi      # 0xe990
leaq 0x3b52(%rip), %rdi      # 0x8246
xorl %eax, %eax
callq 0x2030
incl 0x6d17(%rip)            # 0xb418
movq 0x6d20(%rip), %rax      # 0xb428
movslq 0x6a7d(%rip), %rcx      # 0xb18c
leaq 0x6bca(%rip), %rdx      # 0xb2e0
movl -0x4(%rdx,%rcx,4), %edi
addl (%rax,%r15,4), %edi
callq 0x3a9f
addl %eax, %r12d
xorl %r15d, %r15d
movl 0x6a71(%rip), %edi      # 0xb1a0
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %r11
jmp 0x4799
sarq $0x1e, %r10
movq 0x48(%rsp), %rax
movl (%rax,%r10), %edx
movq 0x30(%rsp), %rax
subl %edx, %eax
movl %r14d, %ecx
addl %eax, %ecx
movl %edx, 0x8(%rsp)
js 0x4777
subl %edx, %r13d
xorl %r15d, %r15d
movl (%rbp,%r15,4), %edi
addl %ebx, %edi
callq 0x3a9f
addl %eax, %r12d
incq %r15
cmpq %r15, %r13
jne 0x4760
movq 0x30(%rsp), %rax
addl 0x18(%rsp), %eax
movl 0x8(%rsp), %r15d
subl %r15d, %eax
addl %eax, %r14d
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %r11
movl 0xc(%rsp), %edi
incl %r14d
movl %r15d, %esi
cmpl %edi, %r14d
jl 0x4566
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq