// File: /workspace/github_c_makefile_star2_O0/rouming[P]io/zmtp-test.c
// Function: on_sock_connection
static int on_sock_connection(void *poller, struct poller_item *item)
{
	int err, psock;
	struct sockaddr addr;
	socklen_t len = sizeof(addr);
	struct loop_ctx *ctx = item->data;
	struct io_req *req;
	struct peer *peer;

	psock = accept4(item->fd, &addr, &len, SOCK_CLOEXEC);
	if (psock < 0) {
		switch (errno) {
		case EWOULDBLOCK:
			break;
		default:
			err = -errno;
			assert(0);
			return err;
		}

		return 0;
	}

	peer = malloc(sizeof(*peer));
	assert(peer);
	peer->psock = psock;
	peer->ctx = ctx;
	INIT_LIST_HEAD(&peer->list);
	io_queue_init(&peer->q);
	err = io_queue_bind(&peer->q, ctx->poller, psock);
	assert(err == 0);
	err = zmtp_init(&peer->zmtp, &peer->q, ZMTP_REP);
	assert(err == 0);

	req = io_req_create(&peer->q, REQ_RD, peer, on_read);
	assert(req);
	req->buf = (struct io_buf){
		.iov_num  = 1,
		.is_vari_len = true,
	};
	err = io_queue_submit(req);
	assert(err == 0);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x10, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %edi
leaq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rsi
leaq -0x34(%rbp), %rdx
movl $0x80000, %ecx          # imm = 0x80000
callq 0x10a0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x1ae9
callq 0x1050
movl (%rax), %eax
subl $0xb, %eax
jne 0x1aaf
jmp 0x1aad
jmp 0x1add
callq 0x1050
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x1c(%rbp)
leaq 0x5bc4(%rip), %rdi      # 0x7689
leaq 0x561d(%rip), %rsi      # 0x70e9
movl $0xdf, %edx
leaq 0x56e8(%rip), %rcx      # 0x71c0
callq 0x10d0
movl $0x0, -0x4(%rbp)
jmp 0x1c9a
movl $0x1c8, %edi            # imm = 0x1C8
callq 0x1190
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x1b00
jmp 0x1b1f
leaq 0x56ee(%rip), %rdi      # 0x71f5
leaq 0x55db(%rip), %rsi      # 0x70e9
movl $0xe7, %edx
leaq 0x56a6(%rip), %rcx      # 0x71c0
callq 0x10d0
movl -0x20(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x1c0(%rax)
movq -0x50(%rbp), %rdi
callq 0x1950
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x20(%rbp), %edx
callq 0x42f0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1b71
jmp 0x1b90
leaq 0x5596(%rip), %rdi      # 0x710e
leaq 0x556a(%rip), %rsi      # 0x70e9
movl $0xed, %edx
leaq 0x5635(%rip), %rcx      # 0x71c0
callq 0x10d0
movq -0x50(%rbp), %rdi
addq $0x190, %rdi            # imm = 0x190
movq -0x50(%rbp), %rsi
addq $0x18, %rsi
xorl %edx, %edx
callq 0x22d0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1bb5
jmp 0x1bd4
leaq 0x5552(%rip), %rdi      # 0x710e
leaq 0x5526(%rip), %rsi      # 0x70e9
movl $0xef, %edx
leaq 0x55f1(%rip), %rcx      # 0x71c0
callq 0x10d0
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
movq -0x50(%rbp), %rdx
xorl %esi, %esi
leaq 0xc7(%rip), %rcx        # 0x1cb0
callq 0x4b00
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x1bfb
jmp 0x1c1a
leaq 0x5672(%rip), %rdi      # 0x7274
leaq 0x54e0(%rip), %rsi      # 0x70e9
movl $0xf2, %edx
leaq 0x55ab(%rip), %rcx      # 0x71c0
callq 0x10d0
movq -0x48(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
xorl %esi, %esi
movl $0x148, %edx            # imm = 0x148
callq 0x10e0
movq -0x1a8(%rbp), %rdi
movq $0x1, -0x80(%rbp)
movb $0x1, -0x78(%rbp)
leaq -0x1a0(%rbp), %rsi
movl $0x148, %edx            # imm = 0x148
callq 0x1170
movq -0x48(%rbp), %rdi
callq 0x4640
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1c74
jmp 0x1c93
leaq 0x5493(%rip), %rdi      # 0x710e
leaq 0x5467(%rip), %rsi      # 0x70e9
movl $0xf8, %edx
leaq 0x5532(%rip), %rcx      # 0x71c0
callq 0x10d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw %cs:(%rax,%rax)