// File: /workspace/github_c_makefile_star2_O1/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 0xde6c
movq %rax, %rbx
movq (%rax), %r13
testq %r12, %r12
jne 0x7f79
movq 0x30(%rbx), %rax
movl 0x4(%rax), %eax
leaq 0x18(%rsp), %r12
movl %eax, 0x4(%r12)
movl %eax, (%r12)
movq %r12, %rdi
callq 0xd017
movq 0x30(%rbx), %rax
movl (%r12), %ecx
movl $0x0, (%rax)
movl %ecx, 0x4(%rax)
movq $0x0, 0x8(%rsp)
testb %bpl, %bpl
je 0x8000
xorl %edi, %edi
callq 0x99a4
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rsi
movaps %xmm0, (%rsi)
movl $0x2, 0x10(%rsi)
movq %r14, %rdx
callq 0xa9b3
movl %eax, %r14d
callq 0x40a0
movl (%rax), %ebp
callq 0x4e77
testl %r14d, %r14d
je 0x80c1
movl %ebp, %edi
callq 0x44e0
leaq 0x739b(%rip), %rdi      # 0xf38a
xorl %ebx, %ebx
movq %rax, %rsi
xorl %eax, %eax
callq 0x4de2
jmp 0x810a
leaq 0x4(%rsp), %r12
movl $0x0, (%r12)
leaq 0x10(%rsp), %rdx
movq $0x0, (%rdx)
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %ecx
callq 0xd028
cmpl $0x1, (%r12)
jne 0x8079
movq 0x10(%rsp), %rax
movq (%rax), %rdi
leaq 0x73ba(%rip), %rsi      # 0xf3f9
callq 0x4440
movq %rax, %r15
testq %rax, %rax
je 0x809c
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xd4a5
leaq 0x3(%rsp), %rsi
movb $0x0, (%rsi)
movq %r15, %rdi
callq 0x9a11
movq %rax, 0x8(%rsp)
movq %r15, %rdi
callq 0x4150
jmp 0x80bc
leaq 0x731b(%rip), %rdi      # 0xf39b
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x4de2
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xd4a5
jmp 0x810a
callq 0x40a0
movl (%rax), %edi
callq 0x44e0
leaq 0x7485(%rip), %rdi      # 0xf534
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4de2
testq %r15, %r15
je 0x8108
movq 0x8(%r13), %r14
movq %rbx, %rdi
movl $0x1, %esi
callq 0xdbe9
movq 0x8(%rsp), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0xa286
movq %rax, 0x8(%r13)
cmpq $0x0, 0x8(%rsp)
je 0x80f5
movq 0x30(%rbx), %rax
incl 0x4(%rax)
movb $0x1, 0x39(%r13)
callq 0x4e77
callq 0x51d8
movb $0x1, %bl
jmp 0x810a
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq