// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/vfs.c
// Function: vfs_file_open
static int vfs_file_open(const char *name, struct fs_file *file, bool create)
{
	struct vfs_walk_data wd;
	int rc;

	vfs_walk_start(&wd, name);
	rc = vfs_walk_parent(&wd);
	if (rc) {
		vfs_walk_stop(&wd);
		return rc;
	}

	struct fs_node *dir = wd.entry->node;
	struct fs_entry *entry;

	if (!dir->ops || !dir->ops->lookup) {
		vfs_walk_stop(&wd);
		return -ENOTSUP;
	}
	
	mutex_lock(&dir->mux);
	entry = vfs_lookup(wd.entry, wd.next, create, &rc);
	if (create && entry && !entry->node) {
		if (!dir->ops->create)
			rc = -ENOTSUP;
		else
			rc = dir->ops->create(dir, entry);
	}
	mutex_unlock(&dir->mux);
	vfs_walk_stop(&wd);

	if (rc)
		return rc;

	file->entry = entry;
	file->node = entry->node;
	file->ops = entry->node->fops;
	file->offset = 0;

	if (file->ops && file->ops->open) {
		rc = file->ops->open(file);
		if (rc)
			vfs_file_cleanup(file);
	}

	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0xffffffff8010a1a0
leaq -0x130(%rbp), %rdi
callq 0xffffffff8010a200
movl %eax, -0x134(%rbp)
cmpl $0x0, -0x134(%rbp)
je 0xffffffff801098ff
leaq -0x130(%rbp), %rdi
callq 0xffffffff8010a260
movl -0x134(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xffffffff80109aa2
movq -0x130(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xffffffff80109931
movq -0x140(%rbp), %rax
movq 0x20(%rax), %rax
cmpq $0x0, 0x28(%rax)
jne 0xffffffff80109949
leaq -0x130(%rbp), %rdi
callq 0xffffffff8010a260
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0xffffffff80109aa2
movq -0x140(%rbp), %rdi
callq 0xffffffff8010dff0
movq -0x130(%rbp), %rdi
leaq -0x130(%rbp), %rsi
addq $0x8, %rsi
movb -0x19(%rbp), %al
leaq -0x134(%rbp), %rcx
andb $0x1, %al
movzbl %al, %edx
callq 0xffffffff8010a290
movq %rax, -0x148(%rbp)
testb $0x1, -0x19(%rbp)
je 0xffffffff801099e3
cmpq $0x0, -0x148(%rbp)
je 0xffffffff801099e3
movq -0x148(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0xffffffff801099e3
movq -0x140(%rbp), %rax
movq 0x20(%rax), %rax
cmpq $0x0, (%rax)
jne 0xffffffff801099bd
movl $0xfffffffd, -0x134(%rbp) # imm = 0xFFFFFFFD
jmp 0xffffffff801099e1
movq -0x140(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq -0x140(%rbp), %rdi
movq -0x148(%rbp), %rsi
callq *%rax
movl %eax, -0x134(%rbp)
jmp 0xffffffff801099e3
movq -0x140(%rbp), %rdi
callq 0xffffffff8010e140
leaq -0x130(%rbp), %rdi
callq 0xffffffff8010a260
cmpl $0x0, -0x134(%rbp)
je 0xffffffff80109a12
movl -0x134(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xffffffff80109aa2
movq -0x148(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x148(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x148(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xffffffff80109a99
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, (%rax)
je 0xffffffff80109a99
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movl %eax, -0x134(%rbp)
cmpl $0x0, -0x134(%rbp)
je 0xffffffff80109a97
movq -0x18(%rbp), %rdi
callq 0xffffffff80109b50
jmp 0xffffffff80109a99
movl -0x134(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nop