// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x38(%rdi), %eax
cmpl $0x3, %eax
jne 0x4f352
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x4eafc
jle 0x4f375
leaq 0xb2fb5(%rip), %rax     # 0x102310
movq 0x80(%rax), %rsi
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3c854
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0xb2f8c(%rip), %rax     # 0x102310
movq 0x50(%rax), %rdx
movq %rbx, %rdi
callq 0x41b2b
testq %rax, %rax
je 0x4f4d0
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
movl $0x2, %edx
callq 0x40d47
testl %eax, %eax
jne 0x4f4d0
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x4e53a
cmpl $0x6, %eax
jne 0x4f3ef
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x40753
movq %rax, %r15
movq 0x8(%r14), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x64ccf
movq %rax, 0x8(%r14)
jmp 0x4f407
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x407a8
movq %r14, %rdi
movq %r15, %rsi
callq 0x4e287
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x6d212(%rip), %rsi     # 0xbc62f
movl $0x20, %edi
callq 0x7c665
leaq 0x74148(%rip), %rdi     # 0xc3576
movl $0x4, %esi
callq 0x40744
movq %rax, %r12
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rcx
movq %rbx, %rdi
movl $0x3, %esi
movq %r12, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x3f61d
movq %r15, %rdi
callq 0x40c8f
movq %r12, %rdi
callq 0x40c8f
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d170
movq %r14, %rdi
callq 0x4e5b5
testq %rax, %rax
jne 0x4f4b1
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41e5f
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x6f081(%rip), %rsi     # 0xbe528
movl $0x4, %edi
callq 0x7c665
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41d90
leaq 0xb23df(%rip), %rax     # 0x1018a8
incq 0x720(%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq