// File: /workspace/github_cpp_makefile_star2_O3/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, 0x70(%rsp)
movq %r8, 0x48(%rsp)
movl %edx, 0x8(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x30(%rsp)
xorl %eax, %eax
leaq 0x5e38(%rip), %rdx      # 0xb2e0
cmpl $0x2, %ecx
jl 0x54b3
leal -0x1(%rcx), %eax
movl (%rdx,%rax,4), %eax
movl %eax, 0xc(%rsp)
movq %rcx, 0x20(%rsp)
movslq %ecx, %rcx
movl (%rdx,%rcx,4), %ebp
cmpl 0x4(%rdx,%rcx,4), %ebp
jge 0x58c2
movq %rcx, %rax
movslq 0x28(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movq %rax, %rcx
leaq (%rax,%rax,4), %rax
incq %rcx
movq %rcx, 0x40(%rsp)
leaq 0x8fbe(%rip), %rcx      # 0xe4b0
leaq (%rcx,%rax,8), %r14
movl 0x8(%rsp), %eax
notl %eax
movq %rax, 0x78(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x14(%rsp)
movq %r14, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
callq 0x2d93
movl %ebp, 0x18(%rsp)
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %r13
movq %r13, %rax
subq %rbx, %rax
je 0x5669
sarq $0x2, %rax
xorl %ecx, %ecx
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x20(%rsp), %rsi
movl 0xc(%rsp), %r9d
movl (%rbx,%rcx,4), %edi
addl %r9d, %edi
movq 0x28(%rsp), %rdx
addl %r14d, %edx
movslq %edx, %rdx
movq 0x30(%rsp), %r8
cmpl (%r8,%rdx,4), %edi
jne 0x55a7
leal 0x1(%r14), %r15d
testl %r14d, %r14d
movl 0x10(%rsp), %edx
cmovel %ebp, %edx
movl %edx, 0x10(%rsp)
cmpl 0x8(%rsp), %r15d
jne 0x560a
jmp 0x5759
testl %r14d, %r14d
je 0x5607
movslq %r14d, %rbx
cmpl $0x117, 0x18(%rsp)      # imm = 0x117
jne 0x55d7
movq 0x48(%rsp), %rax
movl (%rax,%rbx,4), %edx
leaq 0x2bc4(%rip), %rdi      # 0x818c
movl %r14d, %esi
xorl %eax, %eax
callq 0x2030
movq 0x20(%rsp), %rsi
testl %esi, %esi
je 0x5625
movq 0x30(%rsp), %rax
movq 0x80(%rsp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x3a9f
movq 0x20(%rsp), %rsi
movq 0x48(%rsp), %rcx
movl (%rcx,%rbx,4), %r15d
subl %r15d, %r14d
imull %eax, %r14d
jmp 0x5631
xorl %r15d, %r15d
testl %esi, %esi
jle 0x5621
callq 0x3a9f
movl 0xc(%rsp), %r9d
movq 0x20(%rsp), %rsi
addl %eax, %ebp
jmp 0x5648
incl %ebp
jmp 0x5648
movq 0x48(%rsp), %rax
movl (%rax,%rbx,4), %r15d
subl %r15d, %r14d
movl 0xc(%rsp), %r9d
addl %r14d, 0x10(%rsp)
decl %r12d
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %r13
incl %r12d
movslq %r12d, %rcx
movq %r13, %rdx
subq %rbx, %rdx
movq %rdx, %rax
sarq $0x2, %rax
movl %r15d, %r14d
cmpq %rcx, %rax
ja 0x556d
jmp 0x5678
xorl %r12d, %r12d
xorl %edx, %edx
xorl %eax, %eax
xorl %r15d, %r15d
movl 0xc(%rsp), %r9d
cmpl 0x8(%rsp), %r15d
jne 0x5695
movl 0x18(%rsp), %ebp
movq 0x38(%rsp), %r14
movl 0x1c(%rsp), %edx
movl 0x14(%rsp), %esi
jmp 0x5771
cmpl 0x92d8(%rip), %r15d     # 0xe974
movl 0x18(%rsp), %ebp
movq 0x38(%rsp), %r14
jne 0x57ae
incl 0x5d6b(%rip)            # 0xb41c
leal 0x1(%r15), %ecx
movslq %ecx, %r8
movslq %r15d, %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpq %r8, %rax
jbe 0x56d7
movq %rax, %rdi
subq %rsi, %rdi
movl -0x8(%rbx,%rdi,4), %edi
addl %r9d, %edi
movl %edi, (%r14)
cmpq %rsi, %rax
jbe 0x56eb
notq %rsi
addq %rdx, %rbx
movl (%rbx,%rsi,4), %ecx
addl %r9d, %ecx
movl %ecx, 0x4(%r14)
movl %ebp, 0x8(%r14)
movl 0x10(%rsp), %eax
subl 0x9293(%rip), %eax      # 0xe990
movl %eax, 0xc(%r14)
movaps 0x2918(%rip), %xmm0     # 0x8020
movups %xmm0, 0x10(%r14)
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x8(%rsp), %edx
movq 0x40(%rsp), %rcx
movq 0x70(%rsp), %r8
movq 0xc0(%rsp), %r9
pushq $0x1
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
callq 0x4d40
addq $0x20, %rsp
leaq 0x5b8c(%rip), %rbx      # 0xb2e0
jmp 0x5887
movl %r12d, %edx
subl 0x8(%rsp), %edx
incl %edx
notl %ecx
addl %ecx, %eax
movl %eax, %esi
movl 0x18(%rsp), %ebp
movq 0x38(%rsp), %r14
incl 0x5ca5(%rip)            # 0xb41c
testl %edx, %edx
jle 0x579f
movl %r12d, %eax
subl 0x8(%rsp), %eax
cltq
movl (%rbx,%rax,4), %eax
addl %r9d, %eax
movl %eax, 0x4(%r14)
cmpl $0x1, %edx
jne 0x57ba
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %edx
jmp 0x57ca
movl $0xffffffff, 0x4(%r14)  # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x57ca
leaq 0x5b2b(%rip), %rbx      # 0xb2e0
jmp 0x5887
movq 0x78(%rsp), %rax
addl %r12d, %eax
cltq
movl (%rbx,%rax,4), %eax
addl %r9d, %eax
movl %eax, (%r14)
movl %ebp, 0x8(%r14)
movl 0x10(%rsp), %eax
subl 0x91b5(%rip), %eax      # 0xe990
movl %eax, 0xc(%r14)
testl %esi, %esi
movl %edx, 0x1c(%rsp)
jle 0x581b
movslq %r12d, %rax
movl 0x4(%rbx,%rax,4), %ecx
addl %r9d, %ecx
movl %ecx, 0x10(%r14)
cmpl $0x1, %esi
je 0x5823
movl 0x8(%rbx,%rax,4), %ecx
addl %r9d, %ecx
movl %ecx, 0x14(%r14)
cmpl $0x3, %esi
jb 0x58b0
movl %esi, 0x14(%rsp)
movl 0xc(%rbx,%rax,4), %eax
addl %r9d, %eax
jmp 0x5834
movl $0xffffffff, 0x10(%r14) # imm = 0xFFFFFFFF
movl %esi, 0x14(%rsp)
movl $0xffffffff, 0x14(%r14) # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x18(%r14)
movl $0x3, 0x1c(%r14)
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x8(%rsp), %edx
movq 0x40(%rsp), %rcx
movq 0x70(%rsp), %r8
movq 0xc0(%rsp), %r9
pushq $0x1
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
callq 0x4d40
addq $0x20, %rsp
leaq 0x5a59(%rip), %rbx      # 0xb2e0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x589e
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
incl %ebp
movq 0x40(%rsp), %rax
cmpl (%rbx,%rax,4), %ebp
jl 0x551e
jmp 0x58c2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x2, 0x14(%rsp)
jmp 0x5834
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 0x58f0
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2220