// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movl %ecx, %r14d
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
movl $0x2710, %edi           # imm = 0x2710
callq 0x21b0
movq %rax, 0x38(%rsp)
movslq %r14d, %r15
leaq 0x7f91(%rip), %rax      # 0xb330
movl (%rax,%r15,4), %r13d
leaq 0x7f36(%rip), %rax      # 0xb2e0
cmpl $0x2, %r15d
jl 0x33b7
decl %r14d
subl (%rax,%r14,4), %r13d
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
movq 0x38(%rsp), %rcx
callq 0x25de
movl %eax, 0x18(%rsp)
movq 0x80d4(%rip), %rdi      # 0xb4a8
movq 0x8075(%rip), %rsi      # 0xb450
movq 0x8056(%rip), %rdx      # 0xb438
movslq %ebp, %r14
movl (%rbx,%r14,4), %ecx
addl %r13d, %ecx
movl 0x7dcd(%rip), %r8d      # 0xb1c0
movl 0x7db2(%rip), %r9d      # 0xb1ac
movl 0x7db0(%rip), %eax      # 0xb1b0
movl %eax, (%rsp)
callq 0x2754
movl %eax, %ebp
movq 0x8097(%rip), %rdi      # 0xb4a8
movq 0x8038(%rip), %rsi      # 0xb450
movq 0x8019(%rip), %rdx      # 0xb438
movl (%rbx,%r14,4), %eax
leal 0x1(%r13,%rax), %ecx
movl 0x7d91(%rip), %r8d      # 0xb1c0
movl 0x7d76(%rip), %r9d      # 0xb1ac
movl 0x7d74(%rip), %eax      # 0xb1b0
movl %eax, (%rsp)
callq 0x2754
movl %eax, %ebx
movq 0x805b(%rip), %rsi      # 0xb4a8
movq 0x7ffc(%rip), %rdx      # 0xb450
movq 0x7fdd(%rip), %rcx      # 0xb438
movl %ebp, %edi
callq 0x268c
subl %eax, %ebp
movq 0x803d(%rip), %rsi      # 0xb4a8
movq 0x7fde(%rip), %rdx      # 0xb450
movq 0x7fbf(%rip), %rcx      # 0xb438
movl %ebx, %edi
callq 0x268c
subl %eax, %ebx
leaq 0x7e57(%rip), %rcx      # 0xb2e0
movl (%rcx,%r15,4), %eax
cmpl %eax, %ebp
cmovlel %eax, %ebp
decl %ebp
movl 0x4(%rcx,%r15,4), %eax
cmpl %eax, %ebx
cmovgel %eax, %ebx
decl %r12d
movl %r12d, 0x2c(%rsp)
decl 0x18(%rsp)
movl %ebx, 0x1c(%rsp)
subl %ebp, %ebx
movl %ebx, %edx
shrl $0x1f, %edx
addl %ebx, %edx
sarl %edx
movq 0x7ff0(%rip), %rbx      # 0xb4b0
movq 0x7f81(%rip), %r14      # 0xb448
movq 0x7f62(%rip), %r15      # 0xb430
leal (%rdx,%rbp), %ecx
incl %ecx
movl %edx, %r12d
addl %ebp, %r12d
movl 0x7ce4(%rip), %r8d      # 0xb1c4
movl 0x7ccd(%rip), %r9d      # 0xb1b4
movl 0x7ccb(%rip), %eax      # 0xb1b8
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rcx, 0x40(%rsp)
callq 0x28de
movl %eax, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x268c
movl $0x0, %r9d
testl %r12d, %r12d
js 0x3557
leal (%r12,%r12), %edx
leal (%rdx,%rdx,2), %ecx
leal (%rdx,%rdx,2), %esi
addl $0x6, %esi
movl 0x7cf3(%rip), %edx      # 0xb224
movq 0x7f60(%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 0x353e
movl %edx, 0x7ccd(%rip)      # 0xb224
shll $0x6, %eax
addl %r9d, %eax
movq 0x7f24(%rip), %r10      # 0xb488
movslq %eax, %rdx
leaq (%r10,%rdx), %rsi
movq $-0x1, %r9
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
movl $0x1, %r8d
addl $0x2, %edi
cmpb $0x1, 0x1(%rsi,%r9)
movq %r8, %rcx
leaq 0x1(%r9), %r9
leaq 0x1(%r8), %r8
jne 0x357d
movl %edi, %esi
addq $0x2, %rsi
leaq (%r10,%rdx), %rdi
decq %rdi
xorl %r13d, %r13d
movzbl (%rdi,%rcx), %edx
leal (%rdx,%r13,2), %r13d
incq %rcx
cmpq %rcx, %rsi
jne 0x35a3
testl %r13d, %r13d
movq %rbp, 0x20(%rsp)
movl %eax, 0x34(%rsp)
je 0x35cf
cmpl $0x1, %r13d
jne 0x35d7
movl $0x1, %r14d
jmp 0x3608
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x3608
movl $0x2, %esi
movl $0x1, %r14d
movl $0x1, %edx
movl %edx, %ecx
addl $0x2, %r14d
cmpl $0x1e, %edx
ja 0x35fc
addl %esi, %esi
leal 0x1(%rcx), %edx
cmpl %r13d, %esi
jbe 0x35e7
cmpl $0x1f, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovael %eax, %r14d
movq 0x7ea1(%rip), %r15      # 0xb4b0
movq 0x7e32(%rip), %rbx      # 0xb448
movq 0x7e13(%rip), %rbp      # 0xb430
leal 0x2(%r12), %ecx
movl 0x7b9b(%rip), %r8d      # 0xb1c4
movl 0x7b84(%rip), %r9d      # 0xb1b4
movl 0x7b82(%rip), %eax      # 0xb1b8
movl %eax, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movl %ecx, 0x30(%rsp)
callq 0x28de
movl %eax, %edi
movq %r15, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x268c
movq 0x40(%rsp), %rcx
addl %ecx, %ecx
leal (%rcx,%rcx,2), %ebp
xorl %ecx, %ecx
cmpl $-0x1, %r12d
movl 0x34(%rsp), %r10d
jl 0x36ad
leal 0x6(%rbp), %esi
movl 0x7ba9(%rip), %edx      # 0xb224
movl %ebp, %edi
leal (%r12,%r12,2), %ecx
leal 0x6(,%rcx,2), %r8d
addq 0x7e08(%rip), %rdi      # 0xb498
xorl %ecx, %ecx
movzbl (%rdi), %r9d
leal (%r9,%rcx,2), %ecx
incl %edx
incl %r8d
incq %rdi
cmpl %r8d, %esi
jg 0x3692
movl %edx, 0x7b77(%rip)      # 0xb224
addl %r10d, %r14d
shll $0x6, %eax
subl %r14d, %eax
addl %ecx, %eax
movq 0x7dc9(%rip), %rdi      # 0xb488
movl 0x7bba(%rip), %r8d      # 0xb280
decl %r13d
movl %eax, 0x10(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movq 0x38(%rsp), %rsi
movl %r14d, %edx
xorl %ecx, %ecx
movl %r13d, %r9d
callq 0x3270
testl %eax, %eax
je 0x37bc
cmpl $0x1, %eax
je 0x37b2
cmpl $0x2, %eax
jne 0x37c1
movq 0x7da1(%rip), %rbx      # 0xb4b0
movq 0x7d32(%rip), %r15      # 0xb448
movq %r12, %r13
movq 0x7d10(%rip), %r12      # 0xb430
movl 0x7a9d(%rip), %r8d      # 0xb1c4
movl 0x7a86(%rip), %r9d      # 0xb1b4
movl 0x7a84(%rip), %eax      # 0xb1b8
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl 0x30(%rsp), %ecx
callq 0x28de
movl %eax, %edi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %r13, %rbx
callq 0x268c
xorl %ecx, %ecx
cmpl $-0x1, %ebx
jl 0x379a
movl 0x7abb(%rip), %edx      # 0xb224
movl %ebp, %esi
addl $0x6, %ebp
leal (%rbx,%rbx,2), %ecx
leal 0x6(,%rcx,2), %edi
addq 0x7d19(%rip), %rsi      # 0xb498
xorl %ecx, %ecx
movzbl (%rsi), %r8d
leal (%r8,%rcx,2), %ecx
incl %edx
incl %edi
incq %rsi
cmpl %edi, %ebp
jg 0x3781
movl %edx, 0x7a8a(%rip)      # 0xb224
shll $0x6, %eax
addl %ecx, %eax
addl 0x7ada(%rip), %r14d     # 0xb280
cmpl %r14d, %eax
movq 0x20(%rsp), %rbp
jle 0x37ef
jmp 0x37ca
movl %r12d, %ebx
movq 0x20(%rsp), %rbp
jmp 0x37ca
movl %r12d, %ebp
jmp 0x37c6
movq 0x20(%rsp), %rbp
movl 0x1c(%rsp), %ebx
movl %ebx, %eax
subl %ebp, %eax
cmpl $0x1, %eax
jg 0x34aa
leaq 0x491f(%rip), %rdi      # 0x80fd
xorl %eax, %eax
callq 0x2030
movl $0x6, %edi
callq 0x21a0
cmpl $-0x1, %ebx
je 0x37e5
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq