// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/t_list.c
// Function: ltrimCommand
void ltrimCommand(client *c) {
    robj *o;
    long start, end, llen, ltrim, rtrim;

    if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != C_OK) ||
        (getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != C_OK)) return;

    if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.ok)) == NULL ||
        checkType(c,o,OBJ_LIST)) return;
    llen = listTypeLength(o);

    /* convert negative indexes */
    if (start < 0) start = llen+start;
    if (end < 0) end = llen+end;
    if (start < 0) start = 0;

    /* Invariant: start >= 0, so this test will be true when end < 0.
     * The range is empty when start > end or start >= length. */
    if (start > end || start >= llen) {
        /* Out of range start or start > end result in empty list */
        ltrim = llen;
        rtrim = 0;
    } else {
        if (end >= llen) end = llen-1;
        ltrim = start;
        rtrim = llen-end-1;
    }

    /* Remove list elements to perform the trim */
    if (o->encoding == OBJ_ENCODING_QUICKLIST) {
        quicklistDelRange(o->ptr,0,ltrim);
        quicklistDelRange(o->ptr,-rtrim,rtrim);
    } else {
        serverPanic("Unknown list encoding");
    }

    notifyKeyspaceEvent(NOTIFY_LIST,"ltrim",c->argv[1],c->db->id);
    if (listTypeLength(o) == 0) {
        dbDelete(c->db,c->argv[1]);
        notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id);
    }
    signalModifiedKey(c->db,c->argv[1]);
    server.dirty++;
    addReply(c,shared.ok);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x10(%rax), %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x44ba1
testl %eax, %eax
jne 0x50971
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x44ba1
testl %eax, %eax
je 0x5097d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0xb6924(%rip), %r12     # 0x1072b0
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x44fbb
testq %rax, %rax
je 0x50971
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1, %edx
callq 0x441ab
testl %eax, %eax
jne 0x50971
movq %r14, %rdi
callq 0x4fc1c
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
jns 0x509cf
addq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
jns 0x509e1
addq %rax, %rcx
movq %rcx, 0x8(%rsp)
cmpq $0x0, 0x10(%rsp)
jns 0x509f2
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
xorl %r15d, %r15d
cmpq %rdx, %rcx
jg 0x50a28
cmpq %rax, %rcx
jge 0x50a28
cmpq %rax, %rdx
jl 0x50a17
leaq -0x1(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq 0x8(%rsp), %rdx
notq %rdx
movq %rax, %r15
addq %rdx, %r15
movq %rcx, %rax
movl $0xf0, %ecx
andl (%r14), %ecx
cmpl $0x90, %ecx
jne 0x50aeb
movq 0x8(%r14), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2f59a
movq 0x8(%r14), %rdi
movq %r15, %rsi
negq %rsi
movq %r15, %rdx
callq 0x2f59a
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x6eb48(%rip), %rsi     # 0xbf5ba
movl $0x10, %edi
callq 0x800c9
movq %r14, %rdi
callq 0x4fc1c
testq %rax, %rax
jne 0x50aba
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x452f3
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x70a06(%rip), %rsi     # 0xc14b6
movl $0x4, %edi
callq 0x800c9
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x45220
leaq 0xb5d86(%rip), %rax     # 0x106858
incq 0x710(%rax)
movq 0x8(%r12), %rsi
movq %rbx, %rdi
callq 0x3fc19
jmp 0x50971
leaq 0x74ee0(%rip), %rdi     # 0xc59d2
leaq 0x757c3(%rip), %rsi     # 0xc62bc
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x6558d
movl $0x1, %edi
callq 0x263d0