// File: /workspace/github_cpp_makefile_star2_O2/TooruAkagi[P]GCIS_Index/gcis_uni_locate.cpp
// Function: pscheck(int*, int, int, int)
int pscheck(int *m,int start,int plen, int round){ //完全一致を探す
    bool *bitlet;
    bitlet = (bool*)malloc(10000);
    //round 0 .. 0からccs[round]
    //round1 ccs[round](118)を足す
    //round2 dc2s[1](57466)を引いた値(0〜dc2s[1]〜[2]にccs[2](56461)を足す)
    //round3 dc2s[2]をひいてccs[3]を足す
    int rofs = ccs[round];
    if(round>=2){rofs-=dc2s[round-1];}
    int y = cmlen(m,start,plen,bitlet);
    int a,b,c,d;
    int posup = selectnew1(k3x,k3sub,k3sub2,m[start]+rofs,Sizelist[8],Sizelist[3],Sizelist[4]);
    int posbt = selectnew1(k3x,k3sub,k3sub2,m[start]+1+rofs,Sizelist[8],Sizelist[3],Sizelist[4]);
    int ry = posup;
    posup = sranknew0(posup,k3x,k3sub,k3sub2,Sizelist[3],Sizelist[4])-1;
    posbt = sranknew0(posbt,k3x,k3sub,k3sub2,Sizelist[3],Sizelist[4]);
    //if(posup>=661175){printf("[%d]のエラー:%d[%d]\n",m[start],ry,rofs);}
    //printf("%d > %d >> (%d 〜 %d)%d - %d[%d]\n",m[start]+rofs,ry,posup,posbt,plen,start,round);
    if(posup < dc2s[round]-1){posup = dc2s[round]-1;}
    if(posbt > dc2s[round+1]){posbt = dc2s[round+1];}
    int pos = 0;
    //printf("%d:(%d 〜 %d)%d - %d\n",rofs,posup,posbt,plen,start);
    //for(int y6=0;y6<plen;y6++){printf("[%d]",m[start+y6]);}
    //posup = 既に絶対違うと考えられるところ(round0だと-1)
    //posbt = 既に絶対違うと考えられるところ(round0だと分割数そのもの)
    while(1){
        pos = posup + (posbt-posup)/2;
        b = selectnew0(d2topx,d2topsub,d2topsub2,pos+1,Sizelist[9],Sizelist[5],Sizelist[6]);
        b = sranknew1(b,d2topx,d2topsub,d2topsub2,Sizelist[5],Sizelist[6]); //その位置までの1の数 = 開始文字.
        c = bread(d2under,pos*6,6);
        d = b*64+c;
        c = gread(d,k);d+=loga(c)*2-1;
            //if(round==9){gate++;}
            a = selectnew0(d2topx,d2topsub,d2topsub2,pos+2,Sizelist[9],Sizelist[5],Sizelist[6]);
            a = sranknew1(a,d2topx,d2topsub,d2topsub2,Sizelist[5],Sizelist[6]);
            a*=64;a+=bread(d2under,(pos+1)*6,6);a-=d;
        b = pscmpr(k,bitlet,d,0,kad,c-1,plen-1,y-1,a);
        //if(round==9){printf("\n[pscmpr(%d,%d,%d,%d / %d,%d,%d)\n]",a,c-1,y-1,b,posup,pos,posbt);}
        if(b==2){
            a = selectnew0(d2topx,d2topsub,d2topsub2,pos+2,Sizelist[9],Sizelist[5],Sizelist[6]);
            a = sranknew1(a,d2topx,d2topsub,d2topsub2,Sizelist[5],Sizelist[6]);
            a*=64;a+=bread(d2under,(pos+1)*6,6);
            if(a>d+kad){b=1;}
            if(a<=d+kad){b=pos;break;}
        }
        if(b==0){posup=pos;}
        if(b==1){posbt=pos;}
        if(posbt-posup<2){
            printf("\n分割にないため存在しない");pos=-1;
            break;
        }
    }
    if(pos==-1){
        //for(int yj=0;yj<plen;yj++){printf(" %d",m[start+yj]);}
        //for(int yj=0;yj<=loops;yj++){printf("\ndc2s[%d]=%d,%d",yj,dc2s[yj],ccs[yj]);}
        //for(int yj=1;yj<=loops;yj++){uhdisp(dc2s[yj]-1);}
        exit(6);
        }
   //printf(" -> %d\n",pos);
    return pos;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r14d
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
movl $0x2710, %edi           # imm = 0x2710
callq 0x21d0
movq %rax, 0x50(%rsp)
movslq %r14d, %r15
leaq 0x7174(%rip), %rax      # 0xa340
movl (%rax,%r15,4), %r13d
leaq 0x7119(%rip), %rax      # 0xa2f0
cmpl $0x2, %r15d
jl 0x31e4
decl %r14d
subl (%rax,%r14,4), %r13d
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
movq 0x50(%rsp), %rcx
callq 0x25b0
movl %eax, 0x28(%rsp)
movq 0x72b7(%rip), %rdi      # 0xa4b8
movq 0x7258(%rip), %rsi      # 0xa460
movq 0x7239(%rip), %rdx      # 0xa448
movslq %ebp, %r14
movl (%rbx,%r14,4), %ecx
addl %r13d, %ecx
movl 0x6fb0(%rip), %r8d      # 0xa1d0
movl 0x6f95(%rip), %r9d      # 0xa1bc
movl 0x6f93(%rip), %eax      # 0xa1c0
movl %eax, (%rsp)
callq 0x271e
movl %eax, %ebp
movq 0x727a(%rip), %rdi      # 0xa4b8
movq 0x721b(%rip), %rsi      # 0xa460
movq 0x71fc(%rip), %rdx      # 0xa448
movl (%rbx,%r14,4), %eax
leal 0x1(%r13,%rax), %ecx
movl 0x6f74(%rip), %r8d      # 0xa1d0
movl 0x6f59(%rip), %r9d      # 0xa1bc
movl 0x6f57(%rip), %eax      # 0xa1c0
movl %eax, (%rsp)
callq 0x271e
movl %eax, %ebx
movq 0x723e(%rip), %rsi      # 0xa4b8
movq 0x71df(%rip), %rdx      # 0xa460
movq 0x71c0(%rip), %rcx      # 0xa448
movl %ebp, %edi
callq 0x2710
movl %eax, %ebp
movq 0x7220(%rip), %rsi      # 0xa4b8
movq 0x71c1(%rip), %rdx      # 0xa460
movq 0x71a2(%rip), %rcx      # 0xa448
movl %ebx, %edi
callq 0x2710
leaq 0x703c(%rip), %rcx      # 0xa2f0
movl (%rcx,%r15,4), %r14d
cmpl %r14d, %ebp
cmovgl %ebp, %r14d
decl %r14d
movl 0x4(%rcx,%r15,4), %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
decl %r12d
movl %r12d, 0x44(%rsp)
decl 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
movl %ecx, %eax
subl %r14d, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %rax, 0x38(%rsp)
movq 0x71cd(%rip), %rbx      # 0xa4c0
movq 0x715e(%rip), %r13      # 0xa458
movq 0x713f(%rip), %rbp      # 0xa440
movl %eax, %r15d
addl %r14d, %r15d
movq %r14, 0x30(%rsp)
leal (%rax,%r14), %ecx
incl %ecx
movl 0x6ebb(%rip), %r8d      # 0xa1d4
movl 0x6ea4(%rip), %r9d      # 0xa1c4
movl 0x6ea2(%rip), %eax      # 0xa1c8
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2880
movl %eax, %edi
movq %rbx, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x2659
movl %eax, %ebx
movq 0x7158(%rip), %rdi      # 0xa4a8
movl %r15d, 0x24(%rsp)
imull $0x6, %r15d, %r14d
movl %r14d, %esi
pushq $0x6
popq %rdx
callq 0x24bf
shll $0x6, %ebx
addl %eax, %ebx
movq 0x7128(%rip), %rsi      # 0xa498
movl %ebx, %edi
callq 0x261f
movl %eax, %ebp
movl %eax, %edi
callq 0x249a
leal (%rbx,%rax,2), %r13d
decl %r13d
movq 0x7132(%rip), %r15      # 0xa4c0
movq 0x70c3(%rip), %r12      # 0xa458
movq 0x70a4(%rip), %rbx      # 0xa440
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rax
leal 0x2(%rcx,%rax), %ecx
movl 0x6e23(%rip), %r8d      # 0xa1d4
movl 0x6e0c(%rip), %r9d      # 0xa1c4
movl 0x6e0a(%rip), %eax      # 0xa1c8
movl %eax, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movl %ecx, 0x48(%rsp)
callq 0x2880
movl %eax, %edi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2659
movl %eax, %ebx
shll $0x6, %ebx
movq 0x70b9(%rip), %rdi      # 0xa4a8
addl $0x6, %r14d
movl %r14d, 0x4c(%rsp)
movl %r14d, %esi
pushq $0x6
popq %rdx
callq 0x24bf
subl %r13d, %ebx
addl %eax, %ebx
movq 0x7089(%rip), %rdi      # 0xa498
movl 0x6e7a(%rip), %r8d      # 0xa290
decl %ebp
movl %ebx, 0x10(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x44(%rsp), %eax
movl %eax, (%rsp)
movq 0x50(%rsp), %rsi
movl %r13d, 0x38(%rsp)
movl %r13d, %edx
xorl %ecx, %ecx
movl %ebp, %r9d
callq 0x3098
testl %eax, %eax
je 0x34d9
cmpl $0x1, %eax
je 0x34ce
cmpl $0x2, %eax
jne 0x34e2
movq 0x7061(%rip), %rbx      # 0xa4c0
movq 0x6ff2(%rip), %r15      # 0xa458
movq 0x6fd3(%rip), %r12      # 0xa440
movl 0x6d60(%rip), %r8d      # 0xa1d4
movl 0x6d49(%rip), %r9d      # 0xa1c4
movl 0x6d47(%rip), %eax      # 0xa1c8
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl 0x48(%rsp), %ecx
callq 0x2880
movl %eax, %edi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x2659
movl %eax, %ebx
shll $0x6, %ebx
movq 0x6ff6(%rip), %rdi      # 0xa4a8
movl 0x4c(%rsp), %esi
pushq $0x6
popq %rdx
callq 0x24bf
addl %ebx, %eax
movl 0x38(%rsp), %ecx
addl 0x6dc6(%rip), %ecx      # 0xa290
cmpl %ecx, %eax
jle 0x350f
movl 0x24(%rsp), %ecx
movq 0x30(%rsp), %r14
jmp 0x34eb
movl 0x24(%rsp), %eax
movl %eax, %r14d
jmp 0x34e7
movq 0x30(%rsp), %r14
movl 0x2c(%rsp), %ecx
movl %ecx, %eax
subl %r14d, %eax
cmpl $0x1, %eax
jg 0x32d8
leaq 0x3bfd(%rip), %rdi      # 0x70fd
xorl %eax, %eax
callq 0x2030
pushq $0x6
popq %rdi
callq 0x21c0
movl 0x24(%rsp), %eax
cmpl $-0x1, %eax
je 0x3507
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq