// File: /workspace/github_c_makefile_star2_O2/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 0x54c7
movq %rsi, %rbx
testq %rsi, %rsi
je 0x54c7
movq %rdi, %r14
movzwl 0x10(%rdi), %eax
cmpw 0x10(%rbx), %ax
jb 0x54c7
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 0x542a
addq %r15, %r12
movzwl 0x12(%rbx), %ecx
cmpq %rcx, %r12
ja 0x5446
jb 0x53c6
movq (%rbx), %rbx
xorl %r12d, %r12d
cmpq %rax, %r13
jne 0x53e5
movq (%r14), %r14
testq %r14, %r14
setne %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
je 0x5462
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x53fe
movzwl 0x12(%rbx), %eax
cmpw 0x10(%rbx), %ax
jne 0x53fe
cmpq $0x0, (%rbx)
jne 0x549a
testq %r14, %r14
je 0x5415
movzwl 0x12(%r14), %eax
cmpw 0x10(%r14), %ax
jne 0x5415
cmpq $0x0, (%r14)
jne 0x547e
testq %rbx, %rbx
jne 0x5374
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xee9b(%rip), %rdi      # 0x142cc
leaq 0xf5fb(%rip), %rsi      # 0x14a33
leaq 0xf3ea(%rip), %rcx      # 0x14829
movl $0x3d9, %edx            # imm = 0x3D9
jmp 0x54b4
leaq 0xee7f(%rip), %rdi      # 0x142cc
leaq 0xf5f6(%rip), %rsi      # 0x14a4a
leaq 0xf3ce(%rip), %rcx      # 0x14829
movl $0x3da, %edx            # imm = 0x3DA
jmp 0x54b4
leaq 0xee63(%rip), %rdi      # 0x142cc
leaq 0xf5f5(%rip), %rsi      # 0x14a65
leaq 0xf3b2(%rip), %rcx      # 0x14829
movl $0x3e4, %edx            # imm = 0x3E4
jmp 0x54b4
leaq 0xee47(%rip), %rdi      # 0x142cc
leaq 0xf5e6(%rip), %rsi      # 0x14a72
leaq 0xf396(%rip), %rcx      # 0x14829
movl $0x3ef, %edx            # imm = 0x3EF
jmp 0x54b4
leaq 0xee2b(%rip), %rdi      # 0x142cc
leaq 0xf5ca(%rip), %rsi      # 0x14a72
leaq 0xf37a(%rip), %rcx      # 0x14829
movl $0x3ea, %edx            # imm = 0x3EA
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0xedfe(%rip), %rdi      # 0x142cc
leaq 0xf52e(%rip), %rsi      # 0x14a03
leaq 0xf34d(%rip), %rcx      # 0x14829
movl $0x3ca, %edx            # imm = 0x3CA
jmp 0x54b4