// File: /workspace/github_c_makefile_star2_O0/bobrippling[P]tim/cmds.c
// Function: write_range
static bool write_range(char *arg, bool force, struct range *range)
{
	arg = skipspace(arg);

	buffer_t *const buf = buffers_cur();
	const char *wfname;

	list_t *seeked = list_seek(buf->head, range->start, false);

	if(!seeked){
		ui_err("out of range");
		return false;
	}

	const int nlines = range->end - range->start + 1;

	if(!*arg){
		/* :a,b write <no arg here> */
		if(!force){
			ui_err("refusing to write partial buffer without force");
			return false;
		}

		wfname = buffer_fname(buf);

	}else{
		if(*arg == '!')
			return shellout_write(arg + 1, seeked, nlines);

		char *fname = arg;

		if(!strncmp(fname, "\\!", 2)){
			/* change \! to ! */
			memmove(fname, fname + 1, strlen(fname));
		}

		wfname = fname;
	}

	/* partial write to file */
	FILE *f = fopen(wfname, "w");
	if(!f){
		ui_err("open %s: %s", wfname, strerror(errno));
		return false;
	}

	int r = list_write_file(seeked, nlines, f, /*eol:*/true);
	int eno = errno;

	if(r){
		ui_err("write %s: %s", wfname, strerror(eno));
		return false;
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10a20
movq %rax, -0x10(%rbp)
callq 0x13c60
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
xorl %edx, %edx
callq 0xcd50
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x8f7b
leaq 0xc658(%rip), %rdi      # 0x155c3
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0x90e8
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x20(%rbp), %rcx
subl (%rcx), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x8fc6
testb $0x1, -0x11(%rbp)
jne 0x8fb4
leaq 0xc62c(%rip), %rdi      # 0x155d0
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0x90e8
movq -0x28(%rbp), %rdi
callq 0xbb30
movq %rax, -0x30(%rbp)
jmp 0x9047
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x21, %eax
jne 0x8ff0
movq -0x10(%rbp), %rdi
addq $0x1, %rdi
movq -0x38(%rbp), %rsi
movl -0x3c(%rbp), %edx
callq 0x105e0
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x90e8
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0xc5fc(%rip), %rsi      # 0x155ff
movl $0x2, %edx
callq 0x40c0
cmpl $0x0, %eax
jne 0x903f
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rdi
callq 0x4170
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq %rax, %rdx
callq 0x4400
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0xca2c(%rip), %rsi      # 0x15a7e
callq 0x4440
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x9091
movq -0x30(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x40a0
movl (%rax), %edi
callq 0x44d0
movq -0x70(%rbp), %rsi
movq %rax, %rdx
leaq 0xc57e(%rip), %rdi      # 0x15602
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0x90e8
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x50(%rbp), %rdx
movl $0x1, %ecx
callq 0xcb60
movl %eax, -0x54(%rbp)
callq 0x40a0
movl (%rax), %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x90e4
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x58(%rbp), %edi
callq 0x44d0
movq -0x78(%rbp), %rsi
movq %rax, %rdx
leaq 0xc537(%rip), %rdi      # 0x1560e
movb $0x0, %al
callq 0x4f30
movb $0x0, -0x1(%rbp)
jmp 0x90e8
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)