// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movl %r8d, 0x14(%rsp)
movl %ecx, %r14d
movq %rdx, 0x30(%rsp)
movq %rsi, %r15
movq %rdi, %r13
xorl %ebx, %ebx
leaq 0x725c(%rip), %rcx      # 0xa6a0
cmpl $0x2, %r9d
jl 0x3451
leal -0x1(%r9), %eax
movl (%rcx,%rax,4), %ebx
movslq %r9d, %rdi
movslq (%rcx,%rdi,4), %rax
cmpl 0x4(%rcx,%rdi,4), %eax
jge 0x369e
leaq (%rdi,%rdi,4), %rcx
incq %rdi
leaq 0x6d00(%rip), %rdx      # 0xa170
leaq (%rdx,%rcx,8), %rcx
movq %rcx, 0x28(%rsp)
movq %rdi, 0x8(%rsp)
movl %r14d, 0x4(%rsp)
movq %r15, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movslq (%r15,%rax,4), %rdx
movslq 0x4(%r15,%rax,4), %rsi
movl $0x0, %r12d
cmpl %esi, %edx
jge 0x354c
movq 0x7265(%rip), %rdi      # 0xa710
movl 0x7186(%rip), %r8d      # 0xa638
movl 0x717b(%rip), %r9d      # 0xa634
movl 0x7180(%rip), %r10d     # 0xa640
addl %r9d, %r10d
movl 0x7166(%rip), %r11d     # 0xa630
addl %r14d, %r11d
decq %r10
decq %r9
leaq (,%rdx,4), %rbp
addq %r13, %rbp
incq %rdx
xorl %ecx, %ecx
movl (%rbp,%rcx,4), %r14d
addl %ebx, %r14d
leal (%r11,%rcx), %r12d
movslq %r12d, %r12
cmpl (%rdi,%r12,4), %r14d
jne 0x3535
cmpl $0x1, %r8d
setne %r13b
cmpl $-0x1, %r8d
setne %r14b
leaq 0x1(%rcx), %r12
cmpq %rcx, %r9
setne %r15b
orb %r14b, %r15b
cmpq %rcx, %r10
setne %r14b
cmpb $0x1, %r15b
jne 0x3538
orb %r14b, %r13b
je 0x3538
addq %rdx, %rcx
cmpq %rsi, %rcx
movq %r12, %rcx
jl 0x34e3
jmp 0x3538
xorl %r12d, %r12d
movl 0x4(%rsp), %r14d
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r13
movq 0x8(%rsp), %rdi
leaq 0x1(%rax), %rbp
movl 0x70de(%rip), %ecx      # 0xa634
movl 0x70e4(%rip), %edx      # 0xa640
addl %ecx, %edx
cmpl %edx, %r12d
jne 0x35a3
incl 0x7183(%rip)            # 0xa6ec
movq 0x28(%rsp), %rsi
movq $-0x1, (%rsi)
movl %eax, 0x8(%rsi)
xorl %ecx, %ecx
subl 0x718c(%rip), %ecx      # 0xa70c
movl %ecx, 0xc(%rsi)
movl (%r15,%rbp,4), %edx
movl (%r15,%rax,4), %ecx
addl %r12d, %ecx
subl %ecx, %edx
testl %edx, %edx
jle 0x35e0
movslq %ecx, %rcx
movl (%r13,%rcx,4), %ecx
addl %ebx, %ecx
movl %ecx, 0x10(%rsi)
jmp 0x35e7
cmpl %ecx, %r12d
leaq 0x70f3(%rip), %r12      # 0xa6a0
jne 0x368e
incl 0x7133(%rip)            # 0xa6ec
movq 0x28(%rsp), %rcx
movq $-0x1, (%rcx)
movl %eax, 0x8(%rcx)
xorl %eax, %eax
subl 0x713c(%rip), %eax      # 0xa70c
movl %eax, 0xc(%rcx)
movaps 0x2a36(%rip), %xmm0     # 0x6010
movups %xmm0, 0x10(%rcx)
jmp 0x3643
movl $0xffffffff, 0x10(%rsi) # imm = 0xFFFFFFFF
movl (%r15,%rbp,4), %edx
movl (%r15,%rax,4), %ecx
addl %r12d, %ecx
subl %ecx, %edx
cmpl $0x2, %edx
jl 0x3608
movslq %ecx, %rcx
movl 0x4(%r13,%rcx,4), %ecx
addl %ebx, %ecx
movl %ecx, 0x14(%rsi)
jmp 0x360f
movl $0xffffffff, 0x14(%rsi) # imm = 0xFFFFFFFF
movl (%r15,%rbp,4), %ecx
addl (%r15,%rax,4), %r12d
subl %r12d, %ecx
cmpl $0x3, %ecx
jl 0x362e
movslq %r12d, %rax
movl 0x8(%r13,%rax,4), %eax
addl %ebx, %eax
movl %eax, 0x18(%rsi)
jmp 0x3635
movl $0xffffffff, 0x18(%rsi) # imm = 0xFFFFFFFF
leaq 0x7064(%rip), %r12      # 0xa6a0
movl $0x2, 0x1c(%rsi)
movq %r13, %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
movl %r14d, %ecx
movl 0x14(%rsp), %r8d
movq 0x8(%rsp), %r9
pushq $0x1
pushq 0xa0(%rsp)
pushq 0xa0(%rsp)
pushq 0xa0(%rsp)
pushq 0xa0(%rsp)
pushq 0xa0(%rsp)
callq 0x2e6e
movq 0x38(%rsp), %rdi
addq $0x30, %rsp
movslq (%r12,%rdi,4), %rcx
movq %rbp, %rax
cmpq %rcx, %rbp
jl 0x348d
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq