// File: /workspace/github_c_makefile_star2_O1/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 0xed0f
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0xec36
cmpq %r14, (%rbx)
jne 0xed47
movq 0x8(%r14), %r15
movq 0x8(%r15), %rax
cmpw $0x0, 0x8(%rax)
je 0xec49
xorl %ebp, %ebp
jmp 0xec7e
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 0xe3a6
movq %r15, %rdi
callq 0x5425
movl %eax, %ebp
movq %r15, %rdi
callq 0x5069
movq 0x8(%r14), %r15
testq %r15, %r15
je 0xecb6
movq 0x8(%r15), %rax
movq (%rax), %r12
movq %r15, %rdi
callq 0x5425
movzwl %bp, %ecx
movzwl %ax, %ebp
addl %ecx, %ebp
cmpl $0x10000, %ebp          # imm = 0x10000
jae 0xece2
movq %r15, %rdi
callq 0x5069
movq %r12, %r15
testq %r12, %r12
jne 0xec87
movq %r14, %rdi
movq %rbx, %rsi
callq 0xf37e
movzwl 0xed00(%rip), %ecx      # 0x1d9c8
cmpw %bp, %cx
jb 0xed2b
movzwl %bp, %eax
subl %ebp, %ecx
movw %cx, 0xecef(%rip)       # 0x1d9c8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x65e3(%rip), %rdi      # 0x152cc
leaq 0x87cd(%rip), %rsi      # 0x174bd
leaq 0x871a(%rip), %rcx      # 0x17411
movl $0xcc, %edx
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0x65b6(%rip), %rdi      # 0x152cc
leaq 0x8782(%rip), %rsi      # 0x1749f
leaq 0x86ed(%rip), %rcx      # 0x17411
movl $0xab, %edx
jmp 0xecfc
leaq 0x659a(%rip), %rdi      # 0x152cc
leaq 0x87a1(%rip), %rsi      # 0x174da
leaq 0x86d1(%rip), %rcx      # 0x17411
movl $0xd2, %edx
jmp 0xecfc
leaq 0x657e(%rip), %rdi      # 0x152cc
leaq 0x8756(%rip), %rsi      # 0x174ab
leaq 0x86b5(%rip), %rcx      # 0x17411
movl $0xad, %edx
jmp 0xecfc