// File: /workspace/github_cpp_makefile_star2_O2/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 $0x88, %rsp
movl %r9d, %r12d
movl %r8d, 0x5c(%rsp)
movq %rsi, %r15
movl 0xe8(%rsp), %r8d
movq 0xe0(%rsp), %rsi
movq 0xd8(%rsp), %r10
movq 0xc8(%rsp), %rax
movq 0xc0(%rsp), %r9
cmpl %r12d, 0x6c23(%rip)     # 0x9728
jne 0x2b31
subq $0x30, %rsp
movl %r8d, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, (%rsp)
movq %r15, %rsi
callq 0x26c6
addq $0x30, %rsp
xorl %eax, %eax
jmp 0x304d
movq %rdx, 0x28(%rsp)
movl %ecx, 0x40(%rsp)
leal -0x1(%r12), %ecx
xorl %esi, %esi
leaq 0x6b58(%rip), %rdx      # 0x96a0
cmpl $0x2, %r12d
jl 0x2b53
movl %ecx, %eax
movl (%rdx,%rax,4), %esi
movslq %r12d, %rax
movslq (%rdx,%rax,4), %r8
leal 0x1(%r12), %r9d
movl %r9d, 0x44(%rsp)
movslq %r9d, %r9
movq %r9, 0x70(%rsp)
movl %ecx, 0x1c(%rsp)
movslq %ecx, %rcx
imulq $0x28, %rcx, %r14
leaq 0x65f2(%rip), %rbx      # 0x9170
leaq (%rbx,%r14), %r9
imulq $0x28, %rax, %rbp
leaq (%rbx,%rbp), %r10
movl 0xe8(%rsp), %eax
movl %eax, %ecx
notl %ecx
addl %r12d, %ecx
movl %ecx, 0x3c(%rsp)
incl %eax
movq %rax, 0x78(%rsp)
movq %rdi, (%rsp)
movl %esi, 0x8(%rsp)
movq %r9, 0x20(%rsp)
movq %r10, 0x10(%rsp)
movq %r12, 0x60(%rsp)
movq 0x70(%rsp), %rax
movslq (%rdx,%rax,4), %rax
cmpq %rax, %r8
jge 0x304a
movslq (%r15,%r8,4), %r11
movq %r8, 0x48(%rsp)
leaq 0x1(%r8), %r13
xorl %ecx, %ecx
movq 0x28(%rsp), %rdx
movq %r13, 0x80(%rsp)
movslq (%r15,%r13,4), %rax
cmpq %rax, %r11
jge 0x303b
movl (%rdi,%r11,4), %eax
addl %esi, %eax
cmpl 0x8(%r9), %eax
jne 0x2f5c
movl %ecx, 0xc(%rsp)
incl 0x6aed(%rip)            # 0x96fc
xorl %eax, %eax
cmpq $0xa, %rax
je 0x2c32
leaq (%r14,%rax,4), %rcx
movl (%rbx,%rcx), %ecx
leaq (,%rax,4), %r8
addq %rbp, %r8
movl %ecx, (%rbx,%r8)
incq %rax
jmp 0x2c11
movq 0x48(%rsp), %rax
cmpl %r11d, (%r15,%rax,4)
movq %r11, 0x30(%rsp)
je 0x2d2a
cmpl $0x0, (%r9)
jns 0x2d2a
movl -0x4(%rdi,%r11,4), %eax
addl %esi, %eax
cmpl $-0x1, 0x4(%r10)
je 0x2c98
movl %eax, (%r10)
movq (%rsp), %rdi
movq %r15, %rsi
movl 0x1c(%rsp), %ecx
movl 0xe8(%rsp), %r8d
movl %r12d, %r9d
callq 0x2068
movq 0x30(%rsp), %r11
movq 0x10(%rsp), %r10
movq 0x20(%rsp), %r9
movl 0x8(%rsp), %esi
movq (%rsp), %rdi
jmp 0x2d2a
movl %eax, 0x4(%r10)
movq 0x48(%rsp), %rax
movslq (%r15,%rax,4), %rax
incq %rax
cmpq %rax, %r11
movl 0x1c(%rsp), %edx
jle 0x2cbb
movl -0x8(%rdi,%r11,4), %eax
addl %esi, %eax
movl %eax, (%r10)
testb $0x1, 0x1c(%r10)
jne 0x2cfa
movq %r15, %rsi
movl 0xe8(%rsp), %ecx
movl %r12d, %r8d
movl 0x40(%rsp), %r9d
callq 0x2150
cmpl $-0x1, %eax
je 0x2fee
movq 0x10(%rsp), %r10
incl 0x1c(%r10)
movq (%rsp), %rdi
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %r9
jmp 0x2d25
movq (%rsp), %rdi
movq %r15, %rsi
movl %edx, %ecx
movl 0xe8(%rsp), %r8d
movl %r12d, %r9d
callq 0x20bb
movq (%rsp), %rdi
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x30(%rsp), %r11
leaq 0x1(%r11), %rax
movslq (%r15,%r13,4), %rcx
cmpq %rcx, %rax
jge 0x2dc6
cmpl $-0x1, 0x18(%r9)
jne 0x2dc6
cmpl $-0x1, 0x14(%r10)
je 0x2d71
movl 0x4(%rdi,%r11,4), %eax
addl %esi, %eax
movl %eax, 0x18(%r10)
movq (%rsp), %rdi
movq %r15, %rsi
movl 0x1c(%rsp), %edx
movl 0xe8(%rsp), %ecx
movl %r12d, %r8d
pushq $0x1
jmp 0x2db6
movl 0x4(%rdi,%r11,4), %ecx
addl %esi, %ecx
leaq 0x2(%r11), %rax
cmpl $-0x1, 0x10(%r10)
je 0x2f76
movl %ecx, 0x14(%r10)
movslq (%r15,%r13,4), %rcx
cmpq %rcx, %rax
jge 0x2d9f
movl 0x8(%rdi,%r11,4), %eax
addl %esi, %eax
movl %eax, 0x18(%r10)
movq (%rsp), %rdi
movq %r15, %rsi
movl 0x1c(%rsp), %edx
movl 0xe8(%rsp), %ecx
movl %r12d, %r8d
pushq $0x2
popq %r9
callq 0x1cce
movq 0x10(%rsp), %r10
movq (%rsp), %rdi
movl 0x18(%r10), %r12d
testl %r12d, %r12d
js 0x2e97
movl (%r10), %eax
testl %eax, %eax
js 0x2e97
movl 0x4(%r10), %ecx
movl %ecx, 0x68(%rsp)
movl %eax, 0x6c(%rsp)
movq %r15, %rsi
movq 0xd8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
leaq 0x68(%rsp), %r8
movl 0x3c(%rsp), %r9d
callq 0x157f
testl %eax, %eax
jne 0x2e76
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x50(%rsp)
movl %r12d, 0x58(%rsp)
movq (%rsp), %rdi
movq %r15, %rsi
movq 0xe0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
leaq 0x50(%rsp), %r8
movl 0x3c(%rsp), %r9d
callq 0x16f6
testl %eax, %eax
jne 0x2e76
movq 0x10(%rsp), %rax
movl 0xc(%rax), %r9d
addl 0xc(%rsp), %r9d
movq (%rsp), %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
movq 0x48(%rsp), %rcx
movl 0x44(%rsp), %r8d
callq 0x2336
movq 0x28(%rsp), %rdx
movq (%rsp), %rdi
movq 0x60(%rsp), %r12
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r10
jmp 0x2f53
movq 0x10(%r10), %rax
movq %rax, 0x50(%rsp)
movl %r12d, 0x58(%rsp)
movq %r15, %r12
movq %rdi, %r15
movq %r12, %rsi
movq 0xe0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
leaq 0x50(%rsp), %r8
movl 0x3c(%rsp), %r9d
movq %r10, %r13
callq 0x16f6
cmpl $-0x1, %eax
movq 0x28(%rsp), %rdx
je 0x2f34
movq 0x48(%rsp), %rax
movl %eax, 0x8(%r13)
movl 0xc(%rsp), %eax
addl %eax, 0xc(%r13)
movq %r15, %rdi
movq %r12, %rsi
movl 0x40(%rsp), %ecx
movl 0x5c(%rsp), %r8d
movl 0x44(%rsp), %r9d
pushq 0x78(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
callq 0x2aba
movq 0x58(%rsp), %rdx
addq $0x30, %rsp
movq %r15, %rdi
movq %r12, %r15
movq 0x60(%rsp), %r12
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %r9
movq %r13, %r10
movq 0x80(%rsp), %r13
movq 0x30(%rsp), %r11
movl 0xc(%rsp), %ecx
testl %r12d, %r12d
jle 0x2f6c
movl (%rdi,%r11,4), %eax
addl %esi, %eax
addl (%rdx,%rax,4), %ecx
jmp 0x2f6e
incl %ecx
incq %r11
jmp 0x2be8
movl %ecx, 0x10(%r10)
movslq (%r15,%r13,4), %rcx
cmpq %rcx, %rax
jge 0x2f92
movl 0x8(%rdi,%r11,4), %eax
addl %esi, %eax
movl %eax, 0x14(%r10)
movslq (%r15,%r13,4), %rcx
leaq 0x3(%r11), %rax
cmpq %rcx, %rax
jge 0x2fa6
movl 0xc(%rdi,%r11,4), %eax
addl %esi, %eax
movl %eax, 0x18(%r10)
cmpl $0x1, 0x1c(%r10)
movl 0x1c(%rsp), %edx
jg 0x3013
movq (%rsp), %rdi
movq %r15, %rsi
movl 0xe8(%rsp), %ecx
movl %r12d, %r8d
callq 0x1e48
movq (%rsp), %rdi
cmpl $-0x1, %eax
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x30(%rsp), %r11
jne 0x2dc6
movq 0x28(%rsp), %rdx
jmp 0x300a
movq 0x28(%rsp), %rdx
movq (%rsp), %rdi
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x30(%rsp), %r11
movl 0xc(%rsp), %ecx
jmp 0x2f6e
movq (%rsp), %rdi
movq %r15, %rsi
movl 0xe8(%rsp), %ecx
movl %r12d, %r8d
pushq $0x3
popq %r9
callq 0x1cce
movq (%rsp), %rdi
movq 0x10(%rsp), %r10
jmp 0x2dc6
movq %r13, %r8
leaq 0x665b(%rip), %rdx      # 0x96a0
jmp 0x2bba
pushq $0x1
popq %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq