// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/t_set.c
// Function: spopCommand
void spopCommand(client *c) {
    robj *set, *ele, *aux;
    int64_t llele;
    int encoding;

    if (c->argc == 3) {
        spopWithCountCommand(c);
        return;
    } else if (c->argc > 3) {
        addReply(c,shared.syntaxerr);
        return;
    }

    /* Make sure a key with the name inputted exists, and that it's type is
     * indeed a set */
    if ((set = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
        checkType(c,set,OBJ_SET)) return;

    /* Get a random element from the set */
    encoding = setTypeRandomElement(set,&ele,&llele);

    /* Remove the element from the set */
    if (encoding == OBJ_ENCODING_INTSET) {
        ele = createStringObjectFromLongLong(llele);
        set->ptr = intsetRemove(set->ptr,llele,NULL);
    } else {
        incrRefCount(ele);
        setTypeRemove(set,ele);
    }

    notifyKeyspaceEvent(NOTIFY_SET,"spop",c->argv[1],c->db->id);

    /* Replicate/AOF this command as an SREM operation */
    aux = createStringObject("SREM",4);
    rewriteClientCommandVector(c,3,aux,c->argv[1],ele);
    decrRefCount(ele);
    decrRefCount(aux);

    /* Add the element to the reply */
    addReplyBulk(c,ele);

    /* Delete the set if it's empty */
    if (setTypeSize(set) == 0) {
        dbDelete(c->db,c->argv[1]);
        notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id);
    }

    /* Set has been modified */
    signalModifiedKey(c->db,c->argv[1]);
    server.dirty++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x3, 0x38(%rax)
jne 0x5d144
movq -0x8(%rbp), %rdi
callq 0x5c6c0
jmp 0x5d31a
movq -0x8(%rbp), %rax
cmpl $0x3, 0x38(%rax)
jle 0x5d16a
movq -0x8(%rbp), %rdi
leaq 0x11bae7(%rip), %rax    # 0x178c40
movq 0x80(%rax), %rsi
callq 0x42cc0
jmp 0x5d31a
jmp 0x5d16c
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x11babd(%rip), %rax    # 0x178c40
movq 0x50(%rax), %rdx
callq 0x4a780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x5d1ad
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x5d1b2
jmp 0x5d31a
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x5be60
movl %eax, -0x2c(%rbp)
cmpl $0x6, -0x2c(%rbp)
jne 0x5d1fb
movq -0x28(%rbp), %rdi
callq 0x486f0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x7b840
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x5d211
movq -0x18(%rbp), %rdi
callq 0x487b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5ba40
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x20, %edi
leaq 0xda36b(%rip), %rsi     # 0x13759f
callq 0x9ce20
leaq 0xe099e(%rip), %rdi     # 0x13dbde
movl $0x4, %esi
callq 0x486a0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %r8
movl $0x3, %esi
movb $0x0, %al
callq 0x46840
movq -0x18(%rbp), %rdi
callq 0x48f70
movq -0x20(%rbp), %rdi
callq 0x48f70
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x43630
movq -0x10(%rbp), %rdi
callq 0x5bf20
cmpq $0x0, %rax
jne 0x5d2e1
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4ac10
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x4, %edi
leaq 0xdc1bc(%rip), %rsi     # 0x139498
callq 0x9ce20
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4aa60
leaq 0x11aed7(%rip), %rax    # 0x1781d8
movq 0x720(%rax), %rcx
addq $0x1, %rcx
leaq 0x11aec5(%rip), %rax    # 0x1781d8
movq %rcx, 0x720(%rax)
addq $0x30, %rsp
popq %rbp
retq