// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3HashInsert
SQLITE_PRIVATE void *sqlite3HashInsert(Hash *pH, const char *pKey, int nKey, void *data){
  unsigned int h;       /* the hash of the key modulo hash table size */
  HashElem *elem;       /* Used to loop thru the element list */
  HashElem *new_elem;   /* New element added to the pH */

  assert( pH!=0 );
  assert( pKey!=0 );
  assert( nKey>=0 );
  if( pH->htsize ){
    h = strHash(pKey, nKey) % pH->htsize;
  }else{
    h = 0;
  }
  elem = findElementGivenHash(pH,pKey,nKey,h);
  if( elem ){
    void *old_data = elem->data;
    if( data==0 ){
      removeElementGivenHash(pH,elem,h);
    }else{
      elem->data = data;
      elem->pKey = pKey;
      assert(nKey==elem->nKey);
    }
    return old_data;
  }
  if( data==0 ) return 0;
  new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );
  if( new_elem==0 ) return data;
  new_elem->pKey = pKey;
  new_elem->nKey = nKey;
  new_elem->data = data;
  pH->count++;
  if( pH->count>=10 && pH->count > 2*pH->htsize ){
    if( rehash(pH, pH->count*2) ){
      assert( pH->htsize>0 );
      h = strHash(pKey, nKey) % pH->htsize;
    }
  }
  if( pH->ht ){
    insertElement(pH, &pH->ht[h], new_elem);
  }else{
    insertElement(pH, 0, new_elem);
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %rbx
movl (%rdi), %r13d
testl %r13d, %r13d
je 0x2f1e1
movq %r14, %rdi
movl %r12d, %esi
callq 0x2ef0d
xorl %edx, %edx
divl %r13d
movl %edx, %r13d
jmp 0x2f1e4
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
movl %r13d, %ecx
callq 0x2ef3e
testq %rax, %rax
je 0x2f214
movq 0x10(%rax), %r12
testq %r15, %r15
je 0x2f322
movq %r15, 0x10(%rax)
movq %r14, 0x18(%rax)
jmp 0x2f3cf
testq %r15, %r15
je 0x2f3cc
pushq $0x28
popq %rdi
callq 0x9c40
testq %rax, %rax
je 0x2f378
movq %r14, 0x18(%rax)
movl %r12d, 0x20(%rax)
movq %r15, 0x10(%rax)
movl 0x4(%rbx), %esi
incl %esi
movl %esi, 0x4(%rbx)
cmpl $0xa, %esi
jb 0x2f393
movl (%rbx), %ecx
leal (%rcx,%rcx), %edx
cmpl %edx, %esi
jbe 0x2f393
addl %esi, %esi
cmpl $0x40, %esi
pushq $0x40
popq %r15
cmovbl %esi, %r15d
cmpl %ecx, %r15d
je 0x2f393
movq %rax, -0x30(%rbp)
movq 0x59ce7(%rip), %rax     # 0x88f60
testq %rax, %rax
je 0x2f280
callq *%rax
shll $0x4, %r15d
movl %r15d, %edi
callq 0x9c40
movq %rax, %r15
movq 0x59cd2(%rip), %rax     # 0x88f68
testq %rax, %rax
je 0x2f29d
callq *%rax
testq %r15, %r15
movq -0x30(%rbp), %rax
je 0x2f393
movq 0x10(%rbx), %rdi
callq 0x9c7b
movq %r15, 0x10(%rbx)
movq %r15, %rdi
callq *0x58178(%rip)          # 0x87438
sarl $0x4, %eax
movl %eax, (%rbx)
movq %rax, -0x38(%rbp)
movq %rax, %rdx
shlq $0x4, %rdx
movq %r15, -0x40(%rbp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x81e0
movq 0x8(%rbx), %r13
andq $0x0, 0x8(%rbx)
testq %r13, %r13
je 0x2f37d
movq 0x18(%r13), %rdi
movl 0x20(%r13), %esi
callq 0x2ef0d
xorl %edx, %edx
divl -0x38(%rbp)
movq (%r13), %r15
shlq $0x4, %rdx
movq -0x40(%rbp), %rax
leaq (%rdx,%rax), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x2f3e1
movq %r15, %r13
jmp 0x2f2e7
movq (%rax), %rcx
movq 0x8(%rax), %rdx
leaq 0x8(%rbx), %rsi
testq %rdx, %rdx
cmovneq %rdx, %rsi
movq %rcx, (%rsi)
testq %rcx, %rcx
je 0x2f340
movq %rdx, 0x8(%rcx)
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
je 0x2f361
movl %r13d, %edi
shlq $0x4, %rdi
leaq (%rdx,%rdi), %rsi
cmpq %rax, 0x8(%rdx,%rdi)
jne 0x2f35f
movq %rcx, 0x8(%rsi)
decl (%rsi)
movq %rax, %rdi
callq 0x9c7b
decl 0x4(%rbx)
jne 0x2f3cf
movq %rbx, %rdi
callq 0x2be96
jmp 0x2f3cf
movq %r15, %r12
jmp 0x2f3cf
movq %r14, %rdi
movl %r12d, %esi
callq 0x2ef0d
xorl %edx, %edx
divl (%rbx)
movl %edx, %r13d
movq -0x30(%rbp), %rax
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
je 0x2f3b3
movl %r13d, %ecx
shlq $0x4, %rcx
addq %rcx, %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x2f3e1
jmp 0x2f3cc
movq 0x8(%rbx), %rcx
movq %rcx, (%rax)
testq %rcx, %rcx
je 0x2f3c3
movq %rax, 0x8(%rcx)
andq $0x0, 0x8(%rax)
movq %rax, 0x8(%rbx)
xorl %r12d, %r12d
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq