// File: /workspace/github_cpp_makefile_star2_O3/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: findups(unsigned int*, int*, int*, int, int, int, int*, int*, int*, int*, int*, int)
int findups(unsigned int *D,int *D_2,int *D_3,int startm,int mrlen,int round,int *B1,int *B2,int *B3,int *Ls,int *Rs,int count){
    if(DEBUGFLAG==1){
        printf("\n[%d]を探す(round %d / %d)",occart2[round-1][2],round,fround);
        alldr(D,D_2,D_3,occart2[round-1][2],round-1);
        for(int i = 0; i<10; i++){printf("[%d]",occart2[round-1][i]);}
    }
    //1つroundが下の場所でBコアが発見できたものをXとする．
    //Xを探し，その左右のデータを追加するのがこの仕事．
    //count回分だけ下の文字を2-3個揃えるのが仕事．
    if(round==fround){return findupsintop(D,D_2,D_3,startm,mrlen,B1,B2,B3,Ls,Rs,count);}
    int rofs=0;
    if(round>1){rofs=dc2s[round-1];}
    for(int y8=dc2s[round];y8<dc2s[round+1];y8++){
        //printf("\n[%d(%d)]",y8,D_2[y8+1]-D_2[y8]);
        //int tg = 0;
        int ofs = 0;
        for(int y9=D_2[y8];y9<D_2[y8+1];y9++){
            //printf(" %d",rofs+D[y9]);
            if(rofs+D[y9]==occart2[round-1][2]){ //該当する1文字を見つけたら
                gate++;
                if(DEBUGFLAG==1){
                     printf("\n[%dの%d文字目に発見(+%d)]",y8,y9-D_2[y8],ofs);
                }
                //coreans++;
                //左がないなら左を探す(このroundで1つ見つかれば良い)
                for(int i = 0; i<10; i++){occart2[round][i] = occart2[round-1][i];} //コアを見つけたら下階層からゲット
                if(y9==D_2[y8] || occart2[round-1][0]>-1){ //先頭にないか，左[0]が埋まっているなら左は追加できない
                }
                else{ 
                    if(occart2[round][1] == -1){ //2つとも埋まっていないなら
                        occart2[round][1] = rofs+D[y9-1];
                        if(D_2[y8]+1<y9){occart2[round][0] = rofs+D[y9-2];}
                        //printf("\n[%d]記入数 %d %d",y9-D_2[y8],occart2[round][0],occart2[round][1]);
                        if(occart2[round][7]%2==0){
                            if(coreAcheck(D,D_2,round-1,count,round,startm)==-1){
                                 if(DEBUGFLAG==1){printf("Aミスマッチ");}
                                continue;
                            }
                            else{occart2[round][7]++;} //1文字少なくとも入れたはずだし0が帰ってきていれば必ずAコアは調べ終わっている
                        }
                        else{leftopennd(D,D_2,D_3,round-1,count,round);}
                    }
                    else{ //1つ埋まっていないなら
                        occart2[round][0] = rofs+D[y9-1];
                        leftopen(D,D_2,D_3,round-1,count,round);
                    }
                }
                //printf("\n演算[%d = %d][%d]",y9+1,D_2[y8],occart2[round-1][6]);
                if(y9+1<D_2[y8+1] && occart2[round-1][6]==-1){ //右があり，右が埋まっていないなら
                    if(occart2[round][5]==-1){ //2文字埋まってないなら
                        if(occart2[round][4]==-1){ //3文字埋まってないなら
                            occart2[round][4] = rofs+D[y9+1];
                            if(y9+2<D_2[y8+1]){occart2[round][5] = rofs+D[y9+2];}
                            if(y9+3<D_2[y8+1]){occart2[round][6] = rofs+D[y9+3];}
                            if(occart2[round][7]/2<1){
                                if(coreCcheck(D,D_2,round-1,count,round)==-1){
                                     if(DEBUGFLAG==1){printf("Cコアミスマッチ");}
                                    continue;}
                            } //Cのチェックもしていないなら
                            else{rightopennd3(D,D_2,round-1,count,round,3);}
                        }
                        else{
                            occart2[round][5] = rofs+D[y9+1];
                            if(y9+2<D_2[y8+1]){occart2[round][6] = rofs+D[y9+2];}
                            rightopennd3(D,D_2,round-1,count,round,2);
                        }
                    }
                    else{ //1つだけ
                        occart2[round][6] = rofs+D[y9+1];
                        rightopennd3(D,D_2,round-1,count,round,1);
                    }
                    //exit(7);
                }
                //printf("\n結果:");
                //for(int i = 0; i<10; i++){printf("[%d]",occart2[round][i]);}
                if(occart2[round][6]> -1 && occart2[round][0] > -1){
                    //printf("\n[早速チェック]");
                    int e2[2] = {occart2[round][1],occart2[round][0]};
                    int tk = rpsck(D,D_2,Ls,B1,e2,round-count-1);
                    //if(tk==-1){printf("\nこれはコアではない");}
                    if(tk==0){
                        int e[3] = {occart2[round][4],occart2[round][5],occart2[round][6]};
                        tk = psck(D,D_2,Rs,B2,e,round-count-1);
                        //if(tk==-1){printf("\nこれはコアではない");}
                        if(tk==0){ //左右も完璧に合ってた
                            //printf("\n正しい出現を%dの+%dに発見!\n",y8,occart2[round][3]+ofs);
                            findinround1(D,D_2,D_3,y8,round+1,occart2[round][3]+ofs);
                            //exit(1);
                        }
                    }
                }
                else{ //もっと上の階層に再帰するしかない
                    int e[3] = {occart2[round][4],occart2[round][5],occart2[round][6]};
                    int tk = psck(D,D_2,Rs,B2,e,round-count-1);
                    if(tk!=-1){
                        occart2[round][2] = y8;occart2[round][3] += ofs;
                        findups(D,D_2,D_3,startm,mrlen,round+1,B1,B2,B3,Ls,Rs,count+1);
                    }
                    //else{printf("\n[排除できる例(%d,%d)]",y8,y9-D_2[y8]);}
                }
            }
            if(round>0){ofs+=D_3[rofs+D[y9]];}else{ofs++;}
        }
    }
    //printf("\n--[%d]探し 終了--\n",occart2[round-1][2]);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, %r12d
movl %r8d, 0x74(%rsp)
movq %rsi, %r15
movl 0xf8(%rsp), %r10d
movq 0xf0(%rsp), %rsi
movq 0xe8(%rsp), %r8
movq 0xd8(%rsp), %rax
movq 0xd0(%rsp), %r9
cmpl %r12d, 0x7aa6(%rip)     # 0xa728
jne 0x2cae
subq $0x30, %rsp
movl %r10d, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %r8, 0x10(%rsp)
movq %rax, (%rsp)
movq %r15, %rsi
callq 0x2787
addq $0x30, %rsp
xorl %eax, %eax
jmp 0x3250
movq %rdx, 0x28(%rsp)
xorl %r9d, %r9d
leaq 0x79e3(%rip), %rsi      # 0xa6a0
cmpl $0x2, %r12d
jl 0x2ccc
leal -0x1(%r12), %eax
movl (%rsi,%rax,4), %r9d
movslq %r12d, %rdx
movslq (%rsi,%rdx,4), %r11
movl 0x4(%rsi,%rdx,4), %r8d
movl $0x1, %eax
cmpl %r8d, %r11d
jge 0x3250
movl %ecx, 0x4c(%rsp)
leaq 0x1(%rdx), %rax
movq %rax, 0x58(%rsp)
leal -0x1(%r12), %eax
movl %eax, 0xc(%rsp)
cltq
shlq $0x3, %rax
leaq (%rax,%rax,4), %r14
leaq 0x7463(%rip), %rbp      # 0xa170
leaq (%r14,%rbp), %rax
shlq $0x3, %rdx
leaq (%rdx,%rdx,4), %r13
movq %rbp, %rcx
addq %r13, %rcx
movq %rcx, 0x18(%rsp)
movl %r10d, %ecx
notl %ecx
addl %r12d, %ecx
movl %ecx, 0x34(%rsp)
leal 0x1(%r10), %ecx
movq %rcx, 0x90(%rsp)
movq %rax, %r10
movl (%r15,%r11,4), %eax
leal -0x2(%r12), %ecx
movl %ecx, 0x70(%rsp)
movq %rdi, 0x20(%rsp)
movl %r9d, 0x10(%rsp)
movq %r10, 0x38(%rsp)
movq %r12, 0x80(%rsp)
movq %r15, 0x78(%rsp)
movq %r11, %rcx
incq %r11
movq %rcx, 0x50(%rsp)
movl 0x4(%r15,%rcx,4), %edx
cmpl %edx, %eax
jge 0x323d
movslq %eax, %rbx
xorl %ecx, %ecx
movq %r11, 0x40(%rsp)
movq 0x18(%rsp), %r8
movq 0x28(%rsp), %rsi
movl (%rdi,%rbx,4), %eax
addl %r9d, %eax
cmpl 0x8(%r10), %eax
jne 0x3109
movl %ecx, 0x14(%rsp)
incl 0x794e(%rip)            # 0xa6fc
xorl %eax, %eax
leaq (%r14,%rax,4), %rcx
movl (%rbp,%rcx), %ecx
leaq (,%rax,4), %rdx
addq %r13, %rdx
movl %ecx, (%rbp,%rdx)
incq %rax
cmpq $0xa, %rax
jne 0x2db0
movq 0x50(%rsp), %rax
cmpl %ebx, (%r15,%rax,4)
je 0x2de1
cmpl $0x0, (%r10)
js 0x2e2f
leaq 0x1(%rbx), %rax
movslq (%r15,%r11,4), %rcx
cmpq %rcx, %rax
jge 0x2f54
cmpl $-0x1, 0x18(%r10)
jne 0x2f54
cmpl $-0x1, 0x14(%r8)
je 0x2f00
movl 0x4(%rdi,%rbx,4), %eax
addl %r9d, %eax
movl %eax, 0x18(%r8)
movq %r15, %rsi
movl 0xc(%rsp), %edx
movl 0xf8(%rsp), %ecx
movl %r12d, %r8d
movl $0x1, %r9d
jmp 0x2f45
movl -0x4(%rdi,%rbx,4), %edx
addl %r9d, %edx
cmpl $-0x1, 0x4(%r8)
je 0x2e90
movl %edx, (%r8)
movl 0x70(%rsp), %eax
movl 0xf8(%rsp), %ecx
leal 0x1(%rax), %r8d
xorl %esi, %esi
cmpl $0x2, %r8d
jl 0x2e64
movl %eax, %esi
leaq 0x7840(%rip), %r8       # 0xa6a0
movl (%r8,%rsi,4), %esi
testl %edx, %edx
movq 0x18(%rsp), %r8
js 0x2de1
movl %edx, %edx
movslq 0x4(%r15,%rdx,4), %rdx
addl -0x4(%rdi,%rdx,4), %esi
movl %esi, (%r8)
cmpl $0x2, %ecx
jl 0x2de1
decl %ecx
decl %eax
movl %esi, %edx
jmp 0x2e4b
movl %edx, 0x4(%r8)
movq 0x50(%rsp), %rax
movslq (%r15,%rax,4), %rax
incq %rax
cmpq %rax, %rbx
jle 0x2eaf
movl -0x8(%rdi,%rbx,4), %eax
addl %r9d, %eax
movl %eax, (%r8)
testb $0x1, 0x1c(%r8)
jne 0x3130
movq %r15, %rsi
movl 0xc(%rsp), %edx
movl 0xf8(%rsp), %ecx
movl %r12d, %r8d
movl 0x4c(%rsp), %r9d
callq 0x21ed
cmpl $-0x1, %eax
je 0x31db
movq 0x18(%rsp), %r8
incl 0x1c(%r8)
movq 0x20(%rsp), %rdi
movl 0x10(%rsp), %r9d
movq 0x40(%rsp), %r11
movq 0x38(%rsp), %r10
jmp 0x2de1
movl 0x4(%rdi,%rbx,4), %ecx
addl %r9d, %ecx
leaq 0x2(%rbx), %rax
cmpl $-0x1, 0x10(%r8)
je 0x3165
movl %ecx, 0x14(%r8)
movslq (%r15,%r11,4), %rcx
cmpq %rcx, %rax
jge 0x2f2e
movl 0x8(%rdi,%rbx,4), %eax
addl %r9d, %eax
movl %eax, 0x18(%r8)
movq %r15, %rsi
movl 0xc(%rsp), %edx
movl 0xf8(%rsp), %ecx
movl %r12d, %r8d
movl $0x2, %r9d
callq 0x1d78
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %rdi
movl 0x18(%r8), %r12d
testl %r12d, %r12d
js 0x303a
movl (%r8), %eax
testl %eax, %eax
js 0x303a
movl 0x4(%r8), %ecx
movl %ecx, 0x88(%rsp)
movl %eax, 0x8c(%rsp)
movq %r15, %rsi
movq 0xe8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
leaq 0x88(%rsp), %r8
movl 0x34(%rsp), %r9d
callq 0x1587
testl %eax, %eax
jne 0x300f
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x60(%rsp)
movl %r12d, 0x68(%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0xf0(%rsp), %rdx
movq 0xd8(%rsp), %rcx
leaq 0x60(%rsp), %r8
movl 0x34(%rsp), %r9d
callq 0x1748
testl %eax, %eax
jne 0x300f
movq 0x18(%rsp), %rax
movl 0xc(%rax), %r9d
addl 0x14(%rsp), %r9d
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %r8
callq 0x23c3
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x80(%rsp), %r12
movl 0x10(%rsp), %r9d
movq 0x40(%rsp), %r11
movq 0x38(%rsp), %r10
movq 0x18(%rsp), %r8
jmp 0x3105
movq 0x10(%r8), %rax
movq %rax, 0x60(%rsp)
movl %r12d, 0x68(%rsp)
movq %r15, %rsi
movq 0xf0(%rsp), %rdx
movq 0xd8(%rsp), %rcx
movq %rdi, %r15
movq %r8, %r12
leaq 0x60(%rsp), %r8
movl 0x34(%rsp), %r9d
callq 0x1748
cmpl $-0x1, %eax
movq 0x28(%rsp), %rsi
je 0x30e0
movq 0x50(%rsp), %rax
movl %eax, 0x8(%r12)
movl 0x14(%rsp), %eax
addl %eax, 0xc(%r12)
movq %r15, %rdi
movq 0x78(%rsp), %rsi
movq 0x28(%rsp), %rdx
movl 0x4c(%rsp), %ecx
movl 0x74(%rsp), %r8d
movq 0x58(%rsp), %r9
pushq 0x90(%rsp)
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
callq 0x2c37
movq 0x58(%rsp), %rsi
addq $0x30, %rsp
movq %r15, %rdi
movq 0x78(%rsp), %r15
movq 0x80(%rsp), %rax
movl 0x10(%rsp), %r9d
movq 0x40(%rsp), %r11
movq 0x38(%rsp), %r10
movq %r12, %r8
movq %rax, %r12
movl 0x14(%rsp), %ecx
testl %r12d, %r12d
jle 0x3119
movl (%rdi,%rbx,4), %eax
addl %r9d, %eax
addl (%rsi,%rax,4), %ecx
jmp 0x311b
incl %ecx
incq %rbx
movslq (%r15,%r11,4), %rdx
cmpq %rdx, %rbx
jl 0x2d94
jmp 0x322d
movq %r15, %rsi
movl 0xc(%rsp), %ecx
movl 0xf8(%rsp), %r8d
movl %r12d, %r9d
callq 0x2158
movq 0x20(%rsp), %rdi
movl 0x10(%rsp), %r9d
movq 0x40(%rsp), %r11
movq 0x38(%rsp), %r10
movq 0x18(%rsp), %r8
jmp 0x2de1
movl %ecx, 0x10(%r8)
movslq (%r15,%r11,4), %rcx
cmpq %rcx, %rax
jge 0x3181
movl 0x8(%rdi,%rbx,4), %eax
addl %r9d, %eax
movl %eax, 0x14(%r8)
movslq (%r15,%r11,4), %rcx
leaq 0x3(%rbx), %rax
cmpq %rcx, %rax
jge 0x3195
movl 0xc(%rdi,%rbx,4), %eax
addl %r9d, %eax
movl %eax, 0x18(%r8)
cmpl $0x1, 0x1c(%r8)
jg 0x3202
movq %r15, %rsi
movl 0xc(%rsp), %edx
movl 0xf8(%rsp), %ecx
movl %r12d, %r8d
callq 0x1f41
movq 0x20(%rsp), %rdi
cmpl $-0x1, %eax
movl 0x10(%rsp), %r9d
movq 0x40(%rsp), %r11
movq 0x38(%rsp), %r10
movq 0x18(%rsp), %r8
jne 0x2f54
movq 0x28(%rsp), %rsi
jmp 0x31f9
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
movl 0x10(%rsp), %r9d
movq 0x40(%rsp), %r11
movq 0x38(%rsp), %r10
movq 0x18(%rsp), %r8
movl 0x14(%rsp), %ecx
jmp 0x311b
movq %r15, %rsi
movl 0xc(%rsp), %edx
movl 0xf8(%rsp), %ecx
movl %r12d, %r8d
movl $0x3, %r9d
callq 0x1d78
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
jmp 0x2f54
leaq 0x746c(%rip), %rax      # 0xa6a0
movq 0x58(%rsp), %rcx
movl (%rax,%rcx,4), %r8d
movslq %r8d, %rsi
movl %edx, %eax
cmpq %rsi, %r11
jl 0x2d68
movl $0x1, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq