// File: /workspace/github_c_makefile_star2_O1/rouming[P]io/io.c
// Function: complete_req
static int complete_req(struct io_req *req, int len)
{
	struct io_queue *q = req->q;

	bool keep_in_queue = false;
	int off, dir;

	dir = req->flags & REQ_RDWR_MASK;
	io_req_get(req);
	list_del_init(&req->list);
	off = req->io_fn(req, len);
	if (dir == REQ_RD) {
		/* Read path */
		if (off == 0) {
			/* Return to the request queue, continue filling in */
			list_add(&req->list, &q->queue);
			keep_in_queue = true;
		} else {
			if (off > 0 && off != len) {
				/* Stash the rest or everything. */
				off = stash_rest(req, off, len);
			}
		}
	}
	io_req_put(req);
	if (!keep_in_queue) {
		assert(q->reqs_num[dir] > 0);
		q->reqs_num[dir]--;
	}

	return off;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x24(%rdi), %eax
testl %eax, %eax
jle 0x4162
movl %esi, %r15d
movq %rdi, %rbx
movq 0x10(%rdi), %r12
movl 0x20(%rdi), %r13d
andl $0x1, %r13d
incl %eax
movl %eax, 0x24(%rdi)
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq %rcx, 0x8(%rax)
movq %rax, (%rcx)
movq %rdi, (%rdi)
movq %rdi, 0x8(%rdi)
callq *0x178(%rdi)
movl %eax, %ebp
testl %r13d, %r13d
je 0x4075
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x3df6
testb %r14b, %r14b
jne 0x4064
movl 0x148(%r12,%r13,4), %eax
testl %eax, %eax
jle 0x4181
decl %eax
movl %eax, 0x148(%r12,%r13,4)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
je 0x412b
setle %al
cmpl %r15d, %ebp
sete %cl
xorl %r14d, %r14d
orb %al, %cl
jne 0x403d
movq 0x10(%rbx), %rax
cmpl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmovnel %ebp, %r14d
cmpq $0x0, 0x160(%rax)
jne 0x41a0
movq %rax, %rbp
cmpq $0x0, 0x168(%rax)
jne 0x41bf
movslq %r15d, %r15
subq %r14, %r15
movq 0x158(%rbp), %rdi
testq %rdi, %rdi
je 0x40d6
callq 0x1120
cmpq %r15, %rax
jae 0x40fc
leaq 0xfff(%r15), %rsi
andq $-0x1000, %rsi          # imm = 0xF000
movq 0x158(%rbp), %rdi
callq 0x11b0
testq %rax, %rax
je 0x4158
movq %rax, 0x158(%rbp)
leaq 0x28(%rbx), %rdi
movq 0x158(%rbp), %rdx
movq %r14, %rsi
movq %r15, %rcx
callq 0x2af4
cltq
cmpq %rax, %r15
jne 0x41de
movq %r15, 0x160(%rbp)
xorl %ebp, %ebp
jmp 0x403a
leaq 0x138(%r12), %rax
movq 0x138(%r12), %rcx
movq %rbx, 0x8(%rcx)
movq %rcx, (%rbx)
movq %rax, 0x8(%rbx)
movq %rbx, 0x138(%r12)
movb $0x1, %r14b
xorl %ebp, %ebp
jmp 0x403d
movl $0xfffffff4, %ebp       # imm = 0xFFFFFFF4
jmp 0x403a
leaq 0x1408(%rip), %rdi      # 0x5571
leaq 0x1322(%rip), %rsi      # 0x5492
leaq 0x1408(%rip), %rcx      # 0x557f
movl $0x3eb, %edx            # imm = 0x3EB
callq 0x10d0
leaq 0x14e8(%rip), %rdi      # 0x5670
leaq 0x1303(%rip), %rsi      # 0x5492
leaq 0x14ef(%rip), %rcx      # 0x5685
movl $0x227, %edx            # imm = 0x227
callq 0x10d0
leaq 0x1505(%rip), %rdi      # 0x56ac
leaq 0x12e4(%rip), %rsi      # 0x5492
leaq 0x1508(%rip), %rcx      # 0x56bd
movl $0x171, %edx            # imm = 0x171
callq 0x10d0
leaq 0x1527(%rip), %rdi      # 0x56ed
leaq 0x12c5(%rip), %rsi      # 0x5492
leaq 0x14e9(%rip), %rcx      # 0x56bd
movl $0x172, %edx            # imm = 0x172
callq 0x10d0
leaq 0x151a(%rip), %rdi      # 0x56ff
leaq 0x12a6(%rip), %rsi      # 0x5492
leaq 0x14ca(%rip), %rcx      # 0x56bd
movl $0x17b, %edx            # imm = 0x17B
callq 0x10d0