// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %dl, %al
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x20(%rbp), %rdx
leaq -0x28(%rbp), %rcx
leaq -0x2c(%rbp), %r8
callq 0xabe0
testb $0x1, %al
jne 0xa9cf
movb $0x0, -0x1(%rbp)
jmp 0xabca
movq -0x20(%rbp), %rax
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jg 0xa9fd
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jg 0xa9fd
leaq 0xab4c(%rip), %rdi      # 0x15539
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0xabca
callq 0x13c60
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
callq 0xcd50
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xaa42
jmp 0xaa28
movl -0x2c(%rbp), %esi
leaq 0xab28(%rip), %rdi      # 0x1555a
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0xabca
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
xorl %edx, %edx
callq 0xcd50
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xaa81
jmp 0xaa64
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq 0xaae9(%rip), %rdi      # 0x1555a
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0xabca
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x4(%rax), %esi
xorl %edx, %edx
callq 0xcd50
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xaac2
jmp 0xaaa4
movq -0x20(%rbp), %rax
movl 0x4(%rax), %esi
leaq 0xaaa8(%rip), %rdi      # 0x1555a
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0xabca
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq $0x0, 0x18(%rax)
cmpq $0x0, -0x58(%rbp)
je 0xaaed
movq -0x58(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xab31
movq -0x48(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x18(%rax)
cmpq $0x0, -0x58(%rbp)
je 0xab2f
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0xab3d
movq -0x58(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpl $-0x1, -0x2c(%rbp)
jne 0xab71
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xabb4
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xab9c
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movb $0x1, 0x39(%rax)
callq 0x4fd0
callq 0x5050
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)