// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movl %r8d, 0x1c(%rsp)
movl %ecx, %ebx
movq %rdx, 0x40(%rsp)
movq %rsi, %r15
movq %rdi, %r12
movl $0x0, 0x8(%rsp)
leaq 0x740f(%rip), %r13      # 0xa6a0
cmpl $0x2, %r9d
jl 0x32a4
leal -0x1(%r9), %eax
movl (%r13,%rax,4), %eax
movl %eax, 0x8(%rsp)
movslq %r9d, %r14
movslq (%r13,%r14,4), %rax
cmpl 0x4(%r13,%r14,4), %eax
jge 0x34d9
leaq (%r14,%r14,4), %rcx
incq %r14
leaq 0x6eab(%rip), %rdx      # 0xa170
leaq (%rdx,%rcx,8), %r9
movq %r9, 0x10(%rsp)
movl %ebx, 0xc(%rsp)
movq %r15, 0x28(%rsp)
movq %r12, 0x20(%rsp)
movq %r14, 0x38(%rsp)
movslq (%r15,%rax,4), %rsi
movslq 0x4(%r15,%rax,4), %rdi
movl 0x7344(%rip), %edx      # 0xa634
movl 0x734a(%rip), %ecx      # 0xa640
cmpl %edi, %esi
jge 0x3378
movq 0x740f(%rip), %r8       # 0xa710
movl 0x7330(%rip), %r9d      # 0xa638
addl %edx, %ecx
movl 0x731f(%rip), %r10d     # 0xa630
addl %ebx, %r10d
leaq -0x1(%rcx), %r11
movq %rdx, 0x30(%rsp)
leaq -0x1(%rdx), %rbp
leaq (%r12,%rsi,4), %r12
incq %rsi
xorl %r13d, %r13d
movl (%r12,%r13,4), %edx
addl 0x8(%rsp), %edx
leal (%r10,%r13), %r14d
movslq %r14d, %r14
cmpl (%r8,%r14,4), %edx
jne 0x337f
cmpl $0x1, %r9d
setne %r15b
cmpl $-0x1, %r9d
setne %dl
leaq 0x1(%r13), %r14
cmpq %r13, %rbp
setne %bl
orb %dl, %bl
cmpq %r13, %r11
setne %dl
cmpb $0x1, %bl
jne 0x3382
orb %dl, %r15b
je 0x3382
addq %rsi, %r13
cmpq %rdi, %r13
movq %r14, %r13
jl 0x332b
jmp 0x3382
addl %edx, %ecx
xorl %r14d, %r14d
jmp 0x33a1
xorl %r14d, %r14d
movl 0xc(%rsp), %ebx
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r12
leaq 0x7309(%rip), %r13      # 0xa6a0
movq 0x10(%rsp), %r9
movq 0x30(%rsp), %rdx
leaq 0x1(%rax), %rbp
cmpl %ecx, %r14d
jne 0x3443
incl 0x7338(%rip)            # 0xa6ec
movq $-0x1, (%r9)
movl %eax, 0x8(%r9)
xorl %edx, %edx
subl 0x7345(%rip), %edx      # 0xa70c
movl %edx, 0xc(%r9)
movl (%r15,%rbp,4), %r8d
movl (%r15,%rax,4), %esi
addl %ecx, %esi
subl %esi, %r8d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
testl %r8d, %r8d
jle 0x33f2
movslq %esi, %rsi
movl (%r12,%rsi,4), %edi
addl 0x8(%rsp), %edi
movl %edi, 0x10(%r9)
movl (%r15,%rbp,4), %edi
movl (%r15,%rax,4), %esi
addl %ecx, %esi
subl %esi, %edi
cmpl $0x2, %edi
movq 0x38(%rsp), %r14
jl 0x3418
movslq %esi, %rdx
movl 0x4(%r12,%rdx,4), %edx
addl 0x8(%rsp), %edx
movl %edx, 0x14(%r9)
movl (%r15,%rbp,4), %esi
addl (%r15,%rax,4), %ecx
subl %ecx, %esi
movl $0x2, %eax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $0x3, %esi
jl 0x3478
movslq %ecx, %rcx
movl 0x8(%r12,%rcx,4), %edx
addl 0x8(%rsp), %edx
jmp 0x3478
cmpl %edx, %r14d
movq 0x38(%rsp), %r14
jne 0x34c8
incl 0x7299(%rip)            # 0xa6ec
movq $-0x1, %rdx
movq %rdx, (%r9)
movl %eax, 0x8(%r9)
xorl %ecx, %ecx
subl 0x72a3(%rip), %ecx      # 0xa70c
xorl %eax, %eax
movl %ecx, 0xc(%r9)
movq %rdx, 0x10(%r9)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, 0x18(%r9)
movl %eax, 0x1c(%r9)
movq %r12, %rdi
movq %r15, %rsi
movq 0x40(%rsp), %rdx
movl %ebx, %ecx
movl 0x1c(%rsp), %r8d
movl %r14d, %r9d
pushq $0x1
pushq 0xb0(%rsp)
pushq 0xb0(%rsp)
pushq 0xb0(%rsp)
pushq 0xb0(%rsp)
pushq 0xb0(%rsp)
callq 0x2c37
movq 0x40(%rsp), %r9
addq $0x30, %rsp
movslq (%r13,%r14,4), %rcx
movq %rbp, %rax
cmpq %rcx, %rbp
jl 0x32e1
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq