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

```asm
<rebuildchain>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x10,%rsp
  mov    %rdx,%r10
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  mov    %rsp,%r11
  mov    (%rcx),%r12d
  cmp    $0x1,%r12d
  je     L63
  mov    (%rdx),%ebx
  mov    %ebx,%edx
  shl    $0x2,%rdx
  lea    0xf(%rdx),%rax
  shr    $0x4,%rax
  shl    $0x4,%rax
  mov    %rax,%r9
  and    $0xfffffffffffff000,%r9
  mov    %rsp,%r8
  sub    %r9,%r8
L107:
  cmp    %r8,%rsp
  je     L2
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L107
L63:
  mov    0x4(%rdi),%edx
  mov    (%r10),%eax
  mov    %edx,(%rdi,%rax,4)
  mov    0x4(%rsi),%edx
  mov    (%r10),%eax
  mov    %edx,(%rsi,%rax,4)
  movl   $0x320,0x4(%rdi)
  movl   $0x320,0x4(%rsi)
  mov    %r11,%rsp
  jmp    L94
L2:
  mov    %rax,%r8
  and    $0xfff,%r8d
  sub    %r8,%rsp
  test   %r8,%r8
  je     L84
  orq    $0x0,-0x8(%rsp,%r8,1)
L84:
  mov    %rsp,%r8
  add    $0xf,%rdx
  shr    $0x4,%rdx
  shl    $0x4,%rdx
  mov    %rdx,%r9
  and    $0xfffffffffffff000,%r9
  mov    %rsp,%rax
  sub    %r9,%rax
L43:
  cmp    %rax,%rsp
  je     L11
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L43
L11:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L55
  orq    $0x0,-0x8(%rsp,%rax,1)
L55:
  mov    %rsp,%r9
  mov    %r12d,%eax
  mov    %ebx,%ebx
  mov    (%rdi,%rax,4),%edx
  mov    %edx,(%r8,%rbx,4)
  mov    (%rsi,%rax,4),%eax
  mov    %eax,(%r9,%rbx,4)
  mov    $0x1,%eax
L0:
  mov    (%rcx),%edx
  mov    %edx,%r13d
  mov    %eax,%ebx
  mov    (%rdi,%r13,4),%r14d
  mov    %r14d,(%r8,%rbx,4)
  mov    (%rsi,%r13,4),%r13d
  mov    %r13d,(%r9,%rbx,4)
  add    $0x1,%eax
  add    $0x1,%edx
  mov    %edx,(%rcx)
  cmp    (%r10),%edx
  jne    L0
  movl   $0x1,(%rcx)
L30:
  mov    (%rcx),%edx
  mov    %edx,%r13d
  mov    %eax,%ebx
  mov    (%rdi,%r13,4),%r14d
  mov    %r14d,(%r8,%rbx,4)
  mov    (%rsi,%r13,4),%r13d
  mov    %r13d,(%r9,%rbx,4)
  add    $0x1,%eax
  add    $0x1,%edx
  mov    %edx,(%rcx)
  cmp    %edx,%r12d
  jne    L30
  movl   $0x1,(%rcx)
  mov    $0x1,%edx
L47:
  mov    %edx,%eax
  mov    (%r8,%rax,4),%ecx
  mov    %ecx,(%rdi,%rax,4)
  mov    (%r9,%rax,4),%ecx
  mov    %ecx,(%rsi,%rax,4)
  mov    %edx,%eax
  add    $0x1,%edx
  cmp    %eax,(%r10)
  jne    L47
  movl   $0x320,0x4(%rdi)
  movl   $0x320,0x4(%rsi)
  mov    %r11,%rsp
L94:
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L39
  lea    -0x20(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %rbp
  ret
L39:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void rebuildchain(unsigned int *x, unsigned int *y, unsigned int *LENGTH, unsigned int *mv) {
  if (*mv == 1) {
    x[*LENGTH] = x[1];
    y[*LENGTH] = y[1];
    x[1] = ((100) * 8);
    y[1] = ((100) * 8);
    return;
  }
  unsigned int count = 1, Nmv = *mv;
  unsigned int xn[*LENGTH], yn[*LENGTH];
  xn[*LENGTH] = x[*mv];
  yn[*LENGTH] = y[*mv];
  do {
    xn[count] = x[*mv];
    yn[count] = y[*mv];
    count++;
    (*mv)++;
  } while (*mv != *LENGTH);
  *mv = 1;
  do {
    xn[count] = x[*mv];
    yn[count] = y[*mv];
    count++;
    (*mv)++;
  } while (*mv != Nmv);
  count = 1;
  *mv = 1;
  do {
    x[count] = xn[count];
    y[count] = yn[count];
    count++;
  } while (count != (*LENGTH + 1));
  x[1] = ((100) * 8);
  y[1] = ((100) * 8);
}
```