// File: /workspace/github_c_makefile_star2_O1/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 0x8981
testb %al, %al
je 0x88ec
movq 0x8(%rsp), %r12
movl 0x4(%rsp), %eax
cmpl %eax, (%r12)
jg 0x8868
cmpl 0x4(%r12), %eax
jle 0x88f9
callq 0xde6c
movq (%rax), %r15
movq 0x8(%r15), %rdi
movl 0x4(%rsp), %esi
xorl %edx, %edx
callq 0x9ede
testq %rax, %rax
je 0x88f3
movq %rax, %rbx
movq 0x8(%r15), %rdi
movl (%r12), %esi
xorl %edx, %edx
callq 0x9ede
testq %rax, %rax
je 0x890b
movq %rax, %r14
movq 0x8(%r15), %rdi
movl 0x4(%r12), %esi
xorl %edx, %edx
callq 0x9ede
testq %rax, %rax
je 0x8911
movq 0x18(%rax), %rcx
movq $0x0, 0x18(%rax)
testq %rcx, %rcx
je 0x88cc
movq $0x0, 0x20(%rcx)
movq 0x20(%r14), %rdx
testq %rdx, %rdx
je 0x8928
movq $0x0, 0x20(%r14)
movq %rcx, 0x18(%rdx)
testq %rcx, %rcx
je 0x892c
movq %rdx, 0x20(%rcx)
jmp 0x892c
xorl %ebx, %ebx
jmp 0x8973
movl 0x4(%rsp), %esi
jmp 0x8916
leaq 0x6b59(%rip), %rdi      # 0xf459
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
jmp 0x8973
movl (%r12), %esi
jmp 0x8916
movl 0x4(%r12), %esi
leaq 0x6b5d(%rip), %rdi      # 0xf47a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
jmp 0x8973
movq %rcx, 0x8(%r15)
cmpl $-0x1, 0x4(%rsp)
je 0x8952
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x8948
movq %rcx, 0x18(%rax)
movq 0x18(%rbx), %rcx
movq %rax, 0x20(%rcx)
movq %r14, 0x18(%rbx)
movq %rbx, 0x20(%r14)
jmp 0x8962
movq 0x8(%r15), %rcx
movq %rcx, 0x18(%rax)
movq %rax, 0x20(%rcx)
movq %r14, 0x8(%r15)
movb $0x1, 0x39(%r15)
callq 0x4e77
callq 0x51d8
movb $0x1, %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq