// File: /workspace/github_cpp_makefile_star2_O2/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 %rsi, %rbx
testl %r8d, %r8d
movl $0x0, %ebp
cmovgl %r8d, %ebp
movslq %ecx, %rax
shlq $0x2, %rax
movq %rax, 0x50(%rsp)
movq %r8, 0x38(%rsp)
negl %r8d
movq %r8, 0x48(%rsp)
xorl %eax, %eax
xorl %r15d, %r15d
xorl %esi, %esi
movq %rdx, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movq %rdi, 0x40(%rsp)
cmpl 0x726d(%rip), %esi      # 0x9720
jge 0x26b5
movq 0x7258(%rip), %r13      # 0x9718
movslq 0x7261(%rip), %rdi      # 0x9728
leaq -0x1(%rdi), %rcx
movq %rcx, 0x58(%rsp)
movslq %eax, %r8
movq %rsi, 0x8(%rsp)
movslq %esi, %rdx
leal (%rbp,%rax), %ecx
movq %rdx, 0x20(%rsp)
leaq (,%rdx,4), %r12
addq %r13, %r12
movq %r8, %r9
shlq $0x20, %r9
movq 0x7213(%rip), %rsi      # 0x9710
addq 0x50(%rsp), %rsi
leaq (%rsi,%r8,4), %r10
movl %r8d, %r11d
addq 0x48(%rsp), %r11
xorl %esi, %esi
leaq 0x7189(%rip), %rdx      # 0x96a0
cmpq %rsi, %rbp
je 0x2667
movslq (%r12,%rsi,4), %r14
movslq -0x4(%rdx,%rdi,4), %rbx
addq %rbx, %r14
cmpl (%r10,%rsi,4), %r14d
jne 0x2657
incq %rsi
movabsq $0x100000000, %r14      # imm = 0x100000000
addq %r14, %r9
movl %r11d, %r14d
addl %esi, %r14d
jne 0x2517
movq 0x20(%rsp), %rax
movq -0x8(%r13,%rax,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 0x40(%rsp), %r12
movq %r12, %rdi
movq 0x18(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x60(%rsp), %r8
movq 0x58(%rsp), %r14
movl %r14d, %r9d
callq 0x157f
testl %eax, %eax
jne 0x262d
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %rcx
addl %ecx, %eax
cltq
movl (%r13,%rax,4), %ecx
addl %ebx, %ecx
movl %ecx, 0x2c(%rsp)
movl 0x4(%r13,%rax,4), %ecx
addl %ebx, %ecx
movl %ecx, 0x30(%rsp)
addl 0x8(%r13,%rax,4), %ebx
movl %ebx, 0x34(%rsp)
movq %r12, %rdi
movq 0x18(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xb0(%rsp), %rcx
leaq 0x2c(%rsp), %r8
movl %r14d, %r9d
callq 0x16f6
testl %eax, %eax
jne 0x261c
movl %r15d, %esi
subl 0x7104(%rip), %esi      # 0x970c
leaq 0x2b13(%rip), %rdi      # 0x5122
xorl %eax, %eax
callq 0x1030
incl 0x70d4(%rip)            # 0x96f0
movq 0x70f5(%rip), %r13      # 0x9718
movslq 0x70fe(%rip), %r14      # 0x9728
decq %r14
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rax
movslq (%r13,%rax,4), %rax
leaq 0x705d(%rip), %rcx      # 0x96a0
movslq (%rcx,%r14,4), %rcx
addq %rax, %rcx
movq 0x10(%rsp), %rdx
addl (%rdx,%rcx,4), %r15d
xorl %ecx, %ecx
jmp 0x26ac
addq %rsi, %r8
jne 0x266e
movq 0x10(%rsp), %rdx
addl (%rdx,%r14,4), %r15d
xorl %ecx, %ecx
movq 0x8(%rsp), %rsi
jmp 0x26ac
sarq $0x1e, %r9
movq 0xa0(%rsp), %rcx
movl (%rcx,%r9), %ecx
movl %eax, %edi
subl %ecx, %edi
addl %esi, %edi
movslq %edi, %rdi
xorl %r8d, %r8d
movq 0x10(%rsp), %rdx
cmpq %rdi, %r8
jg 0x26a4
movslq (%r12,%r8,4), %r9
addq %rbx, %r9
addl (%rdx,%r9,4), %r15d
incq %r8
jmp 0x268f
addl 0x8(%rsp), %eax
subl %ecx, %eax
addl %eax, %esi
incl %esi
movl %ecx, %eax
jmp 0x24ad
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq