// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv4/ip4_frag.c
// Function: ip_reass_free_complete_datagram
static int
ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev)
{
  u16_t pbufs_freed = 0;
  u16_t clen;
  struct pbuf *p;
  struct ip_reass_helper *iprh;

  LWIP_ASSERT("prev != ipr", prev != ipr);
  if (prev != NULL) {
    LWIP_ASSERT("prev->next == ipr", prev->next == ipr);
  }

  MIB2_STATS_INC(mib2.ipreasmfails);
#if LWIP_ICMP
  iprh = (struct ip_reass_helper *)ipr->p->payload;
  if (iprh->start == 0) {
    /* The first fragment was received, send ICMP time exceeded. */
    /* First, de-queue the first pbuf from r->p. */
    p = ipr->p;
    ipr->p = iprh->next_pbuf;
    /* Then, copy the original header into it. */
    SMEMCPY(p->payload, &ipr->iphdr, IP_HLEN);
    icmp_time_exceeded(p, ICMP_TE_FRAG);
    clen = pbuf_clen(p);
    LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff);
    pbufs_freed = (u16_t)(pbufs_freed + clen);
    pbuf_free(p);
  }
#endif /* LWIP_ICMP */

  /* First, free all received pbufs.  The individual pbufs need to be released
     separately as they have not yet been chained */
  p = ipr->p;
  while (p != NULL) {
    struct pbuf *pcur;
    iprh = (struct ip_reass_helper *)p->payload;
    pcur = p;
    /* get the next pointer before freeing */
    p = iprh->next_pbuf;
    clen = pbuf_clen(pcur);
    LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff);
    pbufs_freed = (u16_t)(pbufs_freed + clen);
    pbuf_free(pcur);
  }
  /* Then, unchain the struct ip_reassdata from the list and free it. */
  ip_reass_dequeue_datagram(ipr, prev);
  LWIP_ASSERT("ip_reass_pbufcount >= pbufs_freed", ip_reass_pbufcount >= pbufs_freed);
  ip_reass_pbufcount = (u16_t)(ip_reass_pbufcount - pbufs_freed);

  return pbufs_freed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpq %rdi, %rsi
je 0xea77
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0xe99e
cmpq %r14, (%rbx)
jne 0xeaaf
movq 0x8(%r14), %r15
movq 0x8(%r15), %rax
cmpw $0x0, 0x8(%rax)
je 0xe9b1
xorl %ebp, %ebp
jmp 0xe9ef
movq (%rax), %rcx
movq %rcx, 0x8(%r14)
movl 0x20(%r14), %ecx
movl %ecx, 0x10(%rax)
movups 0x10(%r14), %xmm0
movups %xmm0, (%rax)
movq %r15, %rdi
movl $0x1, %esi
callq 0xe110
movq %r15, %rdi
callq 0x539e
movl %eax, %ebp
movq %r15, %rdi
callq 0x4fdf
movq 0x8(%r14), %r15
testq %r15, %r15
je 0xea1e
movq 0x8(%r15), %rax
movq (%rax), %r12
movq %r15, %rdi
callq 0x539e
movzwl %bp, %ecx
movzwl %ax, %ebp
addl %ecx, %ebp
cmpl $0x10000, %ebp          # imm = 0x10000
jae 0xea4a
movq %r15, %rdi
callq 0x4fdf
movq %r12, %r15
testq %r12, %r12
jne 0xe9ef
movq %r14, %rdi
movq %rbx, %rsi
callq 0xeffa
movzwl 0xdf98(%rip), %ecx      # 0x1c9c8
cmpw %bp, %cx
jb 0xea93
movzwl %bp, %eax
subl %ebp, %ecx
movw %cx, 0xdf87(%rip)       # 0x1c9c8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x587b(%rip), %rdi      # 0x142cc
leaq 0x7a2d(%rip), %rsi      # 0x16485
leaq 0x797a(%rip), %rcx      # 0x163d9
movl $0xcc, %edx
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0x584e(%rip), %rdi      # 0x142cc
leaq 0x79e2(%rip), %rsi      # 0x16467
leaq 0x794d(%rip), %rcx      # 0x163d9
movl $0xab, %edx
jmp 0xea64
leaq 0x5832(%rip), %rdi      # 0x142cc
leaq 0x7a01(%rip), %rsi      # 0x164a2
leaq 0x7931(%rip), %rcx      # 0x163d9
movl $0xd2, %edx
jmp 0xea64
leaq 0x5816(%rip), %rdi      # 0x142cc
leaq 0x79b6(%rip), %rsi      # 0x16473
leaq 0x7915(%rip), %rcx      # 0x163d9
movl $0xad, %edx
jmp 0xea64