// File: /workspace/github_cpp_makefile_star2_O2/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: findAB(unsigned int*, int*, int*, int, int, int, int*, int*, int*, int*, int*, int*)
int findAB(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){
    //printf("\nAコアがある場合の[");
    //for(int i2 = 0;i2<coredata[5];i2++){printf("%d ",m[startm+coredata[4]+i2]);}
    //printf("]Bを探す(round %d)\nkmpc = ",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 bs = 0; //コアが完全一致した時，どこまで戻るか
    //int fis = -1;
    int i = 0;
    int tg = 0;
    int ofs = 0;
    //int kpofs = 0;
    //int e2[2];
    for(int y8=dc2s[round];y8<dc2s[round+1];y8++){
        //printf("\n[%d(%d)]",y8,D_2[y8+1]-D_2[y8]);
        ofs=0;tg = 0;
        for(int y9=D_2[y8];y9<D_2[y8+1];y9++){
            //printf(" %d",rofs+D[y9]);
            if(rofs+D[y9]==m[startm+coredata[4]+tg]){ //coredata[4]だけずらす
            tg++;
            }else{tg=0;break;}//先頭からしか見ないので不一致が会ったら即forを脱出する
            if(coredata[6]==-1 && tg==coredata[5]){break;} //Cコアがないなら，B判定でbreak
            if(coredata[6]==1 && tg==coredata[5]+coredata[8]){break;} //Cコアがあり，5+8ならbreak
            
        }
        //printf(" / 一致数%d(出現)[%d+%d]",tg,coredata[5],coredata[8]);
        if(tg==coredata[5]+coredata[8]){ //Cコアがある場合は最後にBCコア，そうでない場合はBコアが出現
            //printf("\n(BC出現[%d / %d])",tg,D_2[y8+1]-D_2[y8]);
            coreans++;
            occart2[round][0] = -1;
            occart2[round][1] = -1;
            occart2[round][2] = y8;
            occart2[round][3] = -ocofs; //先頭から出現するのでずれなし
            if(D_2[y8+1]-D_2[y8]-tg>0){occart2[round][4] = rofs+D[D_2[y8]+tg];}else{occart2[round][4] = -1;}
            if(D_2[y8+1]-D_2[y8]-tg>1){occart2[round][5] = rofs+D[D_2[y8]+tg+1];}else{occart2[round][5] = -1;}
            if(D_2[y8+1]-D_2[y8]-tg>2){occart2[round][6] = rofs+D[D_2[y8]+tg+2];}else{occart2[round][6] = -1;}
            if(coredata[6]==1){
                occart2[round][7] = 2;
                //printf("\n(BC出現[%d / %d])",tg,D_2[y8+1]-D_2[y8]);
            } //Cコアがあるなら，BC発見にする
            else{
                //printf("\n(B出現[%d])[Cなし]",tg);
                occart2[round][7] = 2; //B発見(Aはまだ)
            }
            //for(int i = 0;i<10;i++){printf("[%d]",occart2[round][i]);}
            //exit(2);
            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])",tg);
            coreans++;
            occart2[round][0] = -1;
            occart2[round][1] = -1;
            occart2[round][2] = y8;
            occart2[round][3] = -ocofs; //先頭から出現するのでずれなし + コアと出現位置のズレ + Aコアのずれを補正
            occart2[round][4] = -1;
            occart2[round][5] = -1;
            occart2[round][6] = -1;
            occart2[round][7] = 0; //Bのみ発見(Aはまだ)
            //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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, 0xc(%rsp)
movl %ecx, 0x8(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
movq $0x0, (%rsp)
leaq 0x6610(%rip), %r15      # 0x96a0
cmpl $0x2, %r9d
jl 0x30a2
leal -0x1(%r9), %eax
movl (%r15,%rax,4), %eax
movq %rax, (%rsp)
movslq %r9d, %rax
movslq (%r15,%rax,4), %r13
incl %r9d
movq %r9, 0x20(%rsp)
movslq %r9d, %rcx
movq %rcx, 0x38(%rsp)
imulq $0x28, %rax, %rax
leaq 0x60ac(%rip), %r12      # 0x9170
addq %rax, %r12
movq %rbx, 0x10(%rsp)
movq %r14, 0x30(%rsp)
movq %r12, 0x28(%rsp)
movq 0x38(%rsp), %rcx
movslq (%r15,%rcx,4), %rcx
cmpq %rcx, %r13
jge 0x32d1
movq %r13, %rax
movslq (%rbx,%r13,4), %rsi
leaq 0x1(%r13), %rcx
movq %rcx, 0x50(%rsp)
movslq 0x4(%rbx,%r13,4), %rdi
movq 0x660c(%rip), %r8       # 0x9710
movl 0x652d(%rip), %r9d      # 0x9638
movl 0x6523(%rip), %edx      # 0x9634
movl 0x6529(%rip), %ecx      # 0x9640
addl %edx, %ecx
leaq (%r14,%rsi,4), %r10
movl 0x650c(%rip), %r11d     # 0x9630
addl 0x8(%rsp), %r11d
movq %rcx, 0x48(%rsp)
leaq -0x1(%rcx), %r14
pushq $0x1
popq %r15
movq %rdx, 0x40(%rsp)
subq %rdx, %r15
xorl %r13d, %r13d
leaq (%rsi,%r13), %rdx
cmpq %rdi, %rdx
jge 0x3190
movl (%r10,%r13,4), %edx
addl (%rsp), %edx
leal (%r11,%r13), %ebx
movslq %ebx, %rbx
cmpl (%r8,%rbx,4), %edx
jne 0x3195
cmpl $0x1, %r9d
sete %r12b
cmpl $-0x1, %r9d
sete %bpl
leaq 0x1(%r13), %rbx
movq %r15, %rdx
addq %r13, %rdx
sete %cl
cmpq %r13, %r14
sete %dl
testb %cl, %bpl
jne 0x3197
movq %rbx, %r13
andb %dl, %r12b
je 0x3141
jmp 0x3197
movl %r13d, %ebx
jmp 0x3197
xorl %ebx, %ebx
movq 0x48(%rsp), %rdi
cmpl %edi, %ebx
movq 0x30(%rsp), %r14
leaq 0x64f6(%rip), %r15      # 0x96a0
movq 0x28(%rsp), %r12
movq 0x50(%rsp), %r13
jne 0x3244
incl 0x652c(%rip)            # 0x96ec
orq $-0x1, (%r12)
xorl %ecx, %ecx
subl 0x653f(%rip), %ecx      # 0x970c
movl %eax, 0x8(%r12)
movl %ecx, 0xc(%r12)
movq 0x10(%rsp), %rbx
movl 0x4(%rbx,%rax,4), %ecx
movl (%rbx,%rax,4), %edx
addl %edi, %edx
subl %edx, %ecx
pushq $-0x1
popq %rsi
testl %ecx, %ecx
jle 0x31f8
movslq %edx, %rcx
movl (%r14,%rcx,4), %esi
addl (%rsp), %esi
movl %esi, 0x10(%r12)
movl 0x4(%rbx,%rax,4), %ecx
movl (%rbx,%rax,4), %edx
addl %edi, %edx
subl %edx, %ecx
pushq $-0x1
popq %rsi
cmpl $0x2, %ecx
jl 0x321b
movslq %edx, %rcx
movl 0x4(%r14,%rcx,4), %esi
addl (%rsp), %esi
movl %esi, 0x14(%r12)
movl 0x4(%rbx,%rax,4), %ecx
addl (%rbx,%rax,4), %edi
subl %edi, %ecx
pushq $-0x1
popq %rdx
pushq $0x2
popq %rax
cmpl $0x3, %ecx
jl 0x327b
movslq %edi, %rax
movl 0x8(%r14,%rax,4), %edx
addl (%rsp), %edx
pushq $0x2
popq %rax
jmp 0x327b
cmpl 0x40(%rsp), %ebx
movq 0x10(%rsp), %rbx
jne 0x30d6
incl 0x6493(%rip)            # 0x96ec
orq $-0x1, (%r12)
movl %eax, 0x8(%r12)
xorl %eax, %eax
xorl %ecx, %ecx
subl 0x649f(%rip), %ecx      # 0x970c
movl %ecx, 0xc(%r12)
orq $-0x1, 0x10(%r12)
pushq $-0x1
popq %rdx
movl %edx, 0x18(%r12)
movl %eax, 0x1c(%r12)
movq %r14, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
movl 0x8(%rsp), %ecx
movl 0xc(%rsp), %r8d
movq 0x20(%rsp), %r9
pushq $0x1
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
callq 0x2aba
addq $0x30, %rsp
jmp 0x30d6
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq