user: 请从给定的汇编指令推导出C源代码：

```asm
<tcp_checksum>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x24(%rbp),%eax
  add    $0x1,%eax
  sar    %eax
  mov    %ax,-0x14(%rbp)
  mov    D8(%rip),%rax
  mov    (%rax),%edx
  mov    -0x24(%rbp),%eax
  add    %edx,%eax
  cltq
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%rax
  movzwl (%rax),%eax
  movzwl %ax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x2,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x4,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x6,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %edx,%eax
  cltq
  add    %rax,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x24(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L46
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L46:
  mov    -0x10(%rbp),%rax
  movzwl (%rax),%eax
  movzwl %ax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x2,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x4,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x6,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x8,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0xa,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0xc,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0xe,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  add    $0x12,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %edx,%eax
  cltq
  add    %rax,-0x8(%rbp)
  addq   $0x14,-0x10(%rbp)
  subw   $0xa,-0x14(%rbp)
  jmp    L36
L40:
  mov    -0x10(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  movzwl (%rax),%eax
  movzwl %ax,%eax
  add    %rax,-0x8(%rbp)
L36:
  movzwl -0x14(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %dx,-0x14(%rbp)
  test   %ax,%ax
  jne    L40
  mov    -0x8(%rbp),%rax
  mov    %ax,-0x12(%rbp)
  jmp    L12
L1:
  movzwl -0x12(%rbp),%eax
  add    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %ax,-0x12(%rbp)
L12:
  shrq   $0x10,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L1
  movzwl -0x12(%rbp),%eax
  not    %eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned short tcp_checksum(int bytes, char *tcp_segment, char *net_addresses) {
  unsigned short *p = (unsigned short *)net_addresses;
  unsigned short x = (bytes + 1) >> 1;
  unsigned long sum = bytes + IPPROTO_TCP;
  unsigned short carry;
  sum += *p + p[1] + p[2] + p[3];
  p = (unsigned short *)tcp_segment;
  if (bytes & 1)
    tcp_segment[bytes] = 0;
  sum += *p + p[1] + p[2] + p[3] + p[4] + p[5] + p[6] + p[7] + p[9];
  p += 10;
  x -= 10;
  while (x--)
    sum += *p++;
  carry = sum;
  while (sum >>= 16) {
    sum += carry;
    carry = sum;
  }
  return carry ^ 65535;
}
```