// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
cmpl $0x1, -0x20(%rbp)
jge 0x384c
movl $0x0, -0x4(%rbp)
jmp 0x3b6b
movq 0x5e79(%rip), %rax      # 0x96cc
movq %rax, -0x30(%rbp)
movl 0x5e77(%rip), %eax      # 0x96d4
movl %eax, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl 0x9ddc(%rip), %eax      # 0xd650
movl %eax, -0x3c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jle 0x3893
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x9e23(%rip), %rax      # 0xd6b0
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x3, -0x40(%rbp)
jge 0x3a5c
movslq -0x24(%rbp), %rcx
leaq 0x98d1(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl -0x40(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
cmpl $-0x1, (%rax,%rcx,4)
jle 0x3a4c
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rdx
leaq 0x98a8(%rip), %rcx      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl -0x40(%rbp), %edx
addl $0x4, %edx
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x24(%rbp), %rsi
leaq 0x987c(%rip), %rdx      # 0xd180
imulq $0x28, %rsi, %rsi
addq %rsi, %rdx
movl -0x40(%rbp), %esi
addl $0x4, %esi
movslq %esi, %rsi
movl (%rdx,%rsi,4), %edx
addl $0x1, %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x3a4a
cmpl $0x0, -0x3c(%rbp)
jle 0x3962
cmpl $0x1, -0x20(%rbp)
jne 0x3962
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x44(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
cmpl 0x9d06(%rip), %eax      # 0xd64c
jne 0x3956
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3a3c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3b6b
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rdx
addl (%rax,%rdx,4), %ecx
movslq -0x34(%rbp), %rax
movl %ecx, -0x30(%rbp,%rax,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x3, -0x34(%rbp)
jne 0x3a3a
movl $0x0, -0x48(%rbp)
cmpl $0x3, -0x48(%rbp)
jge 0x39c9
movslq -0x48(%rbp), %rax
movl -0x30(%rbp,%rax,4), %edx
movslq -0x24(%rbp), %rcx
leaq 0x97d5(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl -0x48(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x3992
cmpl $0x0, -0x3c(%rbp)
jne 0x3a15
movslq -0x24(%rbp), %rcx
leaq 0x97a6(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
subl $0x1, %edx
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movl -0x24(%rbp), %r8d
movl $0x3, %r9d
callq 0x35e0
movl %eax, -0x4(%rbp)
jmp 0x3b6b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
subl $0x1, %edx
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movl -0x24(%rbp), %r8d
callq 0x3820
movl %eax, -0x4(%rbp)
jmp 0x3b6b
jmp 0x3a3c
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x38f2
jmp 0x3a4c
jmp 0x3a4e
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x389a
cmpl $0x1, -0x20(%rbp)
jne 0x3b0f
cmpl $0x0, -0x34(%rbp)
je 0x3a72
cmpl $0x0, -0x3c(%rbp)
jle 0x3a90
movl -0x34(%rbp), %esi
movl -0x3c(%rbp), %edx
leaq 0x567d(%rip), %rdi      # 0x90fc
movb $0x0, %al
callq 0x2030
movl $0x7, %edi
callq 0x2190
cmpl $0x1, -0x34(%rbp)
jl 0x3aae
movl -0x30(%rbp), %ecx
movslq -0x24(%rbp), %rdx
leaq 0x96dc(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
cmpl $0x2, -0x34(%rbp)
jl 0x3acc
movl -0x2c(%rbp), %ecx
movslq -0x24(%rbp), %rdx
leaq 0x96be(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movslq -0x24(%rbp), %rcx
leaq 0x96a9(%rip), %rax      # 0xd180
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
subl $0x1, %edx
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movl -0x24(%rbp), %r8d
movl $0x3, %r9d
callq 0x35e0
movl %eax, -0x4(%rbp)
jmp 0x3b6b
cmpl $0x1, -0x34(%rbp)
jl 0x3b2d
movl -0x30(%rbp), %ecx
movslq -0x24(%rbp), %rdx
leaq 0x965d(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
cmpl $0x2, -0x34(%rbp)
jl 0x3b4b
movl -0x2c(%rbp), %ecx
movslq -0x24(%rbp), %rdx
leaq 0x963f(%rip), %rax      # 0xd180
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
subl $0x1, %edx
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movl -0x24(%rbp), %r8d
callq 0x3820
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)