// File: /workspace/github_c_makefile_star2_O3/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 0x369f
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 0x3d85(%rip), %rdi      # 0x72a0
movq %r14, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2250
movl %eax, %r13d
testl %eax, %eax
je 0x3575
movl $0x5, %edx
leaq 0x3da4(%rip), %rdi      # 0x72e0
movq %r14, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2250
testl %eax, %eax
je 0x35b9
movl $0x5, %edx
leaq 0x3dc6(%rip), %rdi      # 0x7320
movq %r14, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2250
testl %eax, %eax
jne 0x3667
jmp 0x3653
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, %rbp
movslq 0x30(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
movq %r15, %rsi
callq 0x2160
movsd %xmm0, 0x10(%rsp)
movl $0x2e, %edx
jmp 0x35ec
movslq 0x28(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
leaq 0x18(%rsp), %rsi
movl $0xa, %edx
callq 0x22d0
movq %rax, %rbp
movl 0x30(%rsp), %eax
xorl %ecx, %ecx
cmpl 0x34(%rsp), %eax
sete %cl
leal 0x23(,%rcx,2), %edx
movslq 0x6c(%rbx), %rax
movl 0x68(%rbx), %ecx
cmpq $0x7fff, %rax           # imm = 0x7FFF
jg 0x3605
testq %rbp, %rbp
jne 0x3605
incl %ecx
movl %ecx, 0x68(%rbx)
movslq %ecx, %rsi
addq %rbp, %rsi
cmpq %rax, %rsi
jg 0x3696
movq 0x90(%rbx), %rdi
callq 0x2604
testl %r13d, %r13d
jne 0x3667
movslq 0x68(%rbx), %rax
addq %rax, %rbp
movslq 0x6c(%rbx), %rax
cmpq %rax, %rbp
jge 0x3667
leaq 0x3bd4(%rip), %rax      # 0x7210
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x3667
movq %rbx, %rdi
callq 0x36d0
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 0x34e3
jmp 0x369f
cmpl $0x0, 0x70(%rbx)
je 0x36b1
movl %edx, 0x70(%rbx)
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b4f(%rip), %rdi      # 0x5207
leaq 0x1b67(%rip), %rsi      # 0x5226
leaq 0x1b6e(%rip), %rcx      # 0x5234
movl $0x76, %edx
callq 0x2130