// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds/dispatch_mr.c
// Function: callback_synced
static int
callback_synced(void * cookie)
{
	struct batch * B = cookie;
	struct req_cookie * req;
	struct proto_kvlds_request * R;
	size_t i;

	/* Send response packets. */
	for (i = 0; i < B->nreqs; i++) {
		req = B->reqs[i];
		R = req->R;

		switch (R->type) {
		case PROTO_KVLDS_SET:
			if (proto_kvlds_response_set(B->WQ, R->ID))
				goto err0;
			break;
		case PROTO_KVLDS_CAS:
			if (proto_kvlds_response_cas(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		case PROTO_KVLDS_ADD:
			if (proto_kvlds_response_add(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		case PROTO_KVLDS_MODIFY:
			if (proto_kvlds_response_modify(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		case PROTO_KVLDS_DELETE:
			if (proto_kvlds_response_delete(B->WQ, R->ID))
				goto err0;
			break;
		case PROTO_KVLDS_CAD:
			if (proto_kvlds_response_cad(B->WQ, R->ID,
			    req->opdone ? 0 : 1))
				goto err0;
			break;
		}
	}

	/* Schedule completion callback. */
	if (!events_immediate_register(B->callback_done, B->cookie, 0))
		goto err0;

	/* Clean up requests and request cookies. */
	for (i = 0; i < B->nreqs; i++) {
		proto_kvlds_request_free(B->reqs[i]->R);
		mpool_reqcookie_free(B->reqs[i]);
	}

	/* Free batch cookie. */
	free(B->reqs);
	free(B);

	/* Success! */
	return (0);

err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x617c
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
addl $0xfffffef0, %eax       # imm = 0xFFFFFEF0
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x11, %eax
ja 0x6169
movq -0x38(%rbp), %rax
leaq 0x189f5(%rip), %rcx     # 0x1ea38
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
xorl %edx, %edx
callq 0x19960
cmpl $0x0, %eax
je 0x606c
jmp 0x620a
jmp 0x6169
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x18(%rax), %ecx
movl $0x1, %edx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0x19960
cmpl $0x0, %eax
je 0x60a3
jmp 0x620a
jmp 0x6169
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x18(%rax), %ecx
movl $0x1, %edx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0x19960
cmpl $0x0, %eax
je 0x60da
jmp 0x620a
jmp 0x6169
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x18(%rax), %ecx
movl $0x1, %edx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0x19960
cmpl $0x0, %eax
je 0x6111
jmp 0x620a
jmp 0x6169
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
xorl %edx, %edx
callq 0x19960
cmpl $0x0, %eax
je 0x6133
jmp 0x620a
jmp 0x6169
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x18(%rax), %ecx
movl $0x1, %edx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0x19960
cmpl $0x0, %eax
je 0x6167
jmp 0x620a
jmp 0x6169
jmp 0x616b
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x5fec
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edx, %edx
callq 0x111b0
cmpq $0x0, %rax
jne 0x619a
jmp 0x620a
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x61eb
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
callq 0x19810
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5710
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x61a2
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2040
movq -0x18(%rbp), %rdi
callq 0x2040
movl $0x0, -0x4(%rbp)
jmp 0x6211
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)