// File: /workspace/github_cpp_makefile_star2_O1/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 0x21b0
movq %rax, 0x40(%rsp)
movslq %r14d, %r15
leaq 0x7efa(%rip), %rax      # 0xb330
movl (%rax,%r15,4), %r13d
leaq 0x7e9f(%rip), %rax      # 0xb2e0
cmpl $0x2, %r15d
jl 0x344e
decl %r14d
subl (%rax,%r14,4), %r13d
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
movq 0x40(%rsp), %rcx
callq 0x25ec
movl %eax, 0x24(%rsp)
movq 0x803d(%rip), %rdi      # 0xb4a8
movq 0x7fde(%rip), %rsi      # 0xb450
movq 0x7fbf(%rip), %rdx      # 0xb438
movslq %ebp, %r14
movl (%rbx,%r14,4), %ecx
addl %r13d, %ecx
movl 0x7d36(%rip), %r8d      # 0xb1c0
movl 0x7d1b(%rip), %r9d      # 0xb1ac
movl 0x7d19(%rip), %eax      # 0xb1b0
movl %eax, (%rsp)
callq 0x2762
movl %eax, %ebp
movq 0x8000(%rip), %rdi      # 0xb4a8
movq 0x7fa1(%rip), %rsi      # 0xb450
movq 0x7f82(%rip), %rdx      # 0xb438
movl (%rbx,%r14,4), %eax
leal 0x1(%r13,%rax), %ecx
movl 0x7cfa(%rip), %r8d      # 0xb1c0
movl 0x7cdf(%rip), %r9d      # 0xb1ac
movl 0x7cdd(%rip), %eax      # 0xb1b0
movl %eax, (%rsp)
callq 0x2762
movl %eax, %r13d
movq 0x7fc3(%rip), %rsi      # 0xb4a8
movq 0x7f64(%rip), %rdx      # 0xb450
movq 0x7f45(%rip), %rcx      # 0xb438
movl %ebp, %edi
callq 0x269a
subl %eax, %ebp
movq 0x7fa5(%rip), %rsi      # 0xb4a8
movq 0x7f46(%rip), %rdx      # 0xb450
movq 0x7f27(%rip), %rcx      # 0xb438
movl %r13d, %edi
callq 0x269a
subl %eax, %r13d
leaq 0x7dbd(%rip), %rcx      # 0xb2e0
movl (%rcx,%r15,4), %eax
cmpl %eax, %ebp
cmovlel %eax, %ebp
decl %ebp
movl 0x4(%rcx,%r15,4), %eax
cmpl %eax, %r13d
cmovgel %eax, %r13d
decl %r12d
movl %r12d, 0x34(%rsp)
decl 0x24(%rsp)
movl %r13d, %eax
subl %ebp, %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movq 0x7f55(%rip), %rbx      # 0xb4b0
movq 0x7ee6(%rip), %r14      # 0xb448
movq 0x7ec7(%rip), %r12      # 0xb430
leal (%rdx,%rbp), %ecx
incl %ecx
movl %edx, %r15d
addl %ebp, %r15d
movl 0x7c49(%rip), %r8d      # 0xb1c4
movl 0x7c32(%rip), %r9d      # 0xb1b4
movl 0x7c30(%rip), %eax      # 0xb1b8
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rcx, 0x48(%rsp)
callq 0x293a
movl %eax, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x269a
movl $0x0, %r9d
testl %r15d, %r15d
js 0x35f2
leal (%r15,%r15), %edx
leal (%rdx,%rdx,2), %ecx
leal (%rdx,%rdx,2), %esi
addl $0x6, %esi
movl 0x7c58(%rip), %edx      # 0xb224
movq 0x7ec5(%rip), %rdi      # 0xb498
addq %rcx, %rdi
xorl %r9d, %r9d
movzbl (%rdi), %r8d
leal (%r8,%r9,2), %r9d
incl %edx
incl %ecx
incq %rdi
cmpl %ecx, %esi
jg 0x35d9
movl %edx, 0x7c32(%rip)      # 0xb224
shll $0x6, %eax
addl %r9d, %eax
movq 0x7e89(%rip), %rcx      # 0xb488
movslq %eax, %rdx
leaq (%rcx,%rdx), %rsi
movq $-0x1, %r9
movl $0x1, %r8d
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
addl $0x2, %edi
cmpb $0x1, 0x1(%rsi,%r9)
movq %r8, %r10
leaq 0x1(%r9), %r9
leaq 0x1(%r8), %r8
jne 0x3618
addq %rdx, %rcx
decq %rcx
movl %edi, %edx
addq $0x2, %rdx
xorl %r12d, %r12d
movzbl (%rcx,%r10), %esi
leal (%rsi,%r12,2), %r12d
incq %r10
cmpq %r10, %rdx
jne 0x363d
testl %r12d, %r12d
movl %r13d, 0x3c(%rsp)
movq %rbp, 0x50(%rsp)
movl %eax, 0x28(%rsp)
je 0x366f
cmpl $0x1, %r12d
jne 0x3677
movl $0x1, %r14d
jmp 0x36a8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x36a8
movl $0x2, %esi
movl $0x1, %r14d
movl $0x1, %edx
movl %edx, %ecx
addl $0x2, %r14d
cmpl $0x1e, %edx
ja 0x369c
addl %esi, %esi
leal 0x1(%rcx), %edx
cmpl %r12d, %esi
jbe 0x3687
cmpl $0x1f, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovael %eax, %r14d
movq 0x7e01(%rip), %rbx      # 0xb4b0
movq 0x7d92(%rip), %rbp      # 0xb448
movq 0x7d73(%rip), %r13      # 0xb430
leal 0x2(%r15), %ecx
movl 0x7afc(%rip), %r8d      # 0xb1c4
movl 0x7ae5(%rip), %r9d      # 0xb1b4
movl 0x7ae3(%rip), %eax      # 0xb1b8
movl %eax, (%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movl %ecx, 0x38(%rsp)
callq 0x293a
movl %eax, %edi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x269a
movq 0x48(%rsp), %rcx
addl %ecx, %ecx
leal (%rcx,%rcx,2), %r13d
xorl %ecx, %ecx
cmpl $-0x1, %r15d
movq 0x50(%rsp), %rbp
movl 0x28(%rsp), %r10d
jl 0x3754
leal 0x6(%r13), %esi
movl 0x7b03(%rip), %edx      # 0xb224
movl %r13d, %edi
leal (%r15,%r15,2), %ecx
leal 0x6(,%rcx,2), %r8d
addq 0x7d61(%rip), %rdi      # 0xb498
xorl %ecx, %ecx
movzbl (%rdi), %r9d
leal (%r9,%rcx,2), %ecx
incl %edx
incl %r8d
incq %rdi
cmpl %r8d, %esi
jg 0x3739
movl %edx, 0x7ad0(%rip)      # 0xb224
addl %r10d, %r14d
shll $0x6, %eax
subl %r14d, %eax
addl %ecx, %eax
movq 0x7d22(%rip), %rdi      # 0xb488
movl 0x7b13(%rip), %r8d      # 0xb280
decl %r12d
movl %eax, 0x10(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x34(%rsp), %eax
movl %eax, (%rsp)
movq 0x40(%rsp), %rsi
movl %r14d, %edx
xorl %ecx, %ecx
movl %r12d, %r9d
callq 0x3313
movl %eax, %ecx
cmpl $0x2, %eax
jne 0x3855
movq 0x7d09(%rip), %rbx      # 0xb4b0
movq %r15, 0x28(%rsp)
movq 0x7c95(%rip), %r15      # 0xb448
movq 0x7c76(%rip), %r12      # 0xb430
movl 0x7a03(%rip), %r8d      # 0xb1c4
movl 0x79ec(%rip), %r9d      # 0xb1b4
movl 0x79ea(%rip), %eax      # 0xb1b8
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl 0x38(%rsp), %ecx
callq 0x293a
movl %eax, %edi
movq %rbx, %rsi
movq %r15, %rdx
movq 0x28(%rsp), %r15
movq %r12, %rcx
callq 0x269a
xorl %ecx, %ecx
cmpl $-0x1, %r15d
jl 0x383b
movl 0x7a1e(%rip), %edx      # 0xb224
movl %r13d, %esi
addl $0x6, %r13d
leal (%r15,%r15,2), %ecx
leal 0x6(,%rcx,2), %edi
addq 0x7c79(%rip), %rsi      # 0xb498
xorl %ecx, %ecx
movzbl (%rsi), %r8d
leal (%r8,%rcx,2), %ecx
incl %edx
incl %edi
incq %rsi
cmpl %edi, %r13d
jg 0x3821
movl %edx, 0x79e9(%rip)      # 0xb224
shll $0x6, %eax
addl 0x7a3b(%rip), %r14d     # 0xb280
addl %ecx, %eax
xorl %ecx, %ecx
cmpl %r14d, %eax
setle %al
jle 0x3889
movb %al, %cl
incl %ecx
testl %ecx, %ecx
cmovel %r15d, %ebp
cmpl $0x1, %ecx
movl 0x3c(%rsp), %r13d
cmovel %r15d, %r13d
movl %r13d, %eax
subl %ebp, %eax
cmpl $0x1, %eax
jg 0x3546
leaq 0x4851(%rip), %rdi      # 0x80cd
xorl %eax, %eax
callq 0x2030
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %r15d
je 0x38a1
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x6, %edi
callq 0x21a0