// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %r8d, -0x4(%rsp)
movl 0x38(%rsp), %r14d
leal -0x1(%r9), %ebp
movl 0x3782(%rip), %r8d      # 0x5130
movl %r8d, %r15d
subl (%rsi), %r15d
xorl %r10d, %r10d
movl $0x0, %ebx
movl $0x0, %r11d
cmpl %ecx, %r15d
jge 0x1a2b
xorl %r11d, %r11d
movl %ebp, %ebx
cmpl $0x3, %r9d
jl 0x1a03
xorl %r11d, %r11d
movl %ebp, %ebx
leal (%r11,%rbx), %r9d
shrl %r9d
leal 0x1(%r9), %r15d
imull %r8d, %r15d
subl (%rsi,%r9,4), %r15d
cmpl %ecx, %r15d
jl 0x19f7
decl %r9d
movl %r9d, %ebx
jmp 0x19fa
movl %r9d, %r11d
leal 0x1(%r11), %r9d
cmpl %r9d, %ebx
jg 0x19d7
leal 0x1(%rbx), %r9d
imull %r8d, %r9d
movslq %ebx, %r15
subl (%rsi,%r15,4), %r9d
cmpl %ecx, %r9d
cmovgel %r11d, %r15d
leal 0x1(%r15), %ebx
movl %ebx, %r11d
imull %r8d, %r11d
movslq %r15d, %r9
subl (%rsi,%r9,4), %r11d
movl 0x391f(%rip), %eax      # 0x5350
movl %eax, %esi
imull %ebx, %esi
cmpl %ebx, %ebp
cmovnel %eax, %r14d
leal -0x1(%r14), %r12d
movl %ecx, %ebp
subl %r11d, %ebp
movl 0x36e8(%rip), %r9d      # 0x5134
cmpl $0x3, %r14d
jl 0x1a8b
xorl %r10d, %r10d
leal (%r10,%r12), %r14d
shrl %r14d
movl %r9d, %r13d
imull %r14d, %r13d
leal (%r14,%rsi), %r15d
movslq %r15d, %r15
movzwl (%rdx,%r15,2), %r15d
subl %r15d, %r13d
cmpl %ebp, %r13d
jl 0x1a7f
decl %r14d
movl %r14d, %r12d
jmp 0x1a82
movl %r14d, %r10d
leal 0x1(%r10), %r14d
cmpl %r14d, %r12d
jg 0x1a55
movl %r9d, %r14d
imull %r12d, %r14d
leal (%r12,%rsi), %r15d
movslq %r15d, %r15
movzwl (%rdx,%r15,2), %r15d
subl %r15d, %r14d
cmpl %ebp, %r14d
cmovll %r12d, %r10d
leal -0x1(%rax), %ebp
cmpl %eax, %r10d
cmovnel %r10d, %ebp
imull %ebp, %r9d
imull %r8d, %ebx
leal (%r9,%rbx), %r8d
movl -0x4(%rsp), %eax
cmpl %eax, %r8d
jge 0x1af8
addl %esi, %ebp
movslq %ebp, %rsi
movzwl (%rdx,%rsi,2), %edx
subl %edx, %r11d
addl %r9d, %r11d
movslq %r9d, %rsi
movslq %ebx, %rdx
addq %rsi, %rdx
movslq %eax, %rsi
cmpb $0x0, (%rdi,%rdx)
jne 0x1af0
incl %r11d
cmpl %ecx, %r11d
je 0x1b05
incq %rdx
cmpq %rsi, %rdx
jl 0x1ae2
incl %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edx, %eax
jmp 0x1afa