// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %rcx, %r12
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movl (%rdi), %ecx
testl %ecx, %ecx
je 0x3445f
testl %r15d, %r15d
jle 0x34464
leal 0x1(%r15), %edx
xorl %r8d, %r8d
leaq 0x41c7a(%rip), %rsi     # 0x760b0
movq %r14, %rdi
leal (,%r8,8), %eax
movzbl (%rdi), %r9d
incq %rdi
movzbl (%r9,%rsi), %r9d
xorl %r8d, %eax
xorl %r9d, %eax
decl %edx
movl %eax, %r8d
cmpl $0x1, %edx
ja 0x34439
jmp 0x34466
xorl %r13d, %r13d
jmp 0x3446d
xorl %eax, %eax
xorl %edx, %edx
divl %ecx
movl %edx, %r13d
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
movl %r13d, %ecx
callq 0x340d9
testq %rax, %rax
je 0x34499
movq 0x10(%rax), %r15
testq %r12, %r12
je 0x344c2
movq %r12, 0x10(%rax)
movq %r14, 0x18(%rax)
jmp 0x346ed
testq %r12, %r12
je 0x346ea
cmpl $0x0, 0x5ff57(%rip)     # 0x94400
je 0x3451f
leaq -0x50(%rbp), %rsi
movl $0x28, %edi
callq 0x171f8
leaq -0x50(%rbp), %rax
movq (%rax), %rdx
jmp 0x3452d
movq (%rax), %rcx
movq 0x8(%rax), %rdx
leaq 0x8(%rbx), %rsi
testq %rdx, %rdx
cmovneq %rdx, %rsi
movq %rcx, (%rsi)
testq %rcx, %rcx
je 0x344e0
movq %rdx, 0x8(%rcx)
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
je 0x34501
movl %r13d, %edi
shlq $0x4, %rdi
leaq (%rdx,%rdi), %rsi
cmpq %rax, 0x8(%rdx,%rdi)
jne 0x344ff
movq %rcx, 0x8(%rsi)
decl (%rsi)
movq %rax, %rdi
callq 0xa3c7
decl 0x4(%rbx)
jne 0x346ed
movq %rbx, %rdi
callq 0x30d0d
jmp 0x346ed
movl $0x28, %edi
callq *0x5fef6(%rip)          # 0x94420
movq %rax, %rdx
testq %rdx, %rdx
je 0x346c9
movq %r14, 0x18(%rdx)
movl %r15d, 0x20(%rdx)
movq %r12, 0x10(%rdx)
movl 0x4(%rbx), %eax
incl %eax
movl %eax, 0x4(%rbx)
cmpl $0xa, %eax
jb 0x346ac
movl (%rbx), %ecx
leal (%rcx,%rcx), %esi
cmpl %esi, %eax
jbe 0x346ac
addl %eax, %eax
cmpl $0x40, %eax
movl $0x40, %r12d
cmovbl %eax, %r12d
cmpl %ecx, %r12d
je 0x346ac
movq %rdx, -0x30(%rbp)
movq 0x619dd(%rip), %rax     # 0x95f60
testq %rax, %rax
je 0x3458a
callq *%rax
shll $0x4, %r12d
movl %r12d, %edi
callq 0xa38c
movq %rax, %r12
movq 0x619c8(%rip), %rax     # 0x95f68
testq %rax, %rax
je 0x345a7
callq *%rax
testq %r12, %r12
movq -0x30(%rbp), %rdx
je 0x346ac
movq 0x10(%rbx), %rdi
callq 0xa3c7
movq %r12, 0x10(%rbx)
movq %r12, %rdi
callq *0x5fe6e(%rip)          # 0x94438
sarl $0x4, %eax
movl %eax, (%rbx)
movq %rax, -0x40(%rbp)
movq %rax, %rdx
shlq $0x4, %rdx
movq %r12, %rdi
xorl %r12d, %r12d
movq %rdi, -0x48(%rbp)
xorl %esi, %esi
callq 0x8200
movq 0x8(%rbx), %rcx
movq %rbx, -0x38(%rbp)
movq $0x0, 0x8(%rbx)
testq %rcx, %rcx
je 0x34664
leaq 0x41aa9(%rip), %r13     # 0x760b0
movl 0x20(%rcx), %edx
movl $0x0, %eax
testl %edx, %edx
jle 0x3463c
movq 0x18(%rcx), %rsi
incl %edx
xorl %edi, %edi
leal (,%rdi,8), %eax
movzbl (%rsi), %r8d
incq %rsi
movzbl (%r8,%r13), %r8d
xorl %edi, %eax
xorl %r8d, %eax
decl %edx
movl %eax, %edi
cmpl $0x1, %edx
ja 0x3461b
xorl %edx, %edx
divl -0x40(%rbp)
movq (%rcx), %rbx
shlq $0x4, %rdx
movq -0x48(%rbp), %rax
leaq (%rdx,%rax), %rsi
movq -0x38(%rbp), %rdi
movq %rcx, %rdx
callq 0x346ff
movq %rbx, %rcx
testq %rbx, %rbx
jne 0x34607
testl %r15d, %r15d
jle 0x3469a
incl %r15d
xorl %ecx, %ecx
leaq 0x41a3b(%rip), %rax     # 0x760b0
leal (,%rcx,8), %r12d
movzbl (%r14), %edx
incq %r14
movzbl (%rdx,%rax), %edx
xorl %ecx, %r12d
xorl %edx, %r12d
decl %r15d
movl %r12d, %ecx
cmpl $0x1, %r15d
ja 0x34675
movl %r12d, %eax
xorl %edx, %edx
movq -0x38(%rbp), %rbx
divl (%rbx)
movl %edx, %r13d
movq -0x30(%rbp), %rdx
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
je 0x346ce
movl %r13d, %eax
shlq $0x4, %rax
addq %rax, %rsi
movq %rbx, %rdi
callq 0x346ff
jmp 0x346ea
movq %r12, %r15
jmp 0x346ed
movq 0x8(%rbx), %rax
movq %rax, (%rdx)
testq %rax, %rax
je 0x346de
movq %rdx, 0x8(%rax)
movq $0x0, 0x8(%rdx)
movq %rdx, 0x8(%rbx)
xorl %r15d, %r15d
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq