// File: /workspace/github_cpp_makefile_star2_O2/roberty65[P]bServer/frame/testClient/testBenchmark.cpp
// Function: async_worker(void*)
static void *async_worker(void *p)
{
	int id = (int)(long)p;
	char tag[128]; snprintf(tag, sizeof tag, "thread-%d", id);

	size_t msize = sizeof(struct proto_h16_head) + pkgSize;
	char *reqbuf = new char[msize];
	char *rspbuf = new char[msize];

	memset(reqbuf, 0, msize);
	memset(rspbuf, 0, msize);

	int fd = -1;
	while (true) {	
 		if (fd < 0) {
			fd = beyondy::XbsClient(host, O_NONBLOCK, timeout);
			if (fd < 0) {
				fprintf(stdout, "%s connect failed: %m\n", tag);
				continue;	
			}
		}

		int events = beyondy::XbsWaitPollable(fd, POLLIN|POLLOUT, 10);
		if (events == -1) continue;

		if (events & POLLOUT) {
			if (__send_req(fd, cmd, reqbuf, pkgSize, tag) < 0) {
				fprintf(stdout, "%s send req failed: %m\n", tag);
				close(fd); fd = -1;
				continue;
			}

			++pkgSent[id];
			byteSent[id] += pkgSize;
		}

		if (events & POLLIN) {
			if (__read_rsp(fd, rspbuf, pkgSize, tag) < 0) {
				fprintf(stdout, "%s send req failed: %m\n", tag);
				close(fd); fd = -1;
				continue;
			}

			++pkgRspd[id];
			byteRspd[id] += pkgSize;
		}
	}

	return NULL;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r12
leaq 0x1861(%rip), %rdx      # 0x413e
leaq 0x10(%rsp), %rbx
movl $0x80, %esi
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2240
movslq 0x3875(%rip), %r15      # 0x6170
addq $0x10, %r15
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %r15, %rdi
callq 0x2030
movq %rax, %r13
movq %r14, 0x8(%rsp)
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2100
movq %r13, (%rsp)
movq %r13, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2100
movslq %r12d, %r14
pushq $-0x1
popq %r12
pushq $0x5
popq %rbp
pushq $0xa
popq %r13
testl %r12d, %r12d
jns 0x296c
movq 0x3826(%rip), %rdi      # 0x6178
movl $0x2710, %edx           # imm = 0x2710
movl $0x800, %esi            # imm = 0x800
callq 0x3353
movl %eax, %r12d
testl %eax, %eax
js 0x2a35
movl %r12d, %edi
movl %ebp, %esi
movq %r13, %rdx
callq 0x2b5e
cmpl $-0x1, %eax
je 0x2946
movl %eax, %r15d
testb $0x4, %r15b
je 0x29c4
movl 0x37db(%rip), %esi      # 0x6168
movl 0x37dd(%rip), %ecx      # 0x6170
movl %r12d, %edi
movq 0x8(%rsp), %rdx
movq %rbx, %r8
callq 0x2a55
testl %eax, %eax
js 0x2a09
movq 0x37da(%rip), %rax      # 0x6188
incq (%rax,%r14,8)
movslq 0x37b7(%rip), %rax      # 0x6170
movq 0x37d0(%rip), %rcx      # 0x6190
addq %rax, (%rcx,%r14,8)
testb $0x1, %r15b
je 0x2946
movl 0x379c(%rip), %edx      # 0x6170
movl %r12d, %edi
movq (%rsp), %rsi
movq %rbx, %rcx
callq 0x2aeb
testl %eax, %eax
js 0x2a09
movq 0x37aa(%rip), %rax      # 0x6198
incq (%rax,%r14,8)
movslq 0x3777(%rip), %rax      # 0x6170
movq 0x37a0(%rip), %rcx      # 0x61a0
addq %rax, (%rcx,%r14,8)
jmp 0x2946
movq 0x35a8(%rip), %rax      # 0x5fb8
movq (%rax), %rdi
leaq 0x1745(%rip), %rsi      # 0x415f
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2200
movl %r12d, %edi
callq 0x22a0
pushq $-0x1
popq %r12
jmp 0x2946
movq 0x357c(%rip), %rax      # 0x5fb8
movq (%rax), %rdi
leaq 0x1702(%rip), %rsi      # 0x4148
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2200
jmp 0x2946