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

```asm
<speed2dir>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %edx,-0x1c(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L72
  cmpl   $0x0,-0x18(%rbp)
  jne    L72
  mov    $0x0,%eax
  jmp    L49
L72:
  cmpl   $0x0,-0x14(%rbp)
  jle    L80
  cmpl   $0x0,-0x18(%rbp)
  jns    L64
  negl   -0x18(%rbp)
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jle    L134
  mov    -0x14(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x18(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  mov    %eax,-0x4(%rbp)
  jmp    L53
L134:
  mov    -0x18(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  mov    %eax,%edx
  mov    $0x80,%eax
  sub    %edx,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L53
L64:
  mov    -0x14(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jle    L160
  mov    -0x18(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  sub    $0xffffff80,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L53
L160:
  mov    -0x14(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x18(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  mov    %eax,%edx
  mov    $0x100,%eax
  sub    %edx,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L53
L80:
  negl   -0x14(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  jle    L17
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jle    L40
  mov    -0x14(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x18(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  add    $0x100,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L53
L40:
  mov    -0x18(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  mov    %eax,%edx
  mov    $0x180,%eax
  sub    %edx,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L53
L17:
  negl   -0x18(%rbp)
  mov    -0x14(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jle    L39
  mov    -0x18(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  add    $0x180,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L53
L39:
  mov    -0x14(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x18(%rbp)
  mov    %eax,%edi
  call   <fastatan@plt>
  mov    %eax,%edx
  mov    $0x200,%eax
  sub    %edx,%eax
  mov    %eax,-0x4(%rbp)
L53:
  mov    -0x4(%rbp),%eax
  imul   -0x1c(%rbp),%eax
  add    $0x100,%eax
  sar    $0x9,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x1c(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jle    L79
  mov    -0x4(%rbp),%eax
  add    $0x1,%eax
  jmp    L49
L79:
  mov    $0x1,%eax
L49:
  leave
  ret
```

assistant: ```c
int speed2dir(int sx, int sy, int frames) {
  if (!sx && !sy)
    return 0;
  int at2;
  if (sx > 0) {
    if (sy < 0) {
      sy = -sy;
      if (sy > sx)
        at2 = fastatan(sx * 256 / sy);
      else
        at2 = 128 - fastatan(sy * 256 / sx);
    } else {
      if (sx > sy)
        at2 = 128 + fastatan(sy * 256 / sx);
      else
        at2 = 256 - fastatan(sx * 256 / sy);
    }
  } else {
    sx = -sx;
    if (sy > 0) {
      if (sy > sx)
        at2 = 256 + fastatan(sx * 256 / sy);
      else
        at2 = 384 - fastatan(sy * 256 / sx);
    } else {
      sy = -sy;
      if (sx > sy)
        at2 = 384 + fastatan(sy * 256 / sx);
      else
        at2 = 512 - fastatan(sx * 256 / sy);
    }
  }
  at2 = (at2 * frames + 256) >> 9;
  return at2 > frames - 1 ? 1 : at2 + 1;
}
```