// File: /workspace/github_c_makefile_star2_O2/sasairc[P]clangsay/src/libbenly/src/hash.c
// Function: put_shash
static
int put_shash(SHASH** shash, const char* key, const char* value)
{
    int     status  = 0,
            pos     = 0;

    if (key == NULL || value == NULL)
        return -1;

    if ((pos = (*shash)->exists(*shash, key)) < 0) {
        if ((*shash)->elem_size <= (size_t)(*shash)->elemc) {
            if (reallocate_elem(shash) < 0) {
                status = -2; goto ERR;
            }
        }
        if (put_key_elem(shash, key, (*shash)->elemc) < 0) {
            status = -3; goto ERR;
        }
        if (put_value_elem(shash, value, (*shash)->elemc) < 0) {
            status = -4; goto ERR;
        }
        (*shash)->elemc++;
    } else {
        if (*(*((*shash)->elem + pos) + 1) != NULL) {
            free(*(*((*shash)->elem + pos) + 1));
            *(*((*shash)->elem + pos) + 1) = NULL;
        }
        if (put_value_elem(shash, value, pos) < 0) {
            status = -5; goto ERR;
        }
    }

    return 0;

ERR:
    switch (status) {
        case    -1:
        case    -2:
        case    -3:
            break;
        case    -4:
            remove_key_elem(*shash, (*shash)->elemc);
            *(*((*shash)->elem + (*shash)->elemc)) = NULL;
            break;
        case    -5:
            remove_key_elem(*shash, pos);
            *(*((*shash)->elem + pos)) = NULL;
            break;
    }

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
je 0x3abd
pushq $-0x1
popq %rbp
jmp 0x3b17
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rdi
callq *0x48(%rdi)
movq (%rbx), %r13
testl %eax, %eax
js 0x3b28
movl %eax, %r12d
movq 0x8(%r13), %rax
movl %r12d, %r15d
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x3aff
callq 0x21a0
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r15,8), %rax
andq $0x0, 0x8(%rax)
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x414e
xorl %ebp, %ebp
testl %eax, %eax
js 0x3bae
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x68(%r13), %rax
movslq (%r13), %rbp
cmpq %rbp, %rax
ja 0x3bd3
leaq 0x20(%rax), %rcx
movq %rcx, 0x68(%r13)
movq 0x8(%r13), %rdi
leaq 0x100(,%rax,8), %rsi
callq 0x2420
movq (%rbx), %rcx
movq %rax, 0x8(%rcx)
pushq $-0x2
popq %rbp
testq %rax, %rax
je 0x3b17
movq (%rbx), %r13
movslq (%r13), %r12
cmpq 0x68(%r13), %r12
jae 0x3bcf
pushq $0x10
popq %rdi
callq 0x20e0
movq 0x8(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movq (%rbx), %rcx
movq 0x8(%rcx), %rdx
testq %rax, %rax
je 0x3c6c
movq (%rdx,%r12,8), %rax
andq $0x0, (%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r12,8), %rax
andq $0x0, 0x8(%rax)
incq %r12
movq (%rbx), %r13
jmp 0x3b68
movq (%rbx), %rdi
movl %r12d, %esi
callq 0x41c7
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r15,8), %rax
andq $0x0, (%rax)
pushq $-0x5
jmp 0x3aba
movslq (%r13), %rbp
movq %r15, %rdi
callq 0x21b0
movq %rax, %r12
leaq 0x1(%rax), %rdi
callq 0x20e0
movq 0x8(%r13), %rcx
movq (%rcx,%rbp,8), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x3c47
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%rbp,8), %rax
movq (%rax), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2470
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%rbp,8), %rax
movq (%rax), %rax
movb $0x0, (%rax,%r12)
movq (%rbx), %rax
movl (%rax), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x414e
movq (%rbx), %rdi
movl (%rdi), %esi
testl %eax, %eax
js 0x3c4e
incl %esi
movl %esi, (%rdi)
xorl %ebp, %ebp
jmp 0x3b17
pushq $-0x3
jmp 0x3aba
callq 0x41c7
movq (%rbx), %rax
movq 0x8(%rax), %rcx
movslq (%rax), %rax
movq (%rcx,%rax,8), %rax
andq $0x0, (%rax)
pushq $-0x4
jmp 0x3aba
testq %rdx, %rdx
je 0x3b17
xorl %r14d, %r14d
movq 0x8(%rcx), %rdi
cmpq 0x68(%rcx), %r14
jae 0x3ca7
movq (%rdi,%r14,8), %rax
testq %rax, %rax
je 0x3ca7
movq %rax, %rdi
callq 0x21a0
movq (%rbx), %rax
movq 0x8(%rax), %rax
andq $0x0, (%rax,%r14,8)
incq %r14
movq (%rbx), %rcx
jmp 0x3c78
callq 0x21a0
movq (%rbx), %rax
andq $0x0, 0x8(%rax)
movq (%rbx), %rax
andl $0x0, (%rax)
jmp 0x3b17