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

	io_req_put(req);
	if (len < 0)
		list_add_tail(&peer->list, &peer->ctx->peers_to_free);
	else if (peer->sent == ARRAY_SIZE(replies)) {
		/* Queue is ready for new requests */
		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);
	} else {
		int flags = REQ_WR;
		int err;

		peer->sent++;

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

		printf(" #%d chunk is sent\n", peer->sent);
		/*
		  sleep(1);
		*/
	}

	return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4bb0
cmpl $0x0, -0xc(%rbp)
jge 0x1f9d
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x1c0(%rax), %rsi
addq $0x270, %rsi            # imm = 0x270
callq 0x1f20
jmp 0x21ce
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rax
cmpq $0x6, %rax
jne 0x2073
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movq -0x18(%rbp), %rdx
xorl %esi, %esi
leaq -0x314(%rip), %rcx      # 0x1cb0
callq 0x4b00
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1fd6
jmp 0x1ff5
leaq 0x5297(%rip), %rdi      # 0x7274
leaq 0x5105(%rip), %rsi      # 0x70e9
movl $0x5d, %edx
leaq 0x524a(%rip), %rcx      # 0x723a
callq 0x10d0
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2c0(%rbp)
leaq -0x168(%rbp), %rdi
xorl %esi, %esi
movl $0x148, %edx            # imm = 0x148
callq 0x10e0
movq -0x2c0(%rbp), %rdi
movq $0x1, -0x48(%rbp)
movb $0x1, -0x40(%rbp)
leaq -0x168(%rbp), %rsi
movl $0x148, %edx            # imm = 0x148
callq 0x1170
movq -0x8(%rbp), %rdi
callq 0x4640
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x204f
jmp 0x206e
leaq 0x50b8(%rip), %rdi      # 0x710e
leaq 0x508c(%rip), %rsi      # 0x70e9
movl $0x63, %edx
leaq 0x51d1(%rip), %rcx      # 0x723a
callq 0x10d0
jmp 0x21cc
movl $0x1, -0x16c(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rdx
movl $0x2, %eax
xorl %ecx, %ecx
cmpq $0x6, %rdx
cmovel %ecx, %eax
orl -0x16c(%rbp), %eax
movl %eax, -0x16c(%rbp)
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movl -0x16c(%rbp), %esi
movq -0x18(%rbp), %rdx
leaq -0x175(%rip), %rcx      # 0x1f50
callq 0x4b00
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x20d7
jmp 0x20f6
leaq 0x5196(%rip), %rdi      # 0x7274
leaq 0x5004(%rip), %rsi      # 0x70e9
movl $0x6c, %edx
leaq 0x5149(%rip), %rcx      # 0x723a
callq 0x10d0
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2c8(%rbp)
leaq -0x2b8(%rbp), %rdi
xorl %esi, %esi
movl $0x148, %edx            # imm = 0x148
callq 0x10e0
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x8ff4(%rip), %rax      # 0xb120
movq (%rax,%rcx,8), %rax
movq %rax, -0x2b8(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x8fd5(%rip), %rax      # 0xb120
movq (%rax,%rcx,8), %rdi
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 -0x8(%rbp), %rdi
callq 0x4640
movl %eax, -0x170(%rbp)
cmpl $0x0, -0x170(%rbp)
jne 0x2198
jmp 0x21b7
leaq 0x4f6f(%rip), %rdi      # 0x710e
leaq 0x4f43(%rip), %rsi      # 0x70e9
movl $0x75, %edx
leaq 0x5088(%rip), %rcx      # 0x723a
callq 0x10d0
movq -0x18(%rbp), %rax
movl 0x14(%rax), %esi
leaq 0x5098(%rip), %rdi      # 0x725d
movb $0x0, %al
callq 0x10c0
jmp 0x21ce
movl -0xc(%rbp), %eax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
nopw (%rax,%rax)