// File: /workspace/github_c_makefile_star2_O0/seojangho[P]clee/simclist.c
// Function: list_delete_range
int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int posend) {
    struct list_entry_s *lastvalid, *tmp, *tmp2;
    unsigned int i;
    int movedx;
    unsigned int numdel, midposafter;

    if (l->iter_active || posend < posstart || posend >= l->numels) return -1;

    tmp = list_findpos(l, posstart);    /* first el to be deleted */
    lastvalid = tmp->prev;              /* last valid element */

    numdel = posend - posstart + 1;
    midposafter = (l->numels-1-numdel)/2;

    midposafter = midposafter < posstart ? midposafter : midposafter+numdel;
    movedx = midposafter - (l->numels-1)/2;

    if (movedx > 0) { /* move right */
        for (i = 0; i < (unsigned int)movedx; l->mid = l->mid->next, i++);
    } else {    /* move left */
        movedx = -movedx;
        for (i = 0; i < (unsigned int)movedx; l->mid = l->mid->prev, i++);
    }

    assert(posstart == 0 || lastvalid != l->head_sentinel);
    i = posstart;
    if (l->attrs.copy_data) {
        /* also free element data */
        for (; i <= posend; i++) {
            tmp2 = tmp;
            tmp = tmp->next;
            if (tmp2->data != NULL) free(tmp2->data);
            if (l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS) {
                l->spareels[l->spareelsnum++] = tmp2;
            } else {
                free(tmp2);
            }
        }
    } else {
        /* only free containers */
        for (; i <= posend; i++) {
            tmp2 = tmp;
            tmp = tmp->next;
            if (l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS) {
                l->spareels[l->spareelsnum++] = tmp2;
            } else {
                free(tmp2);
            }
        }
    }
    assert(i == posend+1 && (posend != l->numels || tmp == l->tail_sentinel));

    lastvalid->next = tmp;
    tmp->prev = lastvalid;

    l->numels -= posend - posstart + 1;

    assert(list_repOk(l));

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jne 0x5210
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jb 0x5210
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jb 0x521c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x541b
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x4c70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
subl $0x1, %eax
subl -0x3c(%rbp), %eax
shrl %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x5266
movl -0x40(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x526f
movl -0x40(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %ecx
subl $0x1, %ecx
shrl %ecx
subl %ecx, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jle 0x52c1
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x52bf
jmp 0x52a0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5296
jmp 0x52fb
xorl %eax, %eax
subl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x52f9
jmp 0x52da
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x52d0
jmp 0x52fb
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x58(%rax)
je 0x5384
jmp 0x530d
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
ja 0x5382
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x533f
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0x10(%rbp), %rax
cmpl $0x5, 0x28(%rax)
jae 0x536c
movq -0x30(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rsi
movl 0x28(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x28(%rsi)
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x5375
movq -0x30(%rbp), %rdi
callq 0x3030
jmp 0x5377
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x530d
jmp 0x53e7
jmp 0x5386
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
ja 0x53e5
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x5, 0x28(%rax)
jae 0x53cf
movq -0x30(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rsi
movl 0x28(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x28(%rsi)
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x53d8
movq -0x30(%rbp), %rdi
callq 0x3030
jmp 0x53da
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5386
jmp 0x53e7
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x18(%rbp), %edx
subl -0x14(%rbp), %edx
addl $0x1, %edx
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x18(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)