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

	/* optimize simple timeout */
	if (lua_isnumber(T->L, index)) {
		event->timeout = abstimeout(lua_tonumber(T->L, index));

		return LUA_OK;
	}

	/*
	 * push onto our local stack so we don't dirty the thread stack and
	 * also to allow fast upvalue comparisons
	 */
	lua_pushvalue(T->L, index);
	lua_xmove(T->L, L, 1);

	if (cqs_testudata(L, -1, 2)) {
		event->fd = cqs_socket_pollfd(L, -1);
		event->events = cqs_socket_events(L, -1);
		event->timeout = abstimeout(cqs_socket_timeout(L, -1));
	} else if (cqs_testudata(L, -1, 3)) {
		if ((LUA_OK != (status = object_getcv(L, Q, I, T, -1, event))))
			goto oops;
	} else {
		if (LUA_OK != (status = object_pcall(L, I, T, -1, "pollfd", LUA_TNUMBER, LUA_TUSERDATA, LUA_TNIL)))
			goto oops;

		if (lua_isuserdata(L, -1) && cqs_testudata(L, -1, 3)) {
			if ((LUA_OK != (status = object_getcv(L, Q, I, T, -1, event))))
				goto oops;
		} else {
			event->fd = luaL_optinteger(L, -1, -1);
			event->fd = MAX(event->fd, -1);
		}

		lua_pop(L, 1); /* pop fd or condvar */

		if (LUA_OK != (status = object_pcall(L, I, T, -1, "events", LUA_TNUMBER, LUA_TSTRING, LUA_TNIL)))
			goto oops;

		if (lua_isnumber(L, -1)) {
			event->events = (POLLIN|POLLOUT|POLLPRI) & lua_tointeger(L, -1);
		} else {
			const char *mode = luaL_optstring(L, -1, "");

			event->events = 0;

			while (*mode) {
				if (*mode == 'r')
					event->events |= POLLIN;
				else if (*mode == 'w')
					event->events |= POLLOUT;
				else if (*mode == 'p')
					event->events |= POLLPRI;
				mode++;
			}
		}

		lua_pop(L, 1); /* pop event mode */

		if (LUA_OK != (status = object_pcall(L, I, T, -1, "timeout", LUA_TNUMBER, LUA_TNIL)))
			goto oops;

		event->timeout = abstimeout(luaL_optnumber(L, -1, event->timeout));

		lua_pop(L, 1); /* pop timeout */
	}

	lua_pop(L, 1); /* pop object */

	return LUA_OK;
oops:
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl -0x2c(%rbp), %esi
callq 0xfc70
cmpl $0x0, %eax
je 0x15884
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl -0x2c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x10910
callq 0x15e10
movq -0x38(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x15c1c
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl -0x2c(%rbp), %esi
callq 0xfa50
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x10380
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x2, %edx
callq 0x11980
cmpq $0x0, %rax
je 0x15911
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xf9d0
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x10bd0
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x104e0
callq 0x15e10
movq -0x38(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x15bff
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x3, %edx
callq 0x11980
cmpq $0x0, %rax
je 0x1595e
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %r9
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x15e80
movl %eax, %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x15959
jmp 0x15c16
jmp 0x15bfd
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x3, -0x48(%rbp)
movl $0x7, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
leaq -0x48(%rbp), %r9
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x32814(%rip), %r8      # 0x481a3
movl $0x3, (%rsp)
callq 0x15ff0
movl %eax, %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x159ab
jmp 0x15c16
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x10840
cmpl $0x0, %eax
je 0x15a08
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x3, %edx
callq 0x11980
cmpq $0x0, %rax
je 0x15a08
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %r9
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x15e80
movl %eax, %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x15a06
jmp 0x15c16
jmp 0x15a4c
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq $-0x1, %rdx
callq 0xf450
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
cmpl $-0x1, (%rax)
jle 0x15a39
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x15a43
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x6c(%rbp)
jmp 0x15a43
movl -0x6c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x3, -0x54(%rbp)
movl $0x4, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
leaq -0x54(%rbp), %r9
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x3271f(%rip), %r8      # 0x481aa
movl $0x3, (%rsp)
callq 0x15ff0
movl %eax, %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x15aa7
jmp 0x15c16
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xfc70
cmpl $0x0, %eax
je 0x15ae0
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0xfe30
andq $0x7, %rax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x4(%rax)
jmp 0x15b79
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x37a7b(%rip), %rdx     # 0x4d56b
xorl %eax, %eax
movl %eax, %ecx
callq 0xf940
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movw $0x0, 0x4(%rax)
movq -0x60(%rbp), %rax
cmpb $0x0, (%rax)
je 0x15b77
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
jne 0x15b2d
movq -0x38(%rbp), %rax
movswl 0x4(%rax), %ecx
orl $0x1, %ecx
movw %cx, 0x4(%rax)
jmp 0x15b69
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
jne 0x15b4a
movq -0x38(%rbp), %rax
movswl 0x4(%rax), %ecx
orl $0x4, %ecx
movw %cx, 0x4(%rax)
jmp 0x15b67
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x70, %eax
jne 0x15b65
movq -0x38(%rbp), %rax
movswl 0x4(%rax), %ecx
orl $0x2, %ecx
movw %cx, 0x4(%rax)
jmp 0x15b67
jmp 0x15b69
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x15b07
jmp 0x15b79
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x3, -0x68(%rbp)
movl $0x0, -0x64(%rbp)
leaq -0x68(%rbp), %r9
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x32c2f(%rip), %r8      # 0x487e0
movl $0x2, (%rsp)
callq 0x15ff0
movl %eax, %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x15bca
jmp 0x15c16
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movsd 0x8(%rax), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xf800
callq 0x15e10
movq -0x38(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
jmp 0x15bff
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movl $0x0, -0x4(%rbp)
jmp 0x15c1c
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)