// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/thread.c
// Function: ct_setfarg
static int ct_setfarg(lua_State *L, struct cthread *ct, struct cthread_arg *arg, int index) {
	lua_Debug info;
	lua_CFunction f;
	int error;

	lua_pushvalue(L, index);
	lua_getinfo(L, ">u", &info);

	if ((f = lua_tocfunction(L, index))) {
		if (info.nups > 0)
			goto uperr;

		if ((error = ct_addfunc(ct, f))) {
			if (error == -1)
				return luaL_argerror(L, index, dlerror());

			return error;
		}

		arg->v.pointer = EXTENSION (void *)f;
		arg->iscfunction = 1;
	} else {
		lua_State *T;
		luaL_Buffer B;

		/* _ENV is always first upvalue (if any) in Lua 5.2+ */
		if ((LUA_VERSION_NUM < 502 && info.nups > 0) || info.nups > 1)
			goto uperr;

		luaL_checkstack(L, 2, "too many arguments");

		/*
		 * NOTE: Must put luaL_Buffer on a different stack because
		 * luaL_Buffer has stack constraints that lua_dump is not
		 * guaranteed to meet--we don't know if and how lua_dump
		 * will keep intermediate objects on top of the stack.
		 */
		T = lua_newthread(L);
		luaL_buffinit(T, &B);
		lua_pushvalue(L, index);
		lua_dump(L, &dump_add, &B, 0);
		luaL_pushresult(&B);

		arg->v.string.iov_base = (char *)luaL_checklstring(T, -1, &arg->v.string.iov_len);
	}

	arg->type = LUA_TFUNCTION;

	return 0;
uperr:
	return luaL_argerror(L, index, "function has upvalues");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20f0, %rsp           # imm = 0x20F0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xfa50
movq -0x10(%rbp), %rdi
leaq 0x2487a(%rip), %rsi     # 0x491eb
leaq -0xa8(%rbp), %rdx
callq 0x10180
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x10ba0
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0x24a34
movzbl -0x74(%rbp), %eax
cmpl $0x0, %eax
jle 0x249a8
jmp 0x24ae6
movq -0x18(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x252a0
movl %eax, -0xb4(%rbp)
cmpl $0x0, %eax
je 0x24a10
cmpl $-0x1, -0xb4(%rbp)
jne 0x24a02
movq -0x10(%rbp), %rax
movq %rax, -0x20f0(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x20e4(%rbp)
callq 0xfd50
movq -0x20f0(%rbp), %rdi
movl -0x20e4(%rbp), %esi
movq %rax, %rdx
callq 0xf440
movl %eax, -0x4(%rbp)
jmp 0x24afc
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x24afc
movq -0xb0(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movb 0x4(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x4(%rax)
jmp 0x24ad3
movzbl -0x74(%rbp), %eax
cmpl $0x1, %eax
jle 0x24a42
jmp 0x24ae6
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x23781(%rip), %rdx     # 0x481d3
callq 0xfdb0
movq -0x10(%rbp), %rdi
callq 0x10c50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
leaq -0x20e0(%rbp), %rsi
callq 0x107e0
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xfa50
movq -0x10(%rbp), %rdi
leaq 0x91f(%rip), %rsi       # 0x253b0
leaq -0x20e0(%rbp), %rdx
xorl %ecx, %ecx
callq 0xf5d0
leaq -0x20e0(%rbp), %rdi
callq 0x108d0
movq -0xc0(%rbp), %rdi
movq -0x20(%rbp), %rdx
addq $0x8, %rdx
addq $0x8, %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xf6a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl $0x6, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x24afc
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq 0x246fa(%rip), %rdx     # 0x491ee
callq 0xf440
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20f0, %rsp           # imm = 0x20F0
popq %rbp
retq
nopl (%rax,%rax)