// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/pbuf.c
// Function: pbuf_copy_partial
u16_t
pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
{
  const struct pbuf *p;
  u16_t left = 0;
  u16_t buf_copy_len;
  u16_t copied_total = 0;

  LWIP_ERROR("pbuf_copy_partial: invalid buf", (buf != NULL), return 0;);
  LWIP_ERROR("pbuf_copy_partial: invalid dataptr", (dataptr != NULL), return 0;);

  /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */
  for (p = buf; len != 0 && p != NULL; p = p->next) {
    if ((offset != 0) && (offset >= p->len)) {
      /* don't copy from this buffer -> on to the next */
      offset = (u16_t)(offset - p->len);
    } else {
      /* copy from this buffer. maybe only partially. */
      buf_copy_len = (u16_t)(p->len - offset);
      if (buf_copy_len > len) {
        buf_copy_len = len;
      }
      /* copy the necessary parts of the buffer */
      MEMCPY(&((char *)dataptr)[left], &((char *)p->payload)[offset], buf_copy_len);
      copied_total = (u16_t)(copied_total + buf_copy_len);
      left = (u16_t)(left + buf_copy_len);
      len = (u16_t)(len - buf_copy_len);
      offset = 0;
    }
  }
  return copied_total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %cx, %ax
movw %dx, %cx
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %cx, -0x1a(%rbp)
movw %ax, -0x1c(%rbp)
movw $0x0, -0x2a(%rbp)
movw $0x0, -0x2e(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x82b2
jmp 0x8283
leaq 0x1f042(%rip), %rdi     # 0x272cc
leaq 0x1f8c6(%rip), %rsi     # 0x27b57
movl $0x40a, %edx            # imm = 0x40A
leaq 0x1f60c(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x82b4
jmp 0x82b6
cmpq $0x0, -0x18(%rbp)
jne 0x82ee
jmp 0x82bf
leaq 0x1f006(%rip), %rdi     # 0x272cc
leaq 0x1f8a9(%rip), %rsi     # 0x27b76
movl $0x40b, %edx            # imm = 0x40B
leaq 0x1f5d0(%rip), %rcx     # 0x278a9
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x82f0
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movzwl -0x1a(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2f(%rbp)
je 0x8311
cmpq $0x0, -0x28(%rbp)
setne %al
movb %al, -0x2f(%rbp)
movb -0x2f(%rbp), %al
testb $0x1, %al
jne 0x831d
jmp 0x83d7
movzwl -0x1c(%rbp), %eax
cmpl $0x0, %eax
je 0x834a
movzwl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpl %ecx, %eax
jl 0x834a
movzwl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x1c(%rbp)
jmp 0x83c5
movq -0x28(%rbp), %rax
movzwl 0x12(%rax), %eax
movzwl -0x1c(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0x2c(%rbp)
movzwl -0x2c(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
jle 0x8370
movw -0x1a(%rbp), %ax
movw %ax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
movzwl -0x2a(%rbp), %eax
addq %rax, %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
movzwl -0x1c(%rbp), %eax
addq %rax, %rsi
movzwl -0x2c(%rbp), %eax
movl %eax, %edx
callq 0x2180
movzwl -0x2e(%rbp), %eax
movzwl -0x2c(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0x2e(%rbp)
movzwl -0x2a(%rbp), %eax
movzwl -0x2c(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0x2a(%rbp)
movzwl -0x1a(%rbp), %eax
movzwl -0x2c(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0x1a(%rbp)
movw $0x0, -0x1c(%rbp)
jmp 0x83c7
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x82f8
movw -0x2e(%rbp), %ax
movw %ax, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)