// File: /workspace/github_c_makefile_star2_O0/rouming[P]io/io.c
// Function: _write
static int __write(int fd, struct io_req *req)
{
	struct io_buf *buf = &req->buf;
	struct iovec *iov = buf_it_iov(buf, &buf->pos);
	struct iovec iov_stack[ARRAY_SIZE(buf->iov)];
	int iovcnt = buf->iov_num - buf->pos.iov_ind;
	struct iovec_iter end = END_IT(buf);

	if (iov->iov_base == NULL)
		return -EINVAL;
	if (!buf->pos.iov_off && !SIMULATE_1_BYTE_RDWR) {
		return SAFE_CALL(writev(fd, iov, iovcnt));
	} else {
		iov_stack[0] = (struct iovec){
			.iov_base = buf_it_iovbase(buf, &buf->pos),
			.iov_len  = buf_it_iovlen(buf, &buf->pos, &end)
		};
		if (SIMULATE_1_BYTE_RDWR) {
			iov_stack[0].iov_len = 1;
			iovcnt = 1;
		}
		if (iovcnt > 1)
			memcpy(iov_stack + 1, iov + 1,
			       sizeof(iov_stack[0]) * (iovcnt - 1));

		return SAFE_CALL(writev(fd, iov_stack, iovcnt));
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x100, %rsi            # imm = 0x100
callq 0x4dd0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x120(%rax), %rax
movq -0x18(%rbp), %rcx
subq 0x100(%rcx), %rax
movl %eax, -0x124(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3810
testb $0x1, %al
jne 0x5871
jmp 0x5890
movq -0x18(%rbp), %rax
movq 0x120(%rax), %rax
movq %rax, -0x138(%rbp)
movq $0x0, -0x130(%rbp)
jmp 0x58cb
movq -0x18(%rbp), %rax
movq 0x120(%rax), %rax
subq $0x1, %rax
movq %rax, -0x138(%rbp)
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x120(%rcx), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x58e1
movl $0xffffffea, -0x4(%rbp) # imm = 0xFFFFFFEA
jmp 0x5a6d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x108(%rax)
jne 0x596a
jmp 0x58f1
movl -0x8(%rbp), %edi
movq -0x20(%rbp), %rsi
movl -0x124(%rbp), %edx
callq 0x1060
movl %eax, -0x13c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x13c(%rbp)
movb %al, -0x159(%rbp)
jge 0x592b
callq 0x1050
cmpl $0x4, (%rax)
sete %al
movb %al, -0x159(%rbp)
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x58f1
cmpl $0x0, -0x13c(%rbp)
jge 0x5950
callq 0x1050
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
movl %eax, -0x140(%rbp)
movl -0x140(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5a6d
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x100, %rsi            # imm = 0x100
callq 0x4e50
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x100, %rsi            # imm = 0x100
leaq -0x138(%rbp), %rdx
callq 0x4ca0
movq %rax, -0x148(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpl $0x1, -0x124(%rbp)
jle 0x59f4
leaq -0x120(%rbp), %rdi
addq $0x10, %rdi
movq -0x20(%rbp), %rsi
addq $0x10, %rsi
movl -0x124(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x1170
jmp 0x59f6
movl -0x8(%rbp), %edi
leaq -0x120(%rbp), %rsi
movl -0x124(%rbp), %edx
callq 0x1060
movl %eax, -0x154(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x154(%rbp)
movb %al, -0x15a(%rbp)
jge 0x5a33
callq 0x1050
cmpl $0x4, (%rax)
sete %al
movb %al, -0x15a(%rbp)
movb -0x15a(%rbp), %al
testb $0x1, %al
jne 0x59f6
cmpl $0x0, -0x154(%rbp)
jge 0x5a58
callq 0x1050
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x154(%rbp)
movl -0x154(%rbp), %eax
movl %eax, -0x158(%rbp)
movl -0x158(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax)