user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<rsencode>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x418,%rsp
  mov    %esi,%r9d
  mov    %rdx,0x38(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  movl   $0x1,0x70(%rsp)
  test   %esi,%esi
  jle    L124
  lea    0x70(%rsp),%rcx
  lea    -0x1(%rsi),%eax
  lea    0x74(%rsp,%rax,4),%r8
L198:
  mov    (%rcx),%eax
  lea    (%rax,%rax,2),%edx
  movslq %edx,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %edx,%esi
  sar    $0x1f,%esi
  sub    %esi,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    %edx,0x4(%rcx)
  add    $0x4,%rcx
  cmp    %r8,%rcx
  jne    L198
L124:
  add    %edi,%r9d
  lea    0x6f(%r9),%edx
  movslq %edx,%rax
  imul   $0xffffffff92492493,%rax,%rax
  shr    $0x20,%rax
  add    %edx,%eax
  sar    $0x6,%eax
  sar    $0x1f,%edx
  sub    %edx,%eax
  mov    %eax,0x34(%rsp)
  test   %r9d,%r9d
  jle    L41
  movq   $0x0,0x28(%rsp)
  lea    -0x1(%rax,%rdi,1),%ebx
  mov    %ebx,0x50(%rsp)
  lea    -0x1(%r9,%rax,1),%ebx
  mov    %ebx,0x54(%rsp)
  lea    0x240(%rsp),%rbx
  mov    %rbx,0x58(%rsp)
  lea    0x248(%rsp),%rbx
  mov    %rbx,0x40(%rsp)
  lea    0x78(%rsp),%rbx
  mov    %rbx,0x60(%rsp)
  lea    0x23c(%rsp),%rbx
  mov    %rbx,0x68(%rsp)
  cltq
  mov    %rax,(%rsp)
  mov    $0x71,%r15d
  jmp    L78
L26:
  mov    (%r9),%esi
  mov    %r10,%rdx
L93:
  mov    %esi,%ecx
  imul   -0x4(%rdx),%ecx
  movslq %ecx,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %ecx,%edi
  sar    $0x1f,%edi
  sub    %edi,%eax
  imul   $0x71,%eax,%eax
  mov    (%rdx),%edi
  sub    %ecx,%edi
  lea    0x71(%rdi,%rax,1),%ecx
  movslq %ecx,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %ecx,%edi
  sar    $0x1f,%edi
  sub    %edi,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%ecx
  mov    %ecx,(%rdx)
  sub    $0x4,%rdx
  cmp    %r8,%rdx
  jne    L93
  add    $0x4,%r9
  cmp    %r11,%r9
  jne    L26
L65:
  mov    0x48(%rsp),%edx
  cmp    %r14d,%edx
  jge    L122
  mov    0x34(%rsp),%eax
  imul   %edx,%eax
  cltq
  add    0x28(%rsp),%rax
  add    0x38(%rsp),%rax
L114:
  movb   $0x0,(%rax)
  add    $0x1,%edx
  add    (%rsp),%rax
  cmp    %edx,%r14d
  jne    L114
L122:
  mov    0x48(%rsp),%esi
  test   %esi,%esi
  jle    L182
  mov    0x34(%rsp),%ecx
  mov    %ecx,%eax
  imul   %esi,%eax
  add    %r12d,%eax
  cltq
  mov    0x38(%rsp),%rdi
  add    %rdi,%rax
  mov    %rax,0x8(%rsp)
  lea    -0x1(%r14),%eax
  imul   %ecx,%eax
  add    %ebx,%eax
  cltq
  add    %rdi,%rax
  mov    %rax,0x10(%rsp)
  mov    %rdi,%r13
  mov    0x28(%rsp),%rax
  add    %rax,%r13
  lea    0x1(%rsi),%r10d
  imul   %ecx,%r10d
  movslq %r10d,%r10
  add    %r10,%rax
  add    %rdi,%rax
  mov    %rax,0x20(%rsp)
  mov    0x30(%rsp),%edi
  lea    -0x2(%rdi),%eax
  mov    0x40(%rsp),%rbx
  lea    (%rbx,%rax,4),%rbx
  imul   %ecx,%esi
  movslq %esi,%r11
  neg    %r10
  mov    $0x0,%r12d
  movslq %edi,%rax
  mov    %rax,0x18(%rsp)
  mov    %r14d,0x4c(%rsp)
  mov    (%rsp),%r14
L80:
  movzbl 0x0(%r13),%eax
  mov    0x8(%rsp),%rsi
  movzbl (%rsi),%edx
  add    %edx,%eax
  movslq %eax,%rdi
  imul   $0x487ede05,%rdi,%rdi
  sar    $0x25,%rdi
  imul   $0x71,%edi,%edx
  sub    %edx,%eax
  mov    %eax,%edi
  cmpl   $0x1,0x30(%rsp)
  jle    L30
  lea    0x244(%rsp),%rsi
  mov    0x20(%rsp),%rcx
L40:
  lea    (%rcx,%r11,1),%r8
  mov    %edi,%edx
  imul   (%rsi),%edx
  movslq %edx,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %edx,%r9d
  sar    $0x1f,%r9d
  sub    %r9d,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    %r15d,%r9d
  sub    %edx,%r9d
  movzbl (%rcx),%eax
  lea    (%r9,%rax,1),%edx
  movslq %edx,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %edx,%r9d
  sar    $0x1f,%r9d
  sub    %r9d,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    %dl,(%r8,%r10,1)
  add    $0x4,%rsi
  add    %r14,%rcx
  cmp    %rbx,%rsi
  jne    L40
L30:
  mov    0x18(%rsp),%rax
  imul   0x240(%rsp,%rax,4),%edi
  movslq %edi,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %edi,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edi
  mov    %r15d,%edx
  sub    %edi,%edx
  movslq %edx,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    0x10(%rsp),%rax
  mov    %dl,(%rax)
  add    $0x1,%r12d
  add    %r14,%r13
  cmp    %r12d,%ebp
  jne    L80
  mov    0x4c(%rsp),%r14d
L182:
  mov    0x48(%rsp),%eax
  cmp    %r14d,%eax
  jge    L81
  mov    %eax,%ecx
  imul   0x34(%rsp),%ecx
  movslq %ecx,%rcx
  add    0x28(%rsp),%rcx
  add    0x38(%rsp),%rcx
L72:
  movzbl (%rcx),%eax
  mov    %r15d,%edx
  sub    %eax,%edx
  movslq %edx,%rax
  imul   $0x487ede05,%rax,%rax
  sar    $0x25,%rax
  mov    %edx,%esi
  sar    $0x1f,%esi
  sub    %esi,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    %dl,(%rcx)
  add    $0x1,%ebp
  add    (%rsp),%rcx
  cmp    %ebp,%r14d
  jne    L72
L81:
  addq   $0x1,0x28(%rsp)
  mov    0x28(%rsp),%rax
  cmp    %eax,0x34(%rsp)
  jle    L41
L78:
  mov    0x28(%rsp),%rsi
  mov    %esi,%ebx
  mov    %esi,%r12d
  mov    0x50(%rsp),%eax
  sub    %esi,%eax
  mov    0x34(%rsp),%ecx
  cltd
  idiv   %ecx
  mov    %eax,0x48(%rsp)
  mov    %eax,%r11d
  mov    %eax,%ebp
  mov    0x54(%rsp),%edi
  sub    %esi,%edi
  mov    %edi,%eax
  cltd
  idiv   %ecx
  mov    %eax,%r14d
  mov    %eax,%esi
  sub    %r11d,%esi
  mov    %esi,0x30(%rsp)
  test   %esi,%esi
  jle    L48
  lea    0x244(%rsp),%rdx
  lea    -0x1(%rsi),%eax
  shl    $0x2,%rax
  mov    0x40(%rsp),%rsi
  lea    (%rsi,%rax,1),%rcx
L194:
  movl   $0x0,(%rdx)
  add    $0x4,%rdx
  cmp    %rcx,%rdx
  jne    L194
  movl   $0x1,0x240(%rsp)
  lea    0x74(%rsp),%r9
  mov    0x60(%rsp),%rsi
  lea    (%rsi,%rax,1),%r11
  movslq 0x30(%rsp),%rdx
  shl    $0x2,%rdx
  mov    0x58(%rsp),%rsi
  lea    (%rsi,%rdx,1),%r10
  mov    0x68(%rsp),%rsi
  lea    (%rsi,%rdx,1),%r8
  sub    %rax,%r8
  jmp    L26
L48:
  movl   $0x1,0x240(%rsp)
  jmp    L65
L41:
  mov    0x408(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L38
  add    $0x418,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L38:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void rsencode(int nd, int nc, unsigned char *wd) {
  int i, j, k, nw, start, step, root[113], c[113];
  root[0] = 1;
  for (i = 1; i <= nc; i++)
    root[i] = (3 * root[i - 1]) % 113;
  nw = nd + nc;
  step = (nw + 113 - 2) / (113 - 1);
  for (start = 0; start < step; start++) {
    int ND = (nd - start + step - 1) / step, NW = (nw - start + step - 1) / step, NC = NW - ND;
    for (i = 1; i <= NC; i++)
      c[i] = 0;
    c[0] = 1;
    for (i = 1; i <= NC; i++) {
      for (j = NC; j >= 1; j--) {
        c[j] = (113 + c[j] - (root[i] * c[j - 1]) % 113) % 113;
      }
    }
    for (i = ND; i < NW; i++)
      wd[start + i * step] = 0;
    for (i = 0; i < ND; i++) {
      k = (wd[start + i * step] + wd[start + ND * step]) % 113;
      for (j = 0; j < NC - 1; j++) {
        wd[start + (ND + j) * step] = (113 - ((c[j + 1] * k) % 113) + wd[start + (ND + j + 1) * step]) % 113;
      }
      wd[start + (ND + NC - 1) * step] = (113 - ((c[NC] * k) % 113)) % 113;
    }
    for (i = ND; i < NW; i++)
      wd[start + i * step] = (113 - wd[start + i * step]) % 113;
  }
}
```