// File: TooruAkagi[P]GCIS_Index/gcis_uni_build.cpp
// Function: select0(bool*, int*, unsigned short*, int, int, int, int)
int select0(bool *u,int *u2,unsigned short int *u3,int c,int n,int t2,int t3){ //k番目の0を探す．
    int i = 0;
    int j = 0;
    int l = 0;
    int hmax = t2-1;int hmin = 0;
        if(lpurse-u2[0]<c){
            while(hmax>hmin+1){
                i = (hmax+hmin)/2;
                if((i+1)*lpurse-u2[i]>=c){hmax = i-1;}
                else{hmin = i;}
            }
            if((hmax+1)*lpurse-u2[hmax]>=c){i = hmin;hmax = hmin-1;}
            else{i=hmax;hmin = hmax;}
            l = (i+1)*lpurse-u2[i];
            i++;
        }
    int e = l;l=0;
    int ofi = i*spursesuu;
    j=0; //2
    hmin = 0;hmax = spursesuu-1;
    if(t2-1 == i){hmax = t3-1;}
    while(hmax>hmin+1){
        j = (hmax+hmin)/2;
        if(j*spurse-u3[ofi+j]>=c-e){hmax = j-1;}
        else{hmin = j;}
    }
    if(hmax*spurse-u3[ofi+hmax]>=c-e){j = hmin;}else{j = hmax;}
    if(j==spursesuu){j=spursesuu-1;}
    l = j*spurse-u3[ofi+j];
    e += l;
    for(int p=i*lpurse+j*spurse;p<n;p++){
        if(u[p]==0){
            e++;
            if(e==c){return p;}
        }
    }
    return n+1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl 0x4287(%rip), %eax      # 0x6130
movq -0x18(%rbp), %rcx
subl (%rcx), %eax
cmpl -0x24(%rbp), %eax
jge 0x1f66
jmp 0x1eba
movl -0x3c(%rbp), %eax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1f08
movl -0x3c(%rbp), %eax
addl -0x40(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
imull 0x424b(%rip), %eax      # 0x6130
movq -0x18(%rbp), %rcx
movslq -0x30(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
cmpl -0x24(%rbp), %eax
jl 0x1f00
movl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f06
movl -0x30(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x1eba
movl -0x3c(%rbp), %eax
addl $0x1, %eax
imull 0x421b(%rip), %eax      # 0x6130
movq -0x18(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
cmpl -0x24(%rbp), %eax
jl 0x1f36
movl -0x40(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x40(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f42
movl -0x3c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
imull 0x41e1(%rip), %eax      # 0x6130
movq -0x18(%rbp), %rcx
movslq -0x30(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x30(%rbp), %eax
imull 0x43d3(%rip), %eax      # 0x6350
movl %eax, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x40(%rbp)
movl 0x43bc(%rip), %eax      # 0x6350
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
subl $0x1, %eax
cmpl -0x30(%rbp), %eax
jne 0x1fae
movl 0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1fb0
movl -0x3c(%rbp), %eax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x2008
movl -0x3c(%rbp), %eax
addl -0x40(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
imull 0x415c(%rip), %eax      # 0x6134
movq -0x20(%rbp), %rcx
movl -0x48(%rbp), %edx
addl -0x34(%rbp), %edx
movslq %edx, %rdx
movzwl (%rcx,%rdx,2), %ecx
subl %ecx, %eax
movl -0x24(%rbp), %ecx
subl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2000
movl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2006
movl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x1fb0
movl -0x3c(%rbp), %eax
imull 0x4122(%rip), %eax      # 0x6134
movq -0x20(%rbp), %rcx
movl -0x48(%rbp), %edx
addl -0x3c(%rbp), %edx
movslq %edx, %rdx
movzwl (%rcx,%rdx,2), %ecx
subl %ecx, %eax
movl -0x24(%rbp), %ecx
subl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2037
movl -0x40(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x203d
movl -0x3c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x430a(%rip), %eax      # 0x6350
jne 0x2054
movl 0x4302(%rip), %eax      # 0x6350
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
imull 0x40d6(%rip), %eax      # 0x6134
movq -0x20(%rbp), %rcx
movl -0x48(%rbp), %edx
addl -0x34(%rbp), %edx
movslq %edx, %rdx
movzwl (%rcx,%rdx,2), %ecx
subl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x30(%rbp), %eax
imull 0x40a9(%rip), %eax      # 0x6130
movl -0x34(%rbp), %ecx
imull 0x40a3(%rip), %ecx      # 0x6134
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x20db
movq -0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x20ce
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x20cc
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x20e4
jmp 0x20ce
jmp 0x20d0
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2096
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)