// File: /workspace/github_c_makefile_star2_O0/sabotage-linux[P]libnl-tiny/nl.c
// Function: recvmsgs
static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
{
	int n, err = 0, multipart = 0;
	unsigned char *buf = NULL;
	struct nlmsghdr *hdr;
	struct sockaddr_nl nla = {0};
	struct nl_msg *msg = NULL;
	struct ucred *creds = NULL;

continue_reading:
	NL_DBG(3, "Attempting to read from %p\n", sk);
	if (cb->cb_recv_ow)
		n = cb->cb_recv_ow(sk, &nla, &buf, &creds);
	else
		n = nl_recv(sk, &nla, &buf, &creds);

	if (n <= 0)
		return n;

	/* make clang analyzer happy */
	assert(n > 0 && buf);

	NL_DBG(3, "recvmsgs(%p): Read %d bytes\n", sk, n);

	hdr = (struct nlmsghdr *) buf;
	while (nlmsg_ok(hdr, n)) {
		NL_DBG(3, "recgmsgs(%p): Processing valid message...\n", sk);

		nlmsg_free(msg);
		msg = nlmsg_convert(hdr);
		if (!msg) {
			err = -NLE_NOMEM;
			goto out;
		}

		nlmsg_set_proto(msg, sk->s_proto);
		nlmsg_set_src(msg, &nla);
		if (creds)
			nlmsg_set_creds(msg, creds);

		/* Raw callback is the first, it gives the most control
		 * to the user and he can do his very own parsing. */
		if (cb->cb_set[NL_CB_MSG_IN])
			NL_CB_CALL(cb, NL_CB_MSG_IN, msg);

		/* Sequence number checking. The check may be done by
		 * the user, otherwise a very simple check is applied
		 * enforcing strict ordering */
		if (cb->cb_set[NL_CB_SEQ_CHECK])
			NL_CB_CALL(cb, NL_CB_SEQ_CHECK, msg);
		else if (hdr->nlmsg_seq != sk->s_seq_expect) {
			if (cb->cb_set[NL_CB_INVALID])
				NL_CB_CALL(cb, NL_CB_INVALID, msg);
			else {
				err = -NLE_SEQ_MISMATCH;
				goto out;
			}
		}

		if (hdr->nlmsg_type == NLMSG_DONE ||
		    hdr->nlmsg_type == NLMSG_ERROR ||
		    hdr->nlmsg_type == NLMSG_NOOP ||
		    hdr->nlmsg_type == NLMSG_OVERRUN) {
			/* We can't check for !NLM_F_MULTI since some netlink
			 * users in the kernel are broken. */
			sk->s_seq_expect++;
			NL_DBG(3, "recvmsgs(%p): Increased expected " \
			       "sequence number to %d\n",
			       sk, sk->s_seq_expect);
		}

		if (hdr->nlmsg_flags & NLM_F_MULTI)
			multipart = 1;
	
		/* Other side wishes to see an ack for this message */
		if (hdr->nlmsg_flags & NLM_F_ACK) {
			if (cb->cb_set[NL_CB_SEND_ACK])
				NL_CB_CALL(cb, NL_CB_SEND_ACK, msg);
			else {
				/* FIXME: implement */
			}
		}

		/* messages terminates a multpart message, this is
		 * usually the end of a message and therefore we slip
		 * out of the loop by default. the user may overrule
		 * this action by skipping this packet. */
		if (hdr->nlmsg_type == NLMSG_DONE) {
			multipart = 0;
			if (cb->cb_set[NL_CB_FINISH])
				NL_CB_CALL(cb, NL_CB_FINISH, msg);
		}

		/* Message to be ignored, the default action is to
		 * skip this message if no callback is specified. The
		 * user may overrule this action by returning
		 * NL_PROCEED. */
		else if (hdr->nlmsg_type == NLMSG_NOOP) {
			if (cb->cb_set[NL_CB_SKIPPED])
				NL_CB_CALL(cb, NL_CB_SKIPPED, msg);
			else
				goto skip;
		}

		/* Data got lost, report back to user. The default action is to
		 * quit parsing. The user may overrule this action by retuning
		 * NL_SKIP or NL_PROCEED (dangerous) */
		else if (hdr->nlmsg_type == NLMSG_OVERRUN) {
			if (cb->cb_set[NL_CB_OVERRUN])
				NL_CB_CALL(cb, NL_CB_OVERRUN, msg);
			else {
				err = -NLE_MSG_OVERFLOW;
				goto out;
			}
		}

		/* Message carries a nlmsgerr */
		else if (hdr->nlmsg_type == NLMSG_ERROR) {
			struct nlmsgerr *e = nlmsg_data(hdr);

			if (hdr->nlmsg_len < (unsigned) nlmsg_msg_size(sizeof(*e))) {
				/* Truncated error message, the default action
				 * is to stop parsing. The user may overrule
				 * this action by returning NL_SKIP or
				 * NL_PROCEED (dangerous) */
				if (cb->cb_set[NL_CB_INVALID])
					NL_CB_CALL(cb, NL_CB_INVALID, msg);
				else {
					err = -NLE_MSG_TRUNC;
					goto out;
				}
			} else if (e->error) {
				/* Error message reported back from kernel. */
				if (cb->cb_err) {
					err = cb->cb_err(&nla, e,
							   cb->cb_err_arg);
					if (err < 0)
						goto out;
					else if (err == NL_SKIP)
						goto skip;
					else if (err == NL_STOP) {
						err = -nl_syserr2nlerr(e->error);
						goto out;
					}
				} else {
					err = -nl_syserr2nlerr(e->error);
					goto out;
				}
			} else if (cb->cb_set[NL_CB_ACK])
				NL_CB_CALL(cb, NL_CB_ACK, msg);
		} else {
			/* Valid message (not checking for MULTIPART bit to
			 * get along with broken kernels. NL_SKIP has no
			 * effect on this.  */
			if (cb->cb_set[NL_CB_VALID])
				NL_CB_CALL(cb, NL_CB_VALID, msg);
		}
skip:
		hdr = nlmsg_next(hdr, &n);
	}
	
	nlmsg_free(msg);
	free(buf);
	free(creds);
	buf = NULL;
	msg = NULL;
	creds = NULL;

	if (multipart) {
		/* Multipart message not yet complete, continue reading */
		goto continue_reading;
	}
stop:
	err = 0;
out:
	nlmsg_free(msg);
	free(buf);
	free(creds);

	return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x44(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x3240
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
jmp 0x41db
jmp 0x41dd
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
je 0x420d
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x44(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq *%rax
movl %eax, -0x1c(%rbp)
jmp 0x4225
movq -0x10(%rbp), %rdi
leaq -0x44(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x3350
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jg 0x4236
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x48e5
cmpl $0x0, -0x1c(%rbp)
jle 0x4245
cmpq $0x0, -0x30(%rbp)
je 0x4245
jmp 0x4264
leaq 0x5db4(%rip), %rdi      # 0xa000
leaq 0x5dba(%rip), %rsi      # 0xa00d
movl $0x1fe, %edx            # imm = 0x1FE
leaq 0x5db3(%rip), %rcx      # 0xa012
callq 0x3210
jmp 0x4266
jmp 0x4268
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x31b0
cmpl $0x0, %eax
je 0x487d
jmp 0x4287
jmp 0x4289
movq -0x50(%rbp), %rdi
callq 0x3640
movq -0x38(%rbp), %rdi
callq 0x30d0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x42b2
movl $0xfffffffb, -0x20(%rbp) # imm = 0xFFFFFFFB
jmp 0x48c4
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x49a0
movq -0x50(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x3ab0
cmpq $0x0, -0x58(%rbp)
je 0x42e3
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x49c0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x4341
jmp 0x42f0
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x5, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x64(%rbp)
testl %eax, %eax
je 0x4325
jmp 0x4311
movl -0x64(%rbp), %eax
subl $0x1, %eax
je 0x432e
jmp 0x431b
movl -0x64(%rbp), %eax
subl $0x2, %eax
je 0x4333
jmp 0x4338
movl $0x0, -0x20(%rbp)
jmp 0x433d
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x433f
jmp 0x4341
movq -0x18(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x439f
jmp 0x434e
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x8, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x68(%rbp)
testl %eax, %eax
je 0x4383
jmp 0x436f
movl -0x68(%rbp), %eax
subl $0x1, %eax
je 0x438c
jmp 0x4379
movl -0x68(%rbp), %eax
subl $0x2, %eax
je 0x4391
jmp 0x4396
movl $0x0, -0x20(%rbp)
jmp 0x439b
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x439d
jmp 0x441d
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x24(%rcx), %eax
je 0x441b
movq -0x18(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x440d
jmp 0x43bc
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x7, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x6c(%rbp)
testl %eax, %eax
je 0x43f1
jmp 0x43dd
movl -0x6c(%rbp), %eax
subl $0x1, %eax
je 0x43fa
jmp 0x43e7
movl -0x6c(%rbp), %eax
subl $0x2, %eax
je 0x43ff
jmp 0x4404
movl $0x0, -0x20(%rbp)
jmp 0x4409
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x440b
jmp 0x4419
movl $0xfffffff0, -0x20(%rbp) # imm = 0xFFFFFFF0
jmp 0x48c4
jmp 0x441b
jmp 0x441d
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x3, %eax
je 0x4451
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x2, %eax
je 0x4451
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x1, %eax
je 0x4451
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x4, %eax
jne 0x4462
movq -0x10(%rbp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
jmp 0x4460
jmp 0x4462
movq -0x38(%rbp), %rax
movzwl 0x6(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x4479
movl $0x1, -0x24(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x6(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x44eb
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x44e7
jmp 0x4496
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x9, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x70(%rbp)
testl %eax, %eax
je 0x44cb
jmp 0x44b7
movl -0x70(%rbp), %eax
subl $0x1, %eax
je 0x44d4
jmp 0x44c1
movl -0x70(%rbp), %eax
subl $0x2, %eax
je 0x44d9
jmp 0x44de
movl $0x0, -0x20(%rbp)
jmp 0x44e3
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x44e5
jmp 0x44e9
jmp 0x44e9
jmp 0x44eb
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x3, %eax
jne 0x4562
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x455d
jmp 0x450c
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x1, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x74(%rbp)
testl %eax, %eax
je 0x4541
jmp 0x452d
movl -0x74(%rbp), %eax
subl $0x1, %eax
je 0x454a
jmp 0x4537
movl -0x74(%rbp), %eax
subl $0x2, %eax
je 0x454f
jmp 0x4554
movl $0x0, -0x20(%rbp)
jmp 0x4559
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x455b
jmp 0x455d
jmp 0x4865
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x1, %eax
jne 0x45d7
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x45cd
jmp 0x457c
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x3, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x78(%rbp)
testl %eax, %eax
je 0x45b1
jmp 0x459d
movl -0x78(%rbp), %eax
subl $0x1, %eax
je 0x45ba
jmp 0x45a7
movl -0x78(%rbp), %eax
subl $0x2, %eax
je 0x45bf
jmp 0x45c4
movl $0x0, -0x20(%rbp)
jmp 0x45c9
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x45cb
jmp 0x45d2
jmp 0x4867
jmp 0x4863
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x4, %eax
jne 0x4653
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4642
jmp 0x45f1
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x2, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x7c(%rbp)
testl %eax, %eax
je 0x4626
jmp 0x4612
movl -0x7c(%rbp), %eax
subl $0x1, %eax
je 0x462f
jmp 0x461c
movl -0x7c(%rbp), %eax
subl $0x2, %eax
je 0x4634
jmp 0x4639
movl $0x0, -0x20(%rbp)
jmp 0x463e
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x4640
jmp 0x464e
movl $0xffffffef, -0x20(%rbp) # imm = 0xFFFFFFEF
jmp 0x48c4
jmp 0x4861
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x2, %eax
jne 0x4803
movq -0x38(%rbp), %rdi
callq 0x49f0
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x80(%rbp)
movl $0x14, %edi
callq 0x4a10
movl %eax, %ecx
movl -0x80(%rbp), %eax
cmpl %ecx, %eax
jae 0x4705
movq -0x18(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x46f4
jmp 0x469a
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x7, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x84(%rbp)
testl %eax, %eax
je 0x46d8
jmp 0x46be
movl -0x84(%rbp), %eax
subl $0x1, %eax
je 0x46e1
jmp 0x46cb
movl -0x84(%rbp), %eax
subl $0x2, %eax
je 0x46e6
jmp 0x46eb
movl $0x0, -0x20(%rbp)
jmp 0x46f0
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x46f2
jmp 0x4700
movl $0xffffffee, -0x20(%rbp) # imm = 0xFFFFFFEE
jmp 0x48c4
jmp 0x4801
movq -0x60(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4799
movq -0x18(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x477e
movq -0x18(%rbp), %rax
movq 0xa0(%rax), %rax
movq -0x60(%rbp), %rsi
movq -0x18(%rbp), %rcx
movq 0xa8(%rcx), %rdx
leaq -0x44(%rbp), %rdi
callq *%rax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x474e
jmp 0x48c4
cmpl $0x1, -0x20(%rbp)
jne 0x4759
jmp 0x4867
cmpl $0x2, -0x20(%rbp)
jne 0x4778
movq -0x60(%rbp), %rax
movl (%rax), %edi
callq 0x3390
movl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
jmp 0x48c4
jmp 0x477a
jmp 0x477c
jmp 0x4797
movq -0x60(%rbp), %rax
movl (%rax), %edi
callq 0x3390
movl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
jmp 0x48c4
jmp 0x47ff
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x47fd
jmp 0x47a6
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x88(%rbp)
testl %eax, %eax
je 0x47e4
jmp 0x47ca
movl -0x88(%rbp), %eax
subl $0x1, %eax
je 0x47ed
jmp 0x47d7
movl -0x88(%rbp), %eax
subl $0x2, %eax
je 0x47ef
jmp 0x47f4
movl $0x0, -0x20(%rbp)
jmp 0x47f9
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x47fb
jmp 0x47fd
jmp 0x47ff
jmp 0x4801
jmp 0x485f
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x485d
jmp 0x480f
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
xorl %esi, %esi
callq 0x3ae0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x8c(%rbp)
testl %eax, %eax
je 0x484a
jmp 0x4830
movl -0x8c(%rbp), %eax
subl $0x1, %eax
je 0x4853
jmp 0x483d
movl -0x8c(%rbp), %eax
subl $0x2, %eax
je 0x4855
jmp 0x4857
movl $0x0, -0x20(%rbp)
jmp 0x4859
jmp 0x4867
jmp 0x48bd
jmp 0x48c4
jmp 0x485b
jmp 0x485d
jmp 0x485f
jmp 0x4861
jmp 0x4863
jmp 0x4865
jmp 0x4867
movq -0x38(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x31a0
movq %rax, -0x38(%rbp)
jmp 0x4270
movq -0x50(%rbp), %rdi
callq 0x3640
movq -0x30(%rbp), %rdi
callq 0x3070
movq -0x58(%rbp), %rdi
callq 0x3070
movq $0x0, -0x30(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x48bb
jmp 0x41d9
jmp 0x48bd
movl $0x0, -0x20(%rbp)
movq -0x50(%rbp), %rdi
callq 0x3640
movq -0x30(%rbp), %rdi
callq 0x3070
movq -0x58(%rbp), %rdi
callq 0x3070
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)