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

```asm
<utf8_validate_char>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x1(%rbp)
  movzbl -0x1(%rbp),%eax
  test   %al,%al
  js     L344
  mov    $0x1,%eax
  jmp    L317
L344:
  cmpb   $0xc1,-0x1(%rbp)
  ja     L338
  mov    $0x0,%eax
  jmp    L317
L338:
  cmpb   $0xdf,-0x1(%rbp)
  ja     L347
  mov    -0x20(%rbp),%rax
  sub    -0x18(%rbp),%rax
  test   %rax,%rax
  jg     L107
  mov    $0x0,%eax
  jmp    L317
L107:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L304
  mov    $0x0,%eax
  jmp    L317
L304:
  mov    $0x2,%eax
  jmp    L317
L347:
  cmpb   $0xef,-0x1(%rbp)
  ja     L161
  mov    -0x20(%rbp),%rax
  sub    -0x18(%rbp),%rax
  cmp    $0x1,%rax
  jg     L56
  mov    $0x0,%eax
  jmp    L317
L56:
  cmpb   $0xe0,-0x1(%rbp)
  jne    L134
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x9f,%al
  ja     L134
  mov    $0x0,%eax
  jmp    L317
L134:
  cmpb   $0xed,-0x1(%rbp)
  jne    L328
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x9f,%al
  jbe    L328
  mov    $0x0,%eax
  jmp    L317
L328:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L202
  mov    $0x0,%eax
  jmp    L317
L202:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L384
  mov    $0x0,%eax
  jmp    L317
L384:
  mov    $0x3,%eax
  jmp    L317
L161:
  cmpb   $0xf4,-0x1(%rbp)
  ja     L132
  mov    -0x20(%rbp),%rax
  sub    -0x18(%rbp),%rax
  cmp    $0x2,%rax
  jg     L7
  mov    $0x0,%eax
  jmp    L317
L7:
  cmpb   $0xf0,-0x1(%rbp)
  jne    L109
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x8f,%al
  ja     L109
  mov    $0x0,%eax
  jmp    L317
L109:
  cmpb   $0xf4,-0x1(%rbp)
  jne    L41
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x8f,%al
  jbe    L41
  mov    $0x0,%eax
  jmp    L317
L41:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L193
  mov    $0x0,%eax
  jmp    L317
L193:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L381
  mov    $0x0,%eax
  jmp    L317
L381:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L57
  mov    $0x0,%eax
  jmp    L317
L57:
  mov    $0x4,%eax
  jmp    L317
L132:
  mov    $0x0,%eax
L317:
  pop    %rbp
  ret
```

assistant: ```c
int utf8_validate_char(const char *s, const char *e) {
  unsigned char c = *s++;
  if (c <= 0x7F) {
    return 1;
  } else if (c <= 0xC1) {
    return 0;
  } else if (c <= 0xDF) {
    if (e - s < 1)
      return 0;
    if (((unsigned char)*s++ & 0xC0) != 0x80)
      return 0;
    return 2;
  } else if (c <= 0xEF) {
    if (e - s < 2)
      return 0;
    if (c == 0xE0 && (unsigned char)*s < 0xA0)
      return 0;
    if (c == 0xED && (unsigned char)*s > 0x9F)
      return 0;
    if (((unsigned char)*s++ & 0xC0) != 0x80)
      return 0;
    if (((unsigned char)*s++ & 0xC0) != 0x80)
      return 0;
    return 3;
  } else if (c <= 0xF4) {
    if (e - s < 3)
      return 0;
    if (c == 0xF0 && (unsigned char)*s < 0x90)
      return 0;
    if (c == 0xF4 && (unsigned char)*s > 0x8F)
      return 0;
    if (((unsigned char)*s++ & 0xC0) != 0x80)
      return 0;
    if (((unsigned char)*s++ & 0xC0) != 0x80)
      return 0;
    if (((unsigned char)*s++ & 0xC0) != 0x80)
      return 0;
    return 4;
  } else {
    return 0;
  }
}
```