// File: /workspace/github_cpp_makefile_star2_O3/attractivechaos[P]udb2/bkthomps-hashmap/unordered_map.c
// Function: unordered_map_put
int unordered_map_put(unordered_map me, void *const key, void *const value)
{

    const unsigned long hash = me->hash(key);
    const int index = (int) (hash % me->capacity);
    if (!me->buckets[index]) {
        me->buckets[index] = unordered_map_create_element(me, hash, key, value);
        if (!me->buckets[index]) {
            return -ENOMEM;
        }
    } else {
        struct node *traverse = me->buckets[index];
        if (unordered_map_is_equal(me, traverse, hash, key)) {
            memcpy(traverse->value, value, me->value_size);
            return 0;
        }
        while (traverse->next) {
            traverse = traverse->next;
            if (unordered_map_is_equal(me, traverse, hash, key)) {
                memcpy(traverse->value, value, me->value_size);
                return 0;
            }
        }
        traverse->next = unordered_map_create_element(me, hash, key, value);
        if (!traverse->next) {
            return -ENOMEM;
        }
    }
    me->size++;
    if (me->size >= RESIZE_AT * me->capacity) {
        return unordered_map_resize(me);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq *0x10(%rbx)
movq %rax, %r12
movslq 0x24(%rbx), %rcx
xorl %edx, %edx
divq %rcx
movq 0x28(%rbx), %rax
movslq %edx, %rbp
movq (%rax,%rbp,8), %r13
testq %r13, %r13
je 0x1801
cmpq %r12, 0x10(%r13)
jne 0x182f
jmp 0x1841
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x195b
movq 0x28(%rbx), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0x28(%rbx), %rax
cmpq $0x0, (%rax,%rbp,8)
jne 0x1880
movl $0xfffffff4, %ebp       # imm = 0xFFFFFFF4
jmp 0x1941
movq 0x18(%r13), %rax
testq %rax, %rax
je 0x1866
movq %rax, %r13
cmpq %r12, 0x10(%rax)
jne 0x182f
movq (%r13), %rdi
movq %r15, %rsi
callq *0x18(%rbx)
testl %eax, %eax
jne 0x182f
movq 0x8(%r13), %rdi
movq 0x8(%rbx), %rdx
movq %r14, %rsi
callq 0x1070
xorl %ebp, %ebp
jmp 0x1941
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x195b
movq %rax, 0x18(%r13)
testq %rax, %rax
je 0x1825
movl 0x20(%rbx), %eax
movl 0x24(%rbx), %r12d
incl %eax
cvtsi2sd %eax, %xmm1
movl %eax, 0x20(%rbx)
cvtsi2sd %r12d, %xmm0
movsd 0x7fb(%rip), %xmm2      # 0x2098
mulsd %xmm0, %xmm2
xorl %ebp, %ebp
ucomisd %xmm2, %xmm1
jb 0x1941
mulsd 0x7eb(%rip), %xmm0      # 0x20a0
cvttsd2si %xmm0, %r13d
movq 0x28(%rbx), %r14
movslq %r13d, %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0x1050
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x1952
movl %r13d, 0x24(%rbx)
testl %r12d, %r12d
jle 0x1939
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rsi
testq %rsi, %rsi
je 0x1931
movq 0x10(%rsi), %rax
movq 0x18(%rsi), %rdi
movq 0x28(%rbx), %r8
xorl %edx, %edx
divq %r15
movq $0x0, 0x18(%rsi)
movslq %edx, %rax
movq (%r8,%rax,8), %rdx
testq %rdx, %rdx
je 0x1922
movq %rdx, %rax
movq 0x18(%rdx), %rdx
testq %rdx, %rdx
jne 0x1910
addq $0x18, %rax
jmp 0x1926
leaq (%r8,%rax,8), %rax
movq %rsi, (%rax)
movq %rdi, %rsi
testq %rdi, %rdi
jne 0x18eb
incq %rcx
cmpq %r12, %rcx
jne 0x18e2
movq %r14, %rdi
callq 0x1030
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x28(%rbx)
jmp 0x1825