// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: c_m
bool c_m(int argc, char **argv, bool force, struct range *range)
{
#define NO_LINE(ln) do{             \
		ui_err("no such line %d", ln);  \
		return false;                   \
	}while(0)

	struct range range_store;
	int lno;
	if(!copy_move_common(argc, argv, &range, &range_store, &lno))
		return false;

	if(range->start <= lno && lno <= range->end){
		ui_err("can't move lines into themselves");
		return false;
	}

	buffer_t *const b = windows_cur()->buf;

	list_t *landing = list_seek(b->head, lno, false);
	if(!landing)
		NO_LINE(lno);

	/* move lines over *range to lno */
	list_t *start = list_seek(b->head, range->start, false);
	if(!start)
		NO_LINE(range->start);

	list_t *end = list_seek(b->head, range->end, false);
	if(!end)
		NO_LINE(range->end);

	/* break the bottom link */
	list_t *after = end->next;
	end->next = NULL;
	if(after)
		after->prev = NULL;

	/* break the top link and reattach */
	list_t *before = start->prev;
	if(start->prev){
		start->prev = NULL;

		before->next = after;
		if(after)
			after->prev = before;
	}else{
		b->head = after;
	}

	if(lno == -1){
		/* replace head */

		/* move current head to the end tail */
		end->next = b->head;
		b->head->prev = end;

		/* replace */
		b->head = start;

	}else{
		/* replace landing ->next,
		 * linking up end->next to what was there */
		if(landing->next){
			end->next = landing->next;
			landing->next->prev = end;
		}
		landing->next = start;
		start->prev = landing;
	}

	b->modified = true;

	ui_redraw();
	ui_cur_changed();

	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x8(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x10(%rsp), %rcx
leaq 0x4(%rsp), %r8
callq 0x885a
testb %al, %al
je 0x87b0
movq 0x8(%rsp), %r12
movl 0x4(%rsp), %eax
cmpl %eax, (%r12)
jg 0x8731
cmpl 0x4(%r12), %eax
jle 0x87bd
callq 0xdaf0
movq (%rax), %r15
movq 0x8(%r15), %rdi
movl 0x4(%rsp), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x87b7
movq %rax, %rbx
movq 0x8(%r15), %rdi
movl (%r12), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x87cf
movq %rax, %r14
movq 0x8(%r15), %rdi
movl 0x4(%r12), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x87d5
movq 0x18(%rax), %rcx
movq $0x0, 0x18(%rax)
testq %rcx, %rcx
je 0x87ec
movq $0x0, 0x20(%rcx)
movq 0x20(%r14), %rdx
testq %rdx, %rdx
je 0x8801
movq $0x0, 0x20(%r14)
movq %rcx, 0x18(%rdx)
movq %rdx, 0x20(%rcx)
jmp 0x8805
xorl %ebx, %ebx
jmp 0x884c
movl 0x4(%rsp), %esi
jmp 0x87da
leaq 0x5c89(%rip), %rdi      # 0xe44d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
jmp 0x884c
movl (%r12), %esi
jmp 0x87da
movl 0x4(%r12), %esi
leaq 0x5c8d(%rip), %rdi      # 0xe46e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
jmp 0x884c
movq 0x20(%r14), %rdx
testq %rdx, %rdx
je 0x8801
xorl %ecx, %ecx
movq %rcx, 0x20(%r14)
movq %rcx, 0x18(%rdx)
jmp 0x8805
movq %rcx, 0x8(%r15)
cmpl $-0x1, 0x4(%rsp)
je 0x882b
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x8821
movq %rcx, 0x18(%rax)
movq 0x18(%rbx), %rcx
movq %rax, 0x20(%rcx)
movq %r14, 0x18(%rbx)
movq %rbx, 0x20(%r14)
jmp 0x883b
movq 0x8(%r15), %rcx
movq %rcx, 0x18(%rax)
movq %rax, 0x20(%rcx)
movq %r14, 0x8(%r15)
movb $0x1, 0x39(%r15)
callq 0x4e77
callq 0x51ce
movb $0x1, %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq