// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/raw.c
// Function: raw_input
raw_input_state_t
raw_input(struct pbuf *p, struct netif *inp)
{
  struct raw_pcb *pcb, *prev;
  s16_t proto;
  raw_input_state_t ret = RAW_INPUT_NONE;
  u8_t broadcast = ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif());

  LWIP_UNUSED_ARG(inp);

#if LWIP_IPV6
#if LWIP_IPV4
  if (IP_HDR_GET_VERSION(p->payload) == 6)
#endif /* LWIP_IPV4 */
  {
    struct ip6_hdr *ip6hdr = (struct ip6_hdr *)p->payload;
    proto = IP6H_NEXTH(ip6hdr);
  }
#if LWIP_IPV4
  else
#endif /* LWIP_IPV4 */
#endif /* LWIP_IPV6 */
#if LWIP_IPV4
  {
    proto = IPH_PROTO((struct ip_hdr *)p->payload);
  }
#endif /* LWIP_IPV4 */

  prev = NULL;
  pcb = raw_pcbs;
  /* loop through all raw pcbs until the packet is eaten by one */
  /* this allows multiple pcbs to match against the packet by design */
  while (pcb != NULL) {
    if ((pcb->protocol == proto) && raw_input_local_match(pcb, broadcast) &&
        (((pcb->flags & RAW_FLAGS_CONNECTED) == 0) ||
         ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()))) {
      /* receive callback function available? */
      if (pcb->recv != NULL) {
        u8_t eaten;
#ifndef LWIP_NOASSERT
        void *old_payload = p->payload;
#endif
        ret = RAW_INPUT_DELIVERED;
        /* the receive callback function did not eat the packet? */
        eaten = pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr());
        if (eaten != 0) {
          /* receive function ate the packet */
          p = NULL;
          if (prev != NULL) {
            /* move the pcb to the front of raw_pcbs so that is
               found faster next time */
            prev->next = pcb->next;
            pcb->next = raw_pcbs;
            raw_pcbs = pcb;
          }
          return RAW_INPUT_EATEN;
        } else {
          /* sanity-check that the receive callback did not alter the pbuf */
          LWIP_ASSERT("raw pcb recv callback altered pbuf payload pointer without eating packet",
                      p->payload == old_payload);
        }
      }
      /* no receive callback function was set for this raw PCB */
    }
    /* drop the packet */
    prev = pcb;
    pcb = pcb->next;
  }
  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rdx
leaq 0x169e4(%rip), %r15     # 0x1c770
movb $0x1, %r13b
cmpb $0x6, 0x50(%r15)
je 0x5dae
movl 0x3c(%r15), %edi
movq (%r15), %rsi
movq %rdx, %rbx
callq 0xe5e8
movq %rbx, %rdx
testb %al, %al
sete %r13b
movq 0x8(%rdx), %rbx
movb (%rbx), %cl
andb $-0x10, %cl
xorl %eax, %eax
cmpb $0x60, %cl
setne %sil
movq 0x16b29(%rip), %rcx     # 0x1c8f0
testq %rcx, %rcx
je 0x5f73
movb %sil, %al
leaq (%rax,%rax,2), %rax
movb 0x6(%rbx,%rax), %bpl
xorl %r14d, %r14d
leaq 0x24(%r15), %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movq %r14, %r11
movq %rcx, %r14
cmpb %bpl, 0x40(%rcx)
jne 0x5f64
movb 0x30(%r14), %cl
testb %cl, %cl
je 0x5e19
movq 0x8(%r15), %rsi
movb 0xee(%rsi), %sil
incb %sil
cmpb %sil, %cl
jne 0x5f64
movb 0x14(%r14), %sil
cmpb $0x2e, %sil
jne 0x5e72
testb $0x1, 0x41(%r14)
jne 0x5ef3
movq 0x48(%r14), %r8
testq %r8, %r8
je 0x5f64
movq %r11, 0x8(%rsp)
movq 0x50(%r14), %rdi
movq %r14, %rsi
movq 0x10(%rsp), %rcx
movq %rdx, %r12
callq *%r8
testb %al, %al
jne 0x5f84
movl $0x2, %eax
cmpq %rbx, 0x8(%r12)
movq %r12, %rdx
je 0x5f64
jmp 0x5faf
cmpb 0x50(%r15), %sil
jne 0x5f64
testb %r13b, %r13b
je 0x5f3d
movl (%r14), %ecx
cmpb $0x6, %sil
jne 0x5f52
testl %ecx, %ecx
jne 0x5eaf
cmpl $0x0, 0x4(%r14)
jne 0x5eaf
cmpl $0x0, 0x8(%r14)
jne 0x5eaf
cmpl $0x0, 0xc(%r14)
je 0x5e23
cmpl 0x3c(%r15), %ecx
jne 0x5f64
movl 0x4(%r14), %ecx
cmpl 0x40(%r15), %ecx
jne 0x5f64
movl 0x8(%r14), %ecx
cmpl 0x44(%r15), %ecx
jne 0x5f64
movl 0xc(%r14), %ecx
cmpl 0x48(%r15), %ecx
jne 0x5f64
movb 0x10(%r14), %cl
cmpb 0x4c(%r15), %cl
je 0x5e23
jmp 0x5f64
movb 0x2c(%r14), %r8b
cmpb 0x38(%r15), %r8b
jne 0x5f64
movl 0x18(%r14), %ecx
movl 0x24(%r15), %esi
cmpb $0x6, %r8b
jne 0x5f48
cmpl %esi, %ecx
jne 0x5f64
movl 0x1c(%r14), %ecx
cmpl 0x28(%r15), %ecx
jne 0x5f64
movl 0x20(%r14), %ecx
cmpl 0x2c(%r15), %ecx
jne 0x5f64
movl 0x24(%r14), %ecx
cmpl 0x30(%r15), %ecx
jne 0x5f64
movb 0x28(%r14), %cl
cmpb 0x34(%r15), %cl
je 0x5e2e
jmp 0x5f64
cmpl $0x0, (%r14)
jne 0x5f64
jmp 0x5e23
cmpl %esi, %ecx
je 0x5e2e
jmp 0x5f64
testl %ecx, %ecx
je 0x5e23
cmpl 0x3c(%r15), %ecx
je 0x5e23
movq 0x38(%r14), %rcx
testq %rcx, %rcx
jne 0x5dea
jmp 0x5f75
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0x5f75
movq 0x38(%r14), %rcx
movq %rcx, 0x38(%rdx)
movq 0x1694e(%rip), %rcx     # 0x1c8f0
movq %rcx, 0x38(%r14)
movq %r14, 0x16943(%rip)     # 0x1c8f0
jmp 0x5f75
leaq 0xe316(%rip), %rdi      # 0x142cc
leaq 0xec0f(%rip), %rsi      # 0x14bcc
leaq 0xec51(%rip), %rcx      # 0x14c15
movl $0xc1, %edx
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050