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

```asm
<twiddler_key>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  call   <twiddler_get_table@plt>
  test   %rax,%rax
  je     L103
  mov    %rax,%rbp
  movzbl %bl,%ebx
  movslq D213(%rip),%rax
  cmp    %rbx,%rax
  jbe    L70
  cmpl   $0x0,D194(%rip)
  je     L63
L62:
  mov    %ebx,D282(%rip)
  mov    $0x0,%eax
L72:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L63:
  movl   $0x1,D194(%rip)
  mov    0x0(%rbp,%rax,8),%rdi
  call   <twiddler_use_item@plt>
  mov    D282(%rip),%eax
  cmp    %eax,D282(%rip)
  jne    L46
L117:
  mov    D282(%rip),%eax
  mov    %eax,D38(%rip)
  cltq
  cmp    %rbx,%rax
  ja     L62
L70:
  movslq D38(%rip),%rdx
  cmp    %rbx,%rdx
  je     L149
  movl   $0x0,D194(%rip)
  mov    %ebx,D38(%rip)
  mov    $0x0,%eax
  jmp    L72
L46:
  movl   $0x1,D38(%rip)
  mov    $0x0,%esi
  lea    D21(%rip),%rdi
  call   <gettimeofday@plt>
  jmp    L117
L149:
  cmp    %rax,%rbx
  ja     L120
  mov    $0x0,%eax
  cmpl   $0x2,D38(%rip)
  jne    L72
  mov    $0x0,%esi
  lea    D21(%rip),%rdi
  call   <gettimeofday@plt>
  mov    D21(%rip),%edx
  sub    D107(%rip),%edx
  imul   $0x3e8,%edx,%edx
  mov    D200(%rip),%ecx
  sub    D33(%rip),%ecx
  movslq %ecx,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  add    %eax,%edx
  mov    $0x1,%eax
  cmp    $0x1f4,%edx
  jle    L72
  mov    0x0(%rbp,%rbx,8),%rdi
  call   <twiddler_use_item@plt>
  mov    $0x1,%eax
  jmp    L72
L120:
  movl   $0x0,D194(%rip)
  mov    $0x0,%esi
  lea    D107(%rip),%rdi
  call   <gettimeofday@plt>
  mov    D107(%rip),%eax
  sub    D21(%rip),%eax
  imul   $0x3e8,%eax,%eax
  mov    D33(%rip),%ecx
  sub    D200(%rip),%ecx
  movslq %ecx,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  sar    $0x26,%rdx
  sar    $0x1f,%ecx
  sub    %ecx,%edx
  add    %edx,%eax
  cmp    $0x12b,%eax
  jle    L52
  movl   $0x1,D38(%rip)
  mov    %ebx,D115(%rip)
  mov    $0x0,%esi
  lea    D21(%rip),%rdi
  call   <gettimeofday@plt>
  mov    $0x1,%eax
  jmp    L72
L103:
  mov    $0x0,%eax
  jmp    L72
L52:
  movl   $0x2,D38(%rip)
  mov    %ebx,D115(%rip)
  mov    $0x1,%eax
  jmp    L72
```

assistant: ```c
int twiddler_key(unsigned long message) {
  char **table = twiddler_get_table(message);
  char *val;
  static int last_message;
  static int marked;
  static struct timeval tv1, tv2;
  static int nclick, last_pressed;
  if (!table)
    return 0;
  message &= 0xff;
  val = table[message];
  if ((message < last_message) && !marked) {
    marked++;
    twiddler_use_item(table[last_message]);
    if (last_pressed != last_message) {
      nclick = 1;
      (gettimeofday(&tv1, (struct timezone *)NULL));
    }
    last_pressed = last_message;
  }
  if (message < last_message) {
    last_message = message;
    return 0;
  }
  if (message != last_pressed) {
    marked = 0;
    last_message = message;
    return 0;
  }
  if (message > last_message) {
    marked = 0;
    (gettimeofday(&tv2, (struct timezone *)NULL));
    nclick = 1 + (((tv2.tv_sec - tv1.tv_sec) * 1000 + (tv2.tv_usec - tv1.tv_usec) / 1000) < 300);
    last_message = message;
    if (nclick == 1)
      (gettimeofday(&tv1, (struct timezone *)NULL));
    return 1;
  }
  if (nclick == 2) {
    (gettimeofday(&tv1, (struct timezone *)NULL));
    if (((tv1.tv_sec - tv2.tv_sec) * 1000 + (tv1.tv_usec - tv2.tv_usec) / 1000) > 500)
      twiddler_use_item(table[message]);
    return 1;
  }
  return 0;
}
```