LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: c_run
bool c_run(char *cmd, char *rest, bool force, struct range *range)
{
	if(range){
		/* filter */
		buffer_t *buf = buffers_cur();

		int err = list_filter(
				&buf->head,
				&(region_t){
					.type = REGION_LINE,
					.begin.y = range->start,
					.end.y = range->end,
				},
				rest);

		const int eno = errno;

		ui_redraw();

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

		return true;
	}

	int r = shellout(rest);

	if(r){
		ui_err("command returned %d", r);
		return false;
	}

	return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
testq %rcx, %rcx
je 0x8440
movq %rcx, %r14
callq 0xdaf0
movq (%rax), %rdi
addq $0x8, %rdi
xorl %eax, %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movl (%r14), %ecx
movl %ecx, 0x4(%rsi)
movl %eax, 0x8(%rsi)
movl 0x4(%r14), %eax
movl %eax, 0xc(%rsi)
movl $0x2, 0x10(%rsi)
movq %rbx, %rdx
callq 0xa782
movl %eax, %ebp
callq 0x40a0
movl (%rax), %ebx
callq 0x4e77
testl %ebp, %ebp
je 0x8460
movl %ebx, %edi
callq 0x44e0
leaq 0x5e4c(%rip), %rdi      # 0xe27e
xorl %ebx, %ebx
movq %rax, %rsi
xorl %eax, %eax
callq 0x4de2
jmp 0x8462
movq %rbx, %rdi
callq 0x459e
testl %eax, %eax
je 0x8460
leaq 0x5fe6(%rip), %rdi      # 0xe439
xorl %ebx, %ebx
movl %eax, %esi
xorl %eax, %eax
callq 0x4de2
jmp 0x8462
movb $0x1, %bl
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: c_ls
bool c_ls(int argc, char **argv, bool force, struct range *range)
{
	RANGE_NO();
	ARGV_NO();

	buffer_t *b = buffer_new();
	attach_buffer(b, neighbour_down, NULL);

	list_t *files = NULL, *latest = NULL;

	for(tab *tab = tabs_first(); tab; tab = tab->next){
		window *win;
		ITER_WINDOWS_FROM(win, tab->win){
			buffer_t *buf = win->buf;
			const char *fname = buffer_fname(buf);
			if(fname){
				if(list_contains(files, fname))
					continue;

				list_t *new = list_new(NULL);
				new->line = ustrdup(fname);
				new->len_line = strlen(new->line);
				new->len_malloc = new->len_line + 1;

				files = list_append(files, latest, new);
				latest = new;
			}
		}
	}

	buffer_replace_list(b, files);

	ui_redraw();
	ui_cur_changed();

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rcx, %rcx
je 0x848f
movq (%rsi), %rsi
leaq 0x5e12(%rip), %rdi      # 0xe29c
jmp 0x8588
cmpl $0x1, %edi
jne 0x857e
callq 0x8f53
xorl %r14d, %r14d
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x85a2
callq 0xdbec
testq %rax, %rax
je 0x8563
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %rax, 0x10(%rsp)
movq (%rax), %rdi
callq 0xd4d9
testq %rax, %rax
je 0x8551
movq %rax, %r15
movq %r15, %r13
movq (%r13), %rdi
callq 0x9216
testq %rax, %rax
je 0x853f
movq %rax, %rbp
movq %r14, %rdi
movq %rax, %rsi
callq 0xaec5
testq %rax, %rax
jne 0x853f
xorl %edi, %edi
callq 0x9804
movq %rax, %r12
movq %rbp, %rdi
callq 0x585c
movq %rax, (%r12)
movq %rax, %rdi
callq 0x4170
movq %rax, 0x8(%r12)
incq %rax
movq %rax, 0x10(%r12)
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xa0bd
movq %rax, %r14
movq %r12, %rbx
movq 0x58(%r13), %r13
testq %r13, %r13
jne 0x84df
movq 0x50(%r15), %r15
testq %r15, %r15
jne 0x84dc
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x84c7
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x8f7b
callq 0x4e77
callq 0x51ce
movb $0x1, %bl
jmp 0x8591
movq (%rsi), %rsi
leaq 0x5d2f(%rip), %rdi      # 0xe2b7
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: attach_buffer
static void attach_buffer(
		buffer_t *buf,
		const enum neighbour dir,
		window *const copy_pos_from)
{
	window *w = window_new(buf);
	buffer_release(buf);

	window_add_neighbour(windows_cur(), dir, w);
	windows_set_cur(w);

	if(copy_pos_from){
		*w->ui_pos = *copy_pos_from->ui_pos;

		w->ui_start = copy_pos_from->ui_start;
		if(neighbour_is_vertical(dir)){
			int diff = (w->ui_pos->y - w->ui_start.y) / 2;

			copy_pos_from->ui_start.y += diff;
			w->ui_start.y += diff;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r15
callq 0xd7c4
movq %rax, %r14
leaq 0x974(%rip), %rsi       # 0x8f34
movq %r15, %rdi
callq 0xcaff
callq 0xdaf0
movq %rax, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0xd6b4
movq %r14, %rdi
callq 0xdb04
testq %rbx, %rbx
je 0x8623
movq 0x30(%r14), %rax
movq 0x30(%rbx), %rcx
movq (%rcx), %rcx
movq %rcx, (%rax)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r14)
movl %ebp, %edi
callq 0xd6ad
testb %al, %al
je 0x8623
movq 0x30(%r14), %rax
movl 0x4(%rax), %eax
subl 0xc(%r14), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
addl %ecx, 0xc(%rbx)
addl %ecx, 0xc(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: c_p
bool c_p(int argc, char **argv, bool force, struct range *range)
{
	ARGV_NO();

	window *win = windows_cur();

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

	buffer_t *const b = win->buf;

	list_t *l = list_seek(b->head, range->start, false);
	for(int i = range->start; i <= range->end; i++){
		ui_print(l ? l->line : "", l ? l->len_line : 0);
		if(l)
			l = l->next;
	}

	ui_want_return();

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
cmpl $0x1, %edi
jne 0x86c9
movq %rcx, %r14
callq 0xdaf0
movq %rax, %r15
testq %r14, %r14
jne 0x8668
movq 0x30(%r15), %rax
movl 0x4(%rax), %eax
leaq 0x8(%rsp), %r14
movl %eax, 0x4(%r14)
movl %eax, (%r14)
movq %r14, %rdi
callq 0xcc9d
movq (%r15), %rax
movq 0x8(%rax), %rdi
movl (%r14), %esi
xorl %edx, %edx
callq 0x9d35
movl (%r14), %ebp
cmpl 0x4(%r14), %ebp
jg 0x86c2
movq %rax, %r15
decl %ebp
leaq 0x60b3(%rip), %r12      # 0xe749
testq %r15, %r15
je 0x86ad
movq (%r15), %rdi
movq 0x8(%r15), %rsi
callq 0x57e4
movq 0x18(%r15), %r15
jmp 0x86ba
movq %r12, %rdi
xorl %esi, %esi
callq 0x57e4
xorl %r15d, %r15d
incl %ebp
cmpl 0x4(%r14), %ebp
jl 0x8696
callq 0x5827
jmp 0x86da
movq (%rsi), %rsi
leaq 0x5be4(%rip), %rdi      # 0xe2b7
xorl %eax, %eax
callq 0x4de2
cmpl $0x1, %ebx
sete %al
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: copy_move_common
static bool copy_move_common(
		int argc, char **argv,
		struct range **const range,
		struct range *const range_store,
		int *const out_addr)
{
	if(argc != 2){
		ui_err("Usage: %s address", *argv);
		return false;
	}

	char *addr_end;
	if(!parse_range_1(argv[1], &addr_end, out_addr) || *addr_end){
		ui_err("bad address: \"%s\"", argv[1]);
		return false;
	}

	window *win = windows_cur();

	RANGE_DEFAULT(*range, *range_store, win);

	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
cmpl $0x2, %edi
jne 0x889d
movq %rcx, %rbx
movq %rdx, %r14
movq 0x8(%r15), %rdi
leaq 0x8(%rsp), %rsi
movq %r8, %rdx
callq 0xcb08
testb %al, %al
je 0x8890
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x88bc
movq 0x8(%r15), %rsi
leaq 0x5cf2(%rip), %rdi      # 0xe58d
jmp 0x88a7
movq (%r15), %rsi
leaq 0x5bd7(%rip), %rdi      # 0xe47e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0xdaf0
movq (%r14), %rdi
testq %rdi, %rdi
jne 0x88db
movq 0x30(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, 0x4(%rbx)
movl %eax, (%rbx)
movq %rbx, (%r14)
movq %rbx, %rdi
callq 0xcc9d
movb $0x1, %bl
jmp 0x88b0
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: c_t
bool c_t(int argc, char **argv, bool force, struct range *range)
{
	if(argc != 2){
		ui_err("Usage: %s address", *argv);
		return false;
	}

	struct range range_store;
	int lno;
	if(!copy_move_common(argc, argv, &range, &range_store, &lno))
		return false;

	buffer_t *const b = windows_cur()->buf;

	list_t *landing = list_seek(b->head, lno, false);
	if(!landing)
		NO_LINE(lno);

	/* copy the range */
	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);

	list_t *copied;
	/* break the bottom link temporarily for the copy */
	{
		list_t *after = end->next;
		end->next = NULL;

		copied = list_copy_deep(start, NULL);
		end->next = after;
	}

	if(lno == -1){
		/* special case - head */
		list_t *head = b->head;

		b->head = copied;
		list_t *i;
		for(i = b->head; i->next; i = i->next);

		i->next = head;
		if(head)
			head->prev = i;

	}else{
		list_t *next = landing->next;
		landing->next = copied;
		copied->prev = landing;

		list_t *i;
		for(i = landing; i->next; i = i->next);
		i->next = next;
		if(next)
			next->prev = i;
	}

	b->modified = true;

	ui_redraw();
	ui_cur_changed();

	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rcx, 0x10(%rsp)
cmpl $0x2, %edi
jne 0x89b4
leaq 0x10(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0xc(%rsp), %r8
movl $0x2, %edi
callq 0x885a
testb %al, %al
je 0x89c9
callq 0xdaf0
movq (%rax), %r12
movq 0x8(%r12), %rdi
movl 0xc(%rsp), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x89cd
movq %rax, %rbx
movq 0x8(%r12), %rdi
movq 0x10(%rsp), %r13
movl (%r13), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x89d3
movq %rax, %r14
movq 0x8(%r12), %rdi
movl 0x4(%r13), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x89d9
movq %rax, %r15
movq 0x18(%rax), %r13
movq $0x0, 0x18(%rax)
movq %r14, %rdi
xorl %esi, %esi
callq 0x9818
movq %r13, 0x18(%r15)
cmpl $-0x1, 0xc(%rsp)
je 0x89ef
movq 0x18(%rbx), %rcx
movq %rax, 0x18(%rbx)
movq %rbx, 0x20(%rax)
movq %rbx, %rdx
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
jne 0x89a6
jmp 0x8a05
movq (%rsi), %rsi
leaq 0x5ac0(%rip), %rdi      # 0xe47e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
jmp 0x8a24
xorl %ebx, %ebx
jmp 0x8a24
movl 0xc(%rsp), %esi
jmp 0x89dd
movl (%r13), %esi
jmp 0x89dd
movl 0x4(%r13), %esi
leaq 0x5a8a(%rip), %rdi      # 0xe46e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4de2
jmp 0x8a24
movq 0x8(%r12), %rcx
movq %rax, 0x8(%r12)
movq %rax, %rdx
movq 0x18(%rax), %rax
testq %rax, %rax
jne 0x89f9
movq %rcx, 0x18(%rdx)
testq %rcx, %rcx
je 0x8a12
movq %rdx, 0x20(%rcx)
movb $0x1, 0x39(%r12)
callq 0x4e77
callq 0x51ce
movb $0x1, %bl
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: command_bufaction
static void command_bufaction(
		struct range *range, buffer_action_f *buf_fn, int end_add)
{
	window *win = windows_cur();

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

	range->end += end_add;

	buffer_t *const b = win->buf;

	buf_fn(
			b,
			&(region_t){
				.begin.y = range->start,
				.end.y = range->end,
				.type = REGION_LINE
			},
			&(point_t){});

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

	ui_redraw();
	ui_cur_changed();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
callq 0xdaf0
movq %rax, %r12
testq %r15, %r15
jne 0x8aa0
movq 0x30(%r12), %rax
movl 0x4(%rax), %eax
leaq 0x14(%rsp), %r15
movl %eax, 0x4(%r15)
movl %eax, (%r15)
movq %r15, %rdi
callq 0xcc9d
movl 0x4(%r15), %eax
addl %ebx, %eax
movl %eax, 0x4(%r15)
movq (%r12), %rdi
xorl %ebp, %ebp
leaq 0x1c(%rsp), %rsi
movl %ebp, (%rsi)
movl (%r15), %ecx
movl %ecx, 0x4(%rsi)
movl %ebp, 0x8(%rsi)
movl %eax, 0xc(%rsi)
movl $0x2, 0x10(%rsi)
leaq 0xc(%rsp), %rdx
movq $0x0, (%rdx)
callq *%r14
movq 0x30(%r12), %rax
movl 0x4(%r15), %ecx
subl %ebx, %ecx
movl %ebp, (%rax)
movl %ecx, 0x4(%rax)
callq 0x4e77
callq 0x51ce
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: c_j
bool c_j(int argc, char **argv, bool force, struct range *range)
{
	ARGV_NO();

	if(range && range->start != range->end){
		/* :2j means :2,3j
		 * otherwise, we have :5,6j, in which case we want to say :5,5j */
		range->end--;
	}

	command_bufaction(range, buffer_joinregion_space.fn, 1);

	return true;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
cmpl $0x1, %edi
jne 0x8b3a
testq %rcx, %rcx
je 0x8b21
movl 0x4(%rcx), %eax
cmpl %eax, (%rcx)
je 0x8b21
decl %eax
movl %eax, 0x4(%rcx)
leaq 0xd858(%rip), %rax      # 0x16380
movq (%rax), %rsi
movq %rcx, %rdi
movl $0x1, %edx
callq 0x8a6b
jmp 0x8b4b
movq (%rsi), %rsi
leaq 0x5773(%rip), %rdi      # 0xe2b7
xorl %eax, %eax
callq 0x4de2
cmpl $0x1, %ebx
sete %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/cmds.c
// Function: c_norm
bool c_norm(char *cmd, char *normcmd, bool force, struct range *range)
{
	enum io mode = IO_MAP; /* normal mode mappings */
	if(force)
		mode = IO_NOMAP;

	window *win = windows_cur();

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

	size_t normcmdlen = strlen(normcmd);

	for(int n = range->start;
			n <= range->end;
			n++)
	{
		*win->ui_pos = (point_t){ .y = n };

		size_t const io_empty = io_bufsz();

		/* end with an escape */
		io_ungetch(K_ESC, false);

		/* don't io_map() here - may be in insert mode
		 * when we actually execute */
		for(size_t i = normcmdlen; i > 0; i--)
			io_ungetch(normcmd[i - 1], false);

		do{
			/* run the commands while the buffer is on this line */
			ui_normal_1(/*repeat:*/&(unsigned){ 0 }, mode);
		}while(io_bufsz() > io_empty);
	}

	ui_redraw();
	ui_cur_changed();

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r12
movl %edx, %r15d
movq %rsi, %rbx
callq 0xdaf0
movq %rax, 0x8(%rsp)
testq %r12, %r12
jne 0x8e32
movq 0x8(%rsp), %rax
movq 0x30(%rax), %rax
movl 0x4(%rax), %eax
leaq 0x20(%rsp), %r12
movl %eax, 0x4(%r12)
movl %eax, (%r12)
movq %r12, %rdi
callq 0xcc9d
movq %rbx, %rdi
callq 0x4170
movq %rax, 0x10(%rsp)
movl (%r12), %r14d
cmpl 0x4(%r12), %r14d
jg 0x8edd
movl $0x2, %ebp
subl %r15d, %ebp
leaq 0x4(%rsp), %r13
movq %r12, 0x18(%rsp)
movq 0x8(%rsp), %rax
movq 0x30(%rax), %rax
movl $0x0, (%rax)
movl %r14d, 0x4(%rax)
callq 0xc3bc
movq %rax, %r15
movl $0x1b, %edi
xorl %esi, %esi
callq 0xc50d
cmpq $0x0, 0x10(%rsp)
je 0x8eae
movq 0x10(%rsp), %r12
movsbl -0x1(%rbx,%r12), %edi
xorl %esi, %esi
callq 0xc50d
decq %r12
jne 0x8e9c
movl $0x0, 0x4(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x5402
callq 0xc3bc
cmpq %r15, %rax
ja 0x8eae
leal 0x1(%r14), %eax
movq 0x18(%rsp), %r12
cmpl 0x4(%r12), %r14d
movl %eax, %r14d
jl 0x8e68
callq 0x4e77
callq 0x51ce
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_new
buffer_t *buffer_new()
{
	buffer_t *b = umalloc(sizeof *b);

	retain_init(b);

	b->head = list_new(NULL);
	b->eol = true; /* default to nice eol */
	return b;
}

// Assembly:
pushq %rbx
movl $0x50, %edi
callq 0x5830
movq %rax, %rbx
movl $0x1, (%rax)
xorl %edi, %edi
callq 0x9804
movq %rax, 0x8(%rbx)
movb $0x1, 0x38(%rbx)
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_replace_fname
void buffer_replace_fname(
		buffer_t *const b, const char *fname,
		const char **const err)
{
	*err = NULL;

	FILE *f = fopen(fname, "r");
	if(!f){
err:
		*err = strerror(errno);
		return;
	}

	if(!buffer_replace_file(b, f)){
		fclose(f);
		goto err;
	}
	fclose(f);

	buffer_set_fname(b, fname);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq $0x0, (%rdx)
leaq 0x5434(%rip), %rsi      # 0xe3ed
movq %r14, %rdi
callq 0x4440
testq %rax, %rax
je 0x8ff5
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x900d
movl %eax, %ebp
movq %r12, %rdi
callq 0x4150
testl %ebp, %ebp
je 0x8ff5
movq %r15, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9054
callq 0x40a0
movl (%rax), %edi
callq 0x44e0
movq %rax, (%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_replace_file
static int buffer_replace_file(buffer_t *b, FILE *f)
{
	list_t *l = list_new_file(f, &b->eol);

	if(!l)
		return 0;

	buffer_replace_list(b, l);

	b->mtime = time(NULL);

	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x38(%rdi), %rsi
movq %rax, %rdi
callq 0x986d
testq %rax, %rax
je 0x904a
movq %rax, %r14
movq 0x8(%rbx), %rdi
callq 0x9bd0
movq %r14, 0x8(%rbx)
xorl %edi, %edi
callq 0x4370
movq %rax, 0x40(%rbx)
movl $0x1, %eax
jmp 0x904c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_new_file_nofind
buffer_t *buffer_new_file_nofind(FILE *f)
{
	buffer_t *b = buffer_new();

	if(buffer_replace_file(b, f))
		return b;

	buffer_free(b);

	return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x50, %edi
callq 0x5830
movq %rax, %rbx
movl $0x1, (%rax)
xorl %edi, %edi
callq 0x9804
movq %rax, 0x8(%rbx)
movb $0x1, 0x38(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x900d
testl %eax, %eax
jne 0x90c2
movq %rbx, %rdi
callq 0x8f34
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_new_fname
void buffer_new_fname(
		buffer_t **pb, const char *fname,
		const char **const err)
{
	*err = NULL;

	/* look for an existing buffer first */
	buffer_t *b = buffers_find(fname);

	if(b){
		*pb = retain(b);
		return;
	}

	FILE *f = fopen(fname, "r");
	if(!f){
got_err:
		*err = strerror(errno);
		b = buffer_new();
		b->modified = false; /* editing a non-existant file, etc */
		goto fin;
	}

	b = buffer_new_file_nofind(f);
	fclose(f);

	if(!b){
		if(errno == EISDIR){
			DIR *d = opendir(fname);
			if(!d)
				goto got_err;

			list_t *l = list_from_dir(d);

			const int save_errno = errno;
			closedir(d);
			errno = save_errno;

			if(!l)
				goto got_err;

			b = buffer_new();
			buffer_replace_list(b, l);
		}else{
			goto got_err;
		}
	}

fin:
	buffer_set_fname(b, fname);
	*pb = b;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq $0x0, (%rdx)
movq %rsi, %rdi
callq 0xd2ac
testq %rax, %rax
je 0x9105
movq %rax, %rdi
callq 0xcaf4
movq %rax, %r12
jmp 0x91d8
leaq 0x52e1(%rip), %rsi      # 0xe3ed
movq %r14, %rdi
callq 0x4440
testq %rax, %rax
je 0x9192
movq %rax, %r13
movq %rax, %rdi
callq 0x9080
movq %rax, %r12
movq %r13, %rdi
callq 0x4150
testq %r12, %r12
jne 0x91cd
callq 0x40a0
movq %rax, %r12
cmpl $0x15, (%rax)
jne 0x919a
movq %r14, %rdi
callq 0x4160
testq %rax, %rax
je 0x919a
movq %rax, %rbp
movq %rax, %rdi
callq 0x9a53
movq %rax, (%rsp)
movl (%r12), %r13d
movq %rbp, %rdi
callq 0x4290
movl %r13d, (%r12)
movq (%rsp), %r13
testq %r13, %r13
je 0x919a
callq 0x8f53
movq %rax, %r12
movq 0x8(%rax), %rdi
callq 0x9bd0
movq %r13, 0x8(%r12)
jmp 0x91cd
callq 0x40a0
movq %rax, %r12
movl (%r12), %edi
callq 0x44e0
movq %rax, (%r15)
movl $0x50, %edi
callq 0x5830
movq %rax, %r12
movl $0x1, (%rax)
xorl %edi, %edi
callq 0x9804
movq %rax, 0x8(%r12)
movw $0x1, 0x38(%r12)
movq %r12, %rdi
movq %r14, %rsi
callq 0x9054
movq %r12, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_write_file
int buffer_write_file(buffer_t *b, int n, FILE *f, bool eol)
{
	int r = list_write_file(b->head, n, f, eol);
	b->mtime = time(NULL);
	b->modified = false;
	return r;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x9c00
movl %eax, %ebp
xorl %edi, %edi
callq 0x4370
movq %rax, 0x40(%rbx)
movb $0x0, 0x39(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_last_indent_line
static list_t *buffer_last_indent_line(buffer_t *buf, int y)
{
	list_t *l = list_seek(buf->head, y, false);

	if(!l)
		return NULL;

	/* scan backwards until we hit a non-empty line */
	while(l->prev){
		l = l->prev;
		if(!isallspace(l->line, l->len_line))
			return l;
	}

	return NULL;
}

// Assembly:
pushq %rbx
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x926e
movq %rax, %rbx
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x926c
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0xbdc5
testb %al, %al
jne 0x9251
jmp 0x926e
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: list_count_indent
static int list_count_indent(list_t *l)
{
	int indent = 0;

	/* count indent */
	for(unsigned i = 0; i < l->len_line; i++, indent++)
		if(!isspace(l->line[i]))
			break;

	/* if it ends with a '{', increase indent */
	if(l->len_line > 0 && l->line[l->len_line - 1] == '{')
		indent++;

	return indent;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x8(%rdi), %r14
testq %r14, %r14
je 0x92b8
movq %rdi, %rbx
callq 0x4540
movq (%rax), %rax
movq (%rbx), %rdx
xorl %ecx, %ecx
movsbq (%rdx,%rcx), %rsi
testb $0x20, 0x1(%rax,%rsi,2)
je 0x92a9
incq %rcx
movl %ecx, %esi
cmpq %rsi, %r14
ja 0x9290
movq (%rbx), %rdx
xorl %eax, %eax
cmpb $0x7b, -0x1(%rdx,%r14)
sete %al
addl %ecx, %eax
jmp 0x92ba
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_inschar_at
void buffer_inschar_at(buffer_t *buf, char ch, int *x, int *y)
{
	bool indent = false;
	bool inschar = true;

	switch(ch){
		case CTRL_AND('?'):
		case CTRL_AND('H'):
		case 127:
			if(*x > 0)
				buffer_delchar(buf, x, y);
			inschar = false;
			break;

		case '}':
			/* if we've just started a new line, this unindents */
			buffer_unindent_empty(buf, x, *y);
			indent = false;
			break;

		case '\n':
			indent = true;
	}

	if(inschar){
		list_inschar(buf->head, x, y, ch, /*autogap*/0);
		if(indent)
			buffer_smartindent(buf, x, *y);
	}

	buf->modified = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r15
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x1e, %esi
jle 0x92ee
cmpl $0x7f, %ebp
je 0x931f
cmpl $0x7d, %ebp
je 0x9336
cmpl $0x1f, %ebp
je 0x931f
jmp 0x9373
cmpl $0x8, %ebp
je 0x931f
cmpl $0xa, %ebp
jne 0x9373
movq 0x8(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0xa, %ecx
xorl %r8d, %r8d
callq 0x9efa
movl (%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x921b
jmp 0x9389
cmpl $0x0, (%r14)
jle 0x9389
movq 0x8(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xa059
jmp 0x9389
movl (%r15), %esi
testl %esi, %esi
je 0x9373
movq 0x8(%rbx), %rdi
callq 0x923f
testq %rax, %rax
je 0x9373
movq %rax, %r12
movq (%rax), %rdi
testq %rdi, %rdi
je 0x9373
movslq (%r14), %rsi
callq 0xbdc5
testb %al, %al
je 0x9373
movq %r12, %rdi
callq 0x9273
testl %eax, %eax
je 0x9373
decl %eax
movl %eax, (%r14)
movq 0x8(%rbx), %rdi
movsbl %bpl, %ecx
movq %r14, %rsi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x9efa
movb $0x1, 0x39(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_inscolchar
void buffer_inscolchar(
		buffer_t *buf, char ch, unsigned ncols,
		point_t *const ui_pos)
{
	for(int i = ncols - 1; i >= 0; i--){
		int y = ui_pos->y + i;
		int x = ui_pos->x;
		int *px = &x;
		int *py = &y;

		/* update x and y in the last case */
		if(i == 0){
			px = &ui_pos->x;
			py = &ui_pos->y;
		}

		buffer_inschar_at(buf, ch, px, py);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
decl %ebp
js 0x93fc
movq %rcx, %rbx
movq %rdi, %r14
leaq 0x4(%rcx), %r12
leaq 0x4(%rsp), %r13
movsbl %sil, %r15d
movl 0x4(%rbx), %eax
addl %ebp, %eax
movl %eax, 0x4(%rsp)
movl (%rbx), %eax
subl $0x1, %ebp
movq %rsp, %rdx
cmovbq %rbx, %rdx
movl %eax, (%rsp)
movq %r13, %rcx
cmovbq %r12, %rcx
movq %r14, %rdi
movl %r15d, %esi
callq 0x92c2
cmpl $-0x1, %ebp
jne 0x93cd
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_delregion_f
static
void buffer_delregion_f(buffer_t *buf, const region_t *region, point_t *out)
{
	list_t *del = list_delregion(&buf->head, region);

	if(del){
		release(yank_push(yank_new(del, region->type)), yank_free);

		buf->modified = true;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
addq $0x8, %rdi
callq 0xa0ef
testq %rax, %rax
je 0x944a
movl 0x10(%r14), %esi
movq %rax, %rdi
callq 0xc63c
movq %rax, %rdi
callq 0xc6a5
leaq 0x3252(%rip), %rsi      # 0xc690
movq %rax, %rdi
callq 0xcaff
movb $0x1, 0x39(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_yankregion_f
static
void buffer_yankregion_f(buffer_t *buf, const region_t *region, point_t *out)
{
	list_t *yanked = list_delregion(&buf->head, region);

	if(yanked){
		yank *yank = yank_new(yanked, region->type);
		yank_push(yank);

		point_t ui_pos = region->begin;

		buffer_insyank(buf, yank, &ui_pos,
				/*prepend:*/true, /*modify:*/false);

		release(yank, yank_free);
	}

	/* restore ui pos (set in buffer_insyank) */
	*out = region->begin;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
addq $0x8, %r15
movq %r15, %rdi
callq 0xa0ef
testq %rax, %rax
je 0x94b9
movl 0x10(%r14), %esi
movq %rax, %rdi
callq 0xc63c
movq %rax, %r12
movq %rax, %rdi
callq 0xc6a5
movq (%r14), %rax
leaq 0x4(%rsp), %rcx
movq %rax, -0x4(%rcx)
movq %rsp, %r8
movq %r12, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xc6da
leaq 0x31df(%rip), %rsi      # 0xc690
movq %r12, %rdi
callq 0xcaff
movq (%r14), %rax
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_insyank
void buffer_insyank(
		buffer_t *buf, const yank *y,
		point_t *ui_pos,
		bool prepend, bool modify)
{
	yank_put_in_list(y,
			&buf->head,
			prepend,
			&ui_pos->y,
			&ui_pos->x);

	if(modify)
		buf->modified = true;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %r8d, %ebp
movq %rdx, %r8
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x4(%rdx), %r9
movq %rax, %rdi
movl %ecx, %edx
movq %r9, %rcx
callq 0xc6da
testl %ebp, %ebp
je 0x94f7
movb $0x1, 0x39(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_caseregion
void buffer_caseregion(
		buffer_t *buf,
		enum case_tog tog_type,
		const region_t *r)
{
	int (*f)(int) = NULL;

	switch(tog_type){
		case CASE_TOGGLE: f = ctoggle; break;
		case CASE_UPPER:  f = toupper; break;
		case CASE_LOWER:  f = tolower; break;
	}
	assert(f);

	list_iter_region(buf->head, r, 0, buffer_case_cb, &f);
	buf->modified = true;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x2, %esi
je 0x956c
cmpl $0x1, %esi
je 0x9563
testl %esi, %esi
jne 0x959c
leaq 0x5a(%rip), %rax        # 0x95bb
jmp 0x9573
movq 0xca2e(%rip), %rax      # 0x15f98
jmp 0x9573
movq 0xca55(%rip), %rax      # 0x15fc8
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %rdi
leaq 0x5d(%rip), %rcx        # 0x95e0
leaq 0x8(%rsp), %r8
movq %rdx, %rsi
xorl %edx, %edx
callq 0xa9a8
movb $0x1, 0x39(%rbx)
addq $0x10, %rsp
popq %rbx
retq
leaq 0x4b9a(%rip), %rdi      # 0xe13d
leaq 0x4ff5(%rip), %rsi      # 0xe59f
leaq 0x4ff7(%rip), %rcx      # 0xe5a8
movl $0x1e2, %edx            # imm = 0x1E2
callq 0x4210
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_findat
bool buffer_findat(const buffer_t *buf, const char *search, point_t *at, int dir)
{
	list_t *l = list_seek(buf->head, at->y, 0);

	if(!l){
		if(dir < 0){
			l = list_last(buf->head, &at->y);
		}else{
			return false;
		}
	}

	/* search at the next char */
	l = list_advance_x(l, dir, &at->y, &at->x);

	while(l){
		char *p;
		if((unsigned)at->x < l->len_line
		&& (p = buffer_find2(l->line, l->len_line, search, at->x, dir)))
		{
			at->x = p - l->line;
			at->y = at->y;
			return true;
		}

		l = list_advance_y(l, dir, &at->y, &at->x);
	}

	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movq 0x8(%rdi), %rdi
leaq 0x4(%rdx), %r15
movl 0x4(%rdx), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x96a4
movq %rax, %rdi
movl %ebp, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xabbf
testq %rax, %rax
je 0x96a8
movq %rax, %r12
movl (%rbx), %esi
movq 0x8(%r12), %rax
subq %rsi, %rax
jbe 0x968a
movq (%r12), %rdi
testl %ebp, %ebp
js 0x967d
addq %rsi, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xbd69
jmp 0x9685
movq %r14, %rdx
callq 0xbd1f
testq %rax, %rax
jne 0x96b3
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xab7d
movq %rax, %r12
testq %rax, %rax
jne 0x9659
jmp 0x96a8
testl %ebp, %ebp
js 0x96bd
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
subl (%r12), %eax
movl %eax, (%rbx)
movb $0x1, %al
jmp 0x96aa
movq 0x8(%r12), %rdi
movq %r15, %rsi
callq 0xac04
jmp 0x9641
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_joinregion_f
static
void buffer_joinregion_f(
		buffer_t *buf,
		const region_t *region,
		point_t *out,
		const bool space)
{
	/* could use 'how' here - columns and lines only make sense */
	list_t *l = list_seek(buf->head, region->begin.y, 0);
	const int mid = l ? l->len_line : 0;

	list_joinregion(&buf->head, region, space);

	if(l)
		out->x = mid;
	buf->modified = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x8(%rdi), %r12
movq 0x8(%rdi), %rdi
movl 0x4(%rsi), %esi
xorl %edx, %edx
callq 0x9d35
testq %rax, %rax
je 0x9714
movl 0x8(%rax), %r13d
movzbl %bpl, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0xa617
movl %r13d, (%r14)
jmp 0x9723
movzbl %bpl, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0xa617
movb $0x1, 0x39(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/buffer.c
// Function: buffer_indent2
static
void buffer_indent2(
		buffer_t *buf, const region_t *region,
		point_t *out, int dir)
{
	/* region is sorted by y */
	const int min_x = MIN(region->begin.x, region->end.x);
	list_t *pos = dir < 0
		? list_seek(buf->head, region->begin.y, 0)
		: NULL;

	for(int y = region->begin.y; y <= region->end.y; y++){
		int x = 0;

		switch(region->type){
			case REGION_CHAR:
			case REGION_LINE:
				break;
			case REGION_COL:
				/* indent from the first col onwards */
				x = min_x;
		}

		if(dir > 0){
			buffer_inschar_at(buf, '\t', &x, &y);
		}else{
			if(pos){
				if(pos->len_line > 0 && pos->line[0] == '\t')
					memmove(pos->line, pos->line + 1, --pos->len_line);

				pos = pos->next;
			}else{
				break;
			}
		}
	}
	buf->modified = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
movl 0x8(%rsi), %r12d
cmpl %r12d, %eax
cmovll %eax, %r12d
testl %edx, %edx
js 0x975f
xorl %r15d, %r15d
jmp 0x9771
movq 0x8(%rbx), %rdi
movl 0x4(%r14), %esi
xorl %edx, %edx
callq 0x9d35
movq %rax, %r15
movl 0x4(%r14), %eax
movl %eax, (%rsp)
cmpl 0xc(%r14), %eax
jg 0x97ef
movq %rsp, %r13
cmpl $0x1, 0x10(%r14)
movl $0x0, %eax
cmovel %r12d, %eax
movl %eax, 0x4(%rsp)
testl %ebp, %ebp
jle 0x97b6
movq 0x8(%rbx), %rdi
leaq 0x4(%rsp), %rsi
movq %r13, %rdx
movl $0x9, %ecx
xorl %r8d, %r8d
callq 0x9efa
movb $0x1, 0x39(%rbx)
jmp 0x97e0
testq %r15, %r15
je 0x97ef
movq 0x8(%r15), %rdx
testq %rdx, %rdx
je 0x97dc
movq (%r15), %rdi
cmpb $0x9, (%rdi)
jne 0x97dc
leaq 0x1(%rdi), %rsi
decq %rdx
movq %rdx, 0x8(%r15)
callq 0x4400
movq 0x18(%r15), %r15
movl (%rsp), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%rsp)
cmpl 0xc(%r14), %eax
jl 0x9781
movb $0x1, 0x39(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_copy_deep
list_t *list_copy_deep(const list_t *const l, list_t *prev)
{
	if(!l)
		return NULL;
	list_t *new = list_new(prev);
	new->len_line = l->len_line;
	new->len_malloc = l->len_line; /* len_line, not len_malloc */
	new->line = ustrdup_len(l->line, l->len_line);
	new->next = list_copy_deep(l->next, new);
	return new;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x9862
movq %rsi, %r15
movq %rdi, %r14
movl $0x30, %edi
callq 0x5830
movq %rax, %rbx
movq %r15, 0x20(%rax)
movq 0x8(%r14), %rsi
movq %rsi, 0x8(%rax)
movq %rsi, 0x10(%rax)
movq (%r14), %rdi
callq 0x5889
movq %rax, (%rbx)
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0x9818
movq %rax, 0x18(%rbx)
jmp 0x9864
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_new_fd
static list_t *list_new_fd(int fd, bool *eol)
{
	struct stat st;
	if(fstat(fd, &st) == -1)
		return NULL;

	if(st.st_size == 0)
		goto fallback; /* could be stdin */

	if(S_ISDIR(st.st_mode)){
		errno = EISDIR;
		return NULL;
	}

	void *mem = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);

	if(mem == MAP_FAILED){
		if(errno == EINVAL)
fallback:
			return list_new_fd_read(fd, eol);

		return NULL;
	}

	list_t *l = mmap_to_lines(mem, st.st_size, eol);
	munmap(mem, st.st_size);

	return l;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r13
movl %edi, %ebp
leaq 0x28(%rsp), %rsi
callq 0x4510
cmpl $-0x1, %eax
je 0x98cc
movq 0x58(%rsp), %r15
testq %r15, %r15
je 0x998c
movl $0xf000, %eax           # imm = 0xF000
andl 0x40(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x98d4
callq 0x40a0
movl $0x15, (%rax)
xorl %r14d, %r14d
jmp 0x9a3e
xorl %edi, %edi
movq %r15, %rsi
movl $0x1, %edx
movl $0x2, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x4190
cmpq $-0x1, %rax
je 0x997e
movq %rax, %r12
movq %r13, 0x10(%rsp)
movl $0x30, %edi
callq 0x5830
movq %rax, %r14
movq $0x0, 0x20(%rax)
leaq 0x18(%rsp), %rbp
movq %rax, (%rbp)
leaq (%r12,%r15), %rax
movq %rax, 0x20(%rsp)
movq %rsp, %r13
movq %r12, (%r13)
xorl %ebx, %ebx
cmpb $0xa, (%r12,%rbx)
jne 0x9946
leaq (%r12,%rbx), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0xaef9
incq %rbx
cmpq %rbx, %r15
jne 0x9930
movq 0x20(%rsp), %rsi
cmpq (%rsp), %rsi
movq 0x10(%rsp), %rax
sete (%rax)
je 0x996e
leaq 0x18(%rsp), %rdi
movq %rsp, %rdx
callq 0xaef9
movq %r12, %rdi
movq %r15, %rsi
callq 0x43f0
jmp 0x9a3e
callq 0x40a0
cmpl $0x16, (%rax)
jne 0x98cc
movl $0x30, %edi
callq 0x5830
movq %rax, %r14
movq $0x0, 0x20(%rax)
xorl %eax, %eax
movl %eax, 0x18(%rsp)
movl %eax, (%rsp)
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movl $0x1, %edx
movl %ebp, %edi
callq 0x42b0
movb $0x1, %bl
cmpl $0x1, %eax
jne 0x9a3a
movq %r13, 0x10(%rsp)
xorl %ebx, %ebx
leaq 0x18(%rsp), %r12
leaq 0xc(%rsp), %r13
movl %ebx, %r15d
testb $0x1, %bl
je 0x99f9
movq %r14, %rdi
movq %rsp, %rsi
movq %r12, %rdx
movl $0xa, %ecx
movl $0x20, %r8d
callq 0x9efa
xorl %r15d, %r15d
movl 0xc(%rsp), %eax
movb $0x1, %bl
cmpl $0xa, %eax
je 0x9a1e
movsbl %al, %ecx
movq %r14, %rdi
movq %rsp, %rsi
movq %r12, %rdx
movl $0x20, %r8d
callq 0x9efa
movl %r15d, %ebx
movl $0x1, %edx
movl %ebp, %edi
movq %r13, %rsi
callq 0x42b0
cmpl $0x1, %eax
je 0x99d5
andb $0x1, %bl
movq 0x10(%rsp), %r13
movb %bl, (%r13)
movq %r14, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_from_dir
list_t *list_from_dir(DIR *d)
{
	list_t *head = list_new(NULL), *prev = NULL;
	int dfd = dirfd(d);

	struct dirent *dent;
	while((errno = 0, dent = readdir(d))){
		size_t len = strlen(dent->d_name);
		struct stat st;
		const bool is_dir = (dfd != -1
				&& fstatat(dfd, dent->d_name, &st, 0) == 0
				&& S_ISDIR(st.st_mode));

		char *line;
		if(is_dir){
			len++;
			line = umalloc(len + 1);
			snprintf(line, len + 1, "%s/", dent->d_name);

		}else{
			line = ustrdup_len(dent->d_name, len);
		}

		list_t *l;

		if(!head->line){
			l = head;
		}else{
			assert(prev);
			l = list_new(prev);
			prev->next = l;
		}
		prev = l;

		l->line = line;
		l->len_line = len;
		l->len_malloc = len + 1;
	}

	if(errno){
		int save = errno;
		list_free(head);
		head = NULL;
		errno = save;
	}

	return head;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
movl $0x30, %edi
callq 0x5830
movq %rax, 0x8(%rsp)
movq $0x0, 0x20(%rax)
movq %rbx, %rdi
callq 0x4300
movl %eax, 0x4(%rsp)
callq 0x40a0
movq %rax, %r15
movl $0x0, (%rax)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x4390
testq %rax, %rax
je 0x9b82
movq %rax, %r12
xorl %ebp, %ebp
addq $0x13, %r12
movq %r12, %rdi
callq 0x4170
movq %rax, %r13
cmpl $-0x1, 0x4(%rsp)
je 0x9b21
movl 0x4(%rsp), %edi
movq %r12, %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4530
testl %eax, %eax
jne 0x9b21
movl 0x30(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x9b21
leaq 0x1(%r13), %rbx
addq $0x2, %r13
movq %r13, %rdi
callq 0x5830
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
leaq 0x4ada(%rip), %rdx      # 0xe5ec
movq %r12, %rcx
xorl %eax, %eax
callq 0x41e0
movq %rbx, %r13
jmp 0x9b2f
movq %r12, %rdi
movq %r13, %rsi
callq 0x5889
movq %rax, %r14
movq 0x8(%rsp), %rbx
cmpq $0x0, (%rbx)
je 0x9b54
testq %rbp, %rbp
je 0x9bb1
movl $0x30, %edi
callq 0x5830
movq %rax, %rbx
movq %rbp, 0x20(%rax)
movq %rax, 0x18(%rbp)
movq %r14, (%rbx)
movq %r13, 0x8(%rbx)
incq %r13
movq %r13, 0x10(%rbx)
movl $0x0, (%r15)
movq 0x10(%rsp), %rdi
callq 0x4390
movq %rax, %r12
movq %rbx, %rbp
testq %rax, %rax
jne 0x9ab3
movl (%r15), %ebx
testl %ebx, %ebx
je 0x9b9a
movq 0x8(%rsp), %rdi
callq 0x9bd0
movl %ebx, (%r15)
xorl %eax, %eax
jmp 0x9b9f
movq 0x8(%rsp), %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4d32(%rip), %rdi      # 0xe8ea
leaq 0x4a31(%rip), %rsi      # 0xe5f0
leaq 0x4a31(%rip), %rcx      # 0xe5f7
movl $0xcc, %edx
callq 0x4210
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_free
void list_free(list_t *l)
{
	while(l){
		list_t *next = l->next;

		free(l->line);
		free(l);

		l = next;
	}
}

// Assembly:
testq %rdi, %rdi
je 0x9bff
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rbx), %rdi
movq 0x18(%rbx), %r14
callq 0x4080
movq %rbx, %rdi
callq 0x4080
movq %r14, %rbx
testq %r14, %r14
jne 0x9bdc
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_write_fd
static int list_write_fd(list_t *l, int n, int fd, bool eol)
{
	for(; l && (n == -1 || n --> 0); l = l->next){
		if(write(fd, l->line, l->len_line) != (int)l->len_line)
			goto got_err;

		if(l->next || eol)
			if(write(fd, "\n", 1) != 1)
				goto got_err;
	}

	return 0;
got_err:
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x9ca1
movl %ecx, %ebx
movl %edx, %ebp
movq %rdi, %r14
xorb $0x1, %bl
leaq 0x4b05(%rip), %r15      # 0xe748
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $-0x1, %esi
je 0x9c5d
testl %esi, %esi
jle 0x9ca1
decl %esi
movl %esi, %r13d
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movl %ebp, %edi
callq 0x4110
movslq 0x8(%r14), %rcx
cmpq %rcx, %rax
jne 0x9ca4
cmpq $0x0, 0x18(%r14)
sete %al
testb %bl, %al
jne 0x9ca1
movl $0x1, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x4110
cmpq $0x1, %rax
jne 0x9ca4
movq 0x18(%r14), %r14
movl %r13d, %esi
testq %r14, %r14
jne 0x9c49
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_seekp
list_t **list_seekp(list_t **pl, int y, bool creat)
{
	if(!*pl){
		if(creat)
			*pl = list_new(NULL);
		else
			return NULL;
	}

	while(y > 0){
		if(!(*pl)->next){
			if(creat)
				(*pl)->next = list_new(*pl);
			else
				return NULL;
		}

		pl = &(*pl)->next;
		y--;
	}

	return pl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
cmpq $0x0, (%rdi)
jne 0x9ce3
testb %bl, %bl
je 0x9d1f
movl $0x30, %edi
callq 0x5830
movq $0x0, 0x20(%rax)
movq %rax, (%r14)
testl %ebp, %ebp
jle 0x9d24
incl %ebp
movq (%r14), %r15
cmpq $0x0, 0x18(%r15)
jne 0x9d0f
testb %bl, %bl
je 0x9d1f
movl $0x30, %edi
callq 0x5830
movq %r15, 0x20(%rax)
movq (%r14), %rcx
movq %rax, 0x18(%rcx)
movq (%r14), %r15
addq $0x18, %r15
decl %ebp
movq %r15, %r14
cmpl $0x1, %ebp
jg 0x9ce9
jmp 0x9d27
xorl %r15d, %r15d
jmp 0x9d27
movq %r14, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_evalnewlines1
int list_evalnewlines1(list_t *l)
{
	if(l->len_line == 0)
		return 0;

	int r = 0;
	for(size_t i = l->len_line - 1; ; i--){
		char ch = l->line[i];

		if(ch == '\n' /* XXX: not '\r' / ^M */){
			int cut_len = l->len_line - i;
			char *cut;
			if(cut_len > 0){
				cut = umalloc(cut_len);
				/* cut_len-1, don't copy the \n */
				memcpy(cut, l->line + i + 1, cut_len-1);
			}else{
				cut = NULL;
				cut_len = 0;
			}

			l->len_line = i;

			/* insert a line after */
			list_insline(&l, &(int){0}, &(int){0}, 1);

			list_t *nl = l->next;
			nl->line = cut;
			nl->len_malloc = cut_len;
			nl->len_line = cut_len - 1;

			r = 1; /* we replaced */
		}

		if(i == 0)
			break;
	}

	return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, 0x8(%rsp)
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x9e5d
leaq -0x1(%rax), %rbx
movabsq $0x100000000, %r14      # imm = 0x100000000
subq %rax, %r14
movl $0x1, %r15d
subq %rax, %r15
movl $0x1, %ebp
subl %eax, %ebp
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movq (%rax), %rcx
cmpb $0xa, (%rcx,%rbx)
jne 0x9e48
movq 0x8(%rax), %r13
movq %rbp, %r12
addq %r13, %r12
testl %r12d, %r12d
jle 0x9def
leaq (%r15,%r13), %rdi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
callq 0x5830
movq %rax, %rdi
movq 0x8(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%rbx), %rsi
incq %rsi
addl %r14d, %r13d
movq %rdi, 0x18(%rsp)
movq %r13, %rdx
callq 0x4360
movq 0x8(%rsp), %rax
jmp 0x9dfb
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
movq %rbx, 0x8(%rax)
movl $0x0, 0x14(%rsp)
movl $0x1, %r13d
leaq 0x8(%rsp), %rdi
leaq 0x24(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movl $0x1, %ecx
callq 0x9e72
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movl %r12d, %ecx
movq %rcx, 0x10(%rax)
decl %r12d
movslq %r12d, %rcx
movq %rcx, 0x8(%rax)
incq %r14
incq %r15
incq %rbp
addq $-0x1, %rbx
jb 0x9d96
jmp 0x9e60
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_insline
void list_insline(list_t **pl, int *x, int *y, int dir)
{
	list_t *l, *save;

	*x = 0;

	if(dir < 0 && *y == 0){
		/* special case */
		l = *pl;
		(*pl = list_new(NULL))->next = l;
		if(l)
			l->prev = *pl;
		return;
	}

	if(dir < 0)
		--*y;

	/* list_seekp() to create if necessary,
	 * and make that creation available in *pl */
	l = *list_seekp(pl, *y, true);

	save = l->next;
	l->next = list_new(l);
	l->next->next = save;
	if(save)
		save->prev = l->next;

	++*y;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rdi, %r14
movl $0x0, (%rsi)
movl (%rdx), %esi
testl %ecx, %ecx
jns 0x9e91
testl %esi, %esi
je 0x9ed0
decl %esi
movl %esi, (%rbx)
movq %r14, %rdi
movl $0x1, %edx
callq 0x9cb6
movq (%rax), %r14
movq 0x18(%r14), %r15
movl $0x30, %edi
callq 0x5830
movq %r14, 0x20(%rax)
movq %rax, 0x18(%r14)
movq %r15, 0x18(%rax)
testq %r15, %r15
je 0x9ec8
movq 0x18(%r14), %rax
movq %rax, 0x20(%r15)
incl (%rbx)
popq %rbx
popq %r14
popq %r15
retq
movq (%r14), %rbx
movl $0x30, %edi
callq 0x5830
movq $0x0, 0x20(%rax)
movq %rax, (%r14)
movq %rbx, 0x18(%rax)
testq %rbx, %rbx
je 0x9eca
movq (%r14), %rax
movq %rax, 0x20(%rbx)
jmp 0x9eca
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_inschar
void list_inschar(
		list_t *l, int *x, int *y,
		char ch, char gapchar)
{
	l = list_seek(l, *y, true);

	if((unsigned)*x >= l->len_malloc){
		const int old_len = l->len_malloc;

		l->len_malloc = *x + 1;
		l->line = urealloc(l->line, l->len_malloc);

		memset(l->line + old_len, 0, l->len_malloc - old_len);
	}else{
		/* shift stuff up */
		l->line = urealloc(l->line, ++l->len_malloc);
		memmove(l->line + *x + 1, l->line + *x, l->len_malloc - *x - 1);
	}

	if(!gapchar){
		/* autogap */
		for(int i = 0; i < *x && (unsigned)i < l->len_line; i++){
			if(!isspace(l->line[i])){
				gapchar = ' ';
				break;
			}
		}

		if(!gapchar){
			/* all space, go with a tab */
			gapchar = '\t';
		}
	}

	for(int i = l->len_line; i < *x; i++){
		l->line[i] = gapchar;
		l->len_line++;
	}

	l->line[*x] = ch;
	l->len_line++;
	if(list_evalnewlines1(l)){
		*x = 0;
		++*y;
	}else{
		++*x;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %r15d
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r14
movl (%rdx), %esi
leaq 0x10(%rsp), %rax
movq %rdi, (%rax)
movq %rax, %rdi
movl $0x1, %edx
callq 0x9cb6
testq %rax, %rax
je 0x9f34
movq (%rax), %r12
jmp 0x9f37
xorl %r12d, %r12d
movl (%r14), %eax
movq 0x10(%r12), %r13
cmpq %rax, %r13
jbe 0x9f79
movq (%r12), %rdi
incq %r13
movq %r13, 0x10(%r12)
movq %r13, %rsi
callq 0x584a
movq %rax, (%r12)
movslq (%r14), %rdx
leaq (%rax,%rdx), %rdi
incq %rdi
leaq (%rax,%rdx), %rsi
notq %rdx
addq 0x10(%r12), %rdx
callq 0x4400
jmp 0x9fa7
movslq %eax, %rsi
incq %rsi
movq %rsi, 0x10(%r12)
movq (%r12), %rdi
callq 0x584a
movq %rax, (%r12)
movslq %r13d, %rcx
leaq (%rax,%rcx), %rdi
movq 0x10(%r12), %rdx
subq %rcx, %rdx
xorl %esi, %esi
callq 0x4240
movl (%r14), %r13d
testb %r15b, %r15b
jne 0x9ffa
movb $0x9, %r15b
testl %r13d, %r13d
jle 0x9ffa
movl %ebp, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
movq 0x8(%r12), %rbp
xorl %ebx, %ebx
cmpq %rbx, %rbp
je 0x9ff1
callq 0x4540
movq (%rax), %rax
movq (%r12), %rcx
movsbq (%rcx,%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x9fee
incq %rbx
cmpq %rbx, %r13
jne 0x9fc7
jmp 0x9ff1
movb $0x20, %r15b
movq 0x8(%rsp), %rbx
movl 0x4(%rsp), %ebp
movq 0x8(%r12), %rax
cmpl %eax, %r13d
jle 0xa020
cltq
movq (%r12), %rcx
movb %r15b, (%rcx,%rax)
incq 0x8(%r12)
incq %rax
movslq (%r14), %rcx
cmpq %rcx, %rax
jl 0xa006
jmp 0xa023
movslq %r13d, %rcx
movq (%r12), %rax
movb %bpl, (%rax,%rcx)
incq 0x8(%r12)
movq %r12, %rdi
callq 0x9d52
testl %eax, %eax
je 0xa045
movl $0x0, (%r14)
jmp 0xa048
movq %r14, %rbx
incl (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/list.c
// Function: list_delchar
void list_delchar(list_t *l, int *x, int *y)
{
	l = list_seek(l, *y, false);

	--*x;

	if(!l)
		return;

	if((unsigned)*x >= l->len_line)
		return;

	memmove(l->line + *x, l->line + *x + 1, --l->len_line - *x);
}

// Assembly:
testq %rdi, %rdi
je 0xa0a8
movl (%rdx), %eax
testl %eax, %eax
jle 0xa076
incl %eax
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0xa0a8
decl %eax
cmpl $0x1, %eax
jg 0xa066
movslq (%rsi), %rcx
decq %rcx
movl %ecx, (%rsi)
movl %ecx, %eax
movq 0x8(%rdi), %rdx
cmpq %rax, %rdx
jbe 0xa0aa
movq (%rdi), %rax
leaq (%rax,%rcx), %rsi
incq %rsi
addq %rcx, %rax
decq %rdx
movq %rdx, 0x8(%rdi)
subq %rcx, %rdx
movq %rax, %rdi
jmp 0x4400
decl (%rsi)
retq