// File: /workspace/github_c_makefile_star2_O1/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 0x33d49
testl %r15d, %r15d
jle 0x33d4e
leal 0x1(%r15), %edx
xorl %r8d, %r8d
leaq 0x42340(%rip), %rsi     # 0x76060
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
jg 0x33d23
jmp 0x33d50
xorl %r13d, %r13d
jmp 0x33d57
xorl %eax, %eax
xorl %edx, %edx
divl %ecx
movl %edx, %r13d
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
movl %r13d, %ecx
callq 0x339dc
testq %rax, %rax
je 0x33d87
movq 0x10(%rax), %r15
testq %r12, %r12
je 0x33f39
movq %r12, 0x10(%rax)
movq %r14, 0x18(%rax)
jmp 0x33fb6
testq %r12, %r12
je 0x33fb3
movl $0x28, %edi
callq 0xa2a2
testq %rax, %rax
je 0x33f92
movq %r14, 0x18(%rax)
movl %r15d, 0x20(%rax)
movq %r12, 0x10(%rax)
movl 0x4(%rbx), %esi
incl %esi
movl %esi, 0x4(%rbx)
cmpl $0xa, %esi
jb 0x33f19
movl (%rbx), %ecx
leal (%rcx,%rcx), %edx
cmpl %edx, %esi
jbe 0x33f19
addl %esi, %esi
cmpl $0x40, %esi
movl $0x40, %r12d
cmovbl %esi, %r12d
cmpl %ecx, %r12d
je 0x33f19
movq %rax, -0x30(%rbp)
movq 0x62170(%rip), %rax     # 0x95f60
testq %rax, %rax
je 0x33df7
callq *%rax
shll $0x4, %r12d
movl %r12d, %edi
callq 0xa2a2
movq %rax, %r12
movq 0x6215b(%rip), %rax     # 0x95f68
testq %rax, %rax
je 0x33e14
callq *%rax
testq %r12, %r12
movq -0x30(%rbp), %rax
je 0x33f19
movq 0x10(%rbx), %rdi
callq 0xa2e8
movq %r12, 0x10(%rbx)
movq %r12, %rdi
callq *0x60601(%rip)          # 0x94438
sarl $0x4, %eax
movl %eax, (%rbx)
movq %rax, -0x40(%rbp)
movq %rax, %rdx
shlq $0x4, %rdx
xorl %r13d, %r13d
movq %r12, -0x48(%rbp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x8200
movq 0x8(%rbx), %rcx
movq %rbx, -0x38(%rbp)
movq $0x0, 0x8(%rbx)
testq %rcx, %rcx
je 0x33ed1
leaq 0x421ec(%rip), %r12     # 0x76060
movl 0x20(%rcx), %edx
movl $0x0, %eax
testl %edx, %edx
jle 0x33ea9
movq 0x18(%rcx), %rsi
incl %edx
xorl %edi, %edi
leal (,%rdi,8), %eax
movzbl (%rsi), %r8d
incq %rsi
movzbl (%r8,%r12), %r8d
xorl %edi, %eax
xorl %r8d, %eax
decl %edx
movl %eax, %edi
cmpl $0x1, %edx
jg 0x33e88
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 0x33fc8
movq %rbx, %rcx
testq %rbx, %rbx
jne 0x33e74
testl %r15d, %r15d
jle 0x33f07
incl %r15d
xorl %ecx, %ecx
leaq 0x4217e(%rip), %rax     # 0x76060
leal (,%rcx,8), %r13d
movzbl (%r14), %edx
incq %r14
movzbl (%rdx,%rax), %edx
xorl %ecx, %r13d
xorl %edx, %r13d
decl %r15d
movl %r13d, %ecx
cmpl $0x1, %r15d
jg 0x33ee2
movl %r13d, %eax
xorl %edx, %edx
movq -0x38(%rbp), %rbx
divl (%rbx)
movl %edx, %r13d
movq -0x30(%rbp), %rax
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
je 0x33f97
movl %r13d, %ecx
shlq $0x4, %rcx
addq %rcx, %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x33fc8
jmp 0x33fb3
movq 0x8(%rax), %rdx
leaq 0x8(%rbx), %rcx
testq %rdx, %rdx
cmovneq %rdx, %rcx
movq (%rax), %rsi
movq %rsi, (%rcx)
movq (%rax), %rcx
testq %rcx, %rcx
je 0x33f5a
movq %rdx, 0x8(%rcx)
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
je 0x33f7b
movl %r13d, %edi
shlq $0x4, %rdi
leaq (%rdx,%rdi), %rsi
cmpq %rax, 0x8(%rdx,%rdi)
jne 0x33f79
movq %rcx, 0x8(%rsi)
decl (%rsi)
movq %rax, %rdi
callq 0xa2e8
decl 0x4(%rbx)
jne 0x33fb6
movq %rbx, %rdi
callq 0x30403
jmp 0x33fb6
movq %r12, %r15
jmp 0x33fb6
movq 0x8(%rbx), %rcx
movq %rcx, (%rax)
testq %rcx, %rcx
je 0x33fa7
movq %rax, 0x8(%rcx)
movq $0x0, 0x8(%rax)
movq %rax, 0x8(%rbx)
xorl %r15d, %r15d
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq