// File: /workspace/github_c_makefile_star2_O3/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
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jne 0x43f5
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rdi
callq *0x48(%rdi)
movq (%rbx), %r12
testl %eax, %eax
js 0x423c
movl %eax, %ebp
movq 0x8(%r12), %rax
movl %ebp, %r15d
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x41e2
callq 0x21a0
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r15,8), %rax
movq $0x0, 0x8(%rax)
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x4a04
xorl %ebp, %ebp
testl %eax, %eax
jns 0x43f5
movq (%rbx), %r14
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x422b
callq 0x21a0
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %rax
movq $0x0, (%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r15,8), %rax
movq $0x0, (%rax)
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
jmp 0x43f5
movq 0x68(%r12), %rax
movslq (%r12), %r13
cmpq %r13, %rax
ja 0x42d8
leaq 0x20(%rax), %rcx
movq %rcx, 0x68(%r12)
movq 0x8(%r12), %rdi
leaq 0x100(,%rax,8), %rsi
callq 0x2420
movq (%rbx), %rcx
movq %rax, 0x8(%rcx)
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testq %rax, %rax
je 0x43f5
movq (%rbx), %r12
movslq (%r12), %r13
cmpq %r13, 0x68(%r12)
jbe 0x42d8
movl $0x10, %edi
callq 0x20e0
movq 0x8(%r12), %rcx
movq %rax, (%rcx,%r13,8)
movq (%rbx), %rcx
movq 0x8(%rcx), %rdi
testq %rax, %rax
je 0x4399
movq (%rdi,%r13,8), %rax
xorl %ecx, %ecx
movq %rcx, (%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rax
movq %rcx, 0x8(%rax)
incq %r13
movq (%rbx), %r12
cmpq 0x68(%r12), %r13
jb 0x428c
movslq (%r12), %r13
movq %r15, %rdi
callq 0x21b0
movq %rax, %rbp
leaq 0x1(%rax), %rdi
callq 0x20e0
movq 0x8(%r12), %rcx
movq (%rcx,%r13,8), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x434f
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rax
movq (%rax), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2470
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rax
movq (%rax), %rax
movb $0x0, (%rax,%rbp)
movq (%rbx), %rax
movl (%rax), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4a04
movq (%rbx), %r14
movslq (%r14), %r15
testl %eax, %eax
js 0x4359
incl %r15d
movl %r15d, (%r14)
xorl %ebp, %ebp
jmp 0x43f5
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jmp 0x43f5
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x438b
callq 0x21a0
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %rax
movq $0x0, (%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rcx
movslq (%rax), %rax
movq (%rcx,%rax,8), %rax
movq $0x0, (%rax)
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
jmp 0x43f5
testq %rdi, %rdi
je 0x43f5
cmpq $0x0, 0x68(%rcx)
je 0x43dc
xorl %r14d, %r14d
movq 0x8(%rcx), %rdi
movq (%rdi,%r14,8), %rax
testq %rax, %rax
je 0x43dc
movq %rax, %rdi
callq 0x21a0
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq $0x0, (%rax,%r14,8)
incq %r14
movq (%rbx), %rcx
cmpq 0x68(%rcx), %r14
jb 0x43a8
movq 0x8(%rcx), %rdi
callq 0x21a0
movq (%rbx), %rax
movq $0x0, 0x8(%rax)
movq (%rbx), %rax
movl $0x0, (%rax)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq