// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw $0x0, -0x12(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x8(%rbp), %rax
jne 0x1a891
jmp 0x1a862
leaq 0xca63(%rip), %rdi      # 0x272cc
leaq 0xefef(%rip), %rsi      # 0x2985f
movl $0xab, %edx
leaq 0xef49(%rip), %rcx      # 0x297c5
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1a893
cmpq $0x0, -0x10(%rbp)
je 0x1a8de
jmp 0x1a89c
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x8(%rbp), %rax
je 0x1a8da
jmp 0x1a8ab
leaq 0xca1a(%rip), %rdi      # 0x272cc
leaq 0xefb2(%rip), %rsi      # 0x2986b
movl $0xad, %edx
leaq 0xef00(%rip), %rcx      # 0x297c5
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1a8dc
jmp 0x1a8de
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0x1a9b1
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq %rdx, (%rax)
movq 0x18(%rcx), %rdx
movq %rdx, 0x8(%rax)
movl 0x20(%rcx), %ecx
movl %ecx, 0x10(%rax)
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x19690
movq -0x20(%rbp), %rdi
callq 0x7bf0
movw %ax, -0x14(%rbp)
movzwl -0x12(%rbp), %eax
movzwl -0x14(%rbp), %ecx
addl %ecx, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jle 0x1a998
jmp 0x1a969
leaq 0xc95c(%rip), %rdi      # 0x272cc
leaq 0xef06(%rip), %rsi      # 0x2987d
movl $0xbc, %edx
leaq 0xee42(%rip), %rcx      # 0x297c5
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1a99a
movzwl -0x12(%rbp), %eax
movzwl -0x14(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0x12(%rbp)
movq -0x20(%rbp), %rdi
callq 0x7260
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1aa54
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
callq 0x7bf0
movw %ax, -0x14(%rbp)
movzwl -0x12(%rbp), %eax
movzwl -0x14(%rbp), %ecx
addl %ecx, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jle 0x1aa36
jmp 0x1aa07
leaq 0xc8be(%rip), %rdi      # 0x272cc
leaq 0xee68(%rip), %rsi      # 0x2987d
movl $0xcc, %edx
leaq 0xeda4(%rip), %rcx      # 0x297c5
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1aa38
movzwl -0x12(%rbp), %eax
movzwl -0x14(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0x12(%rbp)
movq -0x30(%rbp), %rdi
callq 0x7260
jmp 0x1a9bd
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1b690
movzwl 0x14f70(%rip), %eax     # 0x2f9d8
movzwl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1aaa1
jmp 0x1aa72
leaq 0xc853(%rip), %rdi      # 0x272cc
leaq 0xee1a(%rip), %rsi      # 0x2989a
movl $0xd2, %edx
leaq 0xed39(%rip), %rcx      # 0x297c5
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1aaa3
movzwl 0x14f2e(%rip), %eax     # 0x2f9d8
movzwl -0x12(%rbp), %ecx
subl %ecx, %eax
movw %ax, 0x14f21(%rip)      # 0x2f9d8
movzwl -0x12(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)