// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5000
cmpq $0x0, -0x20(%rbp)
jne 0x500c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x51cd
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rsi
callq *%rax
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
jge 0x50c4
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
ja 0x5066
movq -0x10(%rbp), %rdi
callq 0x5c40
cmpl $0x0, %eax
jge 0x5064
movl $0xfffffffe, -0x24(%rbp) # imm = 0xFFFFFFFE
jmp 0x5141
jmp 0x5066
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %edx
callq 0x5e40
cmpl $0x0, %eax
jge 0x508d
movl $0xfffffffd, -0x24(%rbp) # imm = 0xFFFFFFFD
jmp 0x5141
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %edx
callq 0x5ef0
cmpl $0x0, %eax
jge 0x50b4
movl $0xfffffffc, -0x24(%rbp) # imm = 0xFFFFFFFC
jmp 0x5141
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x5135
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, 0x8(%rax)
je 0x5115
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
callq 0x2180
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x28(%rbp), %edx
callq 0x5ef0
cmpl $0x0, %eax
jge 0x5133
movl $0xfffffffb, -0x24(%rbp) # imm = 0xFFFFFFFB
jmp 0x5141
jmp 0x5135
movl $0x0, -0x4(%rbp)
jmp 0x51cd
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $-0x5, %eax
je 0x519e
jmp 0x514e
movl -0x2c(%rbp), %eax
subl $-0x4, %eax
je 0x5167
jmp 0x5158
movl -0x2c(%rbp), %eax
addl $0x3, %eax
subl $0x2, %eax
ja 0x51c7
jmp 0x5165
jmp 0x51c7
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %esi
callq 0x5fb0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, (%rax)
jmp 0x51c7
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x28(%rbp), %esi
callq 0x5fb0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, (%rax)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)