// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, 0x28(%rsp)
testl %ecx, %ecx
jle 0x22db
movl %ecx, %ebp
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq $-0x1, 0x10(%rsp)
xorl %r13d, %r13d
movl $0x0, %r14d
cmpl $0x2, %edx
jl 0x2133
leal -0x1(%rdx), %eax
leaq 0x8571(%rip), %rcx      # 0xa6a0
movl (%rcx,%rax,4), %r14d
movl 0x8507(%rip), %ebx      # 0xa640
movslq %r8d, %rax
decl %edx
leal -0x1(%rbp), %ecx
movl %ecx, 0x4(%rsp)
leaq (%rax,%rax,4), %rax
leaq 0x8020(%rip), %rcx      # 0xa170
movq %rax, 0x30(%rsp)
leaq (%rcx,%rax,8), %rdi
addq $0x1c, %rdi
xorl %r15d, %r15d
xorl %r10d, %r10d
movl %r8d, 0x1c(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, 0x8(%rsp)
movslq -0xc(%rdi,%r15,4), %rcx
testq %rcx, %rcx
js 0x2246
movslq (%rsi,%rcx,4), %r9
movslq 0x4(%rsi,%rcx,4), %rcx
cmpl %r9d, %ecx
setg %r12b
jle 0x2240
movq %r10, 0x20(%rsp)
movl 0x849a(%rip), %r10d     # 0xa63c
movq %r9, %r11
incq %r11
movl %ecx, %edi
subl %r9d, %edi
movq 0x28(%rsp), %r9
movl -0x4(%r9,%r11,4), %r9d
addl %r14d, %r9d
cmpl $0x1, %ebp
jne 0x21cc
testl %ebx, %ebx
jle 0x21cc
cmpl %r10d, %r9d
jne 0x2231
decl %ebx
jmp 0x21dd
movslq %r13d, %r13
movl %r9d, 0x10(%rsp,%r13,4)
incl %r13d
cmpl $0x3, %r13d
je 0x21ed
cmpq %rcx, %r11
setl %r12b
incq %r11
decl %edi
jne 0x21ad
jmp 0x2236
movl 0x18(%rsp), %eax
movq 0x8(%rsp), %rcx
movl %eax, -0x4(%rcx)
movq 0x10(%rsp), %rax
movq %rax, -0xc(%rcx)
testl %ebx, %ebx
je 0x2261
movq 0x28(%rsp), %rdi
movl 0x4(%rsp), %ecx
movq %rdx, %r13
callq 0x20e9
movq 0x8(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r13, %rdx
movl 0x1c(%rsp), %r8d
movl $0x3, %r13d
jmp 0x223b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %r10
testb $0x1, %r12b
jne 0x229b
cmpq $0x2, %r15
leaq 0x1(%r15), %rcx
setae %r10b
movq %rcx, %r15
cmpq $0x3, %rcx
jne 0x2172
jmp 0x229b
addl $0x2, (%rcx)
movl $0x3, %r13d
movq 0x28(%rsp), %rdi
movl 0x4(%rsp), %ecx
movl $0x3, %r9d
movq %rdx, 0x40(%rsp)
callq 0x1e6f
movq 0x8(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movl 0x1c(%rsp), %r8d
xorl %eax, %eax
jmp 0x223b
testb $0x1, %r10b
je 0x2314
cmpl $0x1, %ebp
jne 0x22df
testl %r13d, %r13d
je 0x2323
testl %ebx, %ebx
jg 0x2323
testl %r13d, %r13d
movq 0x30(%rsp), %rcx
leaq 0x7eb2(%rip), %rdx      # 0xa170
jle 0x22c8
movl 0x10(%rsp), %eax
movl %eax, 0x10(%rdx,%rcx,8)
cmpl $0x2, %r13d
jl 0x22d6
movl 0x14(%rsp), %eax
movl %eax, 0x14(%rdx,%rcx,8)
addl $0x2, 0x1c(%rdx,%rcx,8)
xorl %eax, %eax
jmp 0x2314
testl %r13d, %r13d
movq 0x30(%rsp), %rcx
leaq 0x7e82(%rip), %rdi      # 0xa170
jle 0x22f8
movl 0x10(%rsp), %eax
movl %eax, 0x10(%rdi,%rcx,8)
cmpl $0x2, %r13d
jl 0x2306
movl 0x14(%rsp), %eax
movl %eax, 0x14(%rdi,%rcx,8)
movq 0x28(%rsp), %rdi
movl 0x4(%rsp), %ecx
callq 0x20e9
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3d8f(%rip), %rdi      # 0x60b9
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1030
movl $0x7, %edi
callq 0x1150