// File: /workspace/github_c_makefile_star2_O0/cglindkamp[P]dfm/src/filedata.c
// Function: filedata_new_from_file
int filedata_new_from_file(struct filedata **filedata, int dirfd, const char *filename)
{
	struct stat stat;
	bool valid = true;

	if(fstatat(dirfd, filename, &stat, AT_SYMLINK_NOFOLLOW) != 0) {
		if(errno == ENOENT)
			return ENOENT;
		valid = false;
		memset(&stat, 0, sizeof(stat));
	}

	*filedata = malloc(sizeof(**filedata));
	if(*filedata == NULL)
		return ENOMEM;

	(*filedata)->filename = strdup(filename);
	if((*filedata)->filename == NULL) {
		free(*filedata);
		*filedata = NULL;
		return ENOMEM;
	}

	(*filedata)->is_marked = false;
	(*filedata)->is_stat_valid = valid;

	if(S_ISLNK(stat.st_mode)) {
		(*filedata)->is_link = true;
		(*filedata)->link_size = stat.st_size;
		if(fstatat(dirfd, (*filedata)->filename, &(*filedata)->stat, 0) != 0) {
			(*filedata)->is_link_broken = true;
			memcpy(&(*filedata)->stat, &stat, sizeof(stat));
		} else
			(*filedata)->is_link_broken = false;
	} else {
		(*filedata)->is_link = false;
		memcpy(&(*filedata)->stat, &stat, sizeof(stat));
	}

	/* st_size field is not used for directories, so zero it out to get
	 * better file size count statistics in dirmodel */
	if(S_ISDIR((*filedata)->stat.st_mode))
		(*filedata)->stat.st_size = 0;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movb $0x1, -0xb1(%rbp)
movl -0x14(%rbp), %edi
movq -0x20(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
movl $0x100, %ecx            # imm = 0x100
callq 0x3710
cmpl $0x0, %eax
je 0x9daa
callq 0x30d0
cmpl $0x2, (%rax)
jne 0x9d90
movl $0x2, -0x4(%rbp)
jmp 0x9f1a
movb $0x0, -0xb1(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x90, %edx
callq 0x32e0
movl $0xb0, %edi
callq 0x3490
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x9dd4
movl $0xc, -0x4(%rbp)
jmp 0x9f1a
movq -0x20(%rbp), %rdi
callq 0x36a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, (%rax)
jne 0x9e1a
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3740
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movl $0xc, -0x4(%rbp)
jmp 0x9f1a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movb $0x0, 0xa8(%rax)
movb -0xb1(%rbp), %cl
movq -0x10(%rbp), %rax
movq (%rax), %rax
andb $0x1, %cl
movb %cl, 0xa9(%rax)
movl -0x98(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xa000, %eax           # imm = 0xA000
jne 0x9ec7
movq -0x10(%rbp), %rax
movq (%rax), %rax
movb $0x1, 0x8(%rax)
movq -0x80(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0xa0(%rax)
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
addq $0x10, %rdx
xorl %ecx, %ecx
callq 0x3710
cmpl $0x0, %eax
je 0x9eba
movq -0x10(%rbp), %rax
movq (%rax), %rax
movb $0x1, 0x9(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x10, %rdi
leaq -0xb0(%rbp), %rsi
movl $0x90, %edx
callq 0x3450
jmp 0x9ec5
movq -0x10(%rbp), %rax
movq (%rax), %rax
movb $0x0, 0x9(%rax)
jmp 0x9eee
movq -0x10(%rbp), %rax
movq (%rax), %rax
movb $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x10, %rdi
leaq -0xb0(%rbp), %rsi
movl $0x90, %edx
callq 0x3450
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x28(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x9f13
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x40(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)