// File: /workspace/github_cpp_makefile_star2_O2/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: coreCcheck(unsigned int*, int*, int, int, int)
int coreCcheck(unsigned int *D,int *D_2,int round,int count,int tround){ //一つレベルの高い分割を2つ抑える．[-B][C*][**]と3つが得られる．
    //コアCが出現するかを確認する．出現するなら，余った部分をrightopennd3に回す．
    //coredata[7]がcoredata[8]回出現するのを見届ける
    if(DEBUGFLAG==1){
        printf("\n[Cコア%dを%d回チェック(%d-%d / %d)]",coredata[7],coredata[8],round,tround,count);
        for(int i = 0; i<10; i++){printf("[%d]",occart2[tround][i]);}
    }
    if(count<1){return 0;}
    //printf("\n");
    int a[3] = {-1,-1,-1};int tg = 0;
    int rofs=0;int Clef = coredata[8];
    if(round>1){rofs=dc2s[round-1];}
    for(int u = 0;u<3;u++){
        if(occart2[tround][4+u] > -1){
            if(DEBUGFLAG==1){
                 printf("\n展開:occart2[%d] = %d",4+u,occart2[tround][4+u]);
            }
            for(int i = D_2[occart2[tround][4+u]];i<D_2[1+occart2[tround][4+u]];i++){
                if(Clef>0 && count==1){
                    if(rofs+D[i]==coredata[7]){
                        Clef--;
                        if(DEBUGFLAG==1){printf("\n[hit %d(%d) / あと%d]",rofs+D[i],D[i],Clef);}
                        continue;}else{return -1;}
                }
                //if(fround==0){return 0;} //Clefがなくなって，froundが0ならもう右はあっているのでは
                a[tg] = rofs+D[i];tg++;
                 if(DEBUGFLAG==1){printf(" got(%d [+%d]) ",rofs+D[i],rofs);}
                if(tg==3){
                    for(int j = 0;j<3;j++){
                         if(DEBUGFLAG==1){printf("\noccart2[%d] = %d",4+j,a[j]);}
                        occart2[tround][4+j] = a[j];
                    }
                    if(Clef==0){occart2[tround][7] += 2;return rightopennd3(D,D_2,round-1,count-1,tround,3);} //Cコア把握
                    return coreCcheck(D,D_2,round-1,count-1,tround);
                }
            }
        }
    }
    if(count==1){//Cの存在を確かめた上で右分割が足りない場合
        if(tg==0 || Clef>0){printf("おかしい!(%d,%d)",tg,Clef);exit(7);}
        if(tg>=1){occart2[tround][4] = a[0];}
        if(tg>=2){occart2[tround][5] = a[1];}
        occart2[tround][7] += 2;
        return rightopennd3(D,D_2,round-1,count-1,tround,3);
    }
    else{ //countがもっと高い
        if(tg>=1){occart2[tround][4] = a[0];}
        if(tg>=2){occart2[tround][5] = a[1];}
        return coreCcheck(D,D_2,round-1,count-1,tround);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r10d
testl %ecx, %ecx
jle 0x1f8d
movl %edx, %ecx
orl $-0x1, 0x28(%rsp)
orq $-0x1, 0x20(%rsp)
leal -0x1(%rcx), %r9d
xorl %eax, %eax
movl $0x0, %ebp
cmpl $0x2, %ecx
jl 0x1e8b
movl %r9d, %ecx
leaq 0x7818(%rip), %rdx      # 0x96a0
movl (%rdx,%rcx,4), %ebp
movl %r9d, 0xc(%rsp)
movl 0x77a9(%rip), %r9d      # 0x9640
movl %r8d, 0x14(%rsp)
movslq %r8d, %rcx
leal -0x1(%r10), %edx
movl %edx, 0x10(%rsp)
imulq $0x28, %rcx, %rdx
leaq 0x72be(%rip), %r8       # 0x9170
leaq (%rdx,%r8), %rcx
addq $0x1c, %rcx
movq %rcx, 0x30(%rsp)
movl 0x7776(%rip), %r12d     # 0x963c
movq %rdx, 0x18(%rsp)
leaq (%r8,%rdx), %r13
pushq $-0x1
popq %rbx
xorl %r11d, %r11d
cmpq $0x3, %r11
je 0x1fa0
movslq 0x10(%r13,%r11,4), %rcx
testq %rcx, %rcx
js 0x1f2d
movslq (%rsi,%rcx,4), %r15
movslq 0x4(%rsi,%rcx,4), %rcx
cmpq %rcx, %r15
jge 0x1f2d
cmpl $0x1, %r10d
setne %r14b
testl %r9d, %r9d
setle %r8b
movl (%rdi,%r15,4), %edx
addl %ebp, %edx
orb %r14b, %r8b
jne 0x1f1b
cmpl %r12d, %edx
jne 0x1f8f
decl %r9d
jmp 0x1f28
cltq
movl %edx, 0x20(%rsp,%rax,4)
incl %eax
cmpl $0x3, %eax
je 0x1f32
incq %r15
jmp 0x1ef2
incq %r11
jmp 0x1ed5
movq 0x18(%rsp), %rax
leaq 0x7232(%rip), %rcx      # 0x9170
addq %rcx, %rax
addq $0x10, %rax
xorl %ecx, %ecx
movl 0x14(%rsp), %r8d
cmpq $0x3, %rcx
je 0x1f5e
movl 0x20(%rsp,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
jmp 0x1f4c
testl %r9d, %r9d
je 0x1f74
movl 0xc(%rsp), %edx
movl 0x10(%rsp), %ecx
callq 0x1e48
movl %eax, %ebx
jmp 0x1f8f
movq 0x30(%rsp), %rax
addl $0x2, (%rax)
pushq $0x3
popq %r9
movl 0xc(%rsp), %edx
movl 0x10(%rsp), %ecx
callq 0x1cce
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r10d
jne 0x2009
testl %eax, %eax
je 0x204d
testl %r9d, %r9d
jg 0x204d
testl %eax, %eax
jle 0x1fe9
movl 0x20(%rsp), %ecx
movq 0x18(%rsp), %rdx
leaq 0x71a5(%rip), %r8       # 0x9170
movl %ecx, 0x10(%rdx,%r8)
cmpl $0x1, %eax
je 0x1fe9
movl 0x24(%rsp), %eax
movq 0x18(%rsp), %rcx
leaq 0x718b(%rip), %rdx      # 0x9170
movl %eax, 0x14(%rcx,%rdx)
movq 0x30(%rsp), %rax
addl $0x2, (%rax)
xorl %ebx, %ebx
pushq $0x3
popq %r9
movl 0xc(%rsp), %edx
xorl %ecx, %ecx
movl 0x14(%rsp), %r8d
callq 0x1cce
jmp 0x1f8f
testl %eax, %eax
movl 0x14(%rsp), %r8d
jle 0x1f63
movl 0x20(%rsp), %ecx
movq 0x18(%rsp), %rdx
leaq 0x714a(%rip), %r9       # 0x9170
movl %ecx, 0x10(%rdx,%r9)
cmpl $0x1, %eax
je 0x1f63
movl 0x24(%rsp), %eax
movq 0x18(%rsp), %rcx
leaq 0x712c(%rip), %rdx      # 0x9170
movl %eax, 0x14(%rcx,%rdx)
jmp 0x1f63
leaq 0x305d(%rip), %rdi      # 0x50b1
movl %eax, %esi
movl %r9d, %edx
xorl %eax, %eax
callq 0x1030
pushq $0x7
popq %rdi
callq 0x1150