// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movq %r9, 0x78(%rsp)
movq %r8, 0x30(%rsp)
movl %ecx, %r14d
movl %edx, %r13d
movq %rsi, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movl $0x0, 0xc(%rsp)
leaq 0x5d7c(%rip), %r12      # 0xb2e0
cmpl $0x2, %ecx
jl 0x5575
leal -0x1(%r14), %eax
movl (%r12,%rax,4), %eax
movl %eax, 0xc(%rsp)
movslq %r14d, %rbp
movl (%r12,%rbp,4), %ebx
cmpl 0x4(%r12,%rbp,4), %ebx
jge 0x5911
movslq 0x38(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq (,%rbp,4), %rax
addq %rbp, %rax
incq %rbp
leaq 0x8f07(%rip), %rcx      # 0xe4b0
leaq (%rcx,%rax,8), %rdx
movq %rdx, 0x10(%rsp)
leaq (%rcx,%rax,8), %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
movl %r13d, %eax
notl %eax
movq %rax, 0x70(%rsp)
xorl %r15d, %r15d
movl $0x0, 0x24(%rsp)
movl $0x0, 0x1c(%rsp)
movl %r13d, 0x4c(%rsp)
movq %rbp, 0x68(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0x50(%rsp), %rdi
movl %ebx, %esi
callq 0x2e23
movl %ebx, 0x20(%rsp)
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x2, %rdx
testq %rcx, %rcx
je 0x570e
xorl %esi, %esi
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %ebp, %ebp
movl (%rax,%rsi,4), %edi
addl 0xc(%rsp), %edi
movq 0x38(%rsp), %r8
addl %ebp, %r8d
movslq %r8d, %r8
movq 0x40(%rsp), %r9
cmpl (%r9,%r8,4), %edi
jne 0x5662
leal 0x1(%rbp), %r8d
testl %ebp, %ebp
cmovel %r12d, %r15d
cmpl %r13d, %r8d
je 0x5715
movl %r8d, %ebp
jmp 0x56b9
testl %ebp, %ebp
je 0x56b7
movq %r14, %r13
movslq %ebp, %r14
cmpl $0x117, 0x20(%rsp)      # imm = 0x117
jne 0x568f
movq 0x30(%rsp), %rax
movl (%rax,%r14,4), %edx
leaq 0x2ad6(%rip), %rdi      # 0x815c
movl %ebp, %esi
xorl %eax, %eax
callq 0x2030
testl %r13d, %r13d
je 0x56cd
movq 0x40(%rsp), %rax
movq 0x80(%rsp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x3b6f
movq 0x30(%rsp), %rcx
subl (%rcx,%r14,4), %ebp
imull %eax, %ebp
jmp 0x56d6
xorl %ebp, %ebp
testl %r14d, %r14d
jle 0x56c8
callq 0x3b6f
addl %eax, %r12d
jmp 0x56e7
incl %r12d
jmp 0x56e7
movq 0x30(%rsp), %rcx
subl (%rcx,%r14,4), %ebp
addl %ebp, %r15d
movl (%rcx,%r14,4), %ebp
decl %ebx
movq %r13, %r14
movl 0x4c(%rsp), %r13d
incl %ebx
movslq %ebx, %rsi
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
ja 0x562d
movl %ebp, %r8d
jmp 0x5728
xorl %ebx, %ebx
xorl %r8d, %r8d
jmp 0x5734
movl %ebx, %edi
subl %r13d, %edi
incl %edi
movl %edi, 0x24(%rsp)
notl %esi
addl %edx, %esi
movl %esi, 0x1c(%rsp)
leaq 0x5bb1(%rip), %r12      # 0xb2e0
movq 0x68(%rsp), %rbp
cmpl %r13d, %r8d
jne 0x575e
incl 0x5cdd(%rip)            # 0xb41c
cmpl $0x0, 0x24(%rsp)
jle 0x57a3
movl %ebx, %ecx
subl %r13d, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
addl 0xc(%rsp), %ecx
movq 0x28(%rsp), %rdx
movl %ecx, (%rdx)
jmp 0x57ae
cmpl 0x920f(%rip), %r8d      # 0xe974
movl 0x20(%rsp), %ebx
jne 0x58ee
incl 0x5ca7(%rip)            # 0xb41c
leal 0x1(%r8), %esi
movslq %esi, %rdi
movslq %r8d, %rsi
cmpq %rdi, %rdx
jbe 0x5862
movq %rdx, %rdi
subq %rsi, %rdi
movl -0x8(%rax,%rdi,4), %edi
addl 0xc(%rsp), %edi
movq 0x10(%rsp), %r8
movl %edi, (%r8)
jmp 0x586d
movq 0x28(%rsp), %rcx
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
cmpl $0x2, 0x24(%rsp)
jl 0x57cf
movq 0x70(%rsp), %rcx
addl %ebx, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
addl 0xc(%rsp), %ecx
movq 0x10(%rsp), %rsi
movl %ecx, (%rsi)
jmp 0x57da
movq 0x10(%rsp), %rsi
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
movl %r15d, %ecx
subl 0x91ad(%rip), %ecx      # 0xe990
movl 0x20(%rsp), %edx
movl %edx, 0x8(%rsi)
movl %ecx, 0xc(%rsi)
movslq %ebx, %rcx
cmpl $0x0, 0x1c(%rsp)
jle 0x5804
movl 0x4(%rax,%rcx,4), %edx
addl 0xc(%rsp), %edx
movl %edx, 0x10(%rsi)
jmp 0x580b
movl $0xffffffff, 0x10(%rsi) # imm = 0xFFFFFFFF
cmpl $0x2, 0x1c(%rsp)
movl 0x20(%rsp), %ebx
jl 0x5828
movl 0x8(%rax,%rcx,4), %edx
addl 0xc(%rsp), %edx
movq 0x10(%rsp), %rsi
movl %edx, 0x14(%rsi)
jmp 0x5834
movq 0x10(%rsp), %rdx
movl $0xffffffff, 0x14(%rdx) # imm = 0xFFFFFFFF
cmpl $0x3, 0x1c(%rsp)
jl 0x584d
movl 0xc(%rax,%rcx,4), %eax
addl 0xc(%rsp), %eax
movq 0x10(%rsp), %rcx
movl %eax, 0x18(%rcx)
jmp 0x5859
movq 0x10(%rsp), %rcx
movl $0xffffffff, 0x18(%rcx) # imm = 0xFFFFFFFF
movl $0x3, 0x1c(%rcx)
jmp 0x58b2
movq 0x10(%rsp), %rdi
movl $0xffffffff, (%rdi)     # imm = 0xFFFFFFFF
cmpq %rsi, %rdx
jbe 0x5888
notq %rsi
addq %rcx, %rax
movl (%rax,%rsi,4), %eax
addl 0xc(%rsp), %eax
movq 0x28(%rsp), %rcx
movl %eax, (%rcx)
jmp 0x5893
movq 0x28(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rcx
movl %ebx, 0x8(%rcx)
movl %r15d, %eax
subl 0x90ec(%rip), %eax      # 0xe990
movl %eax, 0xc(%rcx)
movaps 0x2782(%rip), %xmm0     # 0x8030
movups %xmm0, 0x10(%rcx)
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
movq 0x78(%rsp), %r8
movq 0xc0(%rsp), %r9
pushq $0x1
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
callq 0x4dde
addq $0x20, %rsp
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x5905
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
incl %ebx
cmpl (%r12,%rbp,4), %ebx
jl 0x55e6
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x593f
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2220