// File: /workspace/github_c_makefile_star2_O2/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 0x83d4
testb %al, %al
je 0x833f
movq 0x8(%rsp), %r12
movl 0x4(%rsp), %eax
cmpl %eax, (%r12)
jg 0x82c4
cmpl 0x4(%r12), %eax
jle 0x834c
callq 0xd170
movq (%rax), %r15
movq 0x8(%r15), %rdi
movl 0x4(%rsp), %esi
xorl %edx, %edx
callq 0x9737
testq %rax, %rax
je 0x8346
movq %rax, %rbx
movq 0x8(%r15), %rdi
movl (%r12), %esi
xorl %edx, %edx
callq 0x9737
testq %rax, %rax
je 0x835e
movq %rax, %r14
movq 0x8(%r15), %rdi
movl 0x4(%r12), %esi
xorl %edx, %edx
callq 0x9737
testq %rax, %rax
je 0x8364
movq 0x18(%rax), %rcx
andq $0x0, 0x18(%rax)
testq %rcx, %rcx
je 0x8322
andq $0x0, 0x20(%rcx)
movq 0x20(%r14), %rdx
testq %rdx, %rdx
je 0x837b
andq $0x0, 0x20(%r14)
movq %rcx, 0x18(%rdx)
testq %rcx, %rcx
je 0x837f
movq %rdx, 0x20(%rcx)
jmp 0x837f
xorl %ebx, %ebx
jmp 0x83c6
movl 0x4(%rsp), %esi
jmp 0x8369
leaq 0x60fa(%rip), %rdi      # 0xe44d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4c34
jmp 0x83c6
movl (%r12), %esi
jmp 0x8369
movl 0x4(%r12), %esi
leaq 0x60fe(%rip), %rdi      # 0xe46e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4c34
jmp 0x83c6
movq %rcx, 0x8(%r15)
cmpl $-0x1, 0x4(%rsp)
je 0x83a5
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x839b
movq %rcx, 0x18(%rax)
movq 0x18(%rbx), %rcx
movq %rax, 0x20(%rcx)
movq %r14, 0x18(%rbx)
movq %rbx, 0x20(%r14)
jmp 0x83b5
movq 0x8(%r15), %rcx
movq %rcx, 0x18(%rax)
movq %rax, 0x20(%rcx)
movq %r14, 0x8(%r15)
movb $0x1, 0x39(%r15)
callq 0x4cc7
callq 0x501c
movb $0x1, %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq