// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl %esi, %r12d
jb 0x465e
movq %rdi, %rbx
cmpl $0x0, 0x2c(%rdi)
jne 0x465e
movl %edx, %ebp
movl 0x18(%rbx), %ecx
cmpl %edx, %ecx
jbe 0x465e
movl %esi, %r14d
leal 0x1(%r14), %eax
cvtsi2ss %eax, %xmm0
movl %ecx, %edx
cvtsi2ss %rdx, %xmm1
divss %xmm1, %xmm0
movss 0x28a1(%rip), %xmm1     # 0x6ddc
ucomiss %xmm0, %xmm1
jae 0x4568
movss 0x2898(%rip), %xmm1     # 0x6de0
ucomiss %xmm0, %xmm1
jbe 0x466d
leal -0x1(%rcx), %eax
shrl %eax
incl %eax
movq %rbx, %r15
movq 0x10(%r15), %r15
decl %eax
cmpl %r14d, %eax
jg 0x455b
jmp 0x4578
movq (%rbx), %r15
testl %r14d, %r14d
js 0x4578
movq 0x8(%r15), %r15
decl %eax
jne 0x4570
incl %r12d
decl %ecx
movl %ecx, %eax
subl %r12d, %eax
shrl %eax
xorl %edx, %edx
cmpl %r14d, %eax
cmovael %r12d, %edx
shrl %ecx
subl %ecx, %eax
addl %edx, %eax
testl %eax, %eax
jle 0x45a5
movq 0x10(%rbx), %rcx
movq 0x8(%rcx), %rcx
decl %eax
jne 0x459b
jmp 0x45bc
je 0x45c0
negl %eax
movq 0x10(%rbx), %rcx
xorl %edx, %edx
cmpl $0x1, %eax
sbbl %eax, %edx
movq 0x10(%rcx), %rcx
incl %edx
jne 0x45b4
movq %rcx, 0x10(%rbx)
movq 0x10(%r15), %rax
movq %rax, (%rsp)
cmpl $0x0, 0x58(%rbx)
je 0x4612
cmpl %r14d, %ebp
jb 0x4617
movq (%r15), %rdi
movq 0x8(%r15), %r13
testq %rdi, %rdi
je 0x45e4
callq 0x3030
movl 0x28(%rbx), %eax
cmpq $0x4, %rax
ja 0x45fd
movq 0x20(%rbx), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x28(%rbx)
movq %r15, (%rcx,%rax,8)
jmp 0x4605
movq %r15, %rdi
callq 0x3030
incl %r14d
movq %r13, %r15
cmpl %ebp, %r14d
jbe 0x45d3
jmp 0x464c
cmpl %r14d, %ebp
jae 0x461c
movq %r15, %r13
jmp 0x464c
movq 0x8(%r15), %r13
movl 0x28(%rbx), %eax
cmpq $0x4, %rax
ja 0x4639
movq 0x20(%rbx), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x28(%rbx)
movq %r15, (%rcx,%rax,8)
jmp 0x4641
movq %r15, %rdi
callq 0x3030
incl %r14d
movq %r13, %r15
cmpl %ebp, %r14d
jbe 0x461c
movq (%rsp), %rax
movq %r13, 0x8(%rax)
movq %rax, 0x10(%r13)
subl %r12d, 0x18(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movss 0x276f(%rip), %xmm1     # 0x6de4
ucomiss %xmm0, %xmm1
jae 0x4699
movq 0x8(%rbx), %r15
cmpl %r14d, %ecx
jle 0x4578
movl %ecx, %eax
decl %eax
movq 0x10(%r15), %r15
cmpl %r14d, %eax
jg 0x4689
jmp 0x4578
leal -0x1(%rcx), %edx
shrl %edx
movq 0x10(%rbx), %r15
movl %r14d, %eax
subl %edx, %eax
jle 0x4578
movq 0x8(%r15), %r15
decl %eax
jne 0x46ad
jmp 0x4578