// File: /workspace/github_c_makefile_star2_O1/rouming[P]io/zmtp.c
// Function: zmtp_expect_msg
static int zmtp_expect_msg(struct zmtp *zmtp, struct io_req *req,
			   bool need_payload, bool *more)
{
	int len;
	uint8_t flags;
	uint64_t size;

	assert(req->buf.iov_num >= 1);
	assert(req->buf.iov_num <= 3);

	assert(req->buf.iov[0].iov_len == 1);
	flags = *(uint8_t *)req->buf.iov[0].iov_base;
	if (flags & ~ZMTP_F_MASK) {
		/* TODO: probably respond with ERROR? */
		len = -EMSGSIZE;
		goto out;
	}
	if (req->buf.iov_num == 1) {
		/* Flag is received, size is required */

		len = zmtp_flags_to_size_len(flags);
		if (len < 0)
			goto out;
		/* Advance position by ourselves */
		req->buf.pos.iov_ind = req->buf.iov_num;
		req->buf.pos.iov_off = 0;
		/* Set length of a next buffer to receive */
		req->buf.iov[req->buf.iov_num].iov_len = len;
		req->buf.iov_num += 1;
		len = 0;
	} else {
		/* Flag+size are received */

		/* Short or long size? */
		if (req->buf.iov[1].iov_len == 1)
			size = *(uint8_t *)req->buf.iov[1].iov_base;
		else if (req->buf.iov[1].iov_len == 8) {
			size = *(uint64_t *)req->buf.iov[1].iov_base;
			size = be64toh(size);
		} else
			assert(0);
		if (size > INT_MAX) {
			/* That is insane */
			len = -EMSGSIZE;
			goto out;
		} else
			len = (int)size;
		if (len == 0) {
			/* Delimiter is received. Rewind a buffer and repeat. */
			zmtp_init_rd_hdr_req(zmtp, req);
		} else {
			if (need_payload && req->buf.iov_num == 2) {
				/* Advance position by ourselves */
				req->buf.pos.iov_ind = req->buf.iov_num;
				req->buf.pos.iov_off = 0;
				/* Set size for a payload */
				req->buf.iov[req->buf.iov_num].iov_len = size;
				req->buf.iov_num += 1;
				len = 0;
			}
			if (more)
				*more = !!(flags & ZMTP_F_MORE);
		}
	}

out:
	return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x148(%rsi), %rax
testq %rax, %rax
je 0x22c0
cmpq $0x4, %rax
jae 0x22df
movq %rsi, %rbx
cmpq $0x1, 0x30(%rsi)
jne 0x22fe
movq %rdi, %r14
leaq 0x28(%rbx), %rdi
movq (%rdi), %rsi
movb (%rsi), %sil
movl $0xffffffa6, %ebp       # imm = 0xFFFFFFA6
cmpb $0x7, %sil
ja 0x22b3
cmpq $0x1, %rax
jne 0x21ea
testb $0x2, %sil
movq %rax, 0x128(%rbx)
movq $0x0, 0x130(%rbx)
movl $0x1, %ecx
movl $0x8, %edx
cmoveq %rcx, %rdx
movq %rax, %rcx
shlq $0x4, %rcx
movq %rdx, 0x8(%rdi,%rcx)
incq %rax
movq %rax, 0x148(%rbx)
xorl %ebp, %ebp
jmp 0x22b3
leaq 0x38(%rbx), %r15
movq 0x40(%rbx), %r8
cmpq $0x8, %r8
je 0x220b
cmpq $0x1, %r8
jne 0x231d
movq (%r15), %r8
movzbl (%r8), %r8d
jmp 0x2214
movq (%r15), %r8
movq (%r8), %r8
bswapq %r8
cmpq $0x7fffffff, %r8        # imm = 0x7FFFFFFF
ja 0x22b3
testq %r8, %r8
je 0x2273
cmpq $0x2, %rax
setne %r9b
xorb $0x1, %dl
orb %r9b, %dl
movl %r8d, %ebp
jne 0x2265
movq $0x2, 0x128(%rbx)
movq $0x0, 0x130(%rbx)
shlq $0x4, %rax
movq %r8, 0x8(%rdi,%rax)
movq $0x3, 0x148(%rbx)
xorl %ebp, %ebp
testq %rcx, %rcx
je 0x22b3
andb $0x1, %sil
movb %sil, (%rcx)
jmp 0x22b3
callq 0x29c7
addq $0x18, %r14
movq %r14, 0x28(%rbx)
movl $0x1, %r14d
movq %r14, 0x30(%rbx)
xorl %ebp, %ebp
movl $0x110, %edx            # imm = 0x110
movq %r15, %rdi
xorl %esi, %esi
callq 0x10e0
movq %r14, 0x148(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x150(%rbx)
movups %xmm0, 0x160(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3025(%rip), %rdi      # 0x52ec
leaq 0x2fc6(%rip), %rsi      # 0x5294
leaq 0x302d(%rip), %rcx      # 0x5302
movl $0x113, %edx            # imm = 0x113
callq 0x10d0
leaq 0x305e(%rip), %rdi      # 0x5344
leaq 0x2fa7(%rip), %rsi      # 0x5294
leaq 0x300e(%rip), %rcx      # 0x5302
movl $0x114, %edx            # imm = 0x114
callq 0x10d0
leaq 0x3055(%rip), %rdi      # 0x535a
leaq 0x2f88(%rip), %rsi      # 0x5294
leaq 0x2fef(%rip), %rcx      # 0x5302
movl $0x116, %edx            # imm = 0x116
callq 0x10d0
leaq 0x3327(%rip), %rdi      # 0x564b
leaq 0x2f69(%rip), %rsi      # 0x5294
leaq 0x2fd0(%rip), %rcx      # 0x5302
movl $0x134, %edx            # imm = 0x134
callq 0x10d0