// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x1, 0x148(%rax)
jb 0x2b2b
jmp 0x2b4a
leaq 0x479e(%rip), %rdi      # 0x72d0
leaq 0x473f(%rip), %rsi      # 0x7278
movl $0x113, %edx            # imm = 0x113
leaq 0x47a1(%rip), %rcx      # 0x72e6
callq 0x10d0
movq -0x10(%rbp), %rax
cmpq $0x3, 0x148(%rax)
ja 0x2b5a
jmp 0x2b79
leaq 0x47c7(%rip), %rdi      # 0x7328
leaq 0x4710(%rip), %rsi      # 0x7278
movl $0x114, %edx            # imm = 0x114
leaq 0x4772(%rip), %rcx      # 0x72e6
callq 0x10d0
movq -0x10(%rbp), %rax
cmpq $0x1, 0x30(%rax)
jne 0x2b86
jmp 0x2ba5
leaq 0x47b1(%rip), %rdi      # 0x733e
leaq 0x46e4(%rip), %rsi      # 0x7278
movl $0x116, %edx            # imm = 0x116
leaq 0x4746(%rip), %rcx      # 0x72e6
callq 0x10d0
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movb (%rax), %al
movb %al, -0x25(%rbp)
movzbl -0x25(%rbp), %eax
andl $-0x8, %eax
cmpl $0x0, %eax
je 0x2bca
movl $0xffffffa6, -0x24(%rbp) # imm = 0xFFFFFFA6
jmp 0x2d98
movq -0x10(%rbp), %rax
cmpq $0x1, 0x148(%rax)
jne 0x2c5c
movzbl -0x25(%rbp), %edi
callq 0x2dd0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x2bf3
jmp 0x2d98
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x128(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x130(%rax)
movslq -0x24(%rbp), %rcx
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq -0x10(%rbp), %rdx
movq 0x148(%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x148(%rax)
movl $0x0, -0x24(%rbp)
jmp 0x2d96
movq -0x10(%rbp), %rax
cmpq $0x1, 0x40(%rax)
jne 0x2c78
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movzbl (%rax), %eax
movq %rax, -0x30(%rbp)
jmp 0x2cc2
movq -0x10(%rbp), %rax
cmpq $0x8, 0x40(%rax)
jne 0x2ca1
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2810
movq %rax, -0x30(%rbp)
jmp 0x2cc0
leaq 0x49e1(%rip), %rdi      # 0x7689
leaq 0x45c9(%rip), %rsi      # 0x7278
movl $0x134, %edx            # imm = 0x134
leaq 0x462b(%rip), %rcx      # 0x72e6
callq 0x10d0
jmp 0x2cc2
cmpq $0x7fffffff, -0x30(%rbp) # imm = 0x7FFFFFFF
jbe 0x2cd8
movl $0xffffffa6, -0x24(%rbp) # imm = 0xFFFFFFA6
jmp 0x2d98
movq -0x30(%rbp), %rax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x2cf7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2a70
jmp 0x2d94
testb $0x1, -0x11(%rbp)
je 0x2d6f
movq -0x10(%rbp), %rax
cmpq $0x2, 0x148(%rax)
jne 0x2d6f
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x128(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x130(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq -0x10(%rbp), %rdx
movq 0x148(%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x148(%rax)
movl $0x0, -0x24(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2d92
movzbl -0x25(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %cl
xorb $-0x1, %cl
xorb $-0x1, %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
jmp 0x2d94
jmp 0x2d96
jmp 0x2d98
movl -0x24(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)