// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x945b(%rip), %eax      # 0xd730
jge 0x460c
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x45fc
movq 0x9433(%rip), %rax      # 0xd728
movl -0x34(%rbp), %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x9431(%rip), %ecx      # 0xd738
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x939c(%rip), %rcx      # 0xd6b0
addl (%rcx,%rdx,4), %eax
movq 0x9402(%rip), %rcx      # 0xd720
movl -0x1c(%rbp), %edx
addl -0x28(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x4520
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x451b
movq 0x93dc(%rip), %rax      # 0xd728
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x93da(%rip), %ecx      # 0xd738
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x9345(%rip), %rcx      # 0xd6b0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x3c(%rbp)
movq 0x93b0(%rip), %rax      # 0xd728
movl -0x30(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x93ae(%rip), %ecx      # 0xd738
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x9319(%rip), %rcx      # 0xd6b0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq 0x30(%rbp), %rdx
movq 0x18(%rbp), %rcx
leaq -0x3c(%rbp), %r8
movl 0x9380(%rip), %r9d      # 0xd738
subl $0x1, %r9d
callq 0x27e0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x44db
movq 0x9353(%rip), %rax      # 0xd728
movl -0x30(%rbp), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x9351(%rip), %ecx      # 0xd738
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x92bc(%rip), %rcx      # 0xd6b0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x4c(%rbp)
movq 0x9327(%rip), %rax      # 0xd728
movl -0x30(%rbp), %ecx
addl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x9322(%rip), %ecx      # 0xd738
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x928d(%rip), %rcx      # 0xd6b0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x48(%rbp)
movq 0x92f8(%rip), %rax      # 0xd728
movl -0x30(%rbp), %ecx
addl -0x20(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl 0x92f3(%rip), %ecx      # 0xd738
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x925e(%rip), %rcx      # 0xd6b0
addl (%rcx,%rdx,4), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq 0x38(%rbp), %rdx
movq 0x20(%rbp), %rcx
leaq -0x4c(%rbp), %r8
movl 0x92c5(%rip), %r9d      # 0xd738
subl $0x1, %r9d
callq 0x2ae0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x44d9
movl -0x2c(%rbp), %esi
subl 0x928e(%rip), %esi      # 0xd71c
leaq 0x4cd8(%rip), %rdi      # 0x916d
movb $0x0, %al
callq 0x2030
cmpl $0x3e8, 0x925a(%rip)    # imm = 0x3E8
jge 0x44ca
xorl %eax, %eax
testb $0x1, %al
jne 0x44b0
jmp 0x44ca
movl -0x2c(%rbp), %edx
subl 0x9263(%rip), %edx      # 0xd71c
movslq 0x9240(%rip), %rcx      # 0xd700
leaq 0x7cc9(%rip), %rax      # 0xc190
movl %edx, (%rax,%rcx,4)
movl 0x9230(%rip), %eax      # 0xd700
addl $0x1, %eax
movl %eax, 0x9227(%rip)      # 0xd700
jmp 0x44db
movq -0x18(%rbp), %rax
movq 0x9242(%rip), %rcx      # 0xd728
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl 0x9245(%rip), %edx      # 0xd738
subl $0x1, %edx
movslq %edx, %rsi
leaq 0x91b0(%rip), %rdx      # 0xd6b0
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
jmp 0x45fc
jmp 0x45ec
cmpl $0x0, -0x28(%rbp)
je 0x45b1
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl -0x28(%rbp), %ecx
movq 0x10(%rbp), %rdx
movslq -0x28(%rbp), %rsi
subl (%rdx,%rsi,4), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x458d
movq -0x18(%rbp), %rax
movq 0x91d4(%rip), %rcx      # 0xd728
movl -0x50(%rbp), %edx
addl -0x30(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl 0x91d2(%rip), %edx      # 0xd738
subl $0x1, %edx
movslq %edx, %rsi
leaq 0x913d(%rip), %rdx      # 0xd6b0
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x4531
movl -0x28(%rbp), %eax
movq 0x10(%rbp), %rcx
movslq -0x28(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq 0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
jmp 0x45ea
movq -0x18(%rbp), %rax
movq 0x916c(%rip), %rcx      # 0xd728
movl -0x34(%rbp), %edx
addl -0x30(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl 0x916a(%rip), %edx      # 0xd738
subl $0x1, %edx
movslq %edx, %rsi
leaq 0x90d5(%rip), %rdx      # 0xd6b0
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x45fc
jmp 0x45ee
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x42e2
jmp 0x45fe
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x42cc
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)