// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq %rdi, %rbx
movq (%rdi), %r14
testq %rsi, %rsi
je 0x3958
movq 0x8(%rbx), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
movq %rsi, 0x10(%rax)
movq %rdx, 0x8(%rax)
movq 0x28(%r14), %rdi
movq %rax, %rsi
callq 0x999e
movq 0xd8d3(%rip), %rcx      # 0x11200
movq 0xd8d4(%rip), %r15      # 0x11208
testl %eax, %eax
je 0x398d
cmpq %r15, %rcx
jae 0x39b1
movq 0xd8cc(%rip), %rax      # 0x11210
leaq 0x1(%rcx), %rdx
movq %rdx, 0xd8b1(%rip)      # 0x11200
movq %rbx, (%rax,%rcx,8)
jmp 0x3bef
movq (%r14), %r15
movq 0xd89e(%rip), %rax      # 0x11200
movq 0xd89f(%rip), %r12      # 0x11208
cmpq %r12, %rax
jae 0x3a3d
movq 0xd897(%rip), %rcx      # 0x11210
leaq 0x1(%rax), %rdx
movq %rdx, 0xd87c(%rip)      # 0x11200
movq %rbx, (%rcx,%rax,8)
jmp 0x3aec
cmpq %r15, %rcx
jae 0x3b50
movq 0xd873(%rip), %rax      # 0x11210
leaq 0x1(%rcx), %rdx
movq %rdx, 0xd858(%rip)      # 0x11200
movq %rbx, (%rax,%rcx,8)
jmp 0x3be3
movq 0xd860(%rip), %rax      # 0x11218
shrq $0x8, %rax
cmpq %rax, 0xd85d(%rip)      # 0x11220
jbe 0x3ac3
testq %r15, %r15
je 0x3c09
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x2270
testq %rax, %rax
je 0x3ac3
movq %rax, %r14
movq 0xd81f(%rip), %r12      # 0x11210
shlq $0x3, %r15
movq %rax, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2250
cmpq 0xd826(%rip), %r12      # 0x11230
je 0x3a14
movq %r12, %rdi
callq 0x2040
movq %r14, 0xd7f5(%rip)      # 0x11210
shlq 0xd7e6(%rip)            # 0x11208
movq 0xd7d7(%rip), %rax      # 0x11200
leaq 0x1(%rax), %rcx
movq %rcx, 0xd7cc(%rip)      # 0x11200
movq %rbx, (%r14,%rax,8)
jmp 0x3acb
movq 0xd7d4(%rip), %rax      # 0x11218
shrq $0x8, %rax
cmpq %rax, 0xd7d1(%rip)      # 0x11220
jbe 0x3ada
testq %r12, %r12
je 0x3c09
movq %r12, %rdi
shlq $0x4, %rdi
callq 0x2270
testq %rax, %rax
je 0x3ada
movq %rax, %r13
movq 0xd797(%rip), %rbp      # 0x11210
shlq $0x3, %r12
movq %rax, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x2250
cmpq 0xd79e(%rip), %rbp      # 0x11230
je 0x3a9c
movq %rbp, %rdi
callq 0x2040
movq %r13, 0xd76d(%rip)      # 0x11210
shlq 0xd75e(%rip)            # 0x11208
movq 0xd74f(%rip), %rax      # 0x11200
leaq 0x1(%rax), %rcx
movq %rcx, 0xd744(%rip)      # 0x11200
movq %rbx, (%r13,%rax,8)
jmp 0x3ae2
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xd743(%rip)     # 0x11218
jmp 0x3bef
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xd72c(%rip)     # 0x11218
movq %r14, %rdi
callq 0x3de2
testl %eax, %eax
jne 0x3bef
movq %r15, %rdi
callq 0x36cf
movl $0x1, 0x30(%r15)
movq 0x10(%r15), %r15
xorl %ebx, %ebx
testq %r15, %r15
je 0x3bf4
movq %r15, %r14
movq 0x8(%r15), %r15
movq 0x30(%r14), %rdi
testq %rdi, %rdi
je 0x3b12
callq 0x8e2d
movq $0x0, 0x30(%r14)
cmpq $0x0, 0x38(%r14)
jne 0x3b12
movq %r14, %rdi
callq 0x3c28
testl %eax, %eax
je 0x3b12
jmp 0x3bef
movq 0xd6c1(%rip), %rax      # 0x11218
shrq $0x8, %rax
cmpq %rax, 0xd6be(%rip)      # 0x11220
jbe 0x3bd1
testq %r15, %r15
je 0x3c09
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x2270
testq %rax, %rax
je 0x3bd1
movq %rax, %r12
movq 0xd688(%rip), %r13      # 0x11210
shlq $0x3, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2250
cmpq 0xd68f(%rip), %r13      # 0x11230
je 0x3bab
movq %r13, %rdi
callq 0x2040
movq %r12, 0xd65e(%rip)      # 0x11210
shlq 0xd64f(%rip)            # 0x11208
movq 0xd640(%rip), %rax      # 0x11200
leaq 0x1(%rax), %rcx
movq %rcx, 0xd635(%rip)      # 0x11200
movq %rbx, (%r12,%rax,8)
jmp 0x3bd9
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xd635(%rip)     # 0x11218
movq %r14, %rdi
callq 0x3de2
testl %eax, %eax
je 0x3c05
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x3bf4
leaq 0x7826(%rip), %rdi      # 0xb436
leaq 0x7830(%rip), %rsi      # 0xb447
leaq 0x784b(%rip), %rcx      # 0xb469
movl $0x5a, %edx
callq 0x21a0