// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_uni_locate.cpp
// Function: coreCcheck(int*, int, int, int)
int coreCcheck(int *m,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]);
            }
            std::vector<int> x;
            xdisp(x,occart2[tround][4+u]);
            for(int i = 0;i<x.size();i++){
                if(Clef>0 && count==1){
                    if(rofs+x[i]==coredata[7]){
                        Clef--;
                        if(DEBUGFLAG==1){printf("\n[hit %d(%d) / あと%d]",rofs+x[i],x[i],Clef);}
                        continue;}else{return -1;}
                }
                //if(fround==0){return 0;} //Clefがなくなって，froundが0ならもう右はあっているのでは
                a[tg] = rofs+x[i];tg++;
                 if(DEBUGFLAG==1){printf(" got(%d [+%d]) ",rofs+x[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(m,round-1,count-1,tround,3);} //Cコア把握
                    return coreCcheck(m,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(m,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(m,round-1,count-1,tround);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, 0x4(%rsp)
movq %rdi, 0x28(%rsp)
testl %edx, %edx
jle 0x40f9
movl %edx, %r13d
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq $-0x1, 0x10(%rsp)
xorl %r12d, %r12d
movl $0x0, %r14d
cmpl $0x2, %esi
jl 0x3f18
leal -0x1(%rsi), %eax
leaq 0x73cc(%rip), %rcx      # 0xb2e0
movl (%rcx,%rax,4), %r14d
movl 0xaa62(%rip), %ebp      # 0xe980
movslq 0x4(%rsp), %rax
decl %esi
movq %rsi, 0x20(%rsp)
leal -0x1(%r13), %ecx
movl %ecx, 0x8(%rsp)
leaq (%rax,%rax,4), %rax
leaq 0xa573(%rip), %rcx      # 0xe4b0
movq %rax, 0x50(%rsp)
leaq (%rcx,%rax,8), %rcx
addq $0x1c, %rcx
xorl %ebx, %ebx
movq $0x0, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movl -0xc(%rcx,%rbx,4), %esi
testl %esi, %esi
js 0x408e
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x2e23
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
setne %r15b
je 0x406c
sarq $0x2, %rcx
movl 0xa9da(%rip), %edx      # 0xe97c
cmpq $0x1, %rcx
movl $0x0, %esi
sbbq %rcx, %rsi
movl $0x1, %edi
movl -0x4(%rax,%rdi,4), %r8d
addl %r14d, %r8d
cmpl $0x1, %r13d
jne 0x3fce
testl %ebp, %ebp
jle 0x3fce
cmpl %edx, %r8d
jne 0x4034
decl %ebp
jmp 0x3fdf
movslq %r12d, %r12
movl %r8d, 0x10(%rsp,%r12,4)
incl %r12d
cmpl $0x3, %r12d
je 0x3ff8
cmpq %rdi, %rcx
seta %r15b
leaq (%rsi,%rdi), %r8
incq %r8
incq %rdi
cmpq $0x1, %r8
jne 0x3fb3
jmp 0x406c
movl 0x18(%rsp), %eax
movq 0x58(%rsp), %rcx
movl %eax, -0x4(%rcx)
movq 0x10(%rsp), %rax
movq %rax, -0xc(%rcx)
testl %ebp, %ebp
je 0x403e
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x8(%rsp), %edx
movl 0x4(%rsp), %ecx
callq 0x3ec9
movl %eax, 0xc(%rsp)
movl $0x3, %r12d
jmp 0x406c
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
jmp 0x406c
addl $0x2, (%rcx)
movl $0x3, %r12d
movl $0x0, 0xc(%rsp)
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x8(%rsp), %edx
movl 0x4(%rsp), %ecx
movl $0x3, %r8d
callq 0x3c18
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4083
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
testb $0x1, %r15b
movq 0x58(%rsp), %rcx
jne 0x40ab
cmpq $0x2, %rbx
leaq 0x1(%rbx), %rax
setae %dl
movq %rdx, 0x60(%rsp)
movq %rax, %rbx
cmpq $0x3, %rax
jne 0x3f5a
testb $0x1, 0x60(%rsp)
movl 0xc(%rsp), %eax
je 0x413b
cmpl $0x1, %r13d
jne 0x40fd
testl %r12d, %r12d
je 0x414a
testl %ebp, %ebp
jg 0x414a
testl %r12d, %r12d
movq 0x50(%rsp), %rcx
leaq 0xa3d4(%rip), %rdx      # 0xe4b0
jle 0x40e6
movl 0x10(%rsp), %eax
movl %eax, 0x10(%rdx,%rcx,8)
cmpl $0x2, %r12d
jl 0x40f4
movl 0x14(%rsp), %eax
movl %eax, 0x14(%rdx,%rcx,8)
addl $0x2, 0x1c(%rdx,%rcx,8)
xorl %eax, %eax
jmp 0x413b
testl %r12d, %r12d
movq 0x20(%rsp), %rsi
movq 0x50(%rsp), %rcx
leaq 0xa39f(%rip), %rdx      # 0xe4b0
jle 0x411b
movl 0x10(%rsp), %eax
movl %eax, 0x10(%rdx,%rcx,8)
cmpl $0x2, %r12d
jl 0x4129
movl 0x14(%rsp), %eax
movl %eax, 0x14(%rdx,%rcx,8)
movq 0x28(%rsp), %rdi
movl 0x8(%rsp), %edx
movl 0x4(%rsp), %ecx
callq 0x3ec9
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3fa2(%rip), %rdi      # 0x80f3
movl %r12d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2030
movl $0x7, %edi
callq 0x21a0
jmp 0x4169
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4183
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2220