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

```asm
<gridsort>:
  endbr64
  movsbq %sil,%rax
  push   %r15
  imul   $0x5a,%rax,%rax
  push   %r14
  push   %r13
  push   %r12
  lea    (%rdi,%rax,1),%r15
  movsbq %dl,%rax
  push   %rbp
  lea    (%rax,%rax,4),%rax
  push   %rbx
  lea    (%r15,%rax,2),%r13
  xor    %eax,%eax
  cmpb   $0x0,0x0(%r13)
  mov    %r15,-0x18(%rsp)
  jne    L46
  mov    %edx,%ecx
  movsbq %dl,%r14
  mov    %esi,%eax
  mov    $0x56,%edx
  imul   %dl
  sar    $0x7,%sil
  mov    %rdi,%rbx
  movb   $0x0,-0xa(%rsp)
  mov    $0x1,%r10d
  shr    $0x8,%ax
  sub    %esi,%eax
  lea    (%rax,%rax,2),%edi
  add    $0x1,%eax
  movsbl %al,%eax
  mov    %dil,-0x9(%rsp)
  movsbl %dil,%edi
  lea    (%rax,%rax,2),%ebp
  mov    %edx,%eax
  mov    %edi,-0x10(%rsp)
  imul   %cl
  sar    $0x7,%cl
  shr    $0x8,%ax
  sub    %ecx,%eax
  lea    (%rax,%rax,2),%r12d
  add    $0x1,%eax
  movsbl %al,%eax
  movsbl %r12b,%r11d
  lea    (%rax,%rax,2),%edi
  lea    (%r14,%r14,4),%rax
  lea    (%r15,%rax,2),%rax
  mov    %rax,-0x8(%rsp)
  jmp    L119
  nopl   (%rax)
L402:
  add    $0x1,%r10
  cmp    $0xa,%r10
  je     L55
L119:
  cmpb   $0x0,0x0(%r13,%r10,1)
  mov    %r10d,%r15d
  movslq %r10d,%r8
  je     L402
  cmp    -0x10(%rsp),%ebp
  jle    L402
  movzbl -0x9(%rsp),%r9d
  xor    %ecx,%ecx
  nopw   0x0(%rax,%rax,1)
L196:
  cmp    %edi,%r11d
  jge    L344
  movsbq %r9b,%rsi
  mov    %r12d,%edx
  movslq %r11d,%rax
  imul   $0x5a,%rsi,%rsi
  add    %rbx,%rsi
  xchg   %ax,%ax
L227:
  lea    (%rax,%rax,4),%rax
  lea    (%rsi,%rax,2),%rax
  cmpb   $0x1,(%rax,%r8,1)
  adc    $0x0,%cl
  add    $0x1,%edx
  movsbq %dl,%rax
  cmp    %edi,%eax
  jl     L227
L344:
  add    $0x1,%r9d
  movsbl %r9b,%eax
  cmp    %ebp,%eax
  jl     L196
  cmp    $0x8,%cl
  jne    L402
  mov    %r15b,0x0(%r13)
  mov    %r10d,%eax
  cmp    $0x1,%r10
  je     L296
  mov    -0x8(%rsp),%rcx
  cmpb   $0x0,0x1(%rcx)
  je     L251
  movb   $0x0,0x1(%rcx)
  movb   $0x1,-0xa(%rsp)
L251:
  cmp    $0x2,%al
  mov    -0x8(%rsp),%rax
  je     L266
  cmpb   $0x0,0x2(%rax)
  je     L271
L206:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  movb   $0x1,-0xa(%rsp)
  movb   $0x0,0x2(%rcx,%rax,2)
L271:
  cmp    $0x3,%r10
  je     L137
L166:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x3(%rcx,%rax,2)
  je     L167
L129:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  movb   $0x1,-0xa(%rsp)
  movb   $0x0,0x3(%rcx,%rax,2)
L167:
  cmp    $0x4,%r10
  je     L149
L373:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x4(%rcx,%rax,2)
  je     L130
L259:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  movb   $0x1,-0xa(%rsp)
  movb   $0x0,0x4(%rcx,%rax,2)
L130:
  cmp    $0x5,%r10
  je     L44
L67:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x5(%rcx,%rax,2)
  je     L370
L241:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  movb   $0x1,-0xa(%rsp)
  movb   $0x0,0x5(%rcx,%rax,2)
L370:
  cmp    $0x6,%r10
  je     L45
L374:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x6(%rcx,%rax,2)
  je     L209
L113:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  movb   $0x1,-0xa(%rsp)
  movb   $0x0,0x6(%rcx,%rax,2)
L209:
  cmp    $0x7,%r10
  je     L380
L260:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x7(%rcx,%rax,2)
  je     L48
L372:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  movb   $0x1,-0xa(%rsp)
  movb   $0x0,0x7(%rcx,%rax,2)
L48:
  cmp    $0x8,%r10
  je     L61
L133:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x8(%rcx,%rax,2)
  je     L261
L89:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  movb   $0x1,-0xa(%rsp)
  movb   $0x0,0x8(%rcx,%rax,2)
L261:
  cmp    $0x9,%r10
  je     L55
L61:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  lea    (%rcx,%rax,2),%rax
  cmpb   $0x0,0x9(%rax)
  je     L402
  movb   $0x0,0x9(%rax)
  movb   $0x1,-0xa(%rsp)
  jmp    L402
L55:
  movsbl -0xa(%rsp),%eax
L46:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L296:
  mov    -0x8(%rsp),%rax
  cmpb   $0x0,0x2(%rax)
  jne    L206
  jmp    L166
L45:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x7(%rcx,%rax,2)
  jne    L372
  jmp    L133
L44:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x6(%rcx,%rax,2)
  jne    L113
  jmp    L260
L380:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x8(%rcx,%rax,2)
  jne    L89
  jmp    L61
L266:
  cmpb   $0x0,0x3(%rax)
  jne    L129
  jmp    L373
L149:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x5(%rcx,%rax,2)
  jne    L241
  jmp    L374
L137:
  mov    -0x18(%rsp),%rcx
  lea    (%r14,%r14,4),%rax
  cmpb   $0x0,0x4(%rcx,%rax,2)
  jne    L259
  jmp    L67
```

assistant: ```c
int gridsort(char grid[9][9][10], char m, char n) {
  if (grid[m][n][0])
    return 0;
  char i, j, k, l, f = 0;
  for (k = 1; k < 10; ++k)
    if (grid[m][n][k]) {
      l = 0;
      for (i = 3 * (m / 3); i < 3 * (m / 3 + 1); ++i)
        for (j = 3 * (n / 3); j < 3 * (n / 3 + 1); ++j)
          if (!grid[i][j][k])
            l++;
      if (l == 8) {
        grid[m][n][0] = k;
        for (l = 1; l < 10; ++l)
          if (l != k)
            if (grid[m][n][l])
              grid[m][n][l] = 0, f = 1;
      }
    }
  return f;
}
```