// File: /workspace/github_c_makefile_star2_O3/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 %rsi, %rbx
movq 0x148(%rsi), %rsi
testq %rsi, %rsi
je 0x2224
cmpq $0x4, %rsi
jae 0x2243
cmpq $0x1, 0x30(%rbx)
jne 0x2262
movq %rdi, %r14
leaq 0x28(%rbx), %rdi
movq (%rdi), %rax
movb (%rax), %al
movl $0xffffffa6, %ebp       # imm = 0xFFFFFFA6
cmpb $0x7, %al
ja 0x2217
cmpq $0x1, %rsi
jne 0x2156
testb $0x2, %al
movl $0x1, %eax
movq %rax, 0x128(%rbx)
movl $0x8, %ecx
cmoveq %rax, %rcx
movq $0x0, 0x130(%rbx)
movq %rcx, 0x40(%rbx)
movq $0x2, 0x148(%rbx)
xorl %ebp, %ebp
jmp 0x2217
leaq 0x38(%rbx), %r15
movq 0x40(%rbx), %r8
cmpq $0x8, %r8
je 0x2177
cmpq $0x1, %r8
jne 0x2281
movq (%r15), %r8
movzbl (%r8), %r8d
jmp 0x218d
movq (%r15), %r8
movq (%r8), %r8
bswapq %r8
cmpq $0x7fffffff, %r8        # imm = 0x7FFFFFFF
ja 0x2217
testq %r8, %r8
je 0x21d7
cmpq $0x2, %rsi
setne %sil
xorb $0x1, %dl
orb %sil, %dl
movl %r8d, %ebp
jne 0x21cc
movq $0x2, 0x128(%rbx)
movq $0x0, 0x130(%rbx)
movq %r8, 0x50(%rbx)
movq $0x3, 0x148(%rbx)
xorl %ebp, %ebp
testq %rcx, %rcx
je 0x2217
andb $0x1, %al
movb %al, (%rcx)
jmp 0x2217
callq 0x297b
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 0x30a1(%rip), %rdi      # 0x52cc
leaq 0x3042(%rip), %rsi      # 0x5274
leaq 0x30a9(%rip), %rcx      # 0x52e2
movl $0x113, %edx            # imm = 0x113
callq 0x10d0
leaq 0x30da(%rip), %rdi      # 0x5324
leaq 0x3023(%rip), %rsi      # 0x5274
leaq 0x308a(%rip), %rcx      # 0x52e2
movl $0x114, %edx            # imm = 0x114
callq 0x10d0
leaq 0x30d1(%rip), %rdi      # 0x533a
leaq 0x3004(%rip), %rsi      # 0x5274
leaq 0x306b(%rip), %rcx      # 0x52e2
movl $0x116, %edx            # imm = 0x116
callq 0x10d0
leaq 0x33a3(%rip), %rdi      # 0x562b
leaq 0x2fe5(%rip), %rsi      # 0x5274
leaq 0x304c(%rip), %rcx      # 0x52e2
movl $0x134, %edx            # imm = 0x134
callq 0x10d0