// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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 0x3ab5e
testl %eax, %eax
jne 0x44f0f
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x3ab5e
testl %eax, %eax
je 0x44f1b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0xb53e6(%rip), %r12     # 0xfa310
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x3af15
testq %rax, %rax
je 0x44f0f
movq %rax, %r14
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3a311
testl %eax, %eax
jne 0x44f0f
movq %r14, %rdi
callq 0x4427e
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
jns 0x44f6b
addq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
jns 0x44f7d
addq %rax, %rdx
movq %rdx, 0x8(%rsp)
testq %rcx, %rcx
jns 0x44f8a
andq $0x0, 0x10(%rsp)
xorl %ecx, %ecx
xorl %r15d, %r15d
cmpq %rdx, %rcx
jg 0x44fb1
cmpq %rax, %rcx
jae 0x44fb1
cmpq %rax, %rdx
jb 0x44fa5
leaq -0x1(%rax), %rdx
movq %rdx, 0x8(%rsp)
notq %rdx
movq %rax, %r15
addq %rdx, %r15
movq %rcx, %rax
movl $0xf0, %ecx
andl (%r14), %ecx
cmpl $0x90, %ecx
jne 0x45070
movq 0x8(%r14), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x28205
movq 0x8(%r14), %rdi
movq %r15, %rsi
negq %rsi
movq %r15, %rdx
callq 0x28205
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x694ff(%rip), %rsi     # 0xae4fa
pushq $0x10
popq %rdi
callq 0x6fb58
movq %r14, %rdi
callq 0x4427e
testq %rax, %rax
jne 0x4503f
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3b1df
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x6b3e1(%rip), %rsi     # 0xb0418
pushq $0x4
popq %rdi
callq 0x6fb58
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3b125
leaq 0xb4851(%rip), %rax     # 0xf98a8
incq 0x720(%rax)
movq 0x8(%r12), %rsi
movq %rbx, %rdi
callq 0x36987
jmp 0x44f0f
leaq 0x6f09b(%rip), %rdi     # 0xb4112
leaq 0x6f852(%rip), %rsi     # 0xb48d0
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x57b45
pushq $0x1
popq %rdi
callq 0x263c0