// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/mux/dispatch.c
// Function: callback_gotresponse
static int
callback_gotresponse(void * cookie, uint8_t * buf, size_t buflen)
{
	struct forwardee * F = cookie;
	struct sock_active * S = F->conn;
	struct sock_active * S_next;
	struct dispatch_state * dstate = S->dstate;
	struct wire_packet P;

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

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

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

	/* We've finished with a request. */
	if (reqdone(S))
		goto err0;

	/* Success! */
	return (0);

failed:
	/* Free our cookie. */
	mpool_forwardee_free(F);

	/* We've finished with a request. */
	if (reqdone(S))
		goto err0;

	/* Stop trying to accept connections. */
	accept_stop(dstate);

	/* The connection to the upstream server has failed. */
	dstate->failed = 1;

	/* Stop reading requests from connections. */
	for (S = dstate->sock_active; S != NULL; S = S_next) {
		S_next = S->next;
		if ((S->read_cookie != NULL) && readreq_cancel(S))
			goto err0;
	}

	/* 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 $0x28, %rsp
movq %rdi, %rbx
movq (%rdi), %r14
testq %rsi, %rsi
je 0x396a
movq 0x8(%rbx), %rcx
leaq 0x10(%rsp), %rax
movq %rcx, (%rax)
movq %rsi, 0x10(%rax)
movq %rdx, 0x8(%rax)
movq 0x28(%r14), %rdi
movq %rax, %rsi
callq 0x9aa2
movq 0xd8c1(%rip), %r13      # 0x11200
movq 0xd8c2(%rip), %rbp      # 0x11208
testl %eax, %eax
je 0x399f
cmpq %rbp, %r13
jae 0x39c3
movq 0xd8ba(%rip), %rax      # 0x11210
leaq 0x1(%r13), %rcx
movq %rcx, 0xd89f(%rip)      # 0x11200
movq %rbx, (%rax,%r13,8)
jmp 0x3c25
movq (%r14), %r15
movq 0xd88c(%rip), %rbp      # 0x11200
movq 0xd88d(%rip), %r13      # 0x11208
cmpq %r13, %rbp
jae 0x3a5a
movq 0xd885(%rip), %rax      # 0x11210
leaq 0x1(%rbp), %rcx
movq %rcx, 0xd86a(%rip)      # 0x11200
movq %rbx, (%rax,%rbp,8)
jmp 0x3b17
cmpq %rbp, %r13
jae 0x3b7b
movq 0xd861(%rip), %rax      # 0x11210
leaq 0x1(%r13), %rcx
movq %rcx, 0xd846(%rip)      # 0x11200
movq %rbx, (%rax,%r13,8)
jmp 0x3c19
movq 0xd84e(%rip), %rax      # 0x11218
shrq $0x8, %rax
cmpq %rax, 0xd84b(%rip)      # 0x11220
jbe 0x3aee
testq %rbp, %rbp
je 0x3c3f
movq %rbp, %rdi
shlq $0x4, %rdi
callq 0x2270
testq %rax, %rax
je 0x3aee
movq %rax, %r14
movq 0xd80d(%rip), %r15      # 0x11210
leaq (,%rbp,8), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2250
cmpq 0xd813(%rip), %r15      # 0x11230
je 0x3a35
movq %r15, %rdi
callq 0x2040
movq 0xd7da(%rip), %rbp      # 0x11208
movq 0xd7cb(%rip), %r13      # 0x11200
movq %r14, 0xd7d4(%rip)      # 0x11210
addq %rbp, %rbp
movq %rbp, 0xd7c2(%rip)      # 0x11208
leaq 0x1(%r13), %rax
movq %rax, 0xd7af(%rip)      # 0x11200
movq %rbx, (%r14,%r13,8)
jmp 0x3af6
movq 0xd7b7(%rip), %rax      # 0x11218
shrq $0x8, %rax
cmpq %rax, 0xd7b4(%rip)      # 0x11220
jbe 0x3b05
testq %r13, %r13
je 0x3c3f
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x2270
testq %rax, %rax
je 0x3b05
movq %rax, %r12
movq 0xd77a(%rip), %rsi      # 0x11210
movq %rsi, 0x8(%rsp)
leaq (,%r13,8), %rdx
movq %rax, %rdi
callq 0x2250
movq 0x8(%rsp), %rdi
cmpq 0xd779(%rip), %rdi      # 0x11230
je 0x3acc
callq 0x2040
movq 0xd743(%rip), %r13      # 0x11208
movq 0xd734(%rip), %rbp      # 0x11200
movq %r12, 0xd73d(%rip)      # 0x11210
addq %r13, %r13
movq %r13, 0xd72b(%rip)      # 0x11208
leaq 0x1(%rbp), %rax
movq %rax, 0xd718(%rip)      # 0x11200
movq %rbx, (%r12,%rbp,8)
jmp 0x3b0d
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xd718(%rip)     # 0x11218
jmp 0x3c25
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xd701(%rip)     # 0x11218
movq %r14, %rdi
callq 0x3e14
testl %eax, %eax
jne 0x3c25
movq %r15, %rdi
callq 0x36da
movl $0x1, 0x30(%r15)
movq 0x10(%r15), %r15
xorl %ebx, %ebx
testq %r15, %r15
je 0x3c2a
movq %r15, %r14
movq 0x8(%r15), %r15
movq 0x30(%r14), %rdi
testq %rdi, %rdi
je 0x3b3d
callq 0x8eea
movq $0x0, 0x30(%r14)
cmpq $0x0, 0x38(%r14)
jne 0x3b3d
movq %r14, %rdi
callq 0x3c5e
testl %eax, %eax
je 0x3b3d
jmp 0x3c25
movq 0xd696(%rip), %rax      # 0x11218
shrq $0x8, %rax
cmpq %rax, 0xd693(%rip)      # 0x11220
jbe 0x3c07
testq %rbp, %rbp
je 0x3c3f
movq %rbp, %rdi
shlq $0x4, %rdi
callq 0x2270
testq %rax, %rax
je 0x3c07
movq %rax, %r15
movq 0xd65d(%rip), %r12      # 0x11210
leaq (,%rbp,8), %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2250
cmpq 0xd663(%rip), %r12      # 0x11230
je 0x3be5
movq %r12, %rdi
callq 0x2040
movq 0xd62a(%rip), %rbp      # 0x11208
movq 0xd61b(%rip), %r13      # 0x11200
movq %r15, 0xd624(%rip)      # 0x11210
addq %rbp, %rbp
movq %rbp, 0xd612(%rip)      # 0x11208
leaq 0x1(%r13), %rax
movq %rax, 0xd5ff(%rip)      # 0x11200
movq %rbx, (%r15,%r13,8)
jmp 0x3c0f
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xd5ff(%rip)     # 0x11218
movq %r14, %rdi
callq 0x3e14
testl %eax, %eax
je 0x3c3b
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x3c2a
leaq 0x777c(%rip), %rdi      # 0xb3c2
leaq 0x7786(%rip), %rsi      # 0xb3d3
leaq 0x77a1(%rip), %rcx      # 0xb3f5
movl $0x5a, %edx
callq 0x21a0