user: Please show me the C implementation that matches the assembly code listed below:

```asm
<getnextturn>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    %rdx,-0x10(%rbp)
  mov    %rcx,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <checkdir@plt>
  test   %rax,%rax
  je     L66
  mov    $0x0,%eax
  jmp    L115
L66:
  mov    -0x18(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    $0x2d,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rotate@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <checkdir@plt>
  test   %rax,%rax
  je     L16
  mov    $0x2d,%eax
  jmp    L115
L16:
  mov    -0x18(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    $0x10e,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rotate@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <checkdir@plt>
  test   %rax,%rax
  je     L58
  mov    $0x13b,%eax
  jmp    L115
L58:
  mov    -0x18(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    $0x87,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rotate@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <checkdir@plt>
  test   %rax,%rax
  je     L10
  mov    $0x5a,%eax
  jmp    L115
L10:
  mov    -0x18(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    $0xb4,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rotate@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <checkdir@plt>
  test   %rax,%rax
  je     L90
  mov    $0x10e,%eax
  jmp    L115
L90:
  mov    -0x18(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    $0xe1,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rotate@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <checkdir@plt>
  test   %rax,%rax
  je     L111
  mov    $0x87,%eax
  jmp    L115
L111:
  mov    -0x18(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    $0x5a,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rotate@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <checkdir@plt>
  test   %rax,%rax
  je     L122
  mov    $0xe1,%eax
  jmp    L115
L122:
  mov    $0xb4,%eax
L115:
  leave
  ret
```

assistant: ```c
int getnextturn(int x, int y, int *dx, int *dy) {
  if (checkdir(x, y, *dx, *dy)) {
    return 0;
  }
  rotate(dx, dy, 45);
  if (checkdir(x, y, *dx, *dy)) {
    return 45;
  }
  rotate(dx, dy, 270);
  if (checkdir(x, y, *dx, *dy)) {
    return 315;
  }
  rotate(dx, dy, 135);
  if (checkdir(x, y, *dx, *dy)) {
    return 90;
  }
  rotate(dx, dy, 180);
  if (checkdir(x, y, *dx, *dy)) {
    return 270;
  }
  rotate(dx, dy, 225);
  if (checkdir(x, y, *dx, *dy)) {
    return 135;
  }
  rotate(dx, dy, 90);
  if (checkdir(x, y, *dx, *dy)) {
    return 225;
  }
  return 180;
}
```