// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movl %ecx, 0x8(%rsp)
movq %rdi, 0x28(%rsp)
testl %edx, %edx
jle 0x3fee
movl %edx, %r15d
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq $-0x1, 0x10(%rsp)
leal -0x1(%rsi), %eax
movl %eax, 0x4(%rsp)
xorl %r12d, %r12d
movl $0x0, %ebp
cmpl $0x2, %esi
jl 0x3e20
movl 0x4(%rsp), %eax
leaq 0x74c3(%rip), %rcx      # 0xb2e0
movl (%rcx,%rax,4), %ebp
movl 0xab59(%rip), %r13d     # 0xe980
movslq 0x8(%rsp), %rax
leal -0x1(%r15), %ecx
movl %ecx, 0xc(%rsp)
leaq (%rax,%rax,4), %rax
leaq 0xa671(%rip), %rcx      # 0xe4b0
movq %rax, 0x20(%rsp)
leaq (%rcx,%rax,8), %rbx
addq $0x1c, %rbx
xorl %r14d, %r14d
movq %rbx, 0x50(%rsp)
movl -0xc(%rbx,%r14,4), %esi
testl %esi, %esi
js 0x3f8a
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x2d93
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
je 0x3eee
sarq $0x2, %rcx
movl 0xaae7(%rip), %edx      # 0xe97c
cmpq $0x1, %rcx
movl $0x0, %esi
sbbq %rcx, %rsi
movb $0x1, %bl
movl $0x1, %edi
movl -0x4(%rax,%rdi,4), %r8d
addl %ebp, %r8d
cmpl $0x1, %r15d
jne 0x3ec5
testl %r13d, %r13d
jle 0x3ec5
cmpl %edx, %r8d
jne 0x3f2d
decl %r13d
jmp 0x3ed6
movslq %r12d, %r12
movl %r8d, 0x10(%rsp,%r12,4)
incl %r12d
cmpl $0x3, %r12d
je 0x3ef2
cmpq %rdi, %rcx
seta %bl
leaq (%rsi,%rdi), %r8
incq %r8
incq %rdi
cmpq $0x1, %r8
jne 0x3ea8
jmp 0x3f65
xorl %ebx, %ebx
jmp 0x3f65
movl 0x18(%rsp), %eax
movq 0x50(%rsp), %rcx
movl %eax, -0x4(%rcx)
movq 0x10(%rsp), %rax
movq %rax, -0xc(%rcx)
testl %r13d, %r13d
je 0x3f36
movq 0x28(%rsp), %rdi
movl 0x4(%rsp), %esi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x3dcb
movl %eax, (%rsp)
movl $0x3, %r12d
jmp 0x3f65
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
jmp 0x3f65
addl $0x2, (%rcx)
movl $0x3, %r12d
xorl %r13d, %r13d
movq 0x28(%rsp), %rdi
movl 0x4(%rsp), %esi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl $0x3, %r8d
callq 0x3b48
movl $0x0, (%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3f7c
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
testb $0x1, %bl
movq 0x50(%rsp), %rbx
jne 0x403e
incq %r14
cmpq $0x3, %r14
jne 0x3e54
cmpl $0x1, %r15d
jne 0x3ff2
testl %r12d, %r12d
je 0x4050
testl %r13d, %r13d
jg 0x4050
testl %r12d, %r12d
jle 0x3fe2
movl 0x10(%rsp), %eax
movq 0x20(%rsp), %rcx
leaq 0xa4ec(%rip), %rdx      # 0xe4b0
movl %eax, 0x10(%rdx,%rcx,8)
cmpl $0x1, %r12d
je 0x3fe2
movl 0x14(%rsp), %eax
movq 0x20(%rsp), %rcx
leaq 0xa4d2(%rip), %rdx      # 0xe4b0
movl %eax, 0x14(%rdx,%rcx,8)
addl $0x2, (%rbx)
movl $0x0, (%rsp)
jmp 0x403e
xorl %eax, %eax
jmp 0x4041
testl %r12d, %r12d
jle 0x4025
movl 0x10(%rsp), %eax
movq 0x20(%rsp), %rcx
leaq 0xa4a9(%rip), %rdx      # 0xe4b0
movl %eax, 0x10(%rdx,%rcx,8)
cmpl $0x1, %r12d
je 0x4025
movl 0x14(%rsp), %eax
movq 0x20(%rsp), %rcx
leaq 0xa48f(%rip), %rdx      # 0xe4b0
movl %eax, 0x14(%rdx,%rcx,8)
movq 0x28(%rsp), %rdi
movl 0x4(%rsp), %esi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x3dcb
movl %eax, (%rsp)
movl (%rsp), %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40cc(%rip), %rdi      # 0x8123
movl %r12d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x2030
movl $0x7, %edi
callq 0x21a0
jmp 0x4070
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x408a
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2220