// File: TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: findB(unsigned int*, int*, int*, int, int, int, int*, int*, int*, int*, int*, int*)
int findB(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){ //列から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;
        for(y9=D_2[y8];y9<D_2[y8+1];y9++){
            if(rofs+D[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-D_2[y8],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-D_2[y8]+1 - mrlen; //手前に残ってる文字数
                    bsp[2] = D_2[y8+1]-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+=D_3[m[startm]]*(tg - kmpc[tg]);}
                    tg = kmpc[tg];y9--;continue;}
                tg=0;
            }
            //printf(" %d",rofs+D[y9]);
            if(round>0){ofs+=D_3[rofs+D[y9]];}else{ofs++;}
        }
        //if(fis>0){printf("(左に右出現[%d文字])",fis);} //先頭から出現
        if(tg==mrlen){ //完全一致して抜けてきたやつ(A・Cコアが確実にない)
                coreans++;
                if(bsp[1]>0){occart2[round][1] = rofs+D[y9-mrlen];}else{occart2[round][1] = -1;}
                if(bsp[1]>1){occart2[round][0] = rofs+D[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+D[y9+1];}else{occart2[round][4] = -1;}
                if(bsp[2]>1){occart2[round][5] = rofs+D[y9+2];}else{occart2[round][5] = -1;}
                if(bsp[2]>2){occart2[round][6] = rofs+D[y9+3];}else{occart2[round][6] = -1;}
                occart2[round][7] = 3; //ABC全部発見 
                //transk==0なら，findinroundに行っても良いはず
                if(DEBUGFLAG==1){
                    printf("\nチェック：");
                    for(int i = 0;i<10;i++){printf("[%d]",occart2[round][i]);}
                }
                findups(D,D_2,D_3,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(D_2[y8+1]-D_2[y8]>tg+1){occart2[round][0] = rofs+D[D_2[y8+1]-2-tg];}else{occart2[round][0] = -1;}
                if(D_2[y8+1]-D_2[y8]>tg){occart2[round][1] = rofs+D[D_2[y8+1]-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(D,D_2,D_3,startm,mrlen,round+1,B1,B2,B3,Ls,Rs,1); //その不完全なコアの出現を探す
            }
        }
    }
    //printf("\nend of searching.(%d)[%d]",len,i);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x80, %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, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movl %ecx, -0x2c(%rbp)
movl %r8d, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x1, -0x34(%rbp)
jle 0x5c37
movl -0x34(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x7a7f(%rip), %rax      # 0xd6b0
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x20c0
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movslq -0x34(%rbp), %rcx
leaq 0x7a42(%rip), %rax      # 0xd6b0
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rdx
leaq 0x7a29(%rip), %rcx      # 0xd6b0
cmpl (%rcx,%rdx,4), %eax
jge 0x6260
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
movl -0x60(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x5e28
movl -0x3c(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movq 0x7a46(%rip), %rcx      # 0xd720
movl -0x2c(%rbp), %edx
addl -0x50(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x5d52
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
cmpl $0x1, -0x50(%rbp)
jne 0x5cfd
movl -0x54(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x50(%rbp), %eax
cmpl 0x793e(%rip), %eax      # 0xd644
jne 0x5d0a
jmp 0x5d0a
movl -0x50(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x5d4d
movl -0x5c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
movslq -0x60(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
addl $0x1, %eax
subl -0x30(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x20(%rbp), %rax
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
subl -0x5c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x5e28
jmp 0x5dea
cmpl $0x0, -0x50(%rbp)
je 0x5de3
cmpl $0x117, -0x60(%rbp)     # imm = 0x117
jne 0x5d81
movl -0x50(%rbp), %esi
movq 0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x340e(%rip), %rdi      # 0x9188
movb $0x0, %al
callq 0x2030
cmpl $0x0, -0x34(%rbp)
jne 0x5d9d
movl -0x50(%rbp), %eax
movq 0x10(%rbp), %rcx
movslq -0x50(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x5dca
movq -0x28(%rbp), %rax
movq 0x7978(%rip), %rcx      # 0xd720
movslq -0x2c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
movl -0x50(%rbp), %ecx
movq 0x10(%rbp), %rdx
movslq -0x50(%rbp), %rsi
subl (%rdx,%rsi,4), %ecx
imull %ecx, %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movq 0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x50(%rbp)
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x5e1a
movl $0x0, -0x50(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x5e0f
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rdx
movslq -0x5c(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x5e18
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x5e1a
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x5cac
movl -0x50(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x6059
movl 0x78c2(%rip), %eax      # 0xd6fc
addl $0x1, %eax
movl %eax, 0x78b9(%rip)      # 0xd6fc
cmpl $0x0, -0x44(%rbp)
jle 0x5e73
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl -0x5c(%rbp), %edx
subl -0x30(%rbp), %edx
movslq %edx, %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x7319(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x5e8c
movslq -0x34(%rbp), %rcx
leaq 0x7302(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
cmpl $0x1, -0x44(%rbp)
jle 0x5ebe
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl -0x5c(%rbp), %edx
subl -0x30(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x72cd(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
jmp 0x5ed6
movslq -0x34(%rbp), %rcx
leaq 0x72b7(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl -0x60(%rbp), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x729c(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x58(%rbp), %ecx
subl 0x7825(%rip), %ecx      # 0xd71c
movslq -0x34(%rbp), %rdx
leaq 0x727e(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
cmpl $0x0, -0x40(%rbp)
jle 0x5f3c
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl -0x5c(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x7250(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
jmp 0x5f55
movslq -0x34(%rbp), %rcx
leaq 0x7239(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
cmpl $0x1, -0x40(%rbp)
jle 0x5f85
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl -0x5c(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x7207(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
jmp 0x5f9e
movslq -0x34(%rbp), %rcx
leaq 0x71f0(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x14(%rax) # imm = 0xFFFFFFFF
cmpl $0x2, -0x40(%rbp)
jle 0x5fce
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl -0x5c(%rbp), %edx
addl $0x3, %edx
movslq %edx, %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x71be(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x18(%rax)
jmp 0x5fe7
movslq -0x34(%rbp), %rcx
leaq 0x71a7(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movslq -0x34(%rbp), %rcx
leaq 0x718e(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0x3, 0x1c(%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
movl -0x34(%rbp), %r9d
addl $0x1, %r9d
movq 0x18(%rbp), %r14
movq 0x20(%rbp), %rbx
movq 0x28(%rbp), %r11
movq 0x30(%rbp), %r10
movq 0x38(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl $0x1, 0x28(%rsp)
callq 0x4e60
jmp 0x6250
movl -0x50(%rbp), %eax
cmpl 0x75e2(%rip), %eax      # 0xd644
jne 0x624e
movl 0x768e(%rip), %eax      # 0xd6fc
addl $0x1, %eax
movl %eax, 0x7685(%rip)      # 0xd6fc
movq -0x20(%rbp), %rax
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movslq -0x60(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
movl -0x50(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x60d5
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rdx
movl -0x60(%rbp), %esi
addl $0x1, %esi
movslq %esi, %rsi
movl (%rdx,%rsi,4), %edx
subl $0x2, %edx
subl -0x50(%rbp), %edx
movslq %edx, %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x70b6(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
jmp 0x60ed
movslq -0x34(%rbp), %rcx
leaq 0x70a0(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movslq -0x60(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
cmpl -0x50(%rbp), %eax
jle 0x6147
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rdx
movl -0x60(%rbp), %esi
addl $0x1, %esi
movslq %esi, %rsi
movl (%rdx,%rsi,4), %edx
subl $0x1, %edx
subl -0x50(%rbp), %edx
movslq %edx, %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x7045(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x6160
movslq -0x34(%rbp), %rcx
leaq 0x702e(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movl -0x60(%rbp), %ecx
movslq -0x34(%rbp), %rdx
leaq 0x7012(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x58(%rbp), %ecx
subl 0x759b(%rip), %ecx      # 0xd71c
movslq -0x34(%rbp), %rdx
leaq 0x6ff4(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movslq -0x34(%rbp), %rcx
leaq 0x6fdf(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movslq -0x34(%rbp), %rcx
leaq 0x6fc6(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x14(%rax) # imm = 0xFFFFFFFF
movslq -0x34(%rbp), %rcx
leaq 0x6fad(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movslq -0x34(%rbp), %rcx
leaq 0x6f94(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x1c(%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
movl -0x34(%rbp), %r9d
addl $0x1, %r9d
movq 0x18(%rbp), %r14
movq 0x20(%rbp), %rbx
movq 0x28(%rbp), %r11
movq 0x30(%rbp), %r10
movq 0x38(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl $0x1, 0x28(%rsp)
callq 0x4e60
jmp 0x6250
jmp 0x6252
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x5c74
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop