// File: /workspace/github_c_makefile_star2_O2/bobrippling[P]tim/cmds.c
// Function: c_r
bool c_r(char *argv0, char *rest, bool via_shell, struct range *range)
{
	window *const win = windows_cur();
	buffer_t *const b = win->buf;

	struct range rng;
	RANGE_DEFAULT(range, rng, win);

	*win->ui_pos = (point_t){ .y = range->start };

	list_t *lines = NULL;

	if(via_shell){
		lines = list_new(NULL);
		int err = list_filter(
				&lines,
				&(region_t){ .type = REGION_LINE, },
				rest);

		const int eno = errno;

		ui_redraw();

		if(err){
			ui_err("read process: %s", strerror(eno));
			return false;
		}

	}else{
		int argc = 0;
		char **argv = NULL;
		parse_cmd(rest, &argc, &argv, /*shell glob*/true);

		if(argc != 1){
			ui_err("%s: too many filenames", argv0);
			free_argv(argv, argc);
			return false;
		}

		FILE *stream = fopen(argv[0], "r");

		if(!stream){
			ui_err("%s: %s", rest, strerror(errno));
			return false;
		}

		free_argv(argv, argc);

		lines = list_new_file(stream, /*eol:*/&(bool){ false });
		fclose(stream);
	}

	b->head = list_append(b->head, window_current_line(win, true), lines);

	if(lines)
		win->ui_pos->y++;

	b->modified = true;

	ui_redraw();
	ui_cur_changed();

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r12
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
callq 0xd170
movq %rax, %rbx
movq (%rax), %r13
testq %r12, %r12
jne 0x7a9a
movq 0x30(%rbx), %rax
movl 0x4(%rax), %eax
leaq 0x18(%rsp), %r12
movl %eax, 0x4(%r12)
movl %eax, (%r12)
movq %r12, %rdi
callq 0xc3f2
movq 0x30(%rbx), %rax
movl (%r12), %ecx
andl $0x0, (%rax)
movl %ecx, 0x4(%rax)
testb %bpl, %bpl
je 0x7b15
xorl %edi, %edi
callq 0x9280
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rsi
movaps %xmm0, (%rsi)
movl $0x2, 0x10(%rsi)
movq %r14, %rdx
callq 0xa00b
movl %eax, %r14d
callq 0x40a0
movl (%rax), %ebp
callq 0x4cc7
testl %r14d, %r14d
je 0x7b8c
movl %ebp, %edi
callq 0x44e0
leaq 0x687a(%rip), %rdi      # 0xe37e
xorl %ebx, %ebx
movq %rax, %rsi
xorl %eax, %eax
callq 0x4c34
jmp 0x7c16
leaq 0x4(%rsp), %r12
andl $0x0, (%r12)
leaq 0x8(%rsp), %rdx
andq $0x0, (%rdx)
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %r12, %rsi
callq 0xc404
cmpl $0x1, (%r12)
jne 0x7bd1
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x689d(%rip), %rsi      # 0xe3ed
callq 0x4440
testq %rax, %rax
je 0x7bf4
movq %rax, %r15
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xc856
leaq 0x3(%rsp), %rsi
movb $0x0, (%rsi)
movq %r15, %rdi
callq 0x92df
movq %rax, 0x10(%rsp)
movq %r15, %rdi
callq 0x4150
movq 0x8(%r13), %r14
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xcef6
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x9a44
movq %rax, 0x8(%r13)
cmpq $0x0, 0x10(%rsp)
je 0x7bbe
movq 0x30(%rbx), %rax
incl 0x4(%rax)
movb $0x1, 0x39(%r13)
callq 0x4cc7
callq 0x501c
movb $0x1, %bl
jmp 0x7c16
leaq 0x67b7(%rip), %rdi      # 0xe38f
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x4c34
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xc856
jmp 0x7c16
callq 0x40a0
movl (%rax), %edi
callq 0x44e0
leaq 0x691e(%rip), %rdi      # 0xe525
xorl %ebx, %ebx
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4c34
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq