// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/pbuf.c
// Function: pbuf_copy
err_t
pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
{
  size_t offset_to = 0, offset_from = 0, len;

  LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n",
              (const void *)p_to, (const void *)p_from));

  /* is the target big enough to hold the source? */
  LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) &&
             (p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;);

  /* iterate through pbuf chain */
  do {
    /* copy one part of the original chain */
    if ((p_to->len - offset_to) >= (p_from->len - offset_from)) {
      /* complete current p_from fits into current p_to */
      len = p_from->len - offset_from;
    } else {
      /* current p_from does not fit into current p_to */
      len = p_to->len - offset_to;
    }
    MEMCPY((u8_t *)p_to->payload + offset_to, (u8_t *)p_from->payload + offset_from, len);
    offset_to += len;
    offset_from += len;
    LWIP_ASSERT("offset_to <= p_to->len", offset_to <= p_to->len);
    LWIP_ASSERT("offset_from <= p_from->len", offset_from <= p_from->len);
    if (offset_from >= p_from->len) {
      /* on to next p_from (if any) */
      offset_from = 0;
      p_from = p_from->next;
    }
    if (offset_to == p_to->len) {
      /* on to next p_to (if any) */
      offset_to = 0;
      p_to = p_to->next;
      LWIP_ERROR("p_to != NULL", (p_to != NULL) || (p_from == NULL), return ERR_ARG;);
    }

    if ((p_from != NULL) && (p_from->len == p_from->tot_len)) {
      /* don't copy more than one packet! */
      LWIP_ERROR("pbuf_copy() does not allow packet queues!",
                 (p_from->next == NULL), return ERR_VAL;);
    }
    if ((p_to != NULL) && (p_to->len == p_to->tot_len)) {
      /* don't copy more than one packet! */
      LWIP_ERROR("pbuf_copy() does not allow packet queues!",
                 (p_to->next == NULL), return ERR_VAL;);
    }
  } while (p_from);
  LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy: end of chain reached.\n"));
  return ERR_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x56b3
movq %rsi, %rbx
testq %rsi, %rsi
je 0x56b3
movq %rdi, %r14
movzwl 0x10(%rdi), %eax
cmpw 0x10(%rbx), %ax
jb 0x56b3
xorl %r13d, %r13d
xorl %r12d, %r12d
movzwl 0x12(%r14), %eax
subq %r13, %rax
movzwl 0x12(%rbx), %r15d
subq %r12, %r15
cmpq %r15, %rax
cmovbq %rax, %r15
movq 0x8(%r14), %rdi
addq %r13, %rdi
movq 0x8(%rbx), %rsi
addq %r12, %rsi
movq %r15, %rdx
callq 0x2180
addq %r15, %r13
movzwl 0x12(%r14), %eax
cmpq %rax, %r13
ja 0x5616
addq %r15, %r12
movzwl 0x12(%rbx), %ecx
cmpq %rcx, %r12
ja 0x5632
jb 0x55b2
movq (%rbx), %rbx
xorl %r12d, %r12d
cmpq %rax, %r13
jne 0x55d1
movq (%r14), %r14
testq %r14, %r14
setne %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
je 0x564e
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x55ea
movzwl 0x12(%rbx), %eax
cmpw 0x10(%rbx), %ax
jne 0x55ea
cmpq $0x0, (%rbx)
jne 0x5686
testq %r14, %r14
je 0x5601
movzwl 0x12(%r14), %eax
cmpw 0x10(%r14), %ax
jne 0x5601
cmpq $0x0, (%r14)
jne 0x566a
testq %rbx, %rbx
jne 0x5560
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xecaf(%rip), %rdi      # 0x142cc
leaq 0xf40f(%rip), %rsi      # 0x14a33
leaq 0xf1fe(%rip), %rcx      # 0x14829
movl $0x3d9, %edx            # imm = 0x3D9
jmp 0x56a0
leaq 0xec93(%rip), %rdi      # 0x142cc
leaq 0xf40a(%rip), %rsi      # 0x14a4a
leaq 0xf1e2(%rip), %rcx      # 0x14829
movl $0x3da, %edx            # imm = 0x3DA
jmp 0x56a0
leaq 0xec77(%rip), %rdi      # 0x142cc
leaq 0xf409(%rip), %rsi      # 0x14a65
leaq 0xf1c6(%rip), %rcx      # 0x14829
movl $0x3e4, %edx            # imm = 0x3E4
jmp 0x56a0
leaq 0xec5b(%rip), %rdi      # 0x142cc
leaq 0xf3fa(%rip), %rsi      # 0x14a72
leaq 0xf1aa(%rip), %rcx      # 0x14829
movl $0x3ef, %edx            # imm = 0x3EF
jmp 0x56a0
leaq 0xec3f(%rip), %rdi      # 0x142cc
leaq 0xf3de(%rip), %rsi      # 0x14a72
leaq 0xf18e(%rip), %rcx      # 0x14829
movl $0x3ea, %edx            # imm = 0x3EA
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0xec12(%rip), %rdi      # 0x142cc
leaq 0xf342(%rip), %rsi      # 0x14a03
leaq 0xf161(%rip), %rcx      # 0x14829
movl $0x3ca, %edx            # imm = 0x3CA
jmp 0x56a0