// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
jmp 0x7f92
jmp 0x7f94
cmpq $0x0, -0x10(%rbp)
je 0x7fb6
cmpq $0x0, -0x18(%rbp)
je 0x7fb6
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %eax
movq -0x18(%rbp), %rcx
movzwl 0x10(%rcx), %ecx
cmpl %ecx, %eax
jge 0x7fe7
jmp 0x7fb8
leaq 0x1f30d(%rip), %rdi     # 0x272cc
leaq 0x1faf8(%rip), %rsi     # 0x27abe
movl $0x3ca, %edx            # imm = 0x3CA
leaq 0x1f8d7(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x7fe9
jmp 0x7feb
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
subq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
subq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jb 0x801a
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %eax
subq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x802a
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
subq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
addq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
addq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x2180
movq -0x30(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpq %rcx, %rax
jbe 0x80a5
jmp 0x8076
leaq 0x1f24f(%rip), %rdi     # 0x272cc
leaq 0x1fa6a(%rip), %rsi     # 0x27aee
movl $0x3d9, %edx            # imm = 0x3D9
leaq 0x1f819(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x80a7
jmp 0x80a9
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpq %rcx, %rax
jbe 0x80eb
jmp 0x80bc
leaq 0x1f209(%rip), %rdi     # 0x272cc
leaq 0x1fa3b(%rip), %rsi     # 0x27b05
movl $0x3da, %edx            # imm = 0x3DA
leaq 0x1f7d3(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x80ed
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpq %rcx, %rax
jb 0x8111
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpq %rcx, %rax
jne 0x8178
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x8174
cmpq $0x0, -0x18(%rbp)
je 0x8174
jmp 0x8145
leaq 0x1f180(%rip), %rdi     # 0x272cc
leaq 0x1f9cd(%rip), %rsi     # 0x27b20
movl $0x3e4, %edx            # imm = 0x3E4
leaq 0x1f74a(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x8176
jmp 0x8178
cmpq $0x0, -0x18(%rbp)
je 0x81d4
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %eax
movq -0x18(%rbp), %rcx
movzwl 0x10(%rcx), %ecx
cmpl %ecx, %eax
jne 0x81d4
jmp 0x8195
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x81d0
jmp 0x81a1
leaq 0x1f124(%rip), %rdi     # 0x272cc
leaq 0x1f97e(%rip), %rsi     # 0x27b2d
movl $0x3ea, %edx            # imm = 0x3EA
leaq 0x1f6ee(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x81d2
jmp 0x81d4
cmpq $0x0, -0x10(%rbp)
je 0x8230
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
movq -0x10(%rbp), %rcx
movzwl 0x10(%rcx), %ecx
cmpl %ecx, %eax
jne 0x8230
jmp 0x81f1
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x822c
jmp 0x81fd
leaq 0x1f0c8(%rip), %rdi     # 0x272cc
leaq 0x1f922(%rip), %rsi     # 0x27b2d
movl $0x3ef, %edx            # imm = 0x3EF
leaq 0x1f692(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x822e
jmp 0x8230
jmp 0x8232
cmpq $0x0, -0x18(%rbp)
jne 0x7feb
jmp 0x823f
jmp 0x8241
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x30, %rsp
popq %rbp
retq
nop