// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/perf/dispatch.c
// Function: callback_gotresponse
static int
callback_gotresponse(void * cookie, uint8_t * buf, size_t buflen)
{
	struct forwardee * F = cookie;
	struct dispatch_state * D = F->D;
	struct wire_packet P;
	struct timeval t_end;
	uint64_t ID = F->ID;

	/* Get the completion time and compute request duration. */
	if (monoclock_get(&t_end))
		goto err1;

	/* Record the request duration. */
	if (perfstats_add(D->P, F->reqtype, timeval_diff(F->t_start, t_end)))
		goto err1;

	/* This request is no longer in flight. */
	D->nrequests--;

	/* Free the cookie. */
	mpool_forwardee_free(F);

	/* Did the request fail? */
	if (buf == NULL)
		goto failed;

	/* Send the response back to the client. */
	P.ID = ID;
	P.buf = buf;
	P.len = buflen;
	if (wire_writepacket(D->writeq, &P))
		goto err0;

	/* Success! */
	return (0);

failed:
	/*
	 * Stop reading requests -- if the target failed we won't be able to do
	 * anything useful with them anyway!  Once in-flight requests have been
	 * failed, dispatch_alive will return zero.
	 */
	if (D->read_cookie != NULL) {
		wire_readpacket_wait_cancel(D->read_cookie);
		D->read_cookie = NULL;
	}

	/* The failed request has been successfully handled. */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rbp
movq 0x8(%rdi), %r13
leaq 0x20(%rsp), %rdi
callq 0x7bec
testl %eax, %eax
jne 0x3965
movq 0x38(%rbp), %rdi
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq 0x10(%rbx), %rax
cvtsi2sd %rax, %xmm1
subq 0x18(%rbx), %rcx
cvtsi2sd %rcx, %xmm0
movl 0x20(%rbx), %esi
mulsd 0x9914(%rip), %xmm0     # 0xd268
addsd %xmm1, %xmm0
callq 0x3cd5
testl %eax, %eax
je 0x3a4b
movq 0xf8c4(%rip), %r12      # 0x13230
movq 0xf8c5(%rip), %r13      # 0x13238
cmpq %r13, %r12
jae 0x3994
movq 0xf8c1(%rip), %rax      # 0x13240
leaq 0x1(%r12), %rcx
movq %rcx, 0xf8a5(%rip)      # 0x13230
movq %rbx, (%rax,%r12,8)
jmp 0x3a35
movq 0xf8ad(%rip), %rax      # 0x13248
shrq $0x8, %rax
cmpq %rax, 0xf8aa(%rip)      # 0x13250
jbe 0x3a21
testq %r13, %r13
je 0x3b84
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x3a21
movq %rax, %r14
movq 0xf874(%rip), %r15      # 0x13240
leaq (,%r13,8), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2270
cmpq 0xf87a(%rip), %r15      # 0x13260
je 0x39fe
movq %r15, %rdi
callq 0x2040
movq 0xf841(%rip), %r13      # 0x13238
movq 0xf832(%rip), %r12      # 0x13230
movq %r14, 0xf83b(%rip)      # 0x13240
addq %r13, %r13
movq %r13, 0xf829(%rip)      # 0x13238
leaq 0x1(%r12), %rax
movq %rax, 0xf815(%rip)      # 0x13230
movq %rbx, (%r14,%r12,8)
jmp 0x3a29
movq %rbx, %rdi
callq 0x2040
xorpd %xmm0, %xmm0
movupd %xmm0, 0xf813(%rip)     # 0x13248
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq 0x30(%rbp)
movq 0xf7da(%rip), %rdx      # 0x13230
movq 0xf7db(%rip), %r12      # 0x13238
cmpq %r12, %rdx
jae 0x3a7d
movq 0xf7d7(%rip), %rax      # 0x13240
leaq 0x1(%rdx), %rcx
movq %rcx, 0xf7bc(%rip)      # 0x13230
movq %rbx, (%rax,%rdx,8)
jmp 0x3b36
movq 0xf7c4(%rip), %rax      # 0x13248
shrq $0x8, %rax
cmpq %rax, 0xf7c1(%rip)      # 0x13250
jbe 0x3b22
movq %rdx, 0x18(%rsp)
testq %r12, %r12
je 0x3b84
movq %r12, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x3b22
movq 0xf785(%rip), %rsi      # 0x13240
movq %rsi, 0x8(%rsp)
leaq (,%r12,8), %rdx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x2270
movq 0x8(%rsp), %rdi
cmpq 0xf77f(%rip), %rdi      # 0x13260
movq 0x18(%rsp), %rcx
je 0x3afb
callq 0x2040
movq 0xf744(%rip), %r12      # 0x13238
movq 0xf735(%rip), %rcx      # 0x13230
movq 0x10(%rsp), %rdx
movq %rdx, 0xf739(%rip)      # 0x13240
addq %r12, %r12
movq %r12, 0xf727(%rip)      # 0x13238
leaq 0x1(%rcx), %rax
movq %rax, 0xf714(%rip)      # 0x13230
movq %rbx, (%rdx,%rcx,8)
jmp 0x3b2a
movq %rbx, %rdi
callq 0x2040
xorpd %xmm0, %xmm0
movupd %xmm0, 0xf712(%rip)     # 0x13248
testq %r15, %r15
je 0x3b63
leaq 0x30(%rsp), %rsi
movq %r13, (%rsi)
movq %r15, 0x10(%rsi)
movq %r14, 0x8(%rsi)
movq 0x10(%rbp), %rdi
callq 0xad36
testl %eax, %eax
jne 0x3a35
xorl %ebx, %ebx
jmp 0x3a3a
movq 0x20(%rbp), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x3a3a
callq 0xa17e
movq $0x0, 0x20(%rbp)
jmp 0x3a3a
leaq 0x9812(%rip), %rdi      # 0xd39d
leaq 0x981c(%rip), %rsi      # 0xd3ae
leaq 0x9837(%rip), %rcx      # 0xd3d0
movl $0x5a, %edx
callq 0x21b0