// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BitvecSet
SQLITE_PRIVATE int sqlite3BitvecSet(Bitvec *p, u32 i){
  u32 h;
  if( p==0 ) return SQLITE_OK;
  assert( i>0 );
  assert( i<=p->iSize );
  i--;
  while((p->iSize > BITVEC_NBIT) && p->iDivisor) {
    u32 bin = i/p->iDivisor;
    i = i%p->iDivisor;
    if( p->u.apSub[bin]==0 ){
      p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );
      if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM;
    }
    p = p->u.apSub[bin];
  }
  if( p->iSize<=BITVEC_NBIT ){
    p->u.aBitmap[i/BITVEC_SZELEM] |= 1 << (i&(BITVEC_SZELEM-1));
    return SQLITE_OK;
  }
  h = BITVEC_HASH(i++);
  /* if there wasn't a hash collision, and this doesn't */
  /* completely fill the hash, then just add it without */
  /* worring about sub-dividing and re-hashing. */
  if( !p->u.aHash[h] ){
    if (p->nSet<(BITVEC_NINT-1)) {
      goto bitvec_set_end;
    } else {
      goto bitvec_set_rehash;
    }
  }
  /* there was a collision, check to see if it's already */
  /* in hash, if not, try to find a spot for it */
  do {
    if( p->u.aHash[h]==i ) return SQLITE_OK;
    h++;
    if( h>=BITVEC_NINT ) h = 0;
  } while( p->u.aHash[h] );
  /* we didn't find it in the hash.  h points to the first */
  /* available free spot. check to see if this is going to */
  /* make our hash too "full".  */
bitvec_set_rehash:
  if( p->nSet>=BITVEC_MXHASH ){
    unsigned int j;
    int rc;
    u32 *aiValues = sqlite3StackAllocRaw(0, sizeof(p->u.aHash));
    if( aiValues==0 ){
      return SQLITE_NOMEM;
    }else{
      memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));
      memset(p->u.apSub, 0, sizeof(p->u.apSub));
      p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR;
      rc = sqlite3BitvecSet(p, i);
      for(j=0; j<BITVEC_NINT; j++){
        if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]);
      }
      sqlite3StackFree(0, aiValues);
      return rc;
    }
  }
bitvec_set_end:
  p->nSet++;
  p->u.aHash[h] = i;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x19189
movl %esi, %r12d
movq %rdi, %rax
decl %r12d
pushq $0x7
popq %r14
movq %rax, %rbx
cmpl $0xf81, (%rax)          # imm = 0xF81
jb 0x19122
movl 0x8(%rbx), %edi
testl %edi, %edi
je 0x19138
movl %r12d, %eax
xorl %edx, %edx
divl %edi
movl %eax, %r15d
movq 0x10(%rbx,%r15,8), %rax
movl %edx, %r12d
testq %rax, %rax
jne 0x190e8
callq 0x19221
movq %rax, 0x10(%rbx,%r15,8)
testq %rax, %rax
jne 0x190e8
jmp 0x1918c
movl %r12d, %ecx
andb $0x7, %cl
pushq $0x1
popq %rax
shll %cl, %eax
shrl $0x3, %r12d
orb %al, 0x10(%rbx,%r12)
jmp 0x19189
leal 0x1(%r12), %r15d
xorl %ecx, %ecx
pushq $0x7c
popq %rsi
movl %r12d, %eax
xorl %edx, %edx
divl %esi
leaq 0x10(%rbx), %r13
movl 0x10(%rbx,%rdx,4), %eax
testl %eax, %eax
je 0x19177
cmpl %r15d, %eax
je 0x19189
incl %edx
cmpl $0x7c, %edx
cmovael %ecx, %edx
movl (%r13,%rdx,4), %eax
testl %eax, %eax
jne 0x19155
movl 0x4(%rbx), %eax
cmpl $0x3d, %eax
ja 0x1919e
movl %edx, %edx
jmp 0x1917f
movl 0x4(%rbx), %eax
cmpl $0x7b, %eax
jae 0x1919e
incl %eax
movl %eax, 0x4(%rbx)
movl %r15d, 0x10(%rbx,%rdx,4)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1f0, %edi            # imm = 0x1F0
callq 0x9c40
testq %rax, %rax
je 0x1918c
movl $0x1f0, %edx            # imm = 0x1F0
movq %rax, %rdi
movq %r13, %rsi
movq %rax, -0x30(%rbp)
callq 0x82c0
xorl %r12d, %r12d
movl $0x1f0, %edx            # imm = 0x1F0
movq %r13, %rdi
xorl %esi, %esi
callq 0x81e0
movl (%rbx), %eax
addq $0x3d, %rax
pushq $0x3e
popq %rcx
xorl %edx, %edx
divq %rcx
movl %eax, 0x8(%rbx)
movq %rbx, %rdi
movl %r15d, %esi
callq 0x190c4
movl %eax, %r14d
movq -0x30(%rbp), %r15
cmpq $0x7c, %r12
je 0x19214
movl (%r15,%r12,4), %esi
testl %esi, %esi
je 0x1920f
movq %rbx, %rdi
callq 0x190c4
orl %eax, %r14d
incq %r12
jmp 0x191f6
movq %r15, %rdi
callq 0x9c7b
jmp 0x1918c