// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/t_list.c
// Function: lremCommand
void lremCommand(client *c) {
    robj *subject, *obj;
    obj = c->argv[3];
    long toremove;
    long removed = 0;

    if ((getLongFromObjectOrReply(c, c->argv[2], &toremove, NULL) != C_OK))
        return;

    subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero);
    if (subject == NULL || checkType(c,subject,OBJ_LIST)) return;

    listTypeIterator *li;
    if (toremove < 0) {
        toremove = -toremove;
        li = listTypeInitIterator(subject,-1,LIST_HEAD);
    } else {
        li = listTypeInitIterator(subject,0,LIST_TAIL);
    }

    listTypeEntry entry;
    while (listTypeNext(li,&entry)) {
        if (listTypeEqual(&entry,obj)) {
            listTypeDelete(li, &entry);
            server.dirty++;
            removed++;
            if (toremove && removed == toremove) break;
        }
    }
    listTypeReleaseIterator(li);

    if (removed) {
        signalModifiedKey(c->db,c->argv[1]);
        notifyKeyspaceEvent(NOTIFY_GENERIC,"lrem",c->argv[1],c->db->id);
    }

    if (listTypeLength(subject) == 0) {
        dbDelete(c->db,c->argv[1]);
        notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id);
    }

    addReplyLongLong(c,removed);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x18(%rax), %r15
movq 0x10(%rax), %rsi
leaq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x41718
testl %eax, %eax
je 0x4d3fa
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0xb4f07(%rip), %rax     # 0x102310
movq 0x20(%rax), %rdx
movq %rbx, %rdi
callq 0x41b2b
testq %rax, %rax
je 0x4d3eb
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1, %edx
callq 0x40d47
testl %eax, %eax
jne 0x4d3eb
movq 0x8(%rsp), %rax
testq %rax, %rax
js 0x4d447
movq %r14, %rdi
xorl %esi, %esi
movl $0x1, %edx
jmp 0x4d45b
negq %rax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
movq $-0x1, %rsi
xorl %edx, %edx
callq 0x4c4e8
movq %rax, %r13
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x4c580
xorl %r12d, %r12d
testl %eax, %eax
je 0x4d4cb
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4c6e8
testl %eax, %eax
je 0x4d4bc
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4c784
leaq 0xb440b(%rip), %rax     # 0x1018a8
incq 0x720(%rax)
incq %r12
movq 0x8(%rsp), %rax
testq %rax, %rax
setne %cl
cmpq %rax, %r12
sete %al
testb %al, %cl
jne 0x4d4cb
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4c580
testl %eax, %eax
jne 0x4d47c
movq 0x10(%r13), %rdi
callq 0x38413
movq %r13, %rdi
callq 0x38413
testq %r12, %r12
je 0x4d512
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41d90
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x6f108(%rip), %rsi     # 0xbc610
movl $0x4, %edi
callq 0x7c665
movq %r14, %rdi
callq 0x4c4aa
testq %rax, %rax
jne 0x4d550
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 0x70fe2(%rip), %rsi     # 0xbe528
movl $0x4, %edi
callq 0x7c665
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3d23f
jmp 0x4d3eb