// File: /workspace/github_c_makefile_star2_O0/rouming[P]io/zmtp.c
// Function: zmtp_init_wr_hdr_req
static void zmtp_init_wr_hdr_req(struct zmtp *zmtp, struct io_req *hdr_req,
				 struct io_req *wr_req)
{
	int len = buf_len(&wr_req->buf);
	struct iovec *iov;
	uint8_t *hdr_flags;
	uint64_t *hdr_len;
	int hdr_len_sz;

	if (!zmtp->delim_sent) {
		zmtp->delim_sent = true;
		/* Firstly set empty delimiter */
		hdr_req->buf.iov[0].iov_base = ZMTP_DELIM;
		hdr_req->buf.iov[0].iov_len  = sizeof(ZMTP_DELIM);
		hdr_req->buf.iov_num = 1;
	}
	if (!(wr_req->flags & REQ_MORE))
		zmtp->delim_sent = false;

	BUILD_BUG_ON(sizeof(hdr_req->buf.__proto.stash) <
		     sizeof(*hdr_flags) + sizeof(*hdr_len));

	/* Set size */
	hdr_len = (typeof(hdr_len))hdr_req->buf.__proto.stash;
	if (len > 255) {
		*hdr_len = htobe64((uint64_t)len);
		hdr_len_sz = 8;
	} else {
		*hdr_len = (uint8_t)len;
		hdr_len_sz = 1;
	}

	/* Set flags */
	hdr_flags = (typeof(hdr_flags))hdr_len + 1;
	*hdr_flags  = wr_req->flags & REQ_MORE ? ZMTP_F_MORE : 0;
	*hdr_flags |= len > 255 ? ZMTP_F_LONG : 0;

	/* Apply pointers to iov */
	iov = &hdr_req->buf.iov[hdr_req->buf.iov_num];
	iov->iov_base = hdr_flags;
	iov->iov_len  = 1;
	iov += 1;
	iov->iov_base = hdr_len;
	iov->iov_len  = hdr_len_sz;
	hdr_req->buf.iov_num += 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
callq 0x3940
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x2c(%rax)
jne 0x26e0
movq -0x8(%rbp), %rax
movb $0x1, 0x2c(%rax)
movq -0x10(%rbp), %rax
leaq 0x8a99(%rip), %rcx      # 0xb15a
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq $0x2, 0x30(%rax)
movq -0x10(%rbp), %rax
movq $0x1, 0x148(%rax)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x26f7
movq -0x8(%rbp), %rax
movb $0x0, 0x2c(%rax)
movq -0x10(%rbp), %rax
addq $0x28, %rax
addq $0x130, %rax            # imm = 0x130
addq $0x8, %rax
movq %rax, -0x38(%rbp)
cmpl $0xff, -0x1c(%rbp)
jle 0x2732
movslq -0x1c(%rbp), %rdi
callq 0x2810
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movl $0x8, -0x3c(%rbp)
jmp 0x2748
movl -0x1c(%rbp), %eax
movzbl %al, %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x3c(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %edx
andl $0x2, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movl -0x1c(%rbp), %ecx
xorl %edx, %edx
movl $0x2, %eax
cmpl $0xff, %ecx
cmovgl %eax, %edx
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
orl %edx, %ecx
movb %cl, (%rax)
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq -0x10(%rbp), %rcx
movq 0x148(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq $0x1, 0x8(%rax)
movq -0x28(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movslq -0x3c(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x148(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)