// File: /workspace/github_c_makefile_star2_O3/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 0xdaf0
movq %rax, %rbx
movq (%rax), %r13
testq %r12, %r12
jne 0x7e78
movq 0x30(%rbx), %rax
movl 0x4(%rax), %eax
leaq 0x18(%rsp), %r12
movl %eax, 0x4(%r12)
movl %eax, (%r12)
movq %r12, %rdi
callq 0xcc9d
movq 0x30(%rbx), %rax
movl (%r12), %ecx
movl $0x0, (%rax)
movl %ecx, 0x4(%rax)
testb %bpl, %bpl
je 0x7ef6
xorl %edi, %edi
callq 0x9804
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 0xa782
movl %eax, %r14d
callq 0x40a0
movl (%rax), %ebp
callq 0x4e77
testl %r14d, %r14d
je 0x7f75
movl %ebp, %edi
callq 0x44e0
leaq 0x6499(%rip), %rdi      # 0xe37e
xorl %ebx, %ebx
movq %rax, %rsi
xorl %eax, %eax
callq 0x4de2
jmp 0x8001
leaq 0x4(%rsp), %r12
movl $0x0, (%r12)
leaq 0x8(%rsp), %rdx
movq $0x0, (%rdx)
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %ecx
callq 0xccac
cmpl $0x1, (%r12)
jne 0x7fbc
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x64b4(%rip), %rsi      # 0xe3ed
callq 0x4440
testq %rax, %rax
je 0x7fdf
movq %rax, %r15
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xd124
leaq 0x3(%rsp), %rsi
movb $0x0, (%rsi)
movq %r15, %rdi
callq 0x986d
movq %rax, 0x10(%rsp)
movq %r15, %rdi
callq 0x4150
movq 0x8(%r13), %r14
movq %rbx, %rdi
movl $0x1, %esi
callq 0xd868
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0xa0bd
movq %rax, 0x8(%r13)
cmpq $0x0, 0x10(%rsp)
je 0x7fa9
movq 0x30(%rbx), %rax
incl 0x4(%rax)
movb $0x1, 0x39(%r13)
callq 0x4e77
callq 0x51ce
movb $0x1, %bl
jmp 0x8001
leaq 0x63cc(%rip), %rdi      # 0xe38f
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x4de2
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xd124
jmp 0x8001
callq 0x40a0
movl (%rax), %edi
callq 0x44e0
leaq 0x6533(%rip), %rdi      # 0xe525
xorl %ebx, %ebx
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4de2
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq