// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x5
popq %r12
leaq 0x20(%rsp), %rbp
leaq 0x48(%rsp), %r13
cmpq $-0x1, %rdx
je 0x33f7
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)
leaq 0x402e(%rip), %rdi      # 0x72a0
movq %r14, %rsi
movq %r12, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x2250
movl %eax, %r15d
testl %eax, %eax
je 0x32cb
leaq 0x404f(%rip), %rdi      # 0x72e0
movq %r14, %rsi
movq %r12, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x2250
testl %eax, %eax
je 0x3311
leaq 0x4073(%rip), %rdi      # 0x7320
movq %r14, %rsi
movq %r12, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x2250
testl %eax, %eax
jne 0x33ca
jmp 0x33b2
movslq 0x28(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
movq %r13, %rbp
leaq 0x18(%rsp), %r13
movq %r13, %rsi
pushq $0xa
popq %rdx
callq 0x22d0
movq %rax, %r12
movslq 0x30(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
movq %r13, %rsi
movq %rbp, %r13
callq 0x2160
movsd %xmm0, 0x10(%rsp)
pushq $0x2e
popq %rdx
jmp 0x3342
movslq 0x28(%rsp), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
leaq 0x18(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x22d0
movq %rax, %r12
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 0x3362
testq %r12, %r12
leaq 0x20(%rsp), %rbp
jne 0x3367
incl %ecx
movl %ecx, 0x68(%rbx)
jmp 0x3367
leaq 0x20(%rsp), %rbp
movslq %ecx, %rsi
addq %r12, %rsi
cmpq %rax, %rsi
jg 0x33ee
movq 0x90(%rbx), %rdi
callq 0x2520
testl %r15d, %r15d
jne 0x33c6
movslq 0x68(%rbx), %rax
addq %rax, %r12
movslq 0x6c(%rbx), %rax
cmpq %rax, %r12
jge 0x33c6
leaq 0x3e76(%rip), %rax      # 0x7210
cvtsi2sdl (%rax), %xmm0
ucomisd 0x10(%rsp), %xmm0
pushq $0x5
popq %r12
jbe 0x33ca
movq %rbx, %rdi
callq 0x3426
movq 0x90(%rbx), %rdi
movl 0x6c(%rbx), %esi
pushq $0x21
popq %rdx
callq 0x2520
jmp 0x33ca
pushq $0x5
popq %r12
movq 0x80(%rbx), %rsi
movq %r13, %rdi
xorl %edx, %edx
leaq 0x8(%rsp), %rcx
pushq $0x3
popq %r8
callq 0x2330
movq 0x48(%rsp), %rdx
jmp 0x3235
cmpl $0x0, 0x70(%rbx)
je 0x3409
movl %edx, 0x70(%rbx)
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdf7(%rip), %rdi       # 0x4207
leaq 0xe0f(%rip), %rsi       # 0x4226
leaq 0xe16(%rip), %rcx       # 0x4234
pushq $0x76
popq %rdx
callq 0x2130