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

```asm
<solve>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    -0x28(%rbp),%rax
  imul   $0x2260,%rax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  mov    (%rdx,%rax,8),%rax
  cmp    $0xffffffffffffffff,%rax
  jne    L30
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <legal@plt>
  test   %rax,%rax
  je     L55
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdi
  mov    -0x48(%rbp),%rsi
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rsi,%r8
  mov    %rax,%rsi
  call   <solve>
L55:
  mov    -0x30(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <legal@plt>
  test   %rax,%rax
  je     L95
  mov    -0x30(%rbp),%rax
  lea    -0x1(%rax),%rsi
  mov    -0x48(%rbp),%rdi
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <solve>
L95:
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <legal@plt>
  test   %rax,%rax
  je     L90
  mov    -0x28(%rbp),%rax
  imul   $0x2260,%rax,%rax
  lea    -0x2260(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  mov    (%rdx,%rax,8),%rcx
  mov    -0x28(%rbp),%rax
  imul   $0x2260,%rax,%rdx
  mov    -0x40(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  mov    (%rdx,%rax,8),%rax
  add    %rcx,%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L1
L90:
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
L1:
  mov    -0x30(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <legal@plt>
  test   %rax,%rax
  je     L69
  mov    -0x28(%rbp),%rax
  imul   $0x2260,%rax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    -0x30(%rbp),%rdx
  sub    $0x1,%rdx
  mov    (%rax,%rdx,8),%rcx
  mov    -0x28(%rbp),%rax
  imul   $0x2260,%rax,%rdx
  mov    -0x40(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  mov    (%rdx,%rax,8),%rax
  add    %rcx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L47
L69:
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
L47:
  mov    -0x10(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jge    L70
  mov    -0x28(%rbp),%rax
  imul   $0x2260,%rax,%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x30(%rbp),%rax
  mov    -0x20(%rbp),%rdx
  mov    %rdx,(%rcx,%rax,8)
  mov    -0x28(%rbp),%rax
  imul   $0x44c,%rax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x44,(%rax)
  jmp    L39
L70:
  mov    -0x28(%rbp),%rax
  imul   $0x2260,%rax,%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x30(%rbp),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,(%rcx,%rax,8)
  mov    -0x28(%rbp),%rax
  imul   $0x44c,%rax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x52,(%rax)
  jmp    L39
L30:
  nop
L39:
  leave
  ret
```

assistant: ```c
void solve(long long i, long long j, long long af[1100][1100], long long f[1100][1100], char p[1100][1100]) {
  long long a, b, c, d, x, y;
  if (af[i][j] != -1)
    return;
  if (legal(i - 1, j))
    solve(i - 1, j, af, f, p);
  if (legal(i, j - 1))
    solve(i, j - 1, af, f, p);
  if (legal(i - 1, j)) {
    a = af[i - 1][j] + f[i][j];
    x = a;
  } else {
    x = LLONG_MAX;
  }
  if (legal(i, j - 1)) {
    c = af[i][j - 1] + f[i][j];
    y = c;
  } else {
    y = LLONG_MAX;
  }
  if (x < y) {
    af[i][j] = a;
    p[i][j] = 'D';
  } else {
    af[i][j] = c;
    p[i][j] = 'R';
  }
}
```