// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rbp
movq 0x8(%rdi), %r13
leaq 0x10(%rsp), %rdi
callq 0x7b28
testl %eax, %eax
jne 0x3971
movq 0x38(%rbp), %rdi
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq 0x10(%rbx), %rax
cvtsi2sd %rax, %xmm1
subq 0x18(%rbx), %rcx
cvtsi2sd %rcx, %xmm0
movl 0x20(%rbx), %esi
mulsd 0x8968(%rip), %xmm0     # 0xc2c8
addsd %xmm1, %xmm0
callq 0x3cbd
testl %eax, %eax
je 0x3a4a
movq 0xe8b8(%rip), %rax      # 0x12230
movq 0xe8b9(%rip), %r14      # 0x12238
cmpq %r14, %rax
jae 0x399f
movq 0xe8b5(%rip), %rcx      # 0x12240
leaq 0x1(%rax), %rdx
movq %rdx, 0xe89a(%rip)      # 0x12230
movq %rbx, (%rcx,%rax,8)
jmp 0x3a34
movq 0xe8a2(%rip), %rax      # 0x12248
shrq $0x8, %rax
cmpq %rax, 0xe89f(%rip)      # 0x12250
jbe 0x3a20
testq %r14, %r14
je 0x3b68
movq %r14, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x3a20
movq %rax, %r15
movq 0xe869(%rip), %r12      # 0x12240
shlq $0x3, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2270
cmpq 0xe870(%rip), %r12      # 0x12260
je 0x39fa
movq %r12, %rdi
callq 0x2040
movq %r15, 0xe83f(%rip)      # 0x12240
shlq 0xe830(%rip)            # 0x12238
movq 0xe821(%rip), %rax      # 0x12230
leaq 0x1(%rax), %rcx
movq %rcx, 0xe816(%rip)      # 0x12230
movq %rbx, (%r15,%rax,8)
jmp 0x3a28
movq %rbx, %rdi
callq 0x2040
xorpd %xmm0, %xmm0
movupd %xmm0, 0xe814(%rip)     # 0x12248
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq 0x30(%rbp)
movq 0xe7db(%rip), %rax      # 0x12230
movq 0xe7dc(%rip), %r12      # 0x12238
cmpq %r12, %rax
jae 0x3a7c
movq 0xe7d8(%rip), %rcx      # 0x12240
leaq 0x1(%rax), %rdx
movq %rdx, 0xe7bd(%rip)      # 0x12230
movq %rbx, (%rcx,%rax,8)
jmp 0x3b1a
movq 0xe7c5(%rip), %rax      # 0x12248
shrq $0x8, %rax
cmpq %rax, 0xe7c2(%rip)      # 0x12250
jbe 0x3b06
testq %r12, %r12
je 0x3b68
movq %r12, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x3b06
movq 0xe78f(%rip), %rsi      # 0x12240
movq %rsi, (%rsp)
shlq $0x3, %r12
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r12, %rdx
callq 0x2270
movq (%rsp), %rdi
cmpq 0xe78c(%rip), %rdi      # 0x12260
je 0x3adb
callq 0x2040
movq 0x8(%rsp), %rdx
movq %rdx, 0xe759(%rip)      # 0x12240
shlq 0xe74a(%rip)            # 0x12238
movq 0xe73b(%rip), %rax      # 0x12230
leaq 0x1(%rax), %rcx
movq %rcx, 0xe730(%rip)      # 0x12230
movq %rbx, (%rdx,%rax,8)
jmp 0x3b0e
movq %rbx, %rdi
callq 0x2040
xorpd %xmm0, %xmm0
movupd %xmm0, 0xe72e(%rip)     # 0x12248
testq %r15, %r15
je 0x3b47
leaq 0x20(%rsp), %rsi
movq %r13, (%rsi)
movq %r15, 0x10(%rsi)
movq %r14, 0x8(%rsi)
movq 0x10(%rbp), %rdi
callq 0xac96
testl %eax, %eax
jne 0x3a34
xorl %ebx, %ebx
jmp 0x3a39
movq 0x20(%rbp), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x3a39
callq 0xa125
movq $0x0, 0x20(%rbp)
jmp 0x3a39
leaq 0x888e(%rip), %rdi      # 0xc3fd
leaq 0x8898(%rip), %rsi      # 0xc40e
leaq 0x88b3(%rip), %rcx      # 0xc430
movl $0x5a, %edx
callq 0x21b0