// File: 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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
cmpl $0x1, -0x18(%rbp)
jge 0x4ada
movl $0x0, -0x4(%rbp)
jmp 0x4e58
movq 0x6c03(%rip), %rax      # 0xb6e4
movq %rax, -0x28(%rbp)
movl 0x6c01(%rip), %eax      # 0xb6ec
movl %eax, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl 0xce8e(%rip), %eax      # 0x11990
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0x4b21
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x97d5(%rip), %rax      # 0xe2f0
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x4d53
movslq -0x1c(%rbp), %rcx
leaq 0xc983(%rip), %rax      # 0x114c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl -0x38(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
cmpl $-0x1, (%rax,%rcx,4)
jle 0x4d43
leaq -0x50(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x9db0
movq -0x70(%rbp), %rdi
movslq -0x1c(%rbp), %rax
leaq (%rax,%rax,4), %rcx
leaq 0xc949(%rip), %rax      # 0x114c0
leaq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movl 0x10(%rax,%rcx,4), %esi
callq 0x34c0
jmp 0x4b8a
movl $0x0, -0x60(%rbp)
movslq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x9d90
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x4d23
cmpl $0x0, -0x34(%rbp)
jle 0x4c1c
cmpl $0x1, -0x18(%rbp)
jne 0x4c1c
movl -0x30(%rbp), %eax
movl %eax, -0x7c(%rbp)
movslq -0x60(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x9dd0
movq %rax, %rcx
movl -0x7c(%rbp), %eax
addl (%rcx), %eax
cmpl 0xcdad(%rip), %eax      # 0x1198c
jne 0x4c09
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4d15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x9df0
jmp 0x4e64
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x64(%rbp)
jmp 0x4d2a
movl -0x30(%rbp), %eax
movl %eax, -0x80(%rbp)
movslq -0x60(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x9dd0
movl -0x80(%rbp), %ecx
addl (%rax), %ecx
movslq -0x2c(%rbp), %rax
movl %ecx, -0x28(%rbp,%rax,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x3, -0x2c(%rbp)
jne 0x4d13
movl $0x0, -0x68(%rbp)
cmpl $0x3, -0x68(%rbp)
jge 0x4c8d
movslq -0x68(%rbp), %rax
movl -0x28(%rbp,%rax,4), %edx
movslq -0x1c(%rbp), %rcx
leaq 0xc851(%rip), %rax      # 0x114c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl -0x68(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x4c56
cmpl $0x0, -0x34(%rbp)
jne 0x4ce3
movslq -0x1c(%rbp), %rax
leaq (%rax,%rax,4), %rcx
leaq 0xc81e(%rip), %rax      # 0x114c0
movl 0x1c(%rax,%rcx,8), %edx
addl $0x2, %edx
movl %edx, 0x1c(%rax,%rcx,8)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
decl %esi
movl -0x18(%rbp), %edx
decl %edx
movl -0x1c(%rbp), %ecx
movl $0x3, %r8d
callq 0x4820
movl %eax, -0x84(%rbp)
jmp 0x4cd1
movl -0x84(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0x4d2a
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
decl %esi
movl -0x18(%rbp), %edx
decl %edx
movl -0x1c(%rbp), %ecx
callq 0x4ab0
movl %eax, -0x88(%rbp)
jmp 0x4d01
movl -0x88(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0x4d2a
jmp 0x4d15
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x4b91
movl $0x0, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x9df0
movl -0x64(%rbp), %eax
testl %eax, %eax
je 0x4d41
jmp 0x4d3c
jmp 0x4e58
jmp 0x4d43
jmp 0x4d45
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x4b28
cmpl $0x1, -0x18(%rbp)
jne 0x4e01
cmpl $0x0, -0x2c(%rbp)
je 0x4d69
cmpl $0x0, -0x34(%rbp)
jle 0x4d87
movl -0x2c(%rbp), %esi
movl -0x34(%rbp), %edx
leaq 0x63be(%rip), %rdi      # 0xb134
movb $0x0, %al
callq 0x2030
movl $0x7, %edi
callq 0x21e0
cmpl $0x1, -0x2c(%rbp)
jl 0x4da5
movl -0x28(%rbp), %ecx
movslq -0x1c(%rbp), %rdx
leaq 0xc725(%rip), %rax      # 0x114c0
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
cmpl $0x2, -0x2c(%rbp)
jl 0x4dc3
movl -0x24(%rbp), %ecx
movslq -0x1c(%rbp), %rdx
leaq 0xc707(%rip), %rax      # 0x114c0
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movslq -0x1c(%rbp), %rcx
leaq 0xc6f2(%rip), %rax      # 0x114c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
subl $0x1, %esi
movl -0x18(%rbp), %edx
subl $0x1, %edx
movl -0x1c(%rbp), %ecx
movl $0x3, %r8d
callq 0x4820
movl %eax, -0x4(%rbp)
jmp 0x4e58
cmpl $0x1, -0x2c(%rbp)
jl 0x4e1f
movl -0x28(%rbp), %ecx
movslq -0x1c(%rbp), %rdx
leaq 0xc6ab(%rip), %rax      # 0x114c0
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
cmpl $0x2, -0x2c(%rbp)
jl 0x4e3d
movl -0x24(%rbp), %ecx
movslq -0x1c(%rbp), %rdx
leaq 0xc68d(%rip), %rax      # 0x114c0
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
subl $0x1, %esi
movl -0x18(%rbp), %edx
subl $0x1, %edx
movl -0x1c(%rbp), %ecx
callq 0x4ab0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x2250
nopl (%rax)