// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0xc6e0
movq %rax, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x42f0
movl %eax, -0x1c(%rbp)
callq 0x40a0
movl $0x0, (%rax)
movq -0x8(%rbp), %rdi
callq 0x4380
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xcab9
movq -0x28(%rbp), %rdi
addq $0x13, %rdi
callq 0x4170
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpl $-0x1, -0x1c(%rbp)
movb %al, -0xdd(%rbp)
je 0xc9a2
movl -0x1c(%rbp), %edi
movq -0x28(%rbp), %rsi
addq $0x13, %rsi
leaq -0xc0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4520
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xdd(%rbp)
jne 0xc9a2
movl -0xa8(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
sete %al
movb %al, -0xdd(%rbp)
movb -0xdd(%rbp), %al
andb $0x1, %al
movb %al, -0xc1(%rbp)
testb $0x1, -0xc1(%rbp)
je 0xca00
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq $0x1, %rdi
callq 0x5f20
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x1, %rsi
movq -0x28(%rbp), %rcx
addq $0x13, %rcx
leaq 0x8ce4(%rip), %rdx      # 0x156db
movb $0x0, %al
callq 0x41e0
jmp 0xca18
movq -0x28(%rbp), %rdi
addq $0x13, %rdi
movq -0x30(%rbp), %rsi
callq 0x5fe0
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xca2f
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0xca76
cmpq $0x0, -0x18(%rbp)
je 0xca38
jmp 0xca57
leaq 0x8f9b(%rip), %rdi      # 0x159da
leaq 0x8c99(%rip), %rsi      # 0x156df
movl $0xcc, %edx
leaq 0x8c94(%rip), %rcx      # 0x156e6
callq 0x4210
movq -0x18(%rbp), %rdi
callq 0xc6e0
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0xd8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0xd0(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xc920
callq 0x40a0
cmpl $0x0, (%rax)
je 0xcafa
callq 0x40a0
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
movq -0x10(%rbp), %rdi
callq 0xcb10
movq $0x0, -0x10(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0xe4(%rbp)
callq 0x40a0
movl -0xe4(%rbp), %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)