user: Converte this assembly snippet into its equivalent C code:

```asm
<tcp_sum_calc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x4c(%rbp)
  mov    %r8,-0x58(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    D2(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x4c(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L27
  movq   $0x1,-0x20(%rbp)
  mov    -0x38(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movq   $0x0,(%rax)
L27:
  movq   $0x0,-0x28(%rbp)
  jmp    L25
L75:
  mov    -0x28(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  shl    $0x8,%rax
  movzwl %ax,%edx
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x58(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  movzbl %al,%eax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  add    %rax,-0x18(%rbp)
  addq   $0x2,-0x28(%rbp)
L25:
  mov    -0x38(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x28(%rbp)
  jb     L75
  movq   $0x0,-0x28(%rbp)
  jmp    L41
L88:
  mov    -0x28(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  shl    $0x8,%rax
  movzwl %ax,%edx
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  movzbl %al,%eax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  add    %rax,-0x18(%rbp)
  addq   $0x2,-0x28(%rbp)
L41:
  cmpq   $0x3,-0x28(%rbp)
  jbe    L88
  movq   $0x0,-0x28(%rbp)
  jmp    L64
L61:
  mov    -0x28(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  shl    $0x8,%rax
  movzwl %ax,%edx
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  movzbl %al,%eax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  add    %rax,-0x18(%rbp)
  addq   $0x2,-0x28(%rbp)
L64:
  cmpq   $0x3,-0x28(%rbp)
  jbe    L61
  mov    -0x10(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  add    %rax,-0x18(%rbp)
  jmp    L72
L83:
  mov    -0x18(%rbp),%rax
  movzwl %ax,%edx
  mov    -0x18(%rbp),%rax
  shr    $0x10,%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
L72:
  mov    -0x18(%rbp),%rax
  shr    $0x10,%rax
  test   %rax,%rax
  jne    L83
  notq   -0x18(%rbp)
  mov    -0x18(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
uint16_t tcp_sum_calc(uint16_t len_tcp, uint16_t src_addr[], uint16_t dest_addr[], uint8_t padding, uint16_t buff[]) {
  uint32_t i;
  uint16_t padd = 0;
  uint16_t word16;
  uint32_t sum = 0;
  uint16_t prot_tcp = IPPROTO_TCP;
  if ((padding & 1) == 1) {
    padd = 1;
    buff[len_tcp] = 0;
  }
  for (i = 0; i < len_tcp + padd; i = i + 2) {
    word16 = ((buff[i] << 8) & 0xFF00) + (buff[i + 1] & 0xFF);
    sum += (unsigned long)word16;
  }
  for (i = 0; i < 4; i = i + 2) {
    word16 = ((src_addr[i] << 8) & 0xFF00) + (src_addr[i + 1] & 0xFF);
    sum += word16;
  }
  for (i = 0; i < 4; i = i + 2) {
    word16 = ((dest_addr[i] << 8) & 0xFF00) + (dest_addr[i + 1] & 0xFF);
    sum += word16;
  }
  sum += (prot_tcp + len_tcp);
  while (sum >> 16)
    sum = (sum & 0xFFFF) + (sum >> 16);
  sum = ~sum;
  return (uint16_t)sum;
}
```