user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<ip_checksum>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  movl   $0xffff,-0x28(%rbp)
  mov    -0x20(%rbp),%rax
  and    $0x3,%eax
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  je     L23
  mov    $0x4,%eax
  sub    -0x24(%rbp),%eax
  mov    %eax,%eax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  cmp    -0x40(%rbp),%rax
  jbe    L1
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x18(%rbp)
L1:
  movb   $0x0,-0x29(%rbp)
  mov    -0x24(%rbp),%eax
  lea    -0x29(%rbp),%rdx
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  movzbl -0x29(%rbp),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <ntohl@plt>
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x18(%rbp),%rax
  add    %rax,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  sub    %rax,-0x40(%rbp)
L23:
  mov    -0x40(%rbp),%rax
  and    $0xfffffffffffffffc,%rax
  mov    %rax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  jmp    L6
L77:
  mov    -0x20(%rbp),%rcx
  lea    -0x29(%rbp),%rax
  mov    $0x4,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  movzbl -0x29(%rbp),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <ntohl@plt>
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x28(%rbp)
  addq   $0x4,-0x20(%rbp)
L6:
  mov    -0x20(%rbp),%rax
  cmp    -0x10(%rbp),%rax
  jne    L77
  andq   $0x3,-0x40(%rbp)
  cmpq   $0x0,-0x40(%rbp)
  je     L66
  movb   $0x0,-0x29(%rbp)
  mov    -0x40(%rbp),%rdx
  mov    -0x20(%rbp),%rcx
  lea    -0x29(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  movzbl -0x29(%rbp),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <ntohl@plt>
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x28(%rbp)
L66:
  mov    $0x20,%edx
  mov    -0x28(%rbp),%eax
  mov    %edx,%ecx
  sar    %cl,%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x28(%rbp)
  jmp    L16
L8:
  mov    -0x28(%rbp),%eax
  movzwl %ax,%edx
  mov    -0x28(%rbp),%eax
  sar    $0x10,%eax
  add    %edx,%eax
  mov    %eax,-0x28(%rbp)
L16:
  mov    -0x28(%rbp),%eax
  sar    $0x10,%eax
  test   %eax,%eax
  jne    L8
  mov    -0x24(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L40
  mov    -0x28(%rbp),%eax
  sar    $0x8,%eax
  movzbl %al,%edx
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  or     %edx,%eax
  mov    %eax,-0x28(%rbp)
L40:
  mov    -0x28(%rbp),%eax
  not    %eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L30
  call   <__stack_chk_fail@plt>
L30:
  leave
  ret
```

assistant: ```c
uint16_t ip_checksum(void *vdata, size_t length) {
  char *data = (char *)vdata;
  uint64_t acc = 0xffff;
  unsigned int offset = ((uintptr_t)data) & 3;
  if (offset) {
    size_t count = 4 - offset;
    if (count > length)
      count = length;
    uint32_t word = 0;
    memcpy(offset + (char *)&word, data, count);
    acc += ntohl(word);
    data += count;
    length -= count;
  }
  char *data_end = data + (length & ~3);
  while (data != data_end) {
    uint32_t word;
    memcpy(&word, data, 4);
    acc += ntohl(word);
    data += 4;
  }
  length &= 3;
  if (length) {
    uint32_t word = 0;
    memcpy(&word, data, length);
    acc += ntohl(word);
  }
  acc = (acc & 0xffffffff) + (acc >> 32);
  while (acc >> 16) {
    acc = (acc & 0xffff) + (acc >> 16);
  }
  if (offset & 1) {
    acc = ((acc & 0xff00) >> 8) | ((acc & 0x00ff) << 8);
  }
  return htons(~acc);
}
```