// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jne 0x4504
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdi), %rdi
callq *0x48(%rdi)
movl %eax, %ebp
movq (%rbx), %rax
testl %ebp, %ebp
js 0x435b
movq 0x8(%rax), %rax
movl %ebp, %r14d
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x4338
callq 0x21a0
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r14,8), %rax
movq $0x0, 0x8(%rax)
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x4b88
xorl %r14d, %r14d
testl %eax, %eax
jns 0x4504
movl $0xfffffffb, %r14d      # imm = 0xFFFFFFFB
jmp 0x4480
movl %ebp, 0xc(%rsp)
movq 0x68(%rax), %rcx
movslq (%rax), %rdx
cmpq %rdx, %rcx
ja 0x43f6
leaq 0x20(%rcx), %rdx
movq %rdx, 0x68(%rax)
movq 0x8(%rax), %rdi
leaq 0x100(,%rcx,8), %rsi
callq 0x2410
movq (%rbx), %rcx
movq %rax, 0x8(%rcx)
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
testq %rax, %rax
je 0x447c
movq %rax, 0x10(%rsp)
movq (%rbx), %rbp
movslq (%rbp), %r13
cmpq %r13, 0x68(%rbp)
jbe 0x43f6
movl $0x10, %edi
callq 0x20e0
movq 0x8(%rbp), %rcx
movq %rax, (%rcx,%r13,8)
testq %rax, %rax
je 0x4516
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%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), %rbp
cmpq 0x68(%rbp), %r13
jb 0x43b0
movq (%rbx), %rbp
movslq (%rbp), %r13
movq %r12, %rdi
callq 0x21b0
movq %rax, %r14
leaq 0x1(%rax), %rdi
callq 0x20e0
movq 0x8(%rbp), %rcx
movq (%rcx,%r13,8), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x446e
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2460
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rax
movq (%rax), %rax
movb $0x0, (%rax,%r14)
movq (%rbx), %rax
movl (%rax), %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4b88
testl %eax, %eax
js 0x4476
movq (%rbx), %rax
incl (%rax)
xorl %r14d, %r14d
jmp 0x4504
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jmp 0x447c
movl $0xfffffffc, %r14d      # imm = 0xFFFFFFFC
movl 0xc(%rsp), %ebp
cmpl $-0x5, %r14d
je 0x44c6
cmpl $-0x4, %r14d
jne 0x4504
movq (%rbx), %r15
movslq (%r15), %r12
movq 0x8(%r15), %rax
movq (%rax,%r12,8), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x44b6
callq 0x21a0
movq 0x8(%r15), %rax
movq (%rax,%r12,8), %rax
movq $0x0, (%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rcx
movslq (%rax), %rax
movq (%rcx,%rax,8), %rax
jmp 0x44fd
movq (%rbx), %r12
movq 0x8(%r12), %rax
movslq %ebp, %r15
movq (%rax,%r15,8), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x44f2
callq 0x21a0
movq 0x8(%r12), %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 %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x10(%rsp)
je 0x447c
movq (%rbx), %rax
cmpq $0x0, 0x8(%rax)
movl 0xc(%rsp), %ebp
je 0x4480
cmpq $0x0, 0x68(%rax)
je 0x456b
xorl %r15d, %r15d
movq 0x8(%rax), %rcx
movq (%rcx,%r15,8), %rdi
testq %rdi, %rdi
je 0x456b
callq 0x21a0
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq $0x0, (%rax,%r15,8)
incq %r15
movq (%rbx), %rax
cmpq 0x68(%rax), %r15
jb 0x453e
movq 0x8(%rax), %rdi
callq 0x21a0
movq (%rbx), %rax
movq $0x0, 0x8(%rax)
movq (%rbx), %rax
movl $0x0, (%rax)
jmp 0x4480