// File: /workspace/github_cpp_makefile_star2_O2/TooruAkagi[P]GCIS_Index/gcis_uni_locate.cpp
// Function: findB(int*, int, int, int, int*, int*, int*, int*, int*, int*)
int findB(int *m,int startm,int mrlen,int round,int *kmpc,int *B1,int *B2,int *B3,int *Ls,int *Rs){ //列からtgを探す
    //Bコアを探す
    if(DEBUGFLAG==1){
        printf("\nAコアがない場合の[");
        for(int i2 = 0;i2<coredata[5];i2++){printf("%d ",m[startm+coredata[4]+i2]);}
        printf("](%d 文字)Bを探す(round %d)\nkmpc = ",mrlen,round);
        for(int i2 = 0;i2<mrlen;i2++){printf("%d ",kmpc[i2]);}
    }
    int len = 0;
    int rofs=0;
    if(round>1){rofs=dc2s[round-1];}
    int bsp[3] = {0,0,0}; //コアが完全一致した時，どこまで戻るか
    int i = 0;
    int tg = 0;
    int ofs = 0;
    int kpofs = 0;
    int y9;
    for(int y8=dc2s[round];y8<dc2s[round+1];y8++){
        //if(DEBUGFLAG==1){printf("\n[%d(%d)]",y8,D_2[y8+1]-D_2[y8]);}
        ofs=0;tg = 0;
        std::vector<int> x;
        xdisp(x,y8);
        for(y9=0;y9<x.size();y9++){
            if(rofs+x[y9]==m[startm+tg]){
                tg++;if(tg==1){kpofs = ofs;} //1文字一致を確認したらオフセットくらいは覚えておく
                if(tg==coredata[5]){
                     if(DEBUGFLAG==1){printf("(Bコア発見[%d文字目(%d)] / %dの(+%d))",y9,tg,y8,ofs);}
                }
                if(tg==mrlen){ //CコアがなければB = Cの発見と同じ.コアはどうせ1つしかないのでそのままbreak
                    //printf("\n(コア発見[%d文字目(%d)] / %d(+%d))",y9-D_2[y8],tg,y8,ofs);
                    bsp[0] = y9; //コアの最後尾の位置
                    bsp[1] = y9+1 - mrlen; //手前に残ってる文字数
                    bsp[2] = x.size()-y9-1; //この先に残ってる文字数
                    break;
                }
            }else{ //不一致
                if(tg!=0){
                    if(y8==279){printf("[kmpc%d->%d]",tg,kmpc[tg]);}
                    if(round==0){kpofs+= (tg - kmpc[tg]);}
                    else{kpofs+=D3access(m[startm])*(tg - kmpc[tg]);}
                    tg = kmpc[tg];y9--;continue;}
                tg=0;
            }
            //printf(" %d",rofs+D[y9]);
            if(round>0){ofs+=D3access(rofs+x[y9]);}else{ofs++;}
        }
        //if(fis>0){printf("(左に右出現[%d文字])",fis);} //先頭から出現
        if(tg==mrlen){ //完全一致して抜けてきたやつ(A・Cコアが確実にない)
                coreans++;
                if(bsp[1]>0){occart2[round][1] = rofs+x[y9-mrlen];}else{occart2[round][1] = -1;}
                if(bsp[1]>1){occart2[round][0] = rofs+x[y9-mrlen-1];}else{occart2[round][0] = -1;}
                occart2[round][2] = y8;
                occart2[round][3] = kpofs-ocofs; //コアとのずれを最初に払っておく
                if(bsp[2]>0){occart2[round][4] = rofs+x[y9+1];}else{occart2[round][4] = -1;}
                if(bsp[2]>1){occart2[round][5] = rofs+x[y9+2];}else{occart2[round][5] = -1;}
                if(bsp[2]>2){occart2[round][6] = rofs+x[y9+3];}else{occart2[round][6] = -1;}
                occart2[round][7] = 3; //ABC全部発見 
                if(DEBUGFLAG==1){
                    printf("\nチェック：");
                    for(int i = 0;i<10;i++){printf("[%d]",occart2[round][i]);}
                }
                findups(m,startm,mrlen,round+1,B1,B2,B3,Ls,Rs,1); //その不完全なコアの出現を探す
        }
        else{
            if(tg==coredata[5]){ //最後にBコアだけ出現
                //printf("\n(右にBコア出現[%d文字] +%d)\n",tg,ofs);
                coreans++;
                if(x.size()>tg+1){occart2[round][0] = rofs+x[x.size()-2-tg];}else{occart2[round][0] = -1;}
                if(x.size()>tg){occart2[round][1] = rofs+x[x.size()-1-tg];}else{occart2[round][1] = -1;}
                occart2[round][2] = y8;
                occart2[round][3] = kpofs-ocofs; //コアとのずれを最初に払っておく
                occart2[round][4] = -1;
                occart2[round][5] = -1;
                occart2[round][6] = -1;
                occart2[round][7] = 1; //Bのみ発見
                if(DEBUGFLAG==1){
                    printf("Bコアのみが最後に出現するタイプ\n");
                    for(int i = 0;i<10;i++){printf("[%d]",occart2[round][i]);}
                }
                findups(m,startm,mrlen,round+1,B1,B2,B3,Ls,Rs,1); //その不完全なコアの出現を探す
            }
        }
    }
    //printf("\nend of searching.(%d)[%d]",len,i);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x48(%rsp)
movq %r8, 0x38(%rsp)
movl %edx, 0x4(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r13
leaq 0x52ba(%rip), %r14      # 0xa2f0
movl $0x0, (%rsp)
cmpl $0x2, %ecx
jl 0x504c
leal -0x1(%rcx), %eax
movl (%r14,%rax,4), %eax
movl %eax, (%rsp)
movslq %ecx, %rax
movl (%r14,%rax,4), %r15d
leal 0x1(%rcx), %edx
movl %edx, 0xc(%rsp)
movslq %edx, %rdx
movq %rdx, 0x68(%rsp)
movslq 0x20(%rsp), %rdx
movq %rdx, 0x70(%rsp)
imulq $0x28, %rax, %rax
leaq 0x8449(%rip), %rdx      # 0xd4c0
leaq (%rdx,%rax), %r12
addq %rdx, %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
movl 0x4(%rsp), %eax
notl %eax
movl %eax, 0x44(%rsp)
leaq 0x50(%rsp), %rbx
movl $0x0, 0x10(%rsp)
movl $0x0, 0x14(%rsp)
xorl %ebp, %ebp
movq %rcx, 0x18(%rsp)
movq %r12, 0x30(%rsp)
movq 0x68(%rsp), %rax
cmpl (%r14,%rax,4), %r15d
jge 0x53e6
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movq %rbx, %rdi
movl %r15d, %esi
callq 0x2c26
movl %r15d, 0x8(%rsp)
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x18(%rsp), %r8
movslq %r15d, %rcx
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rsi
subq %rax, %rsi
movq %rsi, %rdx
sarq $0x2, %rdx
movslq %r14d, %rbx
cmpq %rcx, %rdx
jbe 0x51cc
movl (%rax,%rcx,4), %edi
addl (%rsp), %edi
movq 0x20(%rsp), %rsi
addl %r14d, %esi
movslq %esi, %rsi
cmpl (%r13,%rsi,4), %edi
jne 0x513e
leal 0x1(%r14), %ebx
testl %r14d, %r14d
cmovel %r12d, %ebp
cmpl 0x4(%rsp), %ebx
jne 0x5197
jmp 0x52ab
testl %r14d, %r14d
je 0x5195
cmpl $0x117, 0x8(%rsp)       # imm = 0x117
jne 0x516b
movq 0x38(%rsp), %rax
movl (%rax,%rbx,4), %edx
leaq 0x2030(%rip), %rdi      # 0x718c
movl %r14d, %esi
xorl %eax, %eax
callq 0x2030
movq 0x18(%rsp), %r8
testl %r8d, %r8d
je 0x51b0
movq 0x70(%rsp), %rax
movl (%r13,%rax,4), %edi
callq 0x3770
movq 0x18(%rsp), %r8
movq 0x38(%rsp), %rcx
movl (%rcx,%rbx,4), %ebx
subl %ebx, %r14d
imull %eax, %r14d
jmp 0x51bb
xorl %ebx, %ebx
testl %r8d, %r8d
jle 0x51ab
callq 0x3770
movq 0x18(%rsp), %r8
addl %eax, %r12d
jmp 0x51c1
incl %r12d
jmp 0x51c1
movq 0x38(%rsp), %rax
movl (%rax,%rbx,4), %ebx
subl %ebx, %r14d
addl %r14d, %ebp
decl %r15d
incl %r15d
movl %ebx, %r14d
jmp 0x50ed
cmpl 0x4(%rsp), %r14d
jne 0x51ec
leaq 0x5116(%rip), %r14      # 0xa2f0
movq 0x30(%rsp), %r12
movl 0x14(%rsp), %edi
movl 0x10(%rsp), %ebx
jmp 0x52c9
cmpl 0x8791(%rip), %r14d     # 0xd984
movq 0x30(%rsp), %r12
jne 0x53c5
incl 0x5228(%rip)            # 0xa42c
incl %r14d
movslq %r14d, %rdi
pushq $-0x1
popq %rcx
cmpq %rdi, %rdx
movl 0x8(%rsp), %r15d
jbe 0x5224
movq %rdx, %rcx
subq %rbx, %rcx
movl -0x8(%rax,%rcx,4), %ecx
addl (%rsp), %ecx
movl %ecx, (%r12)
pushq $-0x1
popq %rcx
cmpq %rbx, %rdx
leaq 0x50bb(%rip), %r14      # 0xa2f0
jbe 0x5243
notq %rbx
addq %rsi, %rax
movl (%rax,%rbx,4), %ecx
addl (%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movl %r15d, 0x8(%r12)
movl %ebp, %eax
subl 0x8749(%rip), %eax      # 0xd9a0
movl %eax, 0xc(%r12)
movaps 0x1dbd(%rip), %xmm0     # 0x7020
movups %xmm0, 0x10(%r12)
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movl 0x4(%rsp), %edx
movl 0xc(%rsp), %ecx
movq 0x48(%rsp), %r8
movq 0xb0(%rsp), %r9
pushq $0x1
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
callq 0x4920
addq $0x20, %rsp
jmp 0x53d1
movl %r15d, %edi
subl 0x4(%rsp), %edi
incl %edi
movl %r15d, %esi
notl %esi
addl %esi, %edx
movl %edx, %ebx
leaq 0x502c(%rip), %r14      # 0xa2f0
movq 0x30(%rsp), %r12
incl 0x515d(%rip)            # 0xa42c
testl %edi, %edi
jle 0x5302
movl %r15d, %edx
subl 0x4(%rsp), %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %edx
addl (%rsp), %edx
movq 0x28(%rsp), %rsi
movl %edx, (%rsi)
pushq $-0x1
popq %rdx
cmpl $0x1, %edi
je 0x530d
addl 0x44(%rsp), %r15d
movslq %r15d, %rdx
movl (%rax,%rdx,4), %edx
addl (%rsp), %edx
jmp 0x530d
movq 0x28(%rsp), %rdx
orl $-0x1, (%rdx)
pushq $-0x1
popq %rdx
movl %edx, (%r12)
movl 0x8(%rsp), %r15d
movl %r15d, 0x8(%r12)
movl %ebp, %edx
subl 0x867d(%rip), %edx      # 0xd9a0
movl %edx, 0xc(%r12)
testl %ebx, %ebx
movl %edi, 0x14(%rsp)
jle 0x5365
movl 0x4(%rax,%rcx,4), %edx
addl (%rsp), %edx
movl %edx, 0x10(%r12)
cmpl $0x1, %ebx
je 0x536b
movl 0x8(%rax,%rcx,4), %edx
addl (%rsp), %edx
movl %edx, 0x14(%r12)
movl %ebx, %esi
pushq $0x2
popq %rbx
pushq $-0x1
popq %rdx
cmpl $0x3, %esi
jb 0x5374
movl 0xc(%rax,%rcx,4), %edx
addl (%rsp), %edx
movl %esi, %ebx
jmp 0x5374
orl $-0x1, 0x10(%r12)
orl $-0x1, 0x14(%r12)
pushq $-0x1
popq %rdx
movl %edx, 0x18(%r12)
movl $0x3, 0x1c(%r12)
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movl 0x4(%rsp), %edx
movl 0xc(%rsp), %ecx
movq 0x48(%rsp), %r8
movq 0xb0(%rsp), %r9
pushq $0x1
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
callq 0x4920
addq $0x20, %rsp
movl %ebx, 0x10(%rsp)
jmp 0x53d1
leaq 0x4f24(%rip), %r14      # 0xa2f0
movl 0x8(%rsp), %r15d
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x6e42
incl %r15d
jmp 0x50b2
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x6e42
movq %rbx, %rdi
callq 0x2240