// File: /workspace/github_c_makefile_star2_O0/martintopholm[P]xping/icmp.c
// Function: read_packet6
static void
read_packet6(int fd, short what, void *thunk)
{
	char inpacket[IP_MAXPACKET];
	struct sockaddr_in6 sin6;
	struct ip6_hdr *oip6;
	struct icmp6_hdr *icmp6h;
	struct icmp6_hdr *oicmp6h;
	socklen_t salen;
	int seq;
	int n;

	salen = sizeof(sin6);
	memset(inpacket, 0, sizeof(inpacket));
	n = recvfrom(fd, inpacket, sizeof(inpacket), 0,
	    (struct sockaddr *)&sin6, &salen);
	if (n < 0) {
		return;
	}
	if (n < ICMP6_MINLEN) {
		return;
	}

	/* SOCK_RAW for IPPROTO_ICMPV6 doesn't include IPv6 header */
	icmp6h = (struct icmp6_hdr *)(inpacket);
	if (icmp6h->icmp6_type == ICMP6_ECHO_REPLY) {
		if (icmp6h->icmp6_id != htons(ident))
			return; /*  skip other ping sessions */
		if (n != sizeof(struct icmp6_hdr) + datalen)
			return;

		seq = ntohs(icmp6h->icmp6_seq);
		find_marktarget(AF_INET6, &sin6.sin6_addr, seq, '.');
	} else {
		/* Skip short icmp error packets. */
		if (n < ICMP6_MINLEN * 2 + sizeof(struct ip6_hdr))
			return;

		/* Check aspects of the original packet */
		oip6 = (struct ip6_hdr *)(icmp6h + 1);
		oicmp6h = (struct icmp6_hdr *)(oip6 + 1);
		if (oip6->ip6_nxt != IPPROTO_ICMPV6)
			return;
		if (oicmp6h->icmp6_type != ICMP6_ECHO_REQUEST)
			return;
		if (oicmp6h->icmp6_id != htons(ident))
			return;

		seq = ntohs(oicmp6h->icmp6_seq);
		if (icmp6h->icmp6_type == ICMP6_DST_UNREACH)
			find_marktarget(AF_INET6, &oip6->ip6_dst, seq, '#');
		else
			find_marktarget(AF_INET6, &oip6->ip6_dst, seq, '%');
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10060, %rsp          # imm = 0x10060
movw %si, %ax
movl %edi, -0x4(%rbp)
movw %ax, -0x6(%rbp)
movq %rdx, -0x10(%rbp)
movl $0x1c, -0x1004c(%rbp)
leaq -0x10010(%rbp), %rdi
xorl %esi, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x2100
movl -0x4(%rbp), %edi
leaq -0x10010(%rbp), %rsi
movl $0xffff, %edx           # imm = 0xFFFF
xorl %ecx, %ecx
leaq -0x1002c(%rbp), %r8
leaq -0x1004c(%rbp), %r9
callq 0x2140
movl %eax, -0x10054(%rbp)
cmpl $0x0, -0x10054(%rbp)
jge 0x557e
jmp 0x573f
movslq -0x10054(%rbp), %rax
cmpq $0x8, %rax
jae 0x5590
jmp 0x573f
leaq -0x10010(%rbp), %rax
movq %rax, -0x10040(%rbp)
movq -0x10040(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x81, %eax
jne 0x5641
movq -0x10040(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, -0x10058(%rbp)
movl 0x3cae(%rip), %eax      # 0x9278
movzwl %ax, %edi
callq 0x2050
movw %ax, %cx
movl -0x10058(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
je 0x55e7
jmp 0x573f
movslq -0x10054(%rbp), %rax
movslq 0x3bfb(%rip), %rcx      # 0x91f0
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x5603
jmp 0x573f
movq -0x10040(%rbp), %rax
movzwl 0x6(%rax), %edi
callq 0x2340
movzwl %ax, %eax
movl %eax, -0x10050(%rbp)
leaq -0x1002c(%rbp), %rsi
addq $0x8, %rsi
movl -0x10050(%rbp), %edx
movl $0xa, %edi
movl $0x2e, %ecx
callq 0x5c80
jmp 0x573f
movslq -0x10054(%rbp), %rax
cmpq $0x38, %rax
jae 0x5653
jmp 0x573f
movq -0x10040(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10038(%rbp)
movq -0x10038(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x10048(%rbp)
movq -0x10038(%rbp), %rax
movzbl 0x6(%rax), %eax
cmpl $0x3a, %eax
je 0x568c
jmp 0x573f
movq -0x10048(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x80, %eax
je 0x56a2
jmp 0x573f
movq -0x10048(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, -0x1005c(%rbp)
movl 0x3bbf(%rip), %eax      # 0x9278
movzwl %ax, %edi
callq 0x2050
movw %ax, %cx
movl -0x1005c(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
je 0x56d3
jmp 0x573f
movq -0x10048(%rbp), %rax
movzwl 0x6(%rax), %edi
callq 0x2340
movzwl %ax, %eax
movl %eax, -0x10050(%rbp)
movq -0x10040(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x571d
movq -0x10038(%rbp), %rsi
addq $0x18, %rsi
movl -0x10050(%rbp), %edx
movl $0xa, %edi
movl $0x23, %ecx
callq 0x5c80
jmp 0x573d
movq -0x10038(%rbp), %rsi
addq $0x18, %rsi
movl -0x10050(%rbp), %edx
movl $0xa, %edi
movl $0x25, %ecx
callq 0x5c80
jmp 0x573f
addq $0x10060, %rsp          # imm = 0x10060
popq %rbp
retq
nopl (%rax,%rax)