// File: /workspace/github_cpp_makefile_star2_O2/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, 0x48(%rsp)
movq %r8, 0x40(%rsp)
testl %edx, %edx
movl $0x0, %r11d
cmovgl %edx, %r11d
movslq %esi, %rax
movq %rdi, 0x18(%rsp)
leaq (%rdi,%rax,4), %rax
movq %rax, 0x58(%rsp)
movq %rdx, 0x38(%rsp)
negl %edx
movq %rdx, 0x50(%rsp)
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %r11, 0x8(%rsp)
cmpl 0x600f(%rip), %r14d     # 0xa1b0
jge 0x4396
movq 0x628a(%rip), %rax      # 0xa438
movslq 0x5fe7(%rip), %rcx      # 0xa19c
leal -0x1(%rcx), %r8d
movslq %edi, %rdx
movq %r14, (%rsp)
movslq %r14d, %rsi
movq %rdi, 0x20(%rsp)
leal (%r11,%rdi), %ebp
movq %rsi, %r15
leaq (%rax,%rsi,4), %rbx
movq %rdx, %rsi
shlq $0x20, %rsi
movq 0x58(%rsp), %rdi
leaq (%rdi,%rdx,4), %r9
movl %edx, %r10d
addq 0x50(%rsp), %r10
xorl %r14d, %r14d
cmpq %r14, %r11
je 0x4339
leaq 0x60f2(%rip), %rdi      # 0xa2f0
movl -0x4(%rdi,%rcx,4), %r13d
movl (%rbx,%r14,4), %edi
addl %r13d, %edi
cmpl (%r9,%r14,4), %edi
jne 0x4325
incq %r14
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %rdi, %rsi
movl %r10d, %edi
addl %r14d, %edi
jne 0x41ee
movq -0x8(%rax,%r15,4), %xmm0
movd %r13d, %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 0x18(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x2c6e
testl %eax, %eax
movq (%rsp), %r14
jne 0x42f7
movq 0x61bd(%rip), %rax      # 0xa438
movq 0x38(%rsp), %rcx
addl %r14d, %ecx
movslq %ecx, %rcx
movslq 0x5f0f(%rip), %r8       # 0xa19c
leaq 0x605c(%rip), %rdx      # 0xa2f0
movl -0x4(%rdx,%r8,4), %edx
decq %r8
movl (%rax,%rcx,4), %esi
addl %edx, %esi
movl %esi, 0x2c(%rsp)
movl 0x4(%rax,%rcx,4), %esi
addl %edx, %esi
movl %esi, 0x30(%rsp)
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x34(%rsp)
movq 0x18(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
callq 0x2eb0
testl %eax, %eax
jne 0x42f7
movl %r12d, %esi
subl 0x96bd(%rip), %esi      # 0xd9a0
leaq 0x2f5c(%rip), %rdi      # 0x7246
xorl %eax, %eax
callq 0x2030
incl 0x6131(%rip)            # 0xa428
movq 0x613a(%rip), %rax      # 0xa438
movslq 0x5e97(%rip), %rcx      # 0xa19c
leaq 0x5fe4(%rip), %rdx      # 0xa2f0
movl -0x4(%rdx,%rcx,4), %edi
addl (%rax,%r15,4), %edi
callq 0x3770
addl %eax, %r12d
xorl %ebp, %ebp
movq 0x8(%rsp), %r11
jmp 0x438c
addq %r14, %rdx
jne 0x433f
callq 0x3770
movq 0x8(%rsp), %r11
addl %eax, %r12d
xorl %ebp, %ebp
movq (%rsp), %r14
jmp 0x438c
sarq $0x1e, %rsi
movq 0x40(%rsp), %rax
movl (%rax,%rsi), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x14(%rsp)
subl %ecx, %eax
addl %r14d, %eax
movslq %eax, %r15
xorl %ebp, %ebp
cmpq %r15, %rbp
jg 0x437b
movl (%rbx,%rbp,4), %edi
addl %r13d, %edi
callq 0x3770
movq 0x8(%rsp), %r11
addl %eax, %r12d
incq %rbp
jmp 0x435e
movq 0x20(%rsp), %rax
addl (%rsp), %eax
movl 0x14(%rsp), %ebp
subl %ebp, %eax
addl %eax, %r14d
incl %r14d
movl %ebp, %edi
jmp 0x419a
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq