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

```asm
<udp_calculate_checksum>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x2c(%rbp)
  movl   $0x11,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L17
L19:
  mov    -0x10(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x2c(%rbp),%eax
  sub    $0x8,%eax
  cmp    %eax,%edx
  jge    L96
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  movzwl %ax,%edx
  mov    -0x10(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  movzbl %al,%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  jmp    L1
L96:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  and    $0xffff,%eax
  mov    %eax,-0xc(%rbp)
L1:
  mov    -0xc(%rbp),%eax
  add    %eax,-0x8(%rbp)
  addl   $0x2,-0x10(%rbp)
L17:
  mov    -0x2c(%rbp),%eax
  sub    $0x8,%eax
  cmp    %eax,-0x10(%rbp)
  jl     L19
  movl   $0x0,-0x10(%rbp)
  jmp    L37
L24:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  movzwl %ax,%edx
  mov    -0x10(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  movzbl %al,%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  add    %eax,-0x8(%rbp)
  addl   $0x2,-0x10(%rbp)
L37:
  cmpl   $0x3,-0x10(%rbp)
  jle    L24
  movl   $0x0,-0x10(%rbp)
  jmp    L4
L6:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  movzwl %ax,%edx
  mov    -0x10(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  movzbl %al,%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  add    %eax,-0x8(%rbp)
  addl   $0x2,-0x10(%rbp)
L4:
  cmpl   $0x3,-0x10(%rbp)
  jle    L6
  mov    -0x8(%rbp),%edx
  mov    -0x4(%rbp),%eax
  add    %eax,%edx
  mov    -0x2c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L57
L93:
  mov    -0x8(%rbp),%eax
  movzwl %ax,%edx
  mov    -0x8(%rbp),%eax
  sar    $0x10,%eax
  add    %edx,%eax
  mov    %eax,-0x8(%rbp)
L57:
  mov    -0x8(%rbp),%eax
  sar    $0x10,%eax
  test   %eax,%eax
  jne    L93
  notl   -0x8(%rbp)
  mov    -0x8(%rbp),%eax
  movzwl %ax,%eax
  pop    %rbp
  ret
```

assistant: ```c
uint16_t udp_calculate_checksum(uint8_t *src_addr, uint8_t *dest_addr, uint8_t *payload, uint16_t udp_len) {
  uint32_t i;
  uint8_t prot_udp = 17;
  uint16_t word16;
  uint32_t sum;
  sum = 0;
  for (i = 0; i < udp_len - 8; i = i + 2) {
    if (i + 1 < udp_len - 8)
      word16 = ((payload[i] << 8) & 0xFF00) + (payload[i + 1] & 0x00FF);
    else
      word16 = ((payload[i] << 8) & 0xFF00);
    sum = sum + (uint32_t)word16;
  }
  for (i = 0; i < 4; i += 2) {
    word16 = ((src_addr[i] << 8) & 0xFF00) + (src_addr[i + 1] & 0xFF);
    sum = sum + word16;
  }
  for (i = 0; i < 4; i += 2) {
    word16 = ((dest_addr[i] << 8) & 0xFF00) + (dest_addr[i + 1] & 0xFF);
    sum = sum + word16;
  }
  sum = sum + prot_udp + udp_len;
  while (sum >> 16) {
    sum = (sum & 0xFFFF) + (sum >> 16);
  }
  sum = ~sum;
  return ((uint16_t)(sum & 0xFFFF));
}
```