user: 请从给定的汇编指令推导出C源代码:

```asm
<rebuildchain>:
  endbr64
  push   %rbp
  mov    %rdx,%r11
  mov    %rsp,%rbp
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x10,%rsp
  mov    (%rcx),%r12d
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  cmp    $0x1,%r12d
  je     L84
  mov    (%rdx),%r8d
  mov    %rcx,%r10
  mov    %rsp,%rcx
  mov    %rsp,%rbx
  lea    0xf(,%r8,4),%rdx
  mov    %rdx,%rax
  shr    $0x4,%rax
  shl    $0x4,%rax
  mov    %rax,%r9
  and    $0xfffffffffffff000,%r9
  sub    %r9,%rcx
  cmp    %rcx,%rsp
  je     L86
L37:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L37
L86:
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  jne    L90
L43:
  shr    $0x4,%rdx
  lea    0x3(%rsp),%rcx
  mov    %rsp,%r9
  shl    $0x4,%rdx
  mov    %rcx,%rax
  and    $0xfffffffffffffffc,%rcx
  mov    %rdx,%r13
  shr    $0x2,%rax
  and    $0xfffffffffffff000,%r13
  sub    %r13,%r9
L48:
  cmp    %r9,%rsp
  je     L29
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L48
  nopl   0x0(%rax,%rax,1)
L84:
  mov    0x4(%rdi),%edx
  mov    (%r11),%eax
  mov    %edx,(%rdi,%rax,4)
  mov    0x4(%rsi),%edx
  mov    (%r11),%eax
  mov    %edx,(%rsi,%rax,4)
  movl   $0x320,0x4(%rdi)
  movl   $0x320,0x4(%rsi)
L19:
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L106
  lea    -0x20(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %rbp
  ret
L90:
  orq    $0x0,-0x8(%rsp,%rax,1)
  jmp    L43
L29:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L109
L119:
  mov    %r12d,%edx
  lea    0x3(%rsp),%r9
  mov    (%rdi,%rdx,4),%r13d
  mov    %r9,%r14
  mov    (%rsi,%rdx,4),%edx
  and    $0xfffffffffffffffc,%r9
  shr    $0x2,%r14
  mov    %r13d,(%rcx,%r8,4)
  mov    %r13d,0x4(,%rax,4)
  lea    0x1(%r12),%eax
  mov    %edx,(%r9,%r8,4)
  mov    %eax,(%r10)
  mov    %edx,0x4(,%r14,4)
  mov    $0x2,%edx
  cmp    %eax,(%r11)
  je     L145
  nopl   0x0(%rax)
L32:
  mov    %eax,%r8d
  add    $0x1,%eax
  mov    (%rdi,%r8,4),%r14d
  mov    (%rsi,%r8,4),%r13d
  mov    %edx,%r8d
  mov    %eax,(%r10)
  add    $0x1,%edx
  mov    %r14d,(%rcx,%r8,4)
  mov    %r13d,(%r9,%r8,4)
  cmp    (%r11),%eax
  jne    L32
L145:
  movl   $0x1,(%r10)
  mov    $0x1,%eax
  lea    -0x1(%rdx),%r13d
  nopl   0x0(%rax)
L33:
  mov    %eax,%r8d
  lea    0x0(%r13,%rax,1),%edx
  add    $0x1,%eax
  mov    (%rdi,%r8,4),%r14d
  mov    (%rsi,%r8,4),%r8d
  mov    %eax,(%r10)
  mov    %r14d,(%rcx,%rdx,4)
  mov    %r8d,(%r9,%rdx,4)
  cmp    %eax,%r12d
  jne    L33
  movl   $0x1,(%r10)
  mov    $0x1,%edx
  nop
L103:
  mov    %edx,%eax
  mov    (%rcx,%rax,4),%r8d
  mov    %r8d,(%rdi,%rax,4)
  mov    (%r9,%rax,4),%r8d
  mov    %r8d,(%rsi,%rax,4)
  mov    %edx,%eax
  add    $0x1,%edx
  cmp    %eax,(%r11)
  jne    L103
  movl   $0x320,0x4(%rdi)
  movl   $0x320,0x4(%rsi)
  mov    %rbx,%rsp
  jmp    L19
L109:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L119
L106:
  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);
}
```