// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rsi
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
jne 0x5a430
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rax), %rsi
leaq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
je 0x5a435
jmp 0x5a639
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x11e7f4(%rip), %rax    # 0x178c40
movq 0x8(%rax), %rdx
callq 0x4a780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x5a476
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x5a47b
jmp 0x5a639
movq -0x10(%rbp), %rdi
callq 0x59140
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0x5a49b
movq -0x28(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x20(%rbp)
jge 0x5a4ae
movq -0x28(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0x5a4bd
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jg 0x5a4d1
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jl 0x5a4e3
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
jmp 0x5a511
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jl 0x5a4f9
movq -0x28(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x9, %eax
jne 0x5a552
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x29800
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
subq -0x38(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x29800
jmp 0x5a574
leaq 0xe2c8c(%rip), %rdi     # 0x13d1e5
leaq 0xe3444(%rip), %rsi     # 0x13d9a4
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
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 $0x10, %edi
leaq 0xdcfe3(%rip), %rsi     # 0x13757a
callq 0x9ce20
movq -0x10(%rbp), %rdi
callq 0x59140
cmpq $0x0, %rax
jne 0x5a5ec
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 0xdeeb1(%rip), %rsi     # 0x139498
callq 0x9ce20
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4aa60
leaq 0x11dbcc(%rip), %rax    # 0x1781d8
movq 0x720(%rax), %rcx
addq $0x1, %rcx
leaq 0x11dbba(%rip), %rax    # 0x1781d8
movq %rcx, 0x720(%rax)
movq -0x8(%rbp), %rdi
leaq 0x11e610(%rip), %rax    # 0x178c40
movq 0x8(%rax), %rsi
callq 0x42cc0
addq $0x40, %rsp
popq %rbp
retq
nop