// File: /workspace/github_c_makefile_star2_O0/TimeToogo[P]ff-proxy/src/hash_table.c
// Function: ff_hash_table_put_item
void ff_hash_table_put_item(struct ff_hash_table *hash_table, uint64_t item_id, void *item)
{
    pthread_mutex_lock(&ff_hash_table_data_mutex);

    union ff_hash_table_bucket *buckets = ff_hash_table_get_or_create_bucket(hash_table, item_id, true, NULL);

    // Find last node or matching in chain
    struct ff_hash_table_node *node = buckets->nodes;
    struct ff_hash_table_node *last_node = node;

    while (node != NULL)
    {
        // Item already exists, update in hash table
        if (node->item_id == item_id)
        {
            node->value = item;
            goto cleanup;
        }

        last_node = node;
        node = node->next;
    }

    // Store new item in hash table
    struct ff_hash_table_node *new_node = calloc(1, sizeof(struct ff_hash_table_node));
    new_node->item_id = item_id;
    new_node->value = item;

    if (last_node == NULL)
    {
        buckets->nodes = new_node;
    }
    else
    {
        last_node->next = new_node;
    }

    // Store new item in global linked list
    if (hash_table->linked_list == NULL)
    {
        hash_table->linked_list = new_node;
        hash_table->linked_list_last = new_node;
    }
    else
    {
        new_node->prev_in_list = hash_table->linked_list_last;
        hash_table->linked_list_last->next_in_list = new_node;
        hash_table->linked_list_last = new_node;
    }

    hash_table->length++;

cleanup:
    pthread_mutex_unlock(&ff_hash_table_data_mutex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0x7b5d(%rip), %rdi      # 0xb318
callq 0x2420
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3590
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x3828
movq -0x28(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x3812
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x38d0
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x37ed
movl $0x1, %edi
movl $0x28, %esi
callq 0x2200
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x30(%rbp)
jne 0x3866
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x3872
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x3897
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x38c3
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
leaq 0x7a41(%rip), %rdi      # 0xb318
callq 0x2240
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)