// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/notify.c
// Function: notify_add
int notify_add(struct notify *nfy, const char *name, int flags) {
	size_t namelen = strlen(name);
	struct file *file;
	int error;

	if (namelen > NAME_MAX)
		return ENAMETOOLONG;
	if (memchr(name, '/', namelen))
		return EISDIR;

	if ((file = lookup(nfy, name, namelen)))
		return 0;

#if ENABLE_FEN
	size_t pathlen = nfy->dirlen + 1 + namelen;

	if (!(file = calloc(1, offsetof(struct file, path) + pathlen + 1)))
		return errno;

	memcpy(file->path, nfy->dirpath, nfy->dirlen);
	file->path[nfy->dirlen] = '/';
	file->pathlen = pathlen;
	file->name = &file->path[nfy->dirlen + 1];

	fenfo_init(&file->fo, file->path);
#else
	if (!(file = calloc(1, offsetof(struct file, name) + namelen + 1)))
		return errno;
#endif

	file->fd = -1;
	file->flags = flags;
	memcpy(file->name, name, namelen);
	file->namelen = namelen;

	LIST_INSERT_HEAD(&nfy->dormant, file, le);
	LIST_INSERT_HEAD(&nfy->defunct, file, sle);
	LLRB_INSERT(files, &nfy->files, file);

#if ENABLE_KQUEUE
	if ((error = kq_readd(nfy, file)))
		goto error;

	NFY_LIST_MOVE(&nfy->dormant, file, le);
	nfy->changes = 0;
#elif ENABLE_FEN
	if ((error = fen_readd(nfy, file)))
		goto error;

	NFY_LIST_MOVE(&nfy->dormant, file, le);
	nfy->changes = 0;
#endif

	return 0;
error:
	discard(nfy, file);

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf5c0
movq %rax, -0x28(%rbp)
cmpq $0xff, -0x28(%rbp)
jbe 0x46026
movl $0x24, -0x4(%rbp)
jmp 0x4617b
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x2f, %esi
callq 0xffa0
cmpq $0x0, %rax
je 0x4604a
movl $0x15, -0x4(%rbp)
jmp 0x4617b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x46190
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x46071
movl $0x0, -0x4(%rbp)
jmp 0x4617b
movq -0x28(%rbp), %rsi
addq $0x60, %rsi
addq $0x1, %rsi
movl $0x1, %edi
callq 0xf930
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x460a0
callq 0xf0a0
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x4617b
movq -0x30(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl -0x1c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rdi
addq $0x60, %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xfb40
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
je 0x460ff
movq -0x30(%rbp), %rcx
addq $0x18, %rcx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x4611d
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movq %rax, 0x28(%rcx)
cmpq $0x0, %rax
je 0x46147
movq -0x30(%rbp), %rcx
addq $0x28, %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rcx
addq $0x28, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movq -0x30(%rbp), %rsi
callq 0x46220
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)