// File: /workspace/github_c_makefile_star2_O0/rouming[P]io/zmtp-test.c
// Function: on_read
static int on_read(struct io_req *req, int len)
{
	struct peer *peer = req->data;
	bool more;
	int err;

	if (len < 0) {
		io_req_put(req);
		list_add_tail(&peer->list, &peer->ctx->peers_to_free);

		return len;
	}

	more = req->flags & REQ_MORE;
	printf("Got: len=%d, more=%d, '%.*s'\n",
	       len, more, len, (char *)req->buf.iov[0].iov_base);
	io_req_put(req);

	if (more) {
		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 len;
	}

	peer->sent = 1;
	req = io_req_create(&peer->q, REQ_WR | REQ_MORE, peer, on_write);
	assert(req);
	req->buf = (struct io_buf){
		.iov[0] = {
			.iov_base = (char *)replies[0],
			.iov_len  = strlen(replies[0])
		},
		.iov_num  = 1,
	};
	err = io_queue_submit(req);
	assert(err == 0);

	return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x1d03
movq -0x10(%rbp), %rdi
callq 0x4bb0
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x1c0(%rax), %rsi
addq $0x270, %rsi            # imm = 0x270
callq 0x1f20
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f0c
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x21(%rbp)
movl -0x14(%rbp), %esi
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %r8
leaq 0x54c5(%rip), %rdi      # 0x71fa
movb $0x0, %al
callq 0x10c0
movq -0x10(%rbp), %rdi
callq 0x4bb0
testb $0x1, -0x21(%rbp)
je 0x1e19
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rdx
xorl %esi, %esi
leaq -0xb4(%rip), %rcx       # 0x1cb0
callq 0x4b00
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1d76
jmp 0x1d95
leaq 0x54f7(%rip), %rdi      # 0x7274
leaq 0x5365(%rip), %rsi      # 0x70e9
movl $0x94, %edx
leaq 0x5488(%rip), %rcx      # 0x7218
callq 0x10d0
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2c0(%rbp)
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
movl $0x148, %edx            # imm = 0x148
callq 0x10e0
movq -0x2c0(%rbp), %rdi
movq $0x1, -0x50(%rbp)
movb $0x1, -0x48(%rbp)
leaq -0x170(%rbp), %rsi
movl $0x148, %edx            # imm = 0x148
callq 0x1170
movq -0x10(%rbp), %rdi
callq 0x4640
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x1def
jmp 0x1e0e
leaq 0x5318(%rip), %rdi      # 0x710e
leaq 0x52ec(%rip), %rsi      # 0x70e9
movl $0x9a, %edx
leaq 0x540f(%rip), %rcx      # 0x7218
callq 0x10d0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f0c
movq -0x20(%rbp), %rax
movl $0x1, 0x14(%rax)
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rdx
movl $0x3, %esi
leaq 0x114(%rip), %rcx       # 0x1f50
callq 0x4b00
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1e4e
jmp 0x1e6d
leaq 0x541f(%rip), %rdi      # 0x7274
leaq 0x528d(%rip), %rsi      # 0x70e9
movl $0xa1, %edx
leaq 0x53b0(%rip), %rcx      # 0x7218
callq 0x10d0
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2c8(%rbp)
leaq -0x2b8(%rbp), %rdi
xorl %esi, %esi
movl $0x148, %edx            # imm = 0x148
callq 0x10e0
movq 0x928a(%rip), %rax      # 0xb120
movq %rax, -0x2b8(%rbp)
movq 0x927c(%rip), %rdi      # 0xb120
callq 0x1090
movq -0x2c8(%rbp), %rdi
movq %rax, -0x2b0(%rbp)
movq $0x1, -0x198(%rbp)
leaq -0x2b8(%rbp), %rsi
movl $0x148, %edx            # imm = 0x148
callq 0x1170
movq -0x10(%rbp), %rdi
callq 0x4640
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x1ee7
jmp 0x1f06
leaq 0x5220(%rip), %rdi      # 0x710e
leaq 0x51f4(%rip), %rsi      # 0x70e9
movl $0xaa, %edx
leaq 0x5317(%rip), %rcx      # 0x7218
callq 0x10d0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
nopl (%rax,%rax)