// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rsi
leaq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
je 0x5a68b
jmp 0x5a835
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x11e59e(%rip), %rax    # 0x178c40
movq 0x20(%rax), %rdx
callq 0x4a780
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x5a6cd
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x5a6d2
jmp 0x5a835
cmpq $0x0, -0x20(%rbp)
jge 0x5a6fb
xorl %eax, %eax
subq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq $-0x1, %rsi
xorl %edx, %edx
callq 0x591a0
movq %rax, -0x30(%rbp)
jmp 0x5a711
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x591a0
movq %rax, -0x30(%rbp)
jmp 0x5a713
movq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x592a0
cmpl $0x0, %eax
je 0x5a787
movq -0x18(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x594b0
cmpl $0x0, %eax
je 0x5a785
movq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x59580
leaq 0x11da8d(%rip), %rax    # 0x1781d8
movq 0x720(%rax), %rcx
addq $0x1, %rcx
leaq 0x11da7b(%rip), %rax    # 0x1781d8
movq %rcx, 0x720(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x5a783
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x5a783
jmp 0x5a787
jmp 0x5a785
jmp 0x5a713
movq -0x30(%rbp), %rdi
callq 0x59270
cmpq $0x0, -0x28(%rbp)
je 0x5a7d8
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4aa60
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 0xdcdad(%rip), %rsi     # 0x137580
callq 0x9ce20
movq -0x10(%rbp), %rdi
callq 0x59140
cmpq $0x0, %rax
jne 0x5a828
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 0xdec75(%rip), %rsi     # 0x139498
callq 0x9ce20
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x43780
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)