// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x1, (%rdi)
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x4779
callq 0x11b52
movq $0x0, 0x18(%rbx)
jmp 0x4779
movq 0x8(%r14), %rax
movq %rax, 0x40(%rbx)
movq (%r14), %rdi
callq 0x10b73
movq 0x18b70(%rip), %r13     # 0x1d220
movq 0x18b71(%rip), %rbp     # 0x1d228
cmpq %rbp, %r13
jae 0x46d7
movq 0x18b6d(%rip), %rax     # 0x1d230
leaq 0x1(%r13), %rcx
movq %rcx, 0x18b52(%rip)     # 0x1d220
movq %r14, (%rax,%r13,8)
jmp 0x4775
movq 0x18b5a(%rip), %rax     # 0x1d238
shrq $0x8, %rax
cmpq %rax, 0x18b57(%rip)     # 0x1d240
jbe 0x4763
testq %rbp, %rbp
je 0x48b6
movq %rbp, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x4763
movq %rax, %r15
movq 0x18b21(%rip), %r12     # 0x1d230
leaq (,%rbp,8), %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2280
cmpq 0x18b27(%rip), %r12     # 0x1d250
je 0x4741
movq %r12, %rdi
callq 0x2040
movq 0x18aee(%rip), %rbp     # 0x1d228
movq 0x18adf(%rip), %r13     # 0x1d220
movq %r15, 0x18ae8(%rip)     # 0x1d230
addq %rbp, %rbp
movq %rbp, 0x18ad6(%rip)     # 0x1d228
leaq 0x1(%r13), %rax
movq %rax, 0x18ac3(%rip)     # 0x1d220
movq %r14, (%r15,%r13,8)
jmp 0x476b
movq %r14, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x18ac3(%rip)    # 0x1d238
decq 0x20(%rbx)
movq 0x40(%rbx), %r14
testq %r14, %r14
jne 0x4699
jmp 0x4872
movq 0x8(%r14), %rax
movq %rax, 0x60(%rbx)
decq 0x88(%rbx)
movq (%r14), %rdi
callq 0x10b73
movq 0x18a77(%rip), %r13     # 0x1d220
movq 0x18a78(%rip), %rbp     # 0x1d228
cmpq %rbp, %r13
jae 0x47d0
movq 0x18a74(%rip), %rax     # 0x1d230
leaq 0x1(%r13), %rcx
movq %rcx, 0x18a59(%rip)     # 0x1d220
movq %r14, (%rax,%r13,8)
jmp 0x486e
movq 0x18a61(%rip), %rax     # 0x1d238
shrq $0x8, %rax
cmpq %rax, 0x18a5e(%rip)     # 0x1d240
jbe 0x485c
testq %rbp, %rbp
je 0x48b6
movq %rbp, %rdi
shlq $0x4, %rdi
callq 0x22a0
testq %rax, %rax
je 0x485c
movq %rax, %r15
movq 0x18a28(%rip), %r12     # 0x1d230
leaq (,%rbp,8), %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2280
cmpq 0x18a2e(%rip), %r12     # 0x1d250
je 0x483a
movq %r12, %rdi
callq 0x2040
movq 0x189f5(%rip), %rbp     # 0x1d228
movq 0x189e6(%rip), %r13     # 0x1d220
movq %r15, 0x189ef(%rip)     # 0x1d230
addq %rbp, %rbp
movq %rbp, 0x189dd(%rip)     # 0x1d228
leaq 0x1(%r13), %rax
movq %rax, 0x189ca(%rip)     # 0x1d220
movq %r14, (%r15,%r13,8)
jmp 0x4864
movq %r14, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0x189ca(%rip)    # 0x1d238
decq 0x20(%rbx)
movq 0x60(%rbx), %r14
testq %r14, %r14
jne 0x478b
movq 0x90(%rbx), %rdi
testq %rdi, %rdi
je 0x489b
callq 0xc792
movq $0x0, 0x90(%rbx)
movl $0x0, 0x98(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfc18(%rip), %rdi      # 0x144d5
leaq 0xfc22(%rip), %rsi      # 0x144e6
leaq 0xfc3d(%rip), %rcx      # 0x14508
movl $0x5a, %edx
callq 0x21c0