// File: TooruAkagi[P]GCIS_Index/gcis_uni_locate.cpp
// Function: pscmpr(bool*, bool*, int, int, int, int, int, int, int)
int pscmpr(bool *ar,bool *ar2,int start,int start2,int l,int bl,int plen,int y,int a){ //分割2つの長さをlまで比べる．
    int od = 0;
    int key = 0;
    int len = 0;
    int rt = l;
    if(a<l){rt = a;} //rtはlとaのうち小さいほう
    int readcount = 0;
    int x;int i;
    for(i = 0;i<rt;i++){
        if(readcount==y && y!=0 && od==1){return 1;}
        if(readcount==bl && bl!=0 && od==2){return 0;}
        //if(gate>0){printf("\n%d ? %d",ar[start+i],ar2[start2+i]);}
        if(ar[start+i]!=ar2[start2+i]){
            if(key==0){
                if(ar[start+i]==0){x = 1;}
                else{x = 0;}
            }
            if(key==1){
                if(ar[start+i]==0){x=0;}
                else{x=1;}
            }
            if(od==3){x = (x+1)%2;}
            if(od==1){return 0;}
            if(od==2){return 1;}
            return x;
        }
        if((ar[start+i] == 1) && key == 0){len+=1;key=1;}
        if(key==0){len++;}
        else{
            len--;
            if(len==0){
                readcount++;
                //if(gate>0){printf("\n%d++",readcount);}
                key=0;
                if(readcount==y){od+=2;}
                if(readcount==bl){od+=1;}
                if(readcount>=plen){break;} //分割を全て読んでしまった
                if(od==1){
                    return 0;}
                if(od==2){
                    if(i+1==a){return 0;}
                    return 1;
                }
            }
        }
    }
    if(a<l){return 0;}
    if(a>l){return 1;}
    if(a==l){return 2;}
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x38(%rbp)
movl 0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x3cac
movl 0x20(%rbp), %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x3eb8
movl -0x3c(%rbp), %eax
cmpl 0x18(%rbp), %eax
jne 0x3ce6
cmpl $0x0, 0x18(%rbp)
je 0x3ce6
cmpl $0x1, -0x2c(%rbp)
jne 0x3ce6
movl $0x1, -0x4(%rbp)
jmp 0x3ef2
movl -0x3c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x3d06
cmpl $0x0, -0x28(%rbp)
je 0x3d06
cmpl $0x2, -0x2c(%rbp)
jne 0x3d06
movl $0x0, -0x4(%rbp)
jmp 0x3ef2
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
movq -0x18(%rbp), %rcx
movl -0x20(%rbp), %edx
addl -0x44(%rbp), %edx
movslq %edx, %rdx
movb (%rcx,%rdx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x3de3
cmpl $0x0, -0x30(%rbp)
jne 0x3d6b
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3d62
movl $0x1, -0x40(%rbp)
jmp 0x3d69
movl $0x0, -0x40(%rbp)
jmp 0x3d6b
cmpl $0x1, -0x30(%rbp)
jne 0x3d9d
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3d94
movl $0x0, -0x40(%rbp)
jmp 0x3d9b
movl $0x1, -0x40(%rbp)
jmp 0x3d9d
cmpl $0x3, -0x2c(%rbp)
jne 0x3db4
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0x40(%rbp)
cmpl $0x1, -0x2c(%rbp)
jne 0x3dc6
movl $0x0, -0x4(%rbp)
jmp 0x3ef2
cmpl $0x2, -0x2c(%rbp)
jne 0x3dd8
movl $0x1, -0x4(%rbp)
jmp 0x3ef2
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ef2
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x3e13
cmpl $0x0, -0x30(%rbp)
jne 0x3e13
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl $0x1, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x3e27
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3ea8
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x3ea6
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x3c(%rbp), %eax
cmpl 0x18(%rbp), %eax
jne 0x3e57
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x3e68
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x3c(%rbp), %eax
cmpl 0x10(%rbp), %eax
jl 0x3e72
jmp 0x3eb8
cmpl $0x1, -0x2c(%rbp)
jne 0x3e81
movl $0x0, -0x4(%rbp)
jmp 0x3ef2
cmpl $0x2, -0x2c(%rbp)
jne 0x3ea4
movl -0x44(%rbp), %eax
addl $0x1, %eax
cmpl 0x20(%rbp), %eax
jne 0x3e9b
movl $0x0, -0x4(%rbp)
jmp 0x3ef2
movl $0x1, -0x4(%rbp)
jmp 0x3ef2
jmp 0x3ea6
jmp 0x3ea8
jmp 0x3eaa
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3cba
movl 0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x3ec9
movl $0x0, -0x4(%rbp)
jmp 0x3ef2
movl 0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jle 0x3eda
movl $0x1, -0x4(%rbp)
jmp 0x3ef2
movl 0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x3eeb
movl $0x2, -0x4(%rbp)
jmp 0x3ef2
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)