// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
cmpq %rdi, %rsi
je 0xe43a
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0xe35e
cmpq %r14, (%rbx)
jne 0xe472
movq 0x8(%r14), %r15
movq 0x8(%r15), %rax
cmpw $0x0, 0x8(%rax)
je 0xe371
xorl %ebp, %ebp
jmp 0xe3d2
movq (%rax), %rcx
movq %rcx, 0x8(%r14)
movl 0x20(%r14), %ecx
movl %ecx, 0x10(%rax)
movups 0x10(%r14), %xmm0
movups %xmm0, (%rax)
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdb0b
movq %r15, %rdi
callq 0x51c5
movl %eax, %ebp
movq %r15, %rdi
callq 0x4e16
movq 0x8(%r14), %r15
jmp 0xe3d2
movq 0x8(%r15), %rax
movq (%rax), %r13
movq %r15, %rdi
callq 0x51c5
movzwl %ax, %ebp
addl %r12d, %ebp
cmpl $0x10000, %ebp          # imm = 0x10000
jae 0xe40d
movq %r15, %rdi
callq 0x4e16
movq %r13, %r15
movzwl %bp, %r12d
testq %r15, %r15
jne 0xe3aa
movq %r14, %rdi
movq %rbx, %rsi
callq 0xe9e2
movzwl 0xf5eb(%rip), %eax      # 0x1d9d8
cmpw %bp, %ax
jb 0xe456
subl %ebp, %eax
movw %ax, 0xf5dd(%rip)       # 0x1d9d8
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5eb8(%rip), %rdi      # 0x142cc
leaq 0x8082(%rip), %rsi      # 0x1649d
leaq 0x7fcf(%rip), %rcx      # 0x163f1
movl $0xcc, %edx
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0x5e8b(%rip), %rdi      # 0x142cc
leaq 0x8037(%rip), %rsi      # 0x1647f
leaq 0x7fa2(%rip), %rcx      # 0x163f1
movl $0xab, %edx
jmp 0xe427
leaq 0x5e6f(%rip), %rdi      # 0x142cc
leaq 0x8056(%rip), %rsi      # 0x164ba
leaq 0x7f86(%rip), %rcx      # 0x163f1
movl $0xd2, %edx
jmp 0xe427
leaq 0x5e53(%rip), %rdi      # 0x142cc
leaq 0x800b(%rip), %rsi      # 0x1648b
leaq 0x7f6a(%rip), %rcx      # 0x163f1
movl $0xad, %edx
jmp 0xe427