// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/cqueues.c
// Function: event_add
static cqs_status_t event_add(lua_State *L, struct cqueue *Q, struct callinfo *I, struct thread *T, int index) {
	struct event *event;
	struct fileno *fileno;
	int error, status;

	if (!(event = pool_get(&Q->pool.event, &error)))
		goto error;

	event_init(event, T, index);

	if (LUA_OK != (status = object_getinfo(L, Q, I, T, index, event)))
		return status;

	if (event->fd >= 0 && event->events) {
		if (!(fileno = fileno_get(Q, event->fd, &error)))
			goto error;

		LIST_INSERT_HEAD(&fileno->events, event, fle);
		event->fileno = fileno;

		LIST_REMOVE(fileno, le);
		LIST_INSERT_HEAD(&Q->fileno.outstanding, fileno, le);
	}

	return LUA_OK;
error:
	err_setinfo(L, I, error, T, index, "unable to add event: %s", cqs_strerror(error));

	return LUA_ERRRUN;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
addq $0x1c0, %rdi            # imm = 0x1C0
addq $0x30, %rdi
leaq -0x44(%rbp), %rsi
callq 0x156c0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x14656
jmp 0x147c5
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x15770
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
movq -0x38(%rbp), %r9
callq 0x15820
movl %eax, %ecx
movl %ecx, -0x48(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x14699
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x14866
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
jl 0x147b9
movq -0x38(%rbp), %rax
movswl 0x4(%rax), %eax
cmpl $0x0, %eax
je 0x147b9
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movl (%rax), %esi
leaq -0x44(%rbp), %rdx
callq 0x15c30
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x146d9
jmp 0x147c5
jmp 0x146db
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq %rax, 0x38(%rcx)
cmpq $0x0, %rax
je 0x14705
movq -0x38(%rbp), %rcx
addq $0x38, %rcx
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
addq $0x8, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1474c
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x40(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, (%rax)
jmp 0x14761
movq -0x18(%rbp), %rax
movq 0x1b0(%rax), %rax
movq -0x40(%rbp), %rcx
movq %rax, 0x30(%rcx)
cmpq $0x0, %rax
je 0x14791
movq -0x40(%rbp), %rcx
addq $0x30, %rcx
movq -0x18(%rbp), %rax
movq 0x1b0(%rax), %rax
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x1b0(%rax)
movq -0x18(%rbp), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
addq $0x10, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0x147b9
movl $0x0, -0x4(%rbp)
jmp 0x14866
movq -0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0xdc(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0xf4(%rbp)
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0xf7d0
movl -0xf4(%rbp), %edi
leaq -0xc8(%rbp), %rsi
movl $0x80, %edx
callq 0xf270
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movl -0xdc(%rbp), %edx
movq -0xd8(%rbp), %rcx
movl -0xcc(%rbp), %r8d
leaq 0x33afb(%rip), %r9      # 0x4834f
movq %rax, (%rsp)
movb $0x0, %al
callq 0x14cc0
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)