// File: /workspace/github_c_makefile_star2_O1/martintopholm[P]xping/icmp-unpriv.c
// Function: readping
static void
readping(int fd, short what, void *thunk)
{
	struct probe *prb = thunk;
	regmatch_t match[5];
	struct evbuffer_ptr evbufptr;
	double rtt;
	size_t len;
	char buf[BUFSIZ];
	char *end;
	long int seq;
	int mark;
	int n;

	evbuffer_read(prb->evbuf, fd, 512);
	evbufptr = evbuffer_search_eol(prb->evbuf, NULL, &len,
	    EVBUFFER_EOL_ANY);
	while (evbufptr.pos != -1) {
		len += evbufptr.pos;
		n = evbuffer_remove(prb->evbuf, buf, MIN(sizeof(buf)-1, len));
		buf[n] = '\0';
		mark = '\0';
		if (regexec(&re_reply, buf, 5, match, 0) == 0) {
			seq = strtol(buf + match[1].rm_so, &end, 10);
			rtt = strtod(buf + match[2].rm_so, &end);
			mark = '.';
		} else if (regexec(&re_other, buf, 5, match, 0) == 0) {
			seq = strtol(buf + match[1].rm_so, &end, 10);
			if (match[2].rm_so != match[2].rm_eo)
				mark = '#';
			else
				mark = '%';
		} else if (regexec(&re_xmiterr, buf, 5, match, 0) == 0) {
			/* Transmit errors are quickly identified,
			 * thus assume they refer to most recent packet */
			target_mark(prb->owner, prb->seqlast, '!');
		}
		if (mark != '\0') {
			/* Adjust sequence adjustment delta. In cast the
			 * first packet has icmp_seq=0 instead of 1 */
			if (prb->seqlast < 32768 && seq == 0)
				prb->seqdelta++;
			/*
			 * seq newer than last sent, thus packet arrived too
			 * early (before probe_send. Cached mark until
			 * probe_send is called next_time.
			 */
			if (prb->seqlast < seq + prb->seqdelta) {
				AZ(prb->early_mark == '\0');
				prb->early_mark = mark;
				return;
			}
			target_mark(prb->owner, seq + prb->seqdelta, mark);

			/* Check for timing drift: If packet isn't the
			 * latest reply and ping thinks rtt is less than
			 * i_interval it must have drifted */
			if (mark == '.' &&
			    seq + prb->seqdelta < prb->seqlast &&
			    rtt < i_interval) {
				killping(prb);
				target_mark(prb->owner, prb->seqlast, '!');
			}
		}
		evbufptr = evbuffer_search_eol(prb->evbuf, NULL, &len,
		    EVBUFFER_EOL_LF);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2068, %rsp           # imm = 0x2068
movq %rdx, %rbx
movl %edi, %esi
movq 0x80(%rdx), %rdi
movl $0x200, %edx            # imm = 0x200
callq 0x20e0
movq 0x80(%rbx), %rsi
leaq 0x60(%rsp), %r14
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x2330
movq (%r14), %rdx
cmpq $-0x1, %rdx
je 0x371f
leaq 0x60(%rsp), %r14
leaq 0x20(%rsp), %r12
addq 0x8(%rsp), %rdx
movq %rdx, 0x8(%rsp)
movq 0x80(%rbx), %rdi
movl $0x1fff, %eax           # imm = 0x1FFF
cmpq %rax, %rdx
cmovaeq %rax, %rdx
movq %r14, %rsi
callq 0x2270
cltq
movb $0x0, 0x60(%rsp,%rax)
movl $0x5, %edx
leaq 0x3d2d(%rip), %rdi      # 0x72a0
movq %r14, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2250
movl %eax, %ebp
testl %eax, %eax
je 0x35e7
movl $0x5, %edx
leaq 0x3d4d(%rip), %rdi      # 0x72e0
movq %r14, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2250
testl %eax, %eax
je 0x362c
xorl %r15d, %r15d
movl $0x5, %edx
leaq 0x3d68(%rip), %rdi      # 0x7320
movq %r14, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2250
movb $0x1, %r12b
testl %eax, %eax
jne 0x3663
movq 0x90(%rbx), %rdi
movl 0x6c(%rbx), %esi
movl $0x21, %edx
callq 0x2604
jmp 0x3663
movslq 0x28(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
leaq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0xa, %edx
callq 0x22d0
movq %rax, %r13
movslq 0x30(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
movq %r15, %rsi
callq 0x2160
movsd %xmm0, 0x10(%rsp)
movl $0x2e, %r15d
jmp 0x3660
movslq 0x28(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
leaq 0x18(%rsp), %rsi
movl $0xa, %edx
callq 0x22d0
movl 0x30(%rsp), %ecx
xorl %edx, %edx
cmpl 0x34(%rsp), %ecx
movq %rax, %r13
sete %dl
leal 0x23(,%rdx,2), %r15d
xorl %r12d, %r12d
testb %r12b, %r12b
leaq 0x20(%rsp), %r12
jne 0x36e6
movslq 0x6c(%rbx), %rax
cmpq $0x7fff, %rax           # imm = 0x7FFF
jg 0x3681
testq %r13, %r13
jne 0x3681
incl 0x68(%rbx)
movslq 0x68(%rbx), %rsi
addq %r13, %rsi
cmpq %rax, %rsi
jg 0x3715
movq 0x90(%rbx), %rdi
movl %r15d, %edx
callq 0x2604
testl %ebp, %ebp
jne 0x36e6
movslq 0x68(%rbx), %rax
addq %r13, %rax
movslq 0x6c(%rbx), %rcx
cmpq %rcx, %rax
jge 0x36e6
leaq 0x3b55(%rip), %rax      # 0x7210
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x36e6
movq %rbx, %rdi
callq 0x3750
movq 0x90(%rbx), %rdi
movl 0x6c(%rbx), %esi
movl $0x21, %edx
callq 0x2604
movq 0x80(%rbx), %rsi
leaq 0x48(%rsp), %rdi
xorl %edx, %edx
leaq 0x8(%rsp), %rcx
movl $0x3, %r8d
callq 0x2330
movq 0x48(%rsp), %rdx
cmpq $-0x1, %rdx
jne 0x353b
jmp 0x371f
cmpl $0x0, 0x70(%rbx)
je 0x3731
movl %r15d, 0x70(%rbx)
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1acf(%rip), %rdi      # 0x5207
leaq 0x1ae7(%rip), %rsi      # 0x5226
leaq 0x1aee(%rip), %rcx      # 0x5234
movl $0x76, %edx
callq 0x2130