// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds/dispatch.c
// Function: dropconnection
static int
dropconnection(void * cookie)
{
	struct dispatch_state * D = cookie;
	struct requestq * RQ;

	/* This connection is dying. */
	D->dying = 1;

	/* If we're reading a packet, stop it. */
	if (D->read_cookie != NULL) {
		wire_readpacket_wait_cancel(D->read_cookie);
		D->read_cookie = NULL;
	}

	/* Free queued requests. */
	while ((RQ = D->nmr_head) != NULL) {
		/* Remove from the queue. */
		D->nmr_head = RQ->next;

		/* Free the request and linked list node. */
		proto_kvlds_request_free(RQ->R);
		mpool_requestq_free(RQ);

		/* That's one request we won't be responding to. */
		D->nrequests -= 1;
	}
	while ((RQ = D->mr_head) != NULL) {
		/* Remove from the queue. */
		D->mr_head = RQ->next;
		D->mr_qlen -= 1;

		/* Free the request and linked list node. */
		proto_kvlds_request_free(RQ->R);
		mpool_requestq_free(RQ);

		/* That's one request we won't be responding to. */
		D->nrequests -= 1;
	}

	/* Cancel any stop-queuing timer; we've freed the queue anyway. */
	if (D->mr_timer != NULL) {
		events_timer_cancel(D->mr_timer);
		D->mr_timer = NULL;
	}

	/* The (unset) timer hasn't expired. */
	D->mr_timer_expired = 0;

	/* Success!  (We can't fail -- but netbuf_write doesn't know that.) */
	return (0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl $0x1, (%rdi)
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x47b0
callq 0x11bb1
movq $0x0, 0x18(%rbx)
jmp 0x47b0
movq 0x8(%r14), %rax
movq %rax, 0x40(%rbx)
movq (%r14), %rdi
callq 0x10bd2
movq 0x18b2e(%rip), %rax     # 0x1d220
movq 0x18b2f(%rip), %r15     # 0x1d228
cmpq %r15, %rax
jae 0x4719
movq 0x18b2b(%rip), %rcx     # 0x1d230
leaq 0x1(%rax), %rdx
movq %rdx, 0x18b10(%rip)     # 0x1d220
movq %r14, (%rcx,%rax,8)
jmp 0x47ac
movq 0x18b18(%rip), %rax     # 0x1d238
shrq $0x8, %rax
cmpq %rax, 0x18b15(%rip)     # 0x1d240
jbe 0x479a
testq %r15, %r15
je 0x48dd
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x479a
movq %rax, %r12
movq 0x18adf(%rip), %r13     # 0x1d230
shlq $0x3, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2280
cmpq 0x18ae6(%rip), %r13     # 0x1d250
je 0x4774
movq %r13, %rdi
callq 0x2040
movq %r12, 0x18ab5(%rip)     # 0x1d230
shlq 0x18aa6(%rip)           # 0x1d228
movq 0x18a97(%rip), %rax     # 0x1d220
leaq 0x1(%rax), %rcx
movq %rcx, 0x18a8c(%rip)     # 0x1d220
movq %r14, (%r12,%rax,8)
jmp 0x47a2
movq %r14, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x18a8c(%rip)    # 0x1d238
decq 0x20(%rbx)
movq 0x40(%rbx), %r14
testq %r14, %r14
jne 0x46db
jmp 0x489e
movq 0x8(%r14), %rax
movq %rax, 0x60(%rbx)
decq 0x88(%rbx)
movq (%r14), %rdi
callq 0x10bd2
movq 0x18a40(%rip), %rax     # 0x1d220
movq 0x18a41(%rip), %r15     # 0x1d228
cmpq %r15, %rax
jae 0x4807
movq 0x18a3d(%rip), %rcx     # 0x1d230
leaq 0x1(%rax), %rdx
movq %rdx, 0x18a22(%rip)     # 0x1d220
movq %r14, (%rcx,%rax,8)
jmp 0x489a
movq 0x18a2a(%rip), %rax     # 0x1d238
shrq $0x8, %rax
cmpq %rax, 0x18a27(%rip)     # 0x1d240
jbe 0x4888
testq %r15, %r15
je 0x48dd
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x4888
movq %rax, %r12
movq 0x189f1(%rip), %r13     # 0x1d230
shlq $0x3, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2280
cmpq 0x189f8(%rip), %r13     # 0x1d250
je 0x4862
movq %r13, %rdi
callq 0x2040
movq %r12, 0x189c7(%rip)     # 0x1d230
shlq 0x189b8(%rip)           # 0x1d228
movq 0x189a9(%rip), %rax     # 0x1d220
leaq 0x1(%rax), %rcx
movq %rcx, 0x1899e(%rip)     # 0x1d220
movq %r14, (%r12,%rax,8)
jmp 0x4890
movq %r14, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x1899e(%rip)    # 0x1d238
decq 0x20(%rbx)
movq 0x60(%rbx), %r14
testq %r14, %r14
jne 0x47c2
movq 0x90(%rbx), %rdi
testq %rdi, %rdi
je 0x48c7
callq 0xc8b1
movq $0x0, 0x90(%rbx)
movl $0x0, 0x98(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xfc51(%rip), %rdi      # 0x14535
leaq 0xfc5b(%rip), %rsi      # 0x14546
leaq 0xfc76(%rip), %rcx      # 0x14568
movl $0x5a, %edx
callq 0x21c0