// File: /workspace/github_c_makefile_star2_O3/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 0x41718
testl %eax, %eax
jne 0x4d232
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x41718
testl %eax, %eax
je 0x4d23e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0xb50c3(%rip), %r12     # 0x102310
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x41b2b
testq %rax, %rax
je 0x4d232
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1, %edx
callq 0x40d47
testl %eax, %eax
jne 0x4d232
movq %r14, %rdi
callq 0x4c4aa
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
jns 0x4d290
addq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
jns 0x4d2a2
addq %rax, %rdx
movq %rdx, 0x8(%rsp)
testq %rcx, %rcx
jns 0x4d2b2
movq $0x0, 0x10(%rsp)
xorl %ecx, %ecx
xorl %r15d, %r15d
cmpq %rdx, %rcx
jg 0x4d2d9
cmpq %rax, %rcx
jae 0x4d2d9
cmpq %rax, %rdx
jb 0x4d2cd
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 0x4d39c
movq 0x8(%r14), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2c31c
movq 0x8(%r14), %rdi
movq %r15, %rsi
negq %rsi
movq %r15, %rdx
callq 0x2c31c
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x6f2e7(%rip), %rsi     # 0xbc60a
movl $0x10, %edi
callq 0x7c665
movq %r14, %rdi
callq 0x4c4aa
testq %rax, %rax
jne 0x4d36b
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 0x711c7(%rip), %rsi     # 0xbe528
movl $0x4, %edi
callq 0x7c665
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41d90
leaq 0xb4525(%rip), %rax     # 0x1018a8
incq 0x720(%rax)
movq 0x8(%r12), %rsi
movq %rbx, %rdi
callq 0x3c854
jmp 0x4d232
leaq 0x756af(%rip), %rdi     # 0xc2a52
leaq 0x75f92(%rip), %rsi     # 0xc333c
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x619b4
movl $0x1, %edi
callq 0x263c0