// File: /workspace/github_cpp_makefile_star2_O1/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, 0x74(%rsp)
movl 0xe8(%rsp), %r10d
movq 0xe0(%rsp), %r8
movq 0xd8(%rsp), %r11
movq 0xc8(%rsp), %rax
movq 0xc0(%rsp), %r9
cmpl %r12d, 0x7872(%rip)     # 0xa728
jne 0x2edf
subq $0x30, %rsp
movl %r10d, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %r11, 0x10(%rsp)
movq %rax, (%rsp)
callq 0x2a73
addq $0x30, %rsp
xorl %eax, %eax
jmp 0x3408
movq %rdx, %r15
xorl %r13d, %r13d
leaq 0x77b4(%rip), %rdx      # 0xa6a0
cmpl $0x2, %r12d
jl 0x2efb
leal -0x1(%r12), %eax
movl (%rdx,%rax,4), %r13d
movslq %r12d, %r8
movslq (%rdx,%r8,4), %r11
movl $0x1, %eax
cmpl 0x4(%rdx,%r8,4), %r11d
jge 0x3408
movl %ecx, 0x44(%rsp)
leaq 0x1(%r8), %rax
movq %rax, 0x60(%rsp)
leal -0x1(%r12), %eax
movl %eax, 0x24(%rsp)
movslq %eax, %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %r14
leaq 0x7236(%rip), %rbp      # 0xa170
leaq (%r14,%rbp), %r9
shlq $0x3, %r8
leaq (%r8,%r8,4), %rbx
leaq (%rbx,%rbp), %r8
movl %r10d, %eax
notl %eax
addl %r12d, %eax
movl %eax, 0x40(%rsp)
leal 0x1(%r10), %eax
movq %rax, 0x80(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, (%rsp)
movq %r9, 0x30(%rsp)
movq %r8, 0x18(%rsp)
movq %r15, %rdx
movq %r12, %r15
movq %rdx, 0x28(%rsp)
movq %r12, 0x68(%rsp)
movl %r13d, 0x48(%rsp)
movq %r11, %rax
movslq (%rsi,%r11,4), %r12
incq %r11
movq %rax, 0x58(%rsp)
cmpl 0x4(%rsi,%rax,4), %r12d
jge 0x33ea
xorl %ecx, %ecx
movq %r11, 0x38(%rsp)
movl (%rdi,%r12,4), %eax
addl %r13d, %eax
cmpl 0x8(%r9), %eax
jne 0x32df
movl %ecx, 0x14(%rsp)
incl 0x7736(%rip)            # 0xa6fc
xorl %eax, %eax
leaq (%r14,%rax,4), %rcx
movl (%rbp,%rcx), %ecx
leaq (%rbx,%rax,4), %rdx
movl %ecx, (%rbp,%rdx)
incq %rax
cmpq $0xa, %rax
jne 0x2fc8
movq 0x58(%rsp), %rax
cmpl %r12d, (%rsi,%rax,4)
je 0x30f0
cmpl $0x0, (%r9)
jns 0x30f0
movl -0x4(%rdi,%r12,4), %eax
addl %r13d, %eax
cmpl $-0x1, 0x4(%r8)
je 0x304b
movl %eax, (%r8)
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
movl 0xe8(%rsp), %r8d
movl %r15d, %r9d
callq 0x2340
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %r9
movq 0x38(%rsp), %r11
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
jmp 0x30f0
movl %eax, 0x4(%r8)
movq 0x58(%rsp), %rax
movslq (%rsi,%rax,4), %rax
incq %rax
cmpq %rax, %r12
movq 0x28(%rsp), %rdx
jle 0x3070
movl -0x8(%rdi,%r12,4), %eax
addl %r13d, %eax
movl %eax, (%r8)
testb $0x1, 0x1c(%r8)
jne 0x30bb
movl 0x24(%rsp), %edx
movl 0xe8(%rsp), %ecx
movl %r15d, %r8d
movl 0x44(%rsp), %r9d
callq 0x244d
cmpl $-0x1, %eax
je 0x33bf
movq 0x18(%rsp), %r8
incl 0x1c(%r8)
movq 0x8(%rsp), %rsi
movq (%rsp), %rdi
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %r9
movq 0x68(%rsp), %r15
jmp 0x30f0
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x24(%rsp), %ecx
movl 0xe8(%rsp), %r8d
movl %r15d, %r9d
callq 0x238f
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %r9
movq 0x18(%rsp), %r8
leaq 0x1(%r12), %rax
movslq (%rsi,%r11,4), %rcx
cmpq %rcx, %rax
jge 0x314a
cmpl $-0x1, 0x18(%r9)
jne 0x314a
movl $0x1, %r9d
cmpl $-0x1, 0x14(%r8)
je 0x3307
movl (%rdi,%rax,4), %eax
addl %r13d, %eax
movl %eax, 0x18(%r8)
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x24(%rsp), %edx
movl 0xe8(%rsp), %ecx
movl %r15d, %r8d
callq 0x1e6f
movq 0x18(%rsp), %r8
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%r8), %r13d
testl %r13d, %r13d
js 0x3213
movl (%r8), %eax
testl %eax, %eax
js 0x3213
movl 0x4(%r8), %ecx
movl %ecx, 0x78(%rsp)
movl %eax, 0x7c(%rsp)
movq 0xd8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
leaq 0x78(%rsp), %r8
movl 0x40(%rsp), %r9d
callq 0x15f5
testl %eax, %eax
jne 0x3200
movq 0x18(%rsp), %rcx
movl 0x10(%rcx), %eax
movl %eax, 0x4c(%rsp)
movl 0x14(%rcx), %eax
movl %eax, 0x50(%rsp)
movl %r13d, 0x54(%rsp)
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0xe0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
leaq 0x4c(%rsp), %r8
movl 0x40(%rsp), %r9d
callq 0x175f
testl %eax, %eax
jne 0x3200
movq 0x18(%rsp), %rax
movl 0xc(%rax), %r9d
addl 0x14(%rsp), %r9d
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %r8
callq 0x26e2
movq 0x28(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq (%rsp), %rdi
jmp 0x32c7
movl 0x10(%r8), %eax
movl %eax, 0x4c(%rsp)
movl 0x14(%r8), %eax
movl %eax, 0x50(%rsp)
movl %r13d, 0x54(%rsp)
movq %rdi, %r15
movq %rsi, %r13
movq 0xe0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
leaq 0x4c(%rsp), %r8
movl 0x40(%rsp), %r9d
callq 0x175f
cmpl $-0x1, %eax
movq 0x28(%rsp), %rdx
je 0x32bc
movq 0x58(%rsp), %rax
movq 0x18(%rsp), %rcx
movl %eax, 0x8(%rcx)
movl 0x14(%rsp), %eax
addl %eax, 0xc(%rcx)
movq %r15, %rdi
movq %r13, %rsi
movq 0x28(%rsp), %rdx
movl 0x44(%rsp), %ecx
movl 0x74(%rsp), %r8d
movq 0x60(%rsp), %r9
pushq 0x80(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
callq 0x2e6e
movq 0x58(%rsp), %rdx
addq $0x30, %rsp
movq %r13, %rsi
movq %r15, %rdi
movq 0x68(%rsp), %r15
movl 0x48(%rsp), %r13d
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %r9
movq 0x18(%rsp), %r8
movl 0x14(%rsp), %ecx
testl %r15d, %r15d
jle 0x32f0
movl (%rdi,%r12,4), %eax
addl %r13d, %eax
addl (%rdx,%rax,4), %ecx
jmp 0x32f2
incl %ecx
incq %r12
movslq (%rsi,%r11,4), %rax
cmpq %rax, %r12
jl 0x2fab
jmp 0x33ea
movl 0x4(%rdi,%r12,4), %ecx
addl %r13d, %ecx
leaq 0x2(%r12), %rax
cmpl $-0x1, 0x10(%r8)
je 0x3337
movl %ecx, 0x14(%r8)
movslq (%rsi,%r11,4), %rcx
movl $0x2, %r9d
cmpq %rcx, %rax
jl 0x3116
jmp 0x3120
movl %ecx, 0x10(%r8)
movslq (%rsi,%r11,4), %rcx
cmpq %rcx, %rax
jge 0x3350
movl 0x8(%rdi,%r12,4), %eax
addl %r13d, %eax
movl %eax, 0x14(%r8)
leaq 0x3(%r12), %rax
movslq (%rsi,%r11,4), %rcx
cmpq %rcx, %rax
jge 0x336a
movl 0xc(%rdi,%r12,4), %eax
addl %r13d, %eax
movl %eax, 0x18(%r8)
movl $0x3, %r9d
cmpl $0x1, 0x1c(%r8)
jg 0x3120
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x24(%rsp), %edx
movl 0xe8(%rsp), %ecx
movl %r15d, %r8d
callq 0x20e9
movq 0x18(%rsp), %r8
movq 0x38(%rsp), %r11
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
cmpl $-0x1, %eax
movq 0x30(%rsp), %r9
jne 0x314a
movq 0x28(%rsp), %rdx
jmp 0x33e1
movq 0x8(%rsp), %rsi
movq (%rsp), %rdi
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x28(%rsp), %rdx
movq 0x68(%rsp), %r15
movl 0x14(%rsp), %ecx
jmp 0x32f2
leaq 0x72af(%rip), %rax      # 0xa6a0
movq 0x60(%rsp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq %rax, %r11
jl 0x2f8a
movl $0x1, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq