// File: /workspace/github_c_makefile_star2_O1/buf1024[P]mysch/dict.c
// Function: dict_add
int dict_add(dict *d, void *key, int keylen, void *val, int vallen)
{
    int index;
    dict_entry *entry;
    dictht *ht;

    if (dict_is_rehashing(d))
        _dict_rehash_step(d);

    /* Get the index of the new element, or -1 if
     * the element already exists. */
    if ((index = _dict_key_index(d, key, keylen)) == -1)
    {
        return DICT_ERR;
    }

    /* Allocates the memory and stores key */
    ht = dict_is_rehashing(d) ? &d->ht[1] : &d->ht[0];
    entry = (dict_entry*)malloc(sizeof(*entry));

    entry->next = ht->table[index];
    ht->table[index] = entry;
    ht->used++;

    /* Set the hash entry fields. */
    entry->key = key;
    entry->keylen = keylen;
    entry->val = val;
    entry->vallen = vallen;

    return DICT_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r8d, -0x3c(%rbp)
movq %rcx, -0x48(%rbp)
movl %edx, %r15d
movq %rsi, %r8
movq %rdi, %r12
cmpl $-0x1, 0x48(%rdi)
je 0x2a7d
cmpl $0x0, 0x4c(%r12)
jne 0x2a7d
movq %r12, %rdi
movl $0x1, %esi
movq %r8, %rbx
callq 0x27fb
movq %rbx, %r8
cmpl $-0x1, 0x48(%r12)
je 0x2aaf
testl %r15d, %r15d
je 0x2ae9
movl %r15d, %eax
movl $0x1505, %r14d          # imm = 0x1505
xorl %ecx, %ecx
movl %r14d, %edx
shll $0x5, %edx
addl %r14d, %edx
movzbl (%r8,%rcx), %r14d
addl %edx, %r14d
incq %rcx
cmpl %ecx, %eax
jne 0x2a95
jmp 0x2aef
movq 0x10(%r12), %rcx
testq %rcx, %rcx
je 0x2be6
movq 0x20(%r12), %rsi
cmpq %rcx, %rsi
jb 0x2a85
cmpb $0x1, 0x972e(%rip)      # 0xc1fc
jne 0x2ade
movq %rsi, %rax
xorl %edx, %edx
divq %rcx
cmpq $0x6, %rax
jb 0x2a85
movq %r8, %rbx
addq %rsi, %rsi
jmp 0x2bee
movl $0x1505, %r14d          # imm = 0x1505
leaq 0x8(%r12), %rax
movq %rax, -0x50(%rbp)
movslq %r15d, %rbx
xorl %eax, %eax
movq %r12, -0x30(%rbp)
movq %rax, -0x58(%rbp)
shlq $0x5, %rax
movq -0x50(%rbp), %rdx
movl 0x10(%rdx,%rax), %ecx
andl %r14d, %ecx
movq (%rdx,%rax), %rax
movq %rcx, -0x38(%rbp)
movq (%rax,%rcx,8), %r12
testq %r12, %r12
je 0x2b52
cmpl %r15d, (%r12)
jne 0x2b4b
movq 0x8(%r12), %rsi
movq %r8, %rdi
movq %rbx, %rdx
movl %r15d, %r13d
movq %r8, %r15
callq 0x22c0
movq %r15, %r8
movl %r13d, %r15d
testl %eax, %eax
je 0x2b6c
movq 0x18(%r12), %r12
jmp 0x2b20
movq -0x58(%rbp), %rax
testq %rax, %rax
jne 0x2b75
incq %rax
movq -0x30(%rbp), %r12
cmpl $-0x1, 0x48(%r12)
jne 0x2b01
jmp 0x2b79
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %r12
movq -0x38(%rbp), %rax
cmpl $-0x1, %eax
je 0x2bd2
movq %rax, %r13
xorl %ebx, %ebx
cmpl $-0x1, 0x48(%r12)
setne %bl
shll $0x5, %ebx
movl $0x20, %edi
movq %r8, %r14
callq 0x22a0
movq 0x8(%r12,%rbx), %rcx
movslq %r13d, %rdx
movq (%rcx,%rdx,8), %rsi
movq %rsi, 0x18(%rax)
movq %rax, (%rcx,%rdx,8)
incq 0x20(%r12,%rbx)
movq %r14, 0x8(%rax)
movl %r15d, (%rax)
movq -0x48(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x3c(%rbp), %ecx
movl %ecx, 0x4(%rax)
xorl %eax, %eax
jmp 0x2bd7
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, %rbx
movl $0x4, %esi
movq %r12, %rdi
callq 0x275e
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, -0x38(%rbp)
testl %eax, %eax
movq %rbx, %r8
jne 0x2b79
jmp 0x2a85