// File: /workspace/github_cpp_makefile_star2_O3/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 $0x18, %rsp
movl %ecx, %r9d
testl %ecx, %ecx
jle 0x20ae
movl %edx, %ecx
movl $0xffffffff, 0x10(%rsp) # imm = 0xFFFFFFFF
movq $-0x1, 0x8(%rsp)
leal -0x1(%rcx), %r10d
xorl %eax, %eax
movl $0x0, %ebp
cmpl $0x2, %ecx
jl 0x1f8a
movl %r10d, %ecx
leaq 0x8719(%rip), %rdx      # 0xa6a0
movl (%rdx,%rcx,4), %ebp
movl %r10d, 0x4(%rsp)
movl 0x86aa(%rip), %r10d     # 0xa640
movslq %r8d, %rcx
leal -0x1(%r9), %edx
movl %edx, (%rsp)
leaq (%rcx,%rcx,4), %rdx
leaq 0x81c5(%rip), %rcx      # 0xa170
leaq (%rcx,%rdx,8), %r14
addq $0x1c, %r14
movl 0x8682(%rip), %r15d     # 0xa63c
xorl %r12d, %r12d
movslq -0xc(%r14,%r12,4), %r11
testq %r11, %r11
js 0x2014
movslq (%rsi,%r11,4), %rcx
movl 0x4(%rsi,%r11,4), %r13d
cmpl %ecx, %r13d
jle 0x2014
leaq (%rdi,%rcx,4), %rbx
subl %ecx, %r13d
xorl %ecx, %ecx
movl (%rbx,%rcx,4), %r11d
addl %ebp, %r11d
cmpl $0x1, %r9d
jne 0x1ffe
testl %r10d, %r10d
jle 0x1ffe
cmpl %r15d, %r11d
jne 0x2091
decl %r10d
jmp 0x200c
cltq
movl %r11d, 0x8(%rsp,%rax,4)
incl %eax
cmpl $0x3, %eax
je 0x2065
incq %rcx
cmpl %ecx, %r13d
jne 0x1fde
incq %r12
cmpq $0x3, %r12
jne 0x1fbd
cmpl $0x1, %r9d
jne 0x20bf
testl %eax, %eax
je 0x20e9
testl %r10d, %r10d
jg 0x20e9
testl %eax, %eax
jle 0x205f
movl 0x8(%rsp), %ecx
leaq 0x8129(%rip), %rsi      # 0xa170
movl %ecx, 0x10(%rsi,%rdx,8)
cmpl $0x1, %eax
je 0x205f
movl 0xc(%rsp), %eax
leaq 0x8115(%rip), %rcx      # 0xa170
movl %eax, 0x14(%rcx,%rdx,8)
addl $0x2, (%r14)
jmp 0x20ae
movl 0x10(%rsp), %eax
leaq 0x8100(%rip), %rcx      # 0xa170
movl %eax, 0x18(%rcx,%rdx,8)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rcx,%rdx,8)
testl %r10d, %r10d
je 0x2098
movl 0x4(%rsp), %edx
movl (%rsp), %ecx
callq 0x1f41
jmp 0x20b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x20b0
addl $0x2, (%r14)
movl 0x4(%rsp), %edx
movl (%rsp), %ecx
movl $0x3, %r9d
callq 0x1d78
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %eax, %eax
jle 0x2083
movl 0x8(%rsp), %ecx
leaq 0x80a2(%rip), %r9       # 0xa170
movl %ecx, 0x10(%r9,%rdx,8)
cmpl $0x1, %eax
je 0x2083
movl 0xc(%rsp), %eax
leaq 0x808d(%rip), %rcx      # 0xa170
movl %eax, 0x14(%rcx,%rdx,8)
jmp 0x2083
leaq 0x3fc1(%rip), %rdi      # 0x60b1
movl %eax, %esi
movl %r10d, %edx
xorl %eax, %eax
callq 0x1030
movl $0x7, %edi
callq 0x1150